Mercurial > hg > nginx-tests
annotate stream_proxy_complex.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 | f3ba4c74de31 |
children |
rev | line source |
---|---|
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream proxy module with complex value. |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::Stream qw/ stream /; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/stream stream_return/) |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->write_file_expand('nginx.conf', <<'EOF'); |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 stream { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1251
diff
changeset
|
37 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1251
diff
changeset
|
38 |
991
6246d69857cc
Tests: fixed stream_proxy_complex.t when run in parallel.
Sergey Kandaurov <pluknet@nginx.com>
parents:
987
diff
changeset
|
39 upstream %%PORT_8081%% { |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server 127.0.0.1:8091; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
991
6246d69857cc
Tests: fixed stream_proxy_complex.t when run in parallel.
Sergey Kandaurov <pluknet@nginx.com>
parents:
987
diff
changeset
|
43 upstream %%PORT_8082%% { |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 server 127.0.0.1:8092; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server 127.0.0.1:8093; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 listen 127.0.0.1:8081; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 listen 127.0.0.1:8082; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_pass $server_port; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 listen 127.0.0.1:8083; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 proxy_pass $server_addr:%%PORT_8093%%; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 listen 127.0.0.1:8091; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 listen 127.0.0.1:8092; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 listen 127.0.0.1:8093; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 return $server_port; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 EOF |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
992
diff
changeset
|
69 $t->run()->plan(5); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
73 is(stream('127.0.0.1:' . port(8081))->read(), port(8091), 'upstream'); |
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
74 is(stream('127.0.0.1:' . port(8081))->read(), port(8091), 'upstream again'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
76 is(stream('127.0.0.1:' . port(8082))->read(), port(8092), 'upstream 2'); |
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
77 is(stream('127.0.0.1:' . port(8082))->read(), port(8093), 'upstream second'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
79 is(stream('127.0.0.1:' . port(8083))->read(), port(8093), 'implicit'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 ############################################################################### |