Mercurial > hg > nginx-tests
annotate upstream_max_conns.t @ 1156:d12c45f14102
Tests: handled EOF in ssl_proxy_upgrade.t.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 28 Mar 2017 17:58:42 +0300 |
parents | 187524328926 |
children | 766bcbb632ee |
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. |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # Tests for upstream module with max_conns feature. |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 |
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 use warnings; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use strict; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use Test::More; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 use IO::Select; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx qw/ :DEFAULT http_end /; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
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 select STDERR; $| = 1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new() |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has(qw/http proxy rewrite upstream_least_conn upstream_ip_hash/); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
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 http { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 upstream u_unlim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server 127.0.0.1:8081 max_conns=0; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 upstream u_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server 127.0.0.1:8081 max_conns=3; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 upstream u_backup { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 server 127.0.0.1:8082 backup; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 upstream u_backup_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 server 127.0.0.1:8082 backup max_conns=3; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 upstream u_two { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 server 127.0.0.1:8082 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 upstream u_some { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 upstream u_many { |
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:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 server 127.0.0.1:8082; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 upstream u_weight { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 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
|
74 server 127.0.0.1:8082; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 upstream u_pnu { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 # special server to force next upstream |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 server 127.0.0.1:8084; |
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 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 server 127.0.0.1:8082 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 upstream u_lc { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 server 127.0.0.1:8082; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 upstream u_lc_backup { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 server 127.0.0.1:8082 backup; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 upstream u_lc_backup_lim { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 least_conn; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 server 127.0.0.1:8081 max_conns=2; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 server 127.0.0.1:8082 backup max_conns=3; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 upstream u_ih { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 ip_hash; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 server 127.0.0.1:8081 max_conns=1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 server { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 listen 127.0.0.1:8084; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 server_name localhost; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 location / { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 return 444; |
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 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 server { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 listen 127.0.0.1:8080; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 server_name localhost; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 proxy_http_version 1.1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 proxy_set_header Connection ""; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 proxy_buffering off; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 location /u { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 proxy_pass http:/$uri; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 } |
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 location /close { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 proxy_pass http://127.0.0.1:8085; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 EOF |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 $t->run_daemon(\&http_daemon, port(8081), port(8082), port(8085)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 $t->try_run('no upstream max_conns')->plan(14); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 $t->waitforsocket('127.0.0.1:' . port(8081)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 $t->waitforsocket('127.0.0.1:' . port(8082)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 $t->waitforsocket('127.0.0.1:' . port(8085)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 my @ports = my ($p1, $p2) = (port(8081), port(8082)); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 # two peers without max_conns |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 is(parallel('/u_unlim?delay=0', 4), "$p1: 2, $p2: 2", 'unlimited'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 # simple test with limited peer |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 is(parallel('/u_lim', 4), "$p1: 3", 'single'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 # reopen connection to test connection subtraction |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 my @s = http_get_multi('/u_lim', 1, 1.1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 http_get('/u_lim/close'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 push @s, http_get_multi('/u_lim', 1, 1.1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 http_get('/closeall'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 is(http_end_multi(\@s), "$p1: 2", 'conn subtraction'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 # limited peer with backup peer |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 is(peers('/u_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", 'backup'); |
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 # peer and backup peer, both limited |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 is(peers('/u_backup_lim', 6), "$p1 $p1 $p2 $p2 $p2 ", 'backup limited'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 # all peers limited |
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 is(parallel('/u_two', 4), "$p1: 1, $p2: 1", 'all peers'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 # subset of peers limited |
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 is(parallel('/u_some', 4), "$p1: 1, $p2: 3", 'some peers'); |
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 # 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
|
181 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 is(parallel('/u_weight', 4), "$p1: 1, $p2: 3", 'weight'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 # peers with equal server value aggregate max_conns limit |
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 is(parallel('/u_many', 6), "$p1: 2, $p2: 4", 'equal peer'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 # connections to peer selected with proxy_next_upstream are counted |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 is(parallel('/u_pnu', 4), "$p1: 1, $p2: 2", 'proxy_next_upstream'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 # least_conn balancer tests |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 is(parallel('/u_lc', 4), "$p1: 1, $p2: 3", 'least_conn'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 is(peers('/u_lc_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", 'least_conn backup'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 is(peers('/u_lc_backup_lim', 6), "$p1 $p1 $p2 $p2 $p2 ", |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 'least_conn backup limited'); |
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 # ip_hash balancer tests |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 is(parallel('/u_ih', 4), "$p1: 1", 'ip_hash'); |
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 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 sub peers { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 my ($uri, $count) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 my @sockets = http_get_multi($uri, $count, 1.1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 http_get('/closeall'); |
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 join ' ', map { /X-Port: (\d+)/ && $1 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 map { http_end $_ } (@sockets); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 } |
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 sub parallel { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
216 my ($uri, $count) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 my @sockets = http_get_multi($uri, $count); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 for (1 .. 20) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 last if IO::Select->new(@sockets)->can_read(3) == $count; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
221 select undef, undef, undef, 0.01; |
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 http_get('/closeall'); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 return http_end_multi(\@sockets); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 sub http_get_multi { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 my ($uri, $count, $wait) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 my @sockets; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 for (0 .. $count - 1) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 $sockets[$_] = http_get($uri, start => 1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 IO::Select->new($sockets[$_])->can_read($wait) if $wait; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 return @sockets; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 sub http_end_multi { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 my ($sockets) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 my %ports; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 for my $sock (@$sockets) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 if (http_end($sock) =~ /X-Port: (\d+)/) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 $ports{$1} = 0 unless defined $ports{$1}; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 $ports{$1}++; |
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 close $sock; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 ############################################################################### |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
256 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 sub http_daemon { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 my (@ports) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 my (@socks, @clients); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 for my $port (@ports) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 my $server = IO::Socket::INET->new( |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 Proto => 'tcp', |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
264 LocalHost => "127.0.0.1:$port", |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
265 Listen => 42, |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
266 Reuse => 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 ) |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 or die "Can't create listening socket: $!\n"; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 push @socks, $server; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 my $sel = IO::Select->new(@socks); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
273 my $skip = 4; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
274 my $count = 0; |
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 local $SIG{PIPE} = 'IGNORE'; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
277 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 OUTER: |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
279 while (my @ready = $sel->can_read) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
280 foreach my $fh (@ready) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
281 if (grep $_ == $fh, @socks) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
282 my $new = $fh->accept; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
283 $new->autoflush(1); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
284 $sel->add($new); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
285 $count++; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
286 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
287 } else { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
288 my @busy = grep { $_->sockport() } @ready; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
289 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
290 # finish other handles |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
291 if ($fh->sockport() == port(8085) && @busy > 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
292 && grep $_->sockport() != port(8085), |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
293 @busy) |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
294 { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
295 next; |
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 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 # late events in other handles |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 if ($fh->sockport() == port(8085) && @busy == 1 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 && $count > 1 && $skip-- > 0) |
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 select undef, undef, undef, 0.1; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
303 next OUTER; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
304 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
305 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
306 my $rv = process_socket($fh, \@clients); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
307 if ($rv == 1) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
308 $sel->remove($fh); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
309 $fh->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
310 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
311 if ($rv == 2) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
312 for (@clients) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
313 $sel->remove($_); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 $_->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
315 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
316 $sel->remove($fh); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
317 $fh->close; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
318 $skip = 4; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
319 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
320 $count--; |
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 } |
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 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
325 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
326 # Returns true to close connection |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
327 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
328 sub process_socket { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
329 my ($client, $saved) = @_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
330 my $port = $client->sockport(); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
331 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
332 my $headers = ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
333 my $uri = ''; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
334 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
335 while (<$client>) { |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
336 $headers .= $_; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
337 last if (/^\x0d?\x0a?$/); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
338 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
339 return 1 if $headers eq ''; |
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 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
342 return 1 if $uri eq ''; |
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 Test::Nginx::log_core('||', "$port: response, 200"); |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
345 print $client <<EOF; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
346 HTTP/1.1 200 OK |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
347 X-Port: $port |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
348 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
349 OK |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
350 EOF |
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 return 2 if $uri =~ /closeall/; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
353 return 1 if $uri =~ /close/; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
354 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
355 push @$saved, $client; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
356 return 0; |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
357 } |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
358 |
187524328926
Tests: upstream max_conns tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
359 ############################################################################### |