Apache2-ScoreBoardFile

 view release on metacpan or  search on metacpan

t/001.t  view on Meta::CPAN


my $count=0;			# StartServers 2
t_debug "pids: ".join ", ", map {$obj->process($_)->pid} 0..15;
for( my $i=0; $i<16; $i++ ) {
  $count++ if $obj->process($i)->pid;
}

is $count, 3, 'StartServers 3 - found '.$count;

ok !defined($obj->process(17)), 'process(17) - undef (out of range)';
ok !defined($obj->process(-1)), 'process(-1) - undef (out of range)';

$count=0;
for( my $i=0; $i<16; $i++ ) {
  $count+=$obj->worker($i)->thread_num;
}
is $count, 3, 'sum(thread_num)==3';

$count=join "", map {$obj->worker($_)->status} 0..15;
t_debug "status: $count";
is $count=~tr/_//, 3, '3 ready worker (status _)';

t_debug "access_count: ".join ", ", map {$obj->worker($_)->access_count} 0..15;
$count=0;
for( my $i=0; $i<16; $i++ ) {
  $count+=$obj->worker($i)->access_count;
}
is $count, 0, 'sum(access_count)==0';

GET '/index.html' for (1..3);
Apache::TestRequest::module 'h2';
GET '/';

t_debug "access_count: ".join ", ", map {$obj->worker($_)->access_count} 0..15;
$count=0;
for( my $i=0; $i<16; $i++ ) {
  $count+=$obj->worker($i)->access_count;
}
is $count, 4, 'sum(access_count)==4';

$count=join ", ", map {$obj->worker($_)->request} 0..15;
t_debug "request: ".$count;
like $count, qr!GET /index\.html HTTP/1\.\d!, 'GET /index.html';
like $count, qr!GET / HTTP/1\.\d!, 'GET /';

$count=join ", ", map {$obj->worker($_)->vhost} 0..15;
t_debug "vhost: ".$count;
like $count, qr!fritz!, 'Main Server = fritz';
like $count, qr!hugo!, 'vhost = hugo';

$count=join ", ", map {$obj->worker($_)->client} 0..15;
t_debug "client: ".$count;

ok !defined($obj->worker(17)), 'worker(17) - undef (out of range)';
ok !defined($obj->worker(-1)), 'worker(-1) - undef (out of range)';

my %summary;
my @keys=qw/. _ S R W K L D C G I bw iw cw nr nb/;
@summary{@keys}=$obj->summary(@keys);

use Data::Dumper;
t_debug Dumper \%summary;

is_deeply \%summary, {
		      '.' => '13',
		      'C' => '0',
		      'D' => '0',
		      'G' => '0',
		      'I' => '0',
		      'K' => '0',
		      'L' => '0',
		      'R' => '0',
		      'S' => '0',
		      'W' => '0',
		      '_' => '3',
		      'bw' => '0',
		      'cw' => '3',
		      'iw' => '3',
		      'nb' => 4*(-s $indexfile),
		      'nr' => '4'
		     }, 'summary';



( run in 1.704 second using v1.01-cache-2.11-cpan-39bf76dae61 )