Mercurial > hg > nginx-tests
annotate worker_shutdown_timeout_h2.t @ 1888:cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
STREAM and RESET_STREAM frames could be batched, which prevents the stream
from being processed and changes the status code. The fix is to wait for
the stream acknowledgment. Here we just look at the largest acknowledged,
this should be enough for simple cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 04 Apr 2023 00:33:54 +0400 |
parents | 5ac6efbe5552 |
children | 236d038dc04a |
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 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
|
67 |
1507
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 ############################################################################### |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 sub http_silent_daemon { |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 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
|
72 Proto => 'tcp', |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 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
|
74 Listen => 5, |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 Reuse => 1 |
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 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
|
78 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 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
|
80 $client->autoflush(1); |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
8958b5b53c25
Tests: HTTP/2 tests for alerts seen with worker_shutdown_timeout.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 while (<$client>) { } |
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 } |
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 ############################################################################### |