Mercurial > hg > nginx-tests
annotate worker_shutdown_timeout_h2.t @ 1606:e4e0695552ed
Tests: fixed stream_proxy_ssl_conf_command.t.
The stream_proxy_ssl_conf_command.t test used stream return module
to return the response. Since this ignores actual request, but the
perl test code used http_get(). This might result in the request being
sent after the response is returned and the connection closed by the server,
resulting in RST being generated and no response seen by the client at all.
Fix is to use "stream(...)->read()" instead of http_get(), so
no request is sent at all, eliminating possibility of RST being
generated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 10 Nov 2020 05:03:29 +0300 |
parents | fca71a8ebf6d |
children | 5ac6efbe5552 |
rev | line source |
---|---|
1507
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for worker_shutdown_timeout and HTTP/2 with proxy. |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1513
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(2); |
1507
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 worker_shutdown_timeout 10ms; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080 http2; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 location / { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 proxy_pass http://127.0.0.1:8081; |
1513
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
47 proxy_read_timeout 5s; |
1507
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 EOF |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 $t->run_daemon(\&http_silent_daemon); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 ############################################################################### |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 my $s = Test::Nginx::HTTP2->new(); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 ok($s->new_stream(), 'new stream'); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
1518
fca71a8ebf6d
Tests: adjusted worker_shutdown_timeout_h2.t shutdown delay more.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1517
diff
changeset
|
61 $s->h2_ping('SEE-THIS'); |
fca71a8ebf6d
Tests: adjusted worker_shutdown_timeout_h2.t shutdown delay more.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1517
diff
changeset
|
62 $s->read(all => [{ type => 'PING' }]); |
fca71a8ebf6d
Tests: adjusted worker_shutdown_timeout_h2.t shutdown delay more.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1517
diff
changeset
|
63 |
1512
e84a3115bfe8
Tests: worker_shutdown_timeout_h2.t TODO adjusted.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1507
diff
changeset
|
64 $t->stop(); |
e84a3115bfe8
Tests: worker_shutdown_timeout_h2.t TODO adjusted.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1507
diff
changeset
|
65 |
1513
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
66 TODO: { |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
67 local $TODO = 'not yet' unless $t->has_version('1.17.4'); |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
68 |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
69 like($t->read_file('access.log'), qr/ (?!504)\d{3} /, 'shutdown timeout'); |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
70 |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
71 } |
02412b209838
Tests: testing worker_shutdown_timeout works with HTTP/2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1512
diff
changeset
|
72 |
1512
e84a3115bfe8
Tests: worker_shutdown_timeout_h2.t TODO adjusted.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1507
diff
changeset
|
73 $t->todo_alerts() unless $t->has_version('1.17.4'); |
1507
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 ############################################################################### |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 sub http_silent_daemon { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 my $server = IO::Socket::INET->new( |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 Proto => 'tcp', |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 LocalAddr => '127.0.0.1:' . port(8081), |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 Listen => 5, |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 Reuse => 1 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ) |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 or die "Can't create listening socket: $!\n"; |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 while (my $client = $server->accept()) { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $client->autoflush(1); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 while (<$client>) { } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 ############################################################################### |