Mercurial > hg > nginx-tests
changeset 1206:c99c1f43cb15
Tests: reload() introduced in Test::Nginx.
This method replaces ad-hoc solutions to reload nginx, and adds win32 support.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 09 Aug 2017 15:57:38 +0300 |
parents | c0fa3f818103 |
children | b1dc56ad15e9 |
files | h2.t lib/Test/Nginx.pm worker_shutdown_timeout.t |
diffstat | 3 files changed, 25 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/h2.t Wed Aug 09 15:57:36 2017 +0300 +++ b/h2.t Wed Aug 09 15:57:38 2017 +0300 @@ -1117,9 +1117,6 @@ # 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 @@ $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 @@ $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();
--- a/lib/Test/Nginx.pm Wed Aug 09 15:57:36 2017 +0300 +++ b/lib/Test/Nginx.pm Wed Aug 09 15:57:38 2017 +0300 @@ -421,6 +421,29 @@ 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) = @_;
--- a/worker_shutdown_timeout.t Wed Aug 09 15:57:36 2017 +0300 +++ b/worker_shutdown_timeout.t Wed Aug 09 15:57:38 2017 +0300 @@ -24,8 +24,6 @@ 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 @@ 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");