Mercurial > hg > nginx-tests
comparison upstream.t @ 974:882267679006
Tests: simplified parallel modifications in tests.
Mail tests were simplified in c227348453db.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 17:39:03 +0300 |
parents | e9064d691790 |
children |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
34 | 34 |
35 http { | 35 http { |
36 %%TEST_GLOBALS_HTTP%% | 36 %%TEST_GLOBALS_HTTP%% |
37 | 37 |
38 upstream u { | 38 upstream u { |
39 server 127.0.0.1:%%PORT_1%% max_fails=3 fail_timeout=10s; | 39 server 127.0.0.1:8081 max_fails=3 fail_timeout=10s; |
40 server 127.0.0.1:%%PORT_2%% max_fails=3 fail_timeout=10s; | 40 server 127.0.0.1:8082 max_fails=3 fail_timeout=10s; |
41 } | 41 } |
42 | 42 |
43 upstream u2 { | 43 upstream u2 { |
44 server 127.0.0.1:%%PORT_1%% max_fails=3 fail_timeout=10s; | 44 server 127.0.0.1:8081 max_fails=3 fail_timeout=10s; |
45 server 127.0.0.1:%%PORT_2%% max_fails=3 fail_timeout=10s; | 45 server 127.0.0.1:8082 max_fails=3 fail_timeout=10s; |
46 } | 46 } |
47 | 47 |
48 server { | 48 server { |
49 listen 127.0.0.1:%%PORT_0%%; | 49 listen 127.0.0.1:8080; |
50 server_name localhost; | 50 server_name localhost; |
51 | 51 |
52 location / { | 52 location / { |
53 proxy_pass http://u; | 53 proxy_pass http://u; |
54 } | 54 } |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 EOF | 61 EOF |
62 | 62 |
63 $t->run_daemon(\&http_daemon, port(1)); | 63 $t->run_daemon(\&http_daemon, port(8081)); |
64 $t->run_daemon(\&http_daemon, port(2)); | 64 $t->run_daemon(\&http_daemon, port(8082)); |
65 $t->run(); | 65 $t->run(); |
66 | 66 |
67 $t->waitforsocket('127.0.0.1:' . port(1)); | 67 $t->waitforsocket('127.0.0.1:' . port(8081)); |
68 $t->waitforsocket('127.0.0.1:' . port(2)); | 68 $t->waitforsocket('127.0.0.1:' . port(8082)); |
69 | 69 |
70 ############################################################################### | 70 ############################################################################### |
71 | 71 |
72 my @ports = my ($p1, $p2) = (port(1), port(2)); | 72 my @ports = my ($p1, $p2) = (port(8081), port(8082)); |
73 | 73 |
74 is(many('/', 30), "$p1: 15, $p2: 15", 'balanced'); | 74 is(many('/', 30), "$p1: 15, $p2: 15", 'balanced'); |
75 | 75 |
76 # from 9 first requests to the first port, only 6 will be successful, | 76 # from 9 first requests to the first port, only 6 will be successful, |
77 # 3rd, 6th, and 9th requests will fail; after this the backend | 77 # 3rd, 6th, and 9th requests will fail; after this the backend |
138 last if (/^\x0d?\x0a?$/); | 138 last if (/^\x0d?\x0a?$/); |
139 } | 139 } |
140 | 140 |
141 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; | 141 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
142 | 142 |
143 if ($uri =~ 'close' && $port == port(1) && $count++ % 3 == 0) { | 143 if ($uri =~ 'close' && $port == port(8081) && $count++ % 3 == 0) |
144 { | |
144 next; | 145 next; |
145 } | 146 } |
146 | 147 |
147 print $client <<EOF; | 148 print $client <<EOF; |
148 HTTP/1.1 200 OK | 149 HTTP/1.1 200 OK |