.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Rex::Test::Base 3pm" .TH Rex::Test::Base 3pm "2023-08-09" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Rex::Test::Base \- Basic Test Module .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a basic test module to test your code with the help of local VMs. You can place your tests in the \*(L"t\*(R" directory. .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 3 \& 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 .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS "new(name => $test_name)" .el .SS "new(name => \f(CW$test_name\fP)" .IX Subsection "new(name => $test_name)" Constructor if used in \s-1OO\s0 mode. .PP .Vb 1 \& my $test = Rex::Test::Base\->new(name => "test_name"); .Ve .SS "name($name)" .IX Subsection "name($name)" The name of the test. A \s-1VM\s0 called \f(CW$name\fR will be created for each test. If the \s-1VM\s0 already exists, Rex will try to reuse it. .SS "memory($amount)" .IX Subsection "memory($amount)" The amount of memory the \s-1VM\s0 should use, in Megabytes. .SS "cpus($number)" .IX Subsection "cpus($number)" The number of CPUs the \s-1VM\s0 should use. .SS "vm_auth(%auth)" .IX Subsection "vm_auth(%auth)" Authentication options for the \s-1VM.\s0 It accepts the same parameters as \f(CW\*(C`Rex::Box::Base\->auth()\*(C'\fR. .SS "base_vm($vm)" .IX Subsection "base_vm($vm)" The \s-1URL\s0 to a base image to be used for the test \s-1VM.\s0 .SS "redirect_port($port)" .IX Subsection "redirect_port($port)" Redirect local \f(CW$port\fR to the \s-1VM\s0's \s-1SSH\s0 port (default: 2222). .SS "run_task($task)" .IX Subsection "run_task($task)" The task to run on the test \s-1VM.\s0 You can run multiple tasks by passing an array reference. .SH "TEST METHODS" .IX Header "TEST METHODS" .ie n .SS "has_content($file, $regexp)" .el .SS "has_content($file, \f(CW$regexp\fP)" .IX Subsection "has_content($file, $regexp)" Test if the content of \f(CW$file\fR matches against \f(CW$regexp\fR. .SS "has_dir($path)" .IX Subsection "has_dir($path)" Test if \f(CW$path\fR is present and is a directory. .SS "has_file($file)" .IX Subsection "has_file($file)" Test if \f(CW$file\fR is present. .ie n .SS "has_package($package, $version)" .el .SS "has_package($package, \f(CW$version\fP)" .IX Subsection "has_package($package, $version)" Test if \f(CW$package\fR is installed, optionally at \f(CW$version\fR. .SS "has_service_running($service)" .IX Subsection "has_service_running($service)" Test if \f(CW$service\fR is running. .SS "has_service_stopped($service)" .IX Subsection "has_service_stopped($service)" Test if \f(CW$service\fR is stopped. .ie n .SS "has_stat($file, $stat)" .el .SS "has_stat($file, \f(CW$stat\fP)" .IX Subsection "has_stat($file, $stat)" Test if \f(CW$file\fR has properties described in hash reference \f(CW$stat\fR. List of supported checks: .IP "group" 4 .IX Item "group" .PD 0 .IP "owner" 4 .IX Item "owner"