3
3
use Test ::Nginx::Socket;
4
4
5
5
repeat_each(2 );
6
- plan tests => repeat_each() * (2 * blocks());
6
+ plan tests => repeat_each() * (2 * ( blocks() + 2 ));
7
7
8
8
no_shuffle();
9
9
run_tests();
@@ -166,56 +166,43 @@ __DATA__
166
166
echo Failover;
167
167
}
168
168
-- - request
169
+ # it seems that there is no possibility to model sequential requests patterns
170
+ # such as testing that multiple requests must effectively hit all servers in
171
+ # the upstream, so here is only a simple check that a request hits one of them
169
172
GET / cmb
170
173
-- - response_body_like
171
174
Passed to backend[12 ]$
172
175
-- - error_code: 200
173
176
174
- === TEST 2 : combined upstreams singlets 1
175
- -- - request
176
- GET / cmb1
177
- -- - response_body
178
- Passed to backend1
179
- -- - error_code: 200
180
-
181
- === TEST 3 : combined upstreams singlets 2
182
- -- - request
183
- GET / cmb2
184
- -- - response_body
185
- Passed to backend2
186
- -- - error_code: 200
187
-
188
- === TEST 4 : combined upstreams singlets by cookie 1
189
- -- - more_headers
190
- Cookie: rt= 1
191
- -- - request
192
- GET / cmb3
193
- -- - response_body
194
- Passed to backend1
195
- -- - error_code: 200
177
+ === TEST 2 : combined upstreams singlets
178
+ -- - request eval
179
+ [" GET /cmb1" , " GET /cmb2" ]
180
+ -- - response_body eval
181
+ [" Passed to backend1\n " , " Passed to backend2\n " ]
182
+ -- - error_code eval: [200 , 200 ]
196
183
197
- === TEST 5 : combined upstreams singlets bu cookie 2
198
- -- - more_headers
199
- Cookie: rt= 2
200
- -- - request
201
- GET / cmb3
202
- -- - response_body
203
- Passed to backend2
204
- -- - error_code: 200
184
+ === TEST 3 : combined upstreams singlets by cookie
185
+ -- - more_headers eval
186
+ [ " Cookie: rt=1 " , " Cookie: rt=2 " ]
187
+ -- - request eval
188
+ [ " GET /cmb3" , " GET /cmb3 " ]
189
+ -- - response_body eval
190
+ [ " Passed to backend1 \n " , " Passed to backend2\n " ]
191
+ -- - error_code eval : [ 200 , 200 ]
205
192
206
- === TEST 6 : upstrand last returned alive
193
+ === TEST 4 : upstrand last returned alive
207
194
-- - request
208
195
GET / us1
209
196
-- - response_body
210
197
In 8060
211
198
-- - error_code: 200
212
199
213
- === TEST 7 : upstrand last returned no live
200
+ === TEST 5 : upstrand last returned no live
214
201
-- - request
215
202
GET / us2
216
203
-- - response_body_filters eval
217
204
sub {
218
- my ( $ text ) = @ _ ;
205
+ my $ text = shift ;
219
206
my @ lines = split / \r\n/ , $ text ;
220
207
my @ matches = grep / 503 Service Temporarily Unavailable/ , @ lines ;
221
208
scalar @ matches ? " FOUND" : " NOT FOUND" ;
@@ -224,43 +211,45 @@ sub {
224
211
FOUND
225
212
-- - error_code: 503
226
213
227
- === TEST 8 : upstrand intercepted
214
+ === TEST 6 : upstrand intercepted
228
215
-- - request
229
216
GET / us3
230
217
-- - response_body
231
218
Failover
232
219
-- - error_code: 503
233
220
234
- === TEST 9 : upstrand variable echo
221
+ === TEST 7 : upstrand variable echo
235
222
-- - request
223
+ # upstreams u01 and u02 must have been blacklisted to this moment,
224
+ # so upstream b01 is expected to be returned
236
225
GET / echo/ us1
237
226
-- - response_body
238
227
b01
239
228
-- - error_code: 200
240
229
241
- === TEST 10 : dynamic upstrand returned alive
230
+ === TEST 8 : dynamic upstrand returned alive
242
231
-- - request
243
232
GET / dus1? b= us1
244
233
-- - response_body
245
234
In 8060
246
235
-- - error_code: 200
247
236
248
- === TEST 11 : dynamic upstrand failover
237
+ === TEST 9 : dynamic upstrand failover
249
238
-- - request
250
239
GET / dus1? b= us3
251
240
-- - response_body
252
241
Failover
253
242
-- - error_code: 503
254
243
255
- === TEST 12 : upstrand zipped response
244
+ === TEST 10 : upstrand zipped response
256
245
-- - more_headers
257
246
Accept-Encoding: gzip
258
247
-- - request
259
248
GET / zus1
260
249
-- - response_body_filters eval
261
250
use IO ::Uncompress::Gunzip qw ( gunzip ) ;
262
251
sub {
263
- my ( $ text ) = @ _ ;
252
+ my $ text = shift ;
264
253
my $ res ;
265
254
gunzip \$ text => \$ res or die $! ;
266
255
$ res ;
0 commit comments