Add tests on process
This commit is contained in:
parent
18d9152b13
commit
b5d3498b11
47
ACU/t/process_basis.t
Normal file
47
ACU/t/process_basis.t
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
use v5.10.1;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
diag("Testing Process on perl $]");
|
||||||
|
use_ok('Gearman::Worker');
|
||||||
|
use_ok('Process');
|
||||||
|
}
|
||||||
|
|
||||||
|
use Process;
|
||||||
|
|
||||||
|
cmp_ok($Process::nb_cpus, 'gt', 0, 'Check number of CPU detected');
|
||||||
|
|
||||||
|
can_ok('Process', 'register');
|
||||||
|
|
||||||
|
is(Process::check_load(0), '', "Check the load verification");
|
||||||
|
is(Process::check_load(100), '1', "Check the load verification");
|
||||||
|
|
||||||
|
my $gearman_simulation = bless ( { 'handle' => 'H:noyce:167',
|
||||||
|
'argref' => \"<process />",
|
||||||
|
'func' => 'mon_test' },
|
||||||
|
, 'Gearman::Job' );
|
||||||
|
|
||||||
|
is(Process::do_work(sub { "ok" }, undef, 100, $gearman_simulation), "ok", "Check simple work");
|
||||||
|
|
||||||
|
is(Process::do_work(sub { $_[0]->{test} }, { "test" => "It works" }, 100, $gearman_simulation), "It works", "Check returning argument");
|
||||||
|
|
||||||
|
my $GEARMAN_id = "753154abdf";
|
||||||
|
my $GEARMAN_auth = "ksajsdfbnsu-skdghf344J";
|
||||||
|
$gearman_simulation->{argref} = \('<process id="'.$GEARMAN_id.'" priority="10" auth="'.$GEARMAN_auth.'" ><param name="param1">length</param><param name="argument2">size</param><file name="echo.pl">cHJpbnQgIjQyIjsK</file><param>third</param></process>');
|
||||||
|
|
||||||
|
is(Process::do_work(sub { "ok" }, undef, 100, $gearman_simulation), "ok", "Check simple work with more complex XML");
|
||||||
|
|
||||||
|
is(Process::do_work(sub { $_[1]->{id} }, { "test" => "It works" }, 100, $gearman_simulation), $GEARMAN_id, "Check returning id given in XML");
|
||||||
|
is(Process::do_work(sub { $_[1]->{priority} }, { "test" => "It works" }, 100, $gearman_simulation), 10, "Check returning priority given in XML");
|
||||||
|
is(Process::do_work(sub { $_[1]->{auth} }, { "test" => "It works" }, 100, $gearman_simulation), $GEARMAN_auth, "Check returning auth given in XML");
|
||||||
|
|
||||||
|
is(Process::do_work(sub { $_[1]->{param}->{param1} }, { "test" => "It works" }, 100, $gearman_simulation), 'length', "Check returning named parameter");
|
||||||
|
is(Process::do_work(sub { $_[1]->{param}->{argument2} }, { "test" => "It works" }, 100, $gearman_simulation), 'size', "Check returning named parameter");
|
||||||
|
is(Process::do_work(sub { $_[1]->{param}->{3} }, { "test" => "It works" }, 100, $gearman_simulation), 'third', "Check returning unnamed parameter");
|
||||||
|
|
||||||
|
is(Process::do_work(sub { $_[1]->{subtree} }, { "test" => "It works" }, 100, $gearman_simulation), undef, "Check there are no subtree");
|
||||||
|
|
||||||
|
done_testing();
|
Reference in New Issue
Block a user