comparison upstream_least_conn.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
35 http { 35 http {
36 %%TEST_GLOBALS_HTTP%% 36 %%TEST_GLOBALS_HTTP%%
37 37
38 upstream u { 38 upstream u {
39 least_conn; 39 least_conn;
40 server 127.0.0.1:%%PORT_1%%; 40 server 127.0.0.1:8081;
41 server 127.0.0.1:%%PORT_2%%; 41 server 127.0.0.1:8082;
42 } 42 }
43 43
44 server { 44 server {
45 listen 127.0.0.1:%%PORT_0%%; 45 listen 127.0.0.1:8080;
46 server_name localhost; 46 server_name localhost;
47 47
48 location / { 48 location / {
49 proxy_pass http://u; 49 proxy_pass http://u;
50 } 50 }
51 } 51 }
52 } 52 }
53 53
54 EOF 54 EOF
55 55
56 $t->run_daemon(\&http_daemon, port(1)); 56 $t->run_daemon(\&http_daemon, port(8081));
57 $t->run_daemon(\&http_daemon, port(2)); 57 $t->run_daemon(\&http_daemon, port(8082));
58 $t->run(); 58 $t->run();
59 59
60 $t->waitforsocket('127.0.0.1:' . port(1)); 60 $t->waitforsocket('127.0.0.1:' . port(8081));
61 $t->waitforsocket('127.0.0.1:' . port(2)); 61 $t->waitforsocket('127.0.0.1:' . port(8082));
62 62
63 ############################################################################### 63 ###############################################################################
64 64
65 my @ports = my ($port1, $port2) = (port(1), port(2)); 65 my @ports = my ($port1, $port2) = (port(8081), port(8082));
66 66
67 is(many('/', 10), "$port1: 5, $port2: 5", 'balanced'); 67 is(many('/', 10), "$port1: 5, $port2: 5", 'balanced');
68 68
69 my @sockets; 69 my @sockets;
70 push(@sockets, http_get('/w', start => 1)); 70 push(@sockets, http_get('/w', start => 1));
118 last if (/^\x0d?\x0a?$/); 118 last if (/^\x0d?\x0a?$/);
119 } 119 }
120 120
121 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; 121 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
122 122
123 if ($uri eq '/w' && $port == port(1)) { 123 if ($uri eq '/w' && $port == port(8081)) {
124 Test::Nginx::log_core('||', "$port: sleep(2.5)"); 124 Test::Nginx::log_core('||', "$port: sleep(2.5)");
125 select undef, undef, undef, 2.5; 125 select undef, undef, undef, 2.5;
126 } 126 }
127 127
128 Test::Nginx::log_core('||', "$port: response, 200"); 128 Test::Nginx::log_core('||', "$port: response, 200");