Skip to content
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: optional port for nod schema #10477

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/schema_def.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ local nodes_schema = {
type = "object",
}
},
required = {"host", "port", "weight"},
required = {"host", "weight"},
},
}
}
Expand Down
41 changes: 41 additions & 0 deletions t/admin/schema-validate.t
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,44 @@ location /t {
--- error_code: 400
--- response
{"error_msg":"allOf 1 failed: value should match only one schema, but matches none"}



=== TEST 13: Check node_schema optional port
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
headers = {}
headers["X-API-KEY"] = "edd1c9f034335f136f87ad84b625c8f1"
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
{
uri = "/ip",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could search 127.0.0.1:1980 in the project, and find what uri is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done. thanks

upstream = {
type = "roundrobin",
nodes = {
{ host = "httpbin.org", weight = 1,}
}
},
methods = {"GET"},
}, nil, headers
)

if code >= 300 then
ngx.status = code
end
ngx.say(body)

}
}
--- request
GET /t
--- response_body
passed



=== TEST 14: Test route upstream
--- request
GET /ip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Revolyssup Would you like to update these test cases? it is better not to use httpbin.org, it is unstable, and we could check the response body like the other test cases, and no need to add X-API-KEY in the request header and so on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

I remove some useless code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check the response body, like this

=== TEST 8: `url` exist and `route_id` is 1
--- request
GET /hello
--- response_body
hello world

Loading