Mercurial > hg > nginx-tests
annotate stream_upstream_max_conns.t @ 1588:3afb634f287d
Tests: fixed h2_max_requests.t TODOs on linux.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 02 Sep 2020 23:42:12 +0300 |
parents | 3c101e516213 |
children | f3ba4c74de31 |
rev | line source |
---|---|
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Nginx, Inc. |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
4 # (C) Sergey Kandaurov |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
6 # Tests for stream upstream module with max_conns feature. |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use IO::Select; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx qw/ :DEFAULT http_end /; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/stream stream_upstream_least_conn/) |
1394
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
28 ->has(qw/stream_upstream_hash/)->plan(14); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 $t->write_file_expand('nginx.conf', <<'EOF'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 events { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
39 stream { |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 upstream u_unlim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server 127.0.0.1:8081 max_conns=0; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 upstream u_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server 127.0.0.1:8081 max_conns=3; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 upstream u_backup { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 server 127.0.0.1:8082 backup; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 upstream u_backup_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server 127.0.0.1:8082 backup max_conns=3; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 upstream u_two { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server 127.0.0.1:8082 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 upstream u_some { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 upstream u_many { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 upstream u_weight { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 server 127.0.0.1:8081 weight=2 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 upstream u_lc { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 upstream u_lc_backup { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 server 127.0.0.1:8082 backup; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 upstream u_lc_backup_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 server 127.0.0.1:8082 backup max_conns=3; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
1394
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
92 upstream u_hash { |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
93 hash $remote_addr; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
94 server 127.0.0.1:8081 max_conns=1; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
95 server 127.0.0.1:8082 max_conns=2; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
96 } |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
97 upstream u_chash { |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
98 hash $remote_addr consistent; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
99 server 127.0.0.1:8081 max_conns=1; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
100 server 127.0.0.1:8082 max_conns=2; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
101 } |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
102 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
103 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
104 listen 127.0.0.1:8086; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
105 proxy_pass u_unlim; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
106 } |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
107 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
108 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
109 listen 127.0.0.1:8087; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
110 proxy_pass u_lim; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 server { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
114 listen 127.0.0.1:8088; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
115 proxy_pass u_backup; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
116 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
118 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
119 listen 127.0.0.1:8089; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
120 proxy_pass u_backup_lim; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
121 } |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
122 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
123 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
124 listen 127.0.0.1:8090; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
125 proxy_pass u_two; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 server { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
129 listen 127.0.0.1:8091; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
130 proxy_pass u_some; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
131 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
133 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
134 listen 127.0.0.1:8092; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
135 proxy_pass u_many; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
136 } |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
137 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
138 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
139 listen 127.0.0.1:8093; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
140 proxy_pass u_weight; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
141 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
143 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
144 listen 127.0.0.1:8094; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
145 proxy_pass u_lc; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
146 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
148 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
149 listen 127.0.0.1:8095; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
150 proxy_pass u_lc_backup; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
151 } |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
152 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
153 server { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
154 listen 127.0.0.1:8096; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
155 proxy_pass u_lc_backup_lim; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 } |
1394
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
157 |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
158 server { |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
159 listen 127.0.0.1:8097; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
160 proxy_pass u_hash; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
161 } |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
162 |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
163 server { |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
164 listen 127.0.0.1:8098; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
165 proxy_pass u_chash; |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
166 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 EOF |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 $t->run_daemon(\&http_daemon, port(8081), port(8082), port(8085)); |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
172 $t->run(); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 $t->waitforsocket('127.0.0.1:' . port(8081)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 $t->waitforsocket('127.0.0.1:' . port(8082)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 $t->waitforsocket('127.0.0.1:' . port(8085)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 my @ports = my ($p1, $p2) = (port(8081), port(8082)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 # two peers without max_conns |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
184 is(parallel(8086, '/u_unlim?delay=0', 4), "$p1: 2, $p2: 2", 'unlimited'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 # reopen connection to test connection subtraction |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
188 my @s = http_get_multi(8087, '/u_lim', 2, 1.1); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
189 get(8087, '/close'); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
190 push @s, http_get_multi(8087, '/u_lim', 1, 1.1); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
191 get(8085, '/closeall'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
193 is(http_end_multi(\@s), "$p1: 3", 'conn subtraction'); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
194 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
195 # simple test with limited peer |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
196 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
197 is(parallel(8087, '/u_lim', 4), "$p1: 3", 'single'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 # limited peer with backup peer |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
201 is(peers(8088, '/u_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", 'backup'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 # peer and backup peer, both limited |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
205 is(peers(8089, '/u_backup_lim', 6), "$p1 $p1 $p2 $p2 $p2 ", 'backup limited'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 # all peers limited |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
209 is(parallel(8090, '/u_two', 4), "$p1: 1, $p2: 1", 'all peers'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 # subset of peers limited |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
213 is(parallel(8091, '/u_some', 4), "$p1: 1, $p2: 3", 'some peers'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
214 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
215 # ensure that peer "weight" does not affect its max_conns limit |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
217 is(parallel(8093, '/u_weight', 4), "$p1: 1, $p2: 3", 'weight'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 # peers with equal server value aggregate max_conns limit |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
221 is(parallel(8092, '/u_many', 6), "$p1: 2, $p2: 4", 'equal peer'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 # least_conn balancer tests |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
225 is(parallel(8094, '/u_lc', 4), "$p1: 1, $p2: 3", 'least_conn'); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
226 is(peers(8095, '/u_lc_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
227 'least_conn backup'); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
228 is(peers(8096, '/u_lc_backup_lim', 6), "$p1 $p1 $p2 $p2 $p2 ", |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 'least_conn backup limited'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 |
1394
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
231 # hash balancer tests |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
232 |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
233 is(parallel(8097, '/u_hash', 4), "$p1: 1, $p2: 2", 'hash'); |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
234 is(parallel(8098, '/u_chash', 4), "$p1: 1, $p2: 2", 'hash consistent'); |
3c101e516213
Tests: added upstream max_conns tests with hash balancer.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1391
diff
changeset
|
235 |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 sub peers { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
239 my ($port, $uri, $count) = @_; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
241 my @sockets = http_get_multi($port, $uri, $count, 1.1); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
242 get(8085, '/closeall'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
244 join ' ', map { defined $_ && /X-Port: (\d+)/ && $1 } |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 map { http_end $_ } (@sockets); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 sub parallel { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
249 my ($port, $uri, $count) = @_; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
251 my @sockets = http_get_multi($port, $uri, $count); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 for (1 .. 20) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 last if IO::Select->new(@sockets)->can_read(3) == $count; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 select undef, undef, undef, 0.01; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 } |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
256 get(8085, '/closeall'); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 return http_end_multi(\@sockets); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
260 sub get { |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
261 my ($port, $uri, %opts) = @_; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
262 my $s = IO::Socket::INET->new( |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
263 Proto => 'tcp', |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
264 PeerAddr => '127.0.0.1', |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
265 PeerPort => port($port), |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
266 ) |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
267 or die "Can't connect to nginx: $!\n"; |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
268 |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
269 http_get($uri, socket => $s, %opts); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
270 } |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
271 |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 sub http_get_multi { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
273 my ($port, $uri, $count, $wait) = @_; |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
274 my @sockets; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
275 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 for (0 .. $count - 1) { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
277 $sockets[$_] = get($port, $uri, start => 1); |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 IO::Select->new($sockets[$_])->can_read($wait) if $wait; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 return @sockets; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
283 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
284 sub http_end_multi { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
285 my ($sockets) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
286 my %ports; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
287 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
288 for my $sock (@$sockets) { |
1391
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
289 my $r = http_end($sock); |
62f06d8dfc63
Tests: ported upstream max_conns tests to stream, reduced diffs.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
290 if ($r && $r =~ /X-Port: (\d+)/) { |
1041
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
291 $ports{$1} = 0 unless defined $ports{$1}; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
292 $ports{$1}++; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
293 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
294 close $sock; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
295 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
296 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
297 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
301 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
302 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
303 sub http_daemon { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
304 my (@ports) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
305 my (@socks, @clients); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
306 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
307 for my $port (@ports) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
308 my $server = IO::Socket::INET->new( |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
309 Proto => 'tcp', |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
310 LocalHost => "127.0.0.1:$port", |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
311 Listen => 42, |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
312 Reuse => 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
313 ) |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 or die "Can't create listening socket: $!\n"; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
315 push @socks, $server; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
316 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
317 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
318 my $sel = IO::Select->new(@socks); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
319 my $skip = 4; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
320 my $count = 0; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
321 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
322 local $SIG{PIPE} = 'IGNORE'; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
323 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
324 OUTER: |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
325 while (my @ready = $sel->can_read) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
326 foreach my $fh (@ready) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
327 if (grep $_ == $fh, @socks) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
328 my $new = $fh->accept; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
329 $new->autoflush(1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
330 $sel->add($new); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
331 $count++; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
332 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
333 } else { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
334 my @busy = grep { $_->sockport() } @ready; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
335 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
336 # finish other handles |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
337 if ($fh->sockport() == port(8085) && @busy > 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
338 && grep $_->sockport() != port(8085), |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
339 @busy) |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
340 { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
341 next; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
342 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
343 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
344 # late events in other handles |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
345 if ($fh->sockport() == port(8085) && @busy == 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
346 && $count > 1 && $skip-- > 0) |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
347 { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
348 select undef, undef, undef, 0.1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
349 next OUTER; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
350 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
351 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
352 my $rv = process_socket($fh, \@clients); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
353 if ($rv == 1) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
354 $sel->remove($fh); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
355 $fh->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
356 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
357 if ($rv == 2) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
358 for (@clients) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
359 $sel->remove($_); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
360 $_->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
361 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
362 $sel->remove($fh); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
363 $fh->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
364 $skip = 4; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
365 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
366 $count--; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
367 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
368 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
369 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
370 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
371 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
372 # Returns true to close connection |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
373 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
374 sub process_socket { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
375 my ($client, $saved) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
376 my $port = $client->sockport(); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
377 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
378 my $headers = ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
379 my $uri = ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
380 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
381 while (<$client>) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
382 $headers .= $_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
383 last if (/^\x0d?\x0a?$/); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
384 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
385 return 1 if $headers eq ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
386 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
387 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
388 return 1 if $uri eq ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
389 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
390 Test::Nginx::log_core('||', "$port: response, 200"); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
391 print $client <<EOF; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
392 HTTP/1.1 200 OK |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
393 X-Port: $port |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
394 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
395 OK |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
396 EOF |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
397 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
398 return 2 if $uri =~ /closeall/; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
399 return 1 if $uri =~ /close/; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
400 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
401 push @$saved, $client; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
402 return 0; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
403 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
404 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
405 ############################################################################### |