Skip to content

Commit

Permalink
feat: add dafault value roundrobin for upstream_schema (apache#8180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazel6869 authored and Liu-Junlin committed Nov 4, 2022
1 parent 62d21cf commit 46936e3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apisix/schema_def.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ local upstream_schema = {
type = {
description = "algorithms of load balancing",
type = "string",
default = "roundrobin",
},
checks = health_checker,
hash_on = {
Expand Down Expand Up @@ -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"}},
}
}

Expand Down
39 changes: 39 additions & 0 deletions t/admin/upstream.t
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit 46936e3

Please sign in to comment.