# HG changeset patch # User Sergey Kandaurov # Date 1502283458 -10800 # Node ID c99c1f43cb154e9a5515a3c2347594e7b22058f5 # Parent c0fa3f8181039aa12e1be15fc8c8d4d718cf0583 Tests: reload() introduced in Test::Nginx. This method replaces ad-hoc solutions to reload nginx, and adds win32 support. diff --git a/h2.t b/h2.t --- a/h2.t +++ b/h2.t @@ -1117,9 +1117,6 @@ undef $grace4; # GOAWAY without awaiting active streams, further streams ignored -SKIP: { -skip 'win32', 3 if $^O eq 'MSWin32'; - TODO: { local $TODO = 'not yet' unless $t->has_version('1.11.6'); @@ -1127,7 +1124,7 @@ local $TODO = 'not yet' unless $t->has_v $sid = $s->new_stream({ path => '/t1.html' }); $s->read(all => [{ sid => $sid, length => 2**16 - 1 }]); -kill 'HUP', $t->read_file('nginx.pid'); +$t->reload(); $frames = $s->read(all => [{ type => 'GOAWAY' }]); @@ -1150,8 +1147,6 @@ is($frame, undef, 'GOAWAY with active st $sum = eval join '+', map { $_->{length} } @data; is($sum, 81, 'GOAWAY with active stream - active stream DATA after GOAWAY'); -} - # GOAWAY - force closing a connection by server with idle or active streams $s = Test::Nginx::HTTP2->new(); diff --git a/lib/Test/Nginx.pm b/lib/Test/Nginx.pm --- a/lib/Test/Nginx.pm +++ b/lib/Test/Nginx.pm @@ -421,6 +421,29 @@ sub waitforsocket($) { return undef; } +sub reload() { + my ($self) = @_; + + return $self unless $self->{_started}; + + my $pid = $self->read_file('nginx.pid'); + + if ($^O eq 'MSWin32') { + my $testdir = $self->{_testdir}; + my @globals = $self->{_test_globals} ? + () : ('-g', "pid $testdir/nginx.pid; " + . "error_log $testdir/error.log debug;"); + system($NGINX, '-p', $testdir, '-c', "nginx.conf", + '-s', 'reload', @globals) == 0 + or die "system() failed: $?\n"; + + } else { + kill 'HUP', $pid; + } + + return $self; +} + sub stop() { my ($self) = @_; diff --git a/worker_shutdown_timeout.t b/worker_shutdown_timeout.t --- a/worker_shutdown_timeout.t +++ b/worker_shutdown_timeout.t @@ -24,8 +24,6 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -plan(skip_all => 'win32') if $^O eq 'MSWin32'; - my $t = Test::Nginx->new()->has(qw/http/) ->write_file_expand('nginx.conf', <<'EOF'); @@ -58,7 +56,7 @@ my $s = http('', start => 1); select undef, undef, undef, 0.2; -kill 'HUP', $t->read_file('nginx.pid'); +$t->reload(); if (IO::Select->new($s)->can_read(5)) { Test::Nginx::log_core('||', "select: can_read");