(R)?ex Deployment & Configuration Management

Search

News

2016-09-08

Work with (R)?ex at adjust! Check out their job posting for details, or contact our fellow core developer, FErki.

2016-07-16

(R)?ex 1.4.1 released, fixing many bugs. See the release notes for more details.

2016-03-07

(R)?ex 1.4.0 released, containing lots of goodies. See the release notes for more details.

2015-09-04

(R)?ex 1.3.3 released, fixing a bunch of bugs. See the release notes for more details.

2015-06-22

adjust GmbH is sponsoring the (R)?ex project with a new build server. Thank you for your support!

2015-06-17

(R)?ex 1.3.2 released, fixing issues related to file manipulation when run on BSDs. See the release notes for more details.

2015-06-08

(R)?ex 1.3.1 released, fixing Rex::Commands::DB related tests.

2015-05-27

Read the second part of "Rex in practice" series about Test-driven infrastructure.

2015-05-09

repositor.io 1.1.0 released. repositor.io is a repository management tool for apt, yum, yast and docker. This is a bugfix release with fixes for ubuntu and centos7 installation media mirroring.

2015-05-03

(R)?ex 1.2.0 released. See the release notes for more details.

2015-03-27

View the slides of the talk An introduction to Rex from Andy Beverley.

Conferences

2016-06-21

Training

Need Help?

Rex is a pure open source project, you can find community support in the following places:

Professional support is also available.

» Home » Docs » API » 1.4 » Rex » Test » Base.pm

Base.pm

API Version:

NAME

Rex::Test::Base - Basic Test Module

DESCRIPTION

This is a basic test module to test your code with the help of local VMs. You can place your tests in the "t" directory.

EXAMPLE

 use Rex::Test::Base;
 use Data::Dumper;
 use Rex -base;
 
 test {
   my $t = shift;
 
   $t->name("ubuntu test");
 
   $t->base_vm("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova");
   $t->vm_auth(user => "root", password => "box");
 
   $t->run_task("setup");
 
   $t->has_package("vim");
   $t->has_package("ntp");
   $t->has_package("unzip");
 
   $t->has_file("/etc/ntp.conf");
 
   $t->has_service_running("ntp");
 
   $t->has_content("/etc/passwd", qr{root:x:0:}ms);
 
   run "ls -l";
   $t->ok($? == 0, "ls -l returns success.");
 
   $t->finish;
 };
 
 1; # last line

METHODS

new(name => $test_name)

Constructor if used in OO mode.

 my $test = Rex::Test::Base->new(name => "test_name");

name($name)

The name of the test. A VM called $name will be created for each test. If the VM already exists, Rex will try to reuse it.

memory($amount)

The amount of memory the VM should use, in Megabytes.

cpus($number)

The number of CPUs the VM should use.

vm_auth(%auth)

Authentication options for the VM. It accepts the same parameters as Rex::Box::Base->auth().

base_vm($vm)

The URL to a base image to be used for the test VM.

redirect_port($port)

Redirect local $port to the VM's SSH port (default: 2222).

run_task($task)

The task to run on the test VM. You can run multiple tasks by passing an array reference.

TEST METHODS

has_content($file, $regexp)

Test if the content of $file matches against $regexp.

has_dir($path)

Test if $path is present and is a directory.

has_file($file)

Test if $file is present.

has_package($package, $version)

Test if $package is installed, optionally at $version.

has_service_running($service)

Test if $service is running.

has_service_stopped($service)

Test if $service is stopped.

has_stat($file, $stat)

Test if $file has properties described in hash reference $stat. List of supported checks:

group
owner
Fork me on GitHub
Google Group / Twitter / GitHub / Mailinglist / irc.freenode.net #rex   -.รด.-   Disclaimer