Skip to content

Commit b3c872e

Browse files
committed
added a passing test for openresty#853.
thanks jinhua luo for the original test case in openresty/lua-resty-core#58.
1 parent da11870 commit b3c872e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

t/138-balancer.t

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,41 @@ retry counter: 5
488488
489489
--- error_log
490490
set more tries: reduced tries due to limit
491+
492+
493+
494+
=== TEST 16: set_more_tries bugfix
495+
--- http_config
496+
lua_package_path "../lua-resty-core/lib/?.lua;;";
497+
proxy_next_upstream_tries 0;
498+
upstream backend {
499+
server 0.0.0.1;
500+
balancer_by_lua_block {
501+
local balancer = require "ngx.balancer"
502+
local ctx = ngx.ctx
503+
if not ctx.has_run then
504+
ctx.has_run = true
505+
local _, err = balancer.set_more_tries(3)
506+
if err then
507+
ngx.log(ngx.ERR, "failed to set more tries: ", err)
508+
end
509+
end
510+
balancer.set_current_peer("127.0.0.1", 81)
511+
}
512+
}
513+
--- config
514+
location = /t {
515+
proxy_pass http://backend;
516+
}
517+
--- request
518+
GET /t
519+
--- error_code: 502
520+
--- grep_error_log eval: qr/http next upstream, \d+/
521+
--- grep_error_log_out
522+
http next upstream, 2
523+
http next upstream, 2
524+
http next upstream, 2
525+
http next upstream, 2
526+
--- no_error_log
527+
failed to set more tries: reduced tries due to limit
528+
[alert]

0 commit comments

Comments
 (0)