Mercurial > hg > nginx-tests
annotate stream_proxy_next_upstream.t @ 1679:74986ebee2fd
Tests: added proxy_timeout in mail tests.
Default proxy_timeout in mail proxy is 24h, so if nginx shutdown after a test
waits for the timeout to expire for some reason, this may take a while
and hard to diagnose.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 19 May 2021 04:32:59 +0300 |
parents | da1325cb1c39 |
children | 5ac6efbe5552 |
rev | line source |
---|---|
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream proxy module, proxy_next_upstream directive and friends. |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
816
77359b849cd5
Tests: stream package.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
572
diff
changeset
|
19 use Test::Nginx::Stream qw/ stream /; |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1632
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/stream/)->plan(5); |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 stream { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1505
diff
changeset
|
38 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1505
diff
changeset
|
39 |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 upstream u { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 server 127.0.0.1:8083 max_fails=0; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
42 server 127.0.0.1:8084 max_fails=0; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 server 127.0.0.1:8085 backup; |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
572
ca54b445d982
Tests: masked nginx bug in proxy next upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
565
diff
changeset
|
46 upstream u2 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
47 server 127.0.0.1:8083; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 server 127.0.0.1:8085 backup; |
572
ca54b445d982
Tests: masked nginx bug in proxy next upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
565
diff
changeset
|
49 } |
ca54b445d982
Tests: masked nginx bug in proxy next upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
565
diff
changeset
|
50 |
1632
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
51 upstream u3 { |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
52 server 127.0.0.1:8083; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
53 server 127.0.0.1:8085 down; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
54 } |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
55 |
1505
76090a5da00b
Tests: unbreak various tests with TCP blackhole.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1468
diff
changeset
|
56 proxy_connect_timeout 2; |
76090a5da00b
Tests: unbreak various tests with TCP blackhole.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1468
diff
changeset
|
57 |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
59 listen 127.0.0.1:8080; |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 proxy_pass u; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 proxy_next_upstream off; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
65 listen 127.0.0.1:8081; |
572
ca54b445d982
Tests: masked nginx bug in proxy next upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
565
diff
changeset
|
66 proxy_pass u2; |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 proxy_next_upstream on; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
71 listen 127.0.0.1:8082; |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 proxy_pass u; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 proxy_next_upstream on; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 proxy_next_upstream_tries 2; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
1632
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
76 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
77 log_format test "$upstream_addr"; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
78 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
79 server { |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
80 listen 127.0.0.1:8086; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
81 proxy_pass u3; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
82 proxy_next_upstream on; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
83 access_log %%TESTDIR%%/test.log test; |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
84 } |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 EOF |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 $t->run_daemon(\&stream_daemon); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
90 $t->run()->waitforsocket('127.0.0.1:' . port(8085)); |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 ############################################################################### |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
94 is(stream('127.0.0.1:' . port(8080))->io('.'), '', 'next off'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
95 is(stream('127.0.0.1:' . port(8081))->io('.'), 'SEE-THIS', 'next on'); |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 # make sure backup is not tried |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
99 is(stream('127.0.0.1:' . port(8082))->io('.'), '', 'next tries'); |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
1632
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
101 # make sure backend marked as down doesn't count towards "no live upstreams" |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
102 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
103 is(stream('127.0.0.1:' . port(8086))->io('.'), '', 'next down'); |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
104 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
105 $t->stop(); |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
106 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
107 TODO: { |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
108 local $TODO = 'not yet' unless $t->has_version('1.19.6'); |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
109 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
110 is($t->read_file('test.log'), '127.0.0.1:' . port(8083) . "\n", |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
111 'next down log'); |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
112 |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
113 } |
da1325cb1c39
Tests: added proxy_next_upstream test with "down".
Sergey Kandaurov <pluknet@nginx.com>
parents:
1609
diff
changeset
|
114 |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ############################################################################### |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 sub stream_daemon { |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 my $server = IO::Socket::INET->new( |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 Proto => 'tcp', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
120 LocalHost => '127.0.0.1:' . port(8085), |
553
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 Listen => 5, |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 Reuse => 1 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 ) |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 or die "Can't create listening socket: $!\n"; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 local $SIG{PIPE} = 'IGNORE'; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 while (my $client = $server->accept()) { |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 $client->autoflush(1); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 log2c("(new connection $client)"); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 $client->sysread(my $buffer, 65536) or next; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 log2i("$client $buffer"); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 $buffer = 'SEE-THIS'; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 log2o("$client $buffer"); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 $client->syswrite($buffer); |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 } continue { |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 close $client; |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 sub log2c { Test::Nginx::log_core('||', @_); } |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
e47cd1b95997
Tests: stream tests for proxy_next_upstream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 ############################################################################### |