This is an automated email from the ASF dual-hosted git repository. wenming pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push: new f22f494 optimize: updated the error message after updated new `jsonschema`. (#1011) f22f494 is described below commit f22f4943628cdcad0403986b2c546ba9eb880303 Author: YuanSheng Wang <membp...@gmail.com> AuthorDate: Thu Jan 2 21:56:42 2020 +0800 optimize: updated the error message after updated new `jsonschema`. (#1011) --- lua/apisix/schema_def.lua | 4 ++++ rockspec/apisix-master-0.rockspec | 2 +- t/admin/health-check.t | 48 +++++++++++++++++++++++++++++++++++++++ t/admin/routes.t | 8 +++---- t/admin/services.t | 6 ++--- t/admin/upstream.t | 4 ++-- t/plugin/ip-restriction.t | 2 +- 7 files changed, 63 insertions(+), 11 deletions(-) diff --git a/lua/apisix/schema_def.lua b/lua/apisix/schema_def.lua index 1406c49..c4ab627 100644 --- a/lua/apisix/schema_def.lua +++ b/lua/apisix/schema_def.lua @@ -218,6 +218,10 @@ local health_checker = { } }, additionalProperties = false, + anyOf = { + {required = {"active"}}, + {required = {"active", "passive"}}, + }, } diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec index b7c2c25..f8cd330 100644 --- a/rockspec/apisix-master-0.rockspec +++ b/rockspec/apisix-master-0.rockspec @@ -46,7 +46,7 @@ dependencies = { "luafilesystem = 1.7.0-2", "lua-tinyyaml = 0.1", "lua-resty-prometheus = 1.0", - "jsonschema = 0.4", + "jsonschema = 0.5", "lua-resty-ipmatcher = 0.3", } diff --git a/t/admin/health-check.t b/t/admin/health-check.t index c056062..8680768 100644 --- a/t/admin/health-check.t +++ b/t/admin/health-check.t @@ -106,6 +106,14 @@ passed 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 + } + }, "passive": { "healthy": { "http_statuses": [200, 201], @@ -428,3 +436,43 @@ GET /t {"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] + + + +=== TEST 12: only passive +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + + req_data.upstream.checks = json.decode([[{ + "passive": { + "healthy": { + "http_statuses": [200, 201], + "successes": 1 + }, + "unhealthy": { + "http_statuses": [500], + "http_failures": 2 + } + } + }]]) + exp_data.node.value.upstream.checks = req_data.upstream.checks + + local code, body = t('/apisix/admin/routes/1', + ngx.HTTP_PUT, + req_data, + exp_data + ) + + ngx.status = code + 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] diff --git a/t/admin/routes.t b/t/admin/routes.t index 48051c2..57bf614 100644 --- a/t/admin/routes.t +++ b/t/admin/routes.t @@ -447,7 +447,7 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"service_id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"service_id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -555,7 +555,7 @@ passed GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -582,7 +582,7 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"upstream_id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"upstream_id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -949,7 +949,7 @@ passed GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"remote_addr\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"remote_addr\" validation failed: object matches none of the requireds"} --- no_error_log [error] diff --git a/t/admin/services.t b/t/admin/services.t index e562975..d9e2f9e 100644 --- a/t/admin/services.t +++ b/t/admin/services.t @@ -461,7 +461,7 @@ passed GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -488,7 +488,7 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -542,7 +542,7 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"upstream_id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"upstream_id\" validation failed: object matches none of the requireds"} --- no_error_log [error] diff --git a/t/admin/upstream.t b/t/admin/upstream.t index 9b0d7f3..6ca7308 100644 --- a/t/admin/upstream.t +++ b/t/admin/upstream.t @@ -360,7 +360,7 @@ passed GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the requireds"} --- no_error_log [error] @@ -390,7 +390,7 @@ GET /t GET /t --- error_code: 400 --- response_body -{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the alternatives"} +{"error_msg":"invalid configuration: property \"id\" validation failed: object matches none of the requireds"} --- no_error_log [error] diff --git a/t/plugin/ip-restriction.t b/t/plugin/ip-restriction.t index ac2371c..9403819 100644 --- a/t/plugin/ip-restriction.t +++ b/t/plugin/ip-restriction.t @@ -565,6 +565,6 @@ GET /hello GET /t --- response_body invalid ip address: ::1/129 -property "whitelist" validation failed: failed to validate item 1: object matches none of the alternatives +property "whitelist" validation failed: failed to validate item 1: object matches none of the requireds --- no_error_log [error]