You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/11/02 06:25:50 UTC
[apisix] branch master updated: feat: add dafault value roundrobin for upstream_schema (#8180)
This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new f1200764c feat: add dafault value roundrobin for upstream_schema (#8180)
f1200764c is described below
commit f1200764c34b7545b1c3723c390f11f41d8c7d75
Author: chengxiaolan <30...@users.noreply.github.com>
AuthorDate: Wed Nov 2 14:25:42 2022 +0800
feat: add dafault value roundrobin for upstream_schema (#8180)
---
apisix/schema_def.lua | 5 +++--
t/admin/upstream.t | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index 1ec0ea602..f7b117af9 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -437,6 +437,7 @@ local upstream_schema = {
type = {
description = "algorithms of load balancing",
type = "string",
+ default = "roundrobin",
},
checks = health_checker,
hash_on = {
@@ -498,8 +499,8 @@ local upstream_schema = {
id = id_schema,
},
oneOf = {
- {required = {"type", "nodes"}},
- {required = {"type", "service_name", "discovery_type"}},
+ {required = {"nodes"}},
+ {required = {"service_name", "discovery_type"}},
}
}
diff --git a/t/admin/upstream.t b/t/admin/upstream.t
index 12681780c..e47bc526f 100644
--- a/t/admin/upstream.t
+++ b/t/admin/upstream.t
@@ -727,3 +727,42 @@ GET /t
{"error_msg":"failed to fetch ssl info by ssl id [1], wrong ssl type"}
--- no_error_log
[error]
+
+
+
+=== TEST 22: type with default vale
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local etcd = require("apisix.core.etcd")
+ local code, body = t('/apisix/admin/upstreams/admin_up',
+ ngx.HTTP_PUT,
+ [[{
+ "nodes": {
+ "127.0.0.1:8080": 1
+ },
+ "desc": "new upstream"
+ }]],
+ [[{
+ "value": {
+ "nodes": {
+ "127.0.0.1:8080": 1
+ },
+ "type": "roundrobin",
+ "desc": "new upstream"
+ },
+ "key": "/apisix/upstreams/admin_up"
+ }]]
+ )
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]