Skip to content

Commit

Permalink
change test case position
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuo.chen committed Jul 9, 2021
1 parent d809dfc commit 079bd50
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 47 deletions.
32 changes: 0 additions & 32 deletions t/admin/upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -1978,35 +1978,3 @@ GET /t
[delete] code: 200 message: passed
--- no_error_log
[error]



=== TEST 57: retry_timeout is -1 (INVALID)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/upstreams/a-b-c-ABC_0123',
ngx.HTTP_PUT,
[[{
"nodes": {
"127.0.0.1:8080": 1,
"127.0.0.1:8090": 1
},
"retry_timeout": -1,
"type": "roundrobin"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.print(body)
}
}
--- request
GET /t
--- error_code: 400
--- response_body
{"error_msg":"invalid configuration: property \"retry_timeout\" validation failed: expected -1 to be greater than 0"}
--- no_error_log
[error]
32 changes: 32 additions & 0 deletions t/admin/upstream3.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,35 @@ __DATA__
}
--- response_body
{"action":"get","count":0,"node":{"dir":true,"key":"/apisix/upstreams","nodes":{}}}
=== TEST 2: retry_timeout is -1 (INVALID)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/upstreams/a-b-c-ABC_0123',
ngx.HTTP_PUT,
[[{
"nodes": {
"127.0.0.1:8080": 1,
"127.0.0.1:8090": 1
},
"retry_timeout": -1,
"type": "roundrobin"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.print(body)
}
}
--- request
GET /t
--- error_code: 400
--- response_body
{"error_msg":"invalid configuration: property \"retry_timeout\" validation failed: expected -1 to be greater than 0"}
--- no_error_log
[error]
15 changes: 5 additions & 10 deletions t/lib/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ end

function _M.mysleep()
ngx.sleep(tonumber(ngx.var.arg_seconds))
ngx.say(ngx.var.arg_seconds)
if ngx.var.arg_abort then
ngx.exit(ngx.ERROR)
else
ngx.say(ngx.var.arg_seconds)
end
end


Expand Down Expand Up @@ -417,13 +421,4 @@ function _M.server_error()
error("500 Internal Server Error")
end

function _M.retry_error()
local sleep = ngx.var.http_x_test_sleep
if sleep ~= nil then
ngx.sleep(tonumber(sleep))
end

ngx.exit(ngx.ERROR)
end

return _M
8 changes: 3 additions & 5 deletions t/node/upstream-retries.t
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ proxy request to 127.0.0.1:1/
"retry_timeout": 2,
"type": "roundrobin"
},
"uri": "/retry_error"
"uri": "/mysleep"
}]]
)

Expand All @@ -299,10 +299,8 @@ proxy request to 127.0.0.1:1/
local http = require "resty.http"
local httpc = http.new()
local uri = "http://127.0.0.1:" .. ngx.var.server_port
.. "/retry_error"
local res, err = httpc:request_uri(uri, {headers={
["X-Test-Sleep"] = "1"
}})
.. "/mysleep?abort=true&seconds=1"
local res, err = httpc:request_uri(uri)
if not res then
ngx.say(err)
return
Expand Down

0 comments on commit 079bd50

Please sign in to comment.