-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: invalid error after passive health check is changed #5589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,6 +52,15 @@ add_block_preprocessor(sub { | |||||
_EOC_ | ||||||
|
||||||
$block->set_value("init_by_lua_block", $init_by_lua_block); | ||||||
|
||||||
if ((!defined $block->error_log) && (!defined $block->no_error_log)) { | ||||||
$block->set_value("no_error_log", "[error]"); | ||||||
} | ||||||
|
||||||
if (!defined $block->request) { | ||||||
$block->set_value("request", "GET /t"); | ||||||
} | ||||||
|
||||||
}); | ||||||
|
||||||
run_tests; | ||||||
|
@@ -90,12 +99,8 @@ __DATA__ | |||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -137,12 +142,8 @@ passed | |||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -166,13 +167,9 @@ passed | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"healthy\" validation failed: property \"successes\" validation failed: expected 255 to be smaller than 254"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -196,13 +193,9 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"healthy\" validation failed: property \"successes\" validation failed: expected 0 to be greater than 1"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -226,13 +219,9 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"passive\" validation failed: property \"unhealthy\" validation failed: property \"http_statuses\" validation failed: failed to validate item 2: expected 600 to be smaller than 599"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -254,13 +243,9 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"type\" validation failed: matches none of the enum values"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -284,13 +269,9 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"healthy\" validation failed: property \"http_statuses\" validation failed: expected unique items but items 1 and 2 are equal"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -314,13 +295,9 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"unhealthy\" validation failed: property \"http_failures\" validation failed: wrong type: expected integer, got number"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -353,12 +330,8 @@ GET /t | |||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -391,12 +364,8 @@ passed | |||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -429,13 +398,9 @@ passed | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: property \"active\" validation failed: property \"req_headers\" validation failed: failed to validate item 2: wrong type: expected string, got number"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
|
@@ -469,17 +434,64 @@ GET /t | |||||
ngx.print(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- error_code: 400 | ||||||
--- response_body | ||||||
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: object matches none of the requireds: [\"active\"] or [\"active\",\"passive\"]"} | ||||||
--- no_error_log | ||||||
[error] | ||||||
|
||||||
|
||||||
|
||||||
=== TEST 13: number type timeout | ||||||
=== TEST 13: only active | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this test is to verify that the default passive configuration will be added in the case of active only. I think this title description is not very accurate, what do you think? |
||||||
--- config | ||||||
location /t { | ||||||
content_by_lua_block { | ||||||
local t = require("lib.test_admin").test | ||||||
|
||||||
req_data.upstream.checks = json.decode([[{ | ||||||
"active": { | ||||||
"http_path": "/status", | ||||||
"host": "foo.com", | ||||||
"healthy": { | ||||||
"interval": 2, | ||||||
"successes": 1 | ||||||
}, | ||||||
"unhealthy": { | ||||||
"interval": 1, | ||||||
"http_failures": 2 | ||||||
} | ||||||
} | ||||||
}]]) | ||||||
exp_data.node.value.upstream.checks.active = req_data.upstream.checks.active | ||||||
exp_data.node.value.upstream.checks.passive = { | ||||||
type = "http", | ||||||
healthy = { | ||||||
http_statuses = { 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, | ||||||
300, 301, 302, 303, 304, 305, 306, 307, 308 }, | ||||||
successes = 0, | ||||||
}, | ||||||
unhealthy = { | ||||||
http_statuses = { 429, 500, 503 }, | ||||||
tcp_failures = 0, | ||||||
timeouts = 0, | ||||||
http_failures = 0, | ||||||
} | ||||||
} | ||||||
|
||||||
local code, body = t('/apisix/admin/routes/1', | ||||||
ngx.HTTP_PUT, | ||||||
req_data, | ||||||
exp_data | ||||||
) | ||||||
|
||||||
ngx.status = code | ||||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- response_body | ||||||
passed | ||||||
|
||||||
|
||||||
|
||||||
=== TEST 14: number type timeout | ||||||
--- config | ||||||
location /t { | ||||||
content_by_lua_block { | ||||||
|
@@ -512,9 +524,5 @@ GET /t | |||||
ngx.say(body) | ||||||
} | ||||||
} | ||||||
--- request | ||||||
GET /t | ||||||
--- response_body | ||||||
passed | ||||||
--- no_error_log | ||||||
[error] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to set a zero default? Do we need to update the doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the value to 0 will disable the passive health check, which is necessary when only the active check is configured, documentation needs to be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document updated