comparison proxy_next_upstream.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents 3d3c8b5ea8ee
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
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:8081; 39 server 127.0.0.1:%%PORT_1%%;
40 server 127.0.0.1:8082; 40 server 127.0.0.1:%%PORT_2%%;
41 } 41 }
42 42
43 upstream u2 { 43 upstream u2 {
44 server 127.0.0.1:8081; 44 server 127.0.0.1:%%PORT_1%%;
45 server 127.0.0.1:8082; 45 server 127.0.0.1:%%PORT_2%%;
46 } 46 }
47 47
48 server { 48 server {
49 listen 127.0.0.1:8080; 49 listen 127.0.0.1:%%PORT_0%%;
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 proxy_next_upstream http_500 http_404; 54 proxy_next_upstream http_500 http_404;
65 return 200 "$upstream_addr\n"; 65 return 200 "$upstream_addr\n";
66 } 66 }
67 } 67 }
68 68
69 server { 69 server {
70 listen 127.0.0.1:8081; 70 listen 127.0.0.1:%%PORT_1%%;
71 server_name localhost; 71 server_name localhost;
72 72
73 location / { 73 location / {
74 return 404; 74 return 404;
75 } 75 }
84 return 404; 84 return 404;
85 } 85 }
86 } 86 }
87 87
88 server { 88 server {
89 listen 127.0.0.1:8082; 89 listen 127.0.0.1:%%PORT_2%%;
90 server_name localhost; 90 server_name localhost;
91 91
92 location / { 92 location / {
93 return 200 "TEST-OK-IF-YOU-SEE-THIS\n"; 93 return 200 "TEST-OK-IF-YOU-SEE-THIS\n";
94 } 94 }
102 EOF 102 EOF
103 103
104 $t->run(); 104 $t->run();
105 105
106 ############################################################################### 106 ###############################################################################
107
108 my ($p1, $p2) = (port(1), port(2));
107 109
108 # check if both request fallback to a backend 110 # check if both request fallback to a backend
109 # which returns valid response 111 # which returns valid response
110 112
111 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); 113 like(http_get('/'), qr/SEE-THIS/, 'proxy request');
126 unlike(http_get('/ok') . http_get('/ok'), qr/AND-THIS/, 'down after 500'); 128 unlike(http_get('/ok') . http_get('/ok'), qr/AND-THIS/, 'down after 500');
127 129
128 # make sure all backends are tried once 130 # make sure all backends are tried once
129 131
130 like(http_get('/all/rr'), 132 like(http_get('/all/rr'),
131 qr/^127.0.0.1:808(1, 127.0.0.1:8082|2, 127.0.0.1:8081)$/mi, 133 qr/^127.0.0.1:($p1, 127.0.0.1:$p2|$p2, 127.0.0.1:$p1)$/mi,
132 'all tried once'); 134 'all tried once');
133 135
134 ############################################################################### 136 ###############################################################################