Skip to content

Commit 6a8c23a

Browse files
committed
minor improvements in tests
1 parent c93770f commit 6a8c23a

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

test/t/basic.t

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use Test::Nginx::Socket;
44

55
repeat_each(2);
6-
plan tests => repeat_each() * (2 * blocks());
6+
plan tests => repeat_each() * (2 * (blocks() + 2));
77

88
no_shuffle();
99
run_tests();
@@ -166,56 +166,43 @@ __DATA__
166166
echo Failover;
167167
}
168168
--- 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
169172
GET /cmb
170173
--- response_body_like
171174
Passed to backend[12]$
172175
--- error_code: 200
173176

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]
196183

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]
205192

206-
=== TEST 6: upstrand last returned alive
193+
=== TEST 4: upstrand last returned alive
207194
--- request
208195
GET /us1
209196
--- response_body
210197
In 8060
211198
--- error_code: 200
212199

213-
=== TEST 7: upstrand last returned no live
200+
=== TEST 5: upstrand last returned no live
214201
--- request
215202
GET /us2
216203
--- response_body_filters eval
217204
sub {
218-
my ($text) = @_;
205+
my $text = shift;
219206
my @lines = split /\r\n/, $text;
220207
my @matches = grep /503 Service Temporarily Unavailable/, @lines;
221208
scalar @matches ? "FOUND" : "NOT FOUND";
@@ -224,43 +211,45 @@ sub {
224211
FOUND
225212
--- error_code: 503
226213

227-
=== TEST 8: upstrand intercepted
214+
=== TEST 6: upstrand intercepted
228215
--- request
229216
GET /us3
230217
--- response_body
231218
Failover
232219
--- error_code: 503
233220

234-
=== TEST 9: upstrand variable echo
221+
=== TEST 7: upstrand variable echo
235222
--- request
223+
# upstreams u01 and u02 must have been blacklisted to this moment,
224+
# so upstream b01 is expected to be returned
236225
GET /echo/us1
237226
--- response_body
238227
b01
239228
--- error_code: 200
240229

241-
=== TEST 10: dynamic upstrand returned alive
230+
=== TEST 8: dynamic upstrand returned alive
242231
--- request
243232
GET /dus1?b=us1
244233
--- response_body
245234
In 8060
246235
--- error_code: 200
247236

248-
=== TEST 11: dynamic upstrand failover
237+
=== TEST 9: dynamic upstrand failover
249238
--- request
250239
GET /dus1?b=us3
251240
--- response_body
252241
Failover
253242
--- error_code: 503
254243

255-
=== TEST 12: upstrand zipped response
244+
=== TEST 10: upstrand zipped response
256245
--- more_headers
257246
Accept-Encoding: gzip
258247
--- request
259248
GET /zus1
260249
--- response_body_filters eval
261250
use IO::Uncompress::Gunzip qw (gunzip);
262251
sub {
263-
my ($text) = @_;
252+
my $text = shift;
264253
my $res;
265254
gunzip \$text => \$res or die $!;
266255
$res;

test/t/timeout.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use Test::Nginx::Socket;
44

55
repeat_each(1);
6-
plan tests => repeat_each() * (2 * 3 * blocks());
6+
plan tests => repeat_each() * (2 * (blocks() + 2));
77

88
no_shuffle();
99
run_tests();

0 commit comments

Comments
 (0)