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 mode.
my $test = Rex::Test::Base->new(name => "test_name");
name($name)
The name of the test. A called will be created for each test. If the already exists, Rex will try to reuse it.
memory($amount)
The amount of memory the should use, in Megabytes.
cpus($number)
The number of CPUs the should use.
vm_auth(%auth)
Authentication options for the It accepts the same parameters as .
base_vm($vm)
The to a base image to be used for the test
redirect_port($port)
Redirect local to the 's port (default: 2222).
run_task($task)
The task to run on the test You can run multiple tasks by passing an array reference.
TEST METHODS
has_content($file, $regexp)
Test if the content of matches against .
has_dir($path)
Test if is present and is a directory.
has_file($file)
Test if is present.
has_package($package, $version)
Test if is installed, optionally at .
has_service_running($service)
Test if is running.
has_service_stopped($service)
Test if is stopped.
has_stat($file, $stat)
Test if has properties described in hash reference . List of supported checks:
- group
-
- owner
-