Skip to content

fix: optional port for nod schema#10477

Merged
juststillthinking merged 9 commits into
apache:masterfrom
theweakgod:hotfix/optional_port_in_admin_schema
Nov 21, 2023
Merged

fix: optional port for nod schema#10477
juststillthinking merged 9 commits into
apache:masterfrom
theweakgod:hotfix/optional_port_in_admin_schema

Conversation

@theweakgod

@theweakgod theweakgod commented Nov 11, 2023

Copy link
Copy Markdown
Contributor

Description

there is a bug in the schema check of nodes when admin-api saves the upstream configuration.

Fixes # (issue)

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@theweakgod theweakgod changed the title [2023-11-11][optional port for admin schema] bug: optional port for admin schema Nov 11, 2023
@theweakgod theweakgod changed the title bug: optional port for admin schema bug: optional port for nod schema Nov 11, 2023
@theweakgod theweakgod changed the title bug: optional port for nod schema fix: optional port for nod schema Nov 11, 2023
@yujiapingyu

Copy link
Copy Markdown

cheers

@juststillthinking

Copy link
Copy Markdown
Contributor

@theweakgod Could you add a test case to cover this?

@theweakgod

Copy link
Copy Markdown
Contributor Author

@theweakgod Could you add a test case to cover this?

Ok, can you tell me how to add a test case. Or some doc that tells me how to add it

@juststillthinking

Copy link
Copy Markdown
Contributor

@theweakgod

Copy link
Copy Markdown
Contributor Author

@theweakgod

Copy link
Copy Markdown
Contributor Author

@theweakgod Could you add a test case to cover this?

done!

Comment thread t/core/schema_def_optional_port.t Outdated
local schema_def = require("apisix.schema_def")
local core = require("apisix.core")


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

redundant blank

Comment thread t/core/schema_def_optional_port.t Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@theweakgod, the test case you added aren't up to the mark. Please demonstrate using domain name in the nodes without port is acceptable and accessing a route that uses such upstream does not fail.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, you should prove that the route could work

Comment thread t/core/schema_def_optional_port.t Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@theweakgod

Copy link
Copy Markdown
Contributor Author

@monkeyDluffy6017 @shreemaan-abhishek all done

@juststillthinking

Copy link
Copy Markdown
Contributor

please make the ci pass

@juststillthinking juststillthinking added wait for update wait for the author's response in this issue/PR and removed need test cases user responded labels Nov 17, 2023
@theweakgod

Copy link
Copy Markdown
Contributor Author

请让 ci 通过

ok,updated

@theweakgod

Copy link
Copy Markdown
Contributor Author

please make the ci pass

Is this error a problem with the test file? What do I need to do?

@Revolyssup

Copy link
Copy Markdown
Contributor

@theweakgod It was a flaky test. I rerun the CI and it passed.

@theweakgod

Copy link
Copy Markdown
Contributor Author

@theweakgod It was a flaky test. I rerun the CI and it passed.

Ok, I see.

Comment thread t/admin/schema-validate.t Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

okay

Copy link
Copy Markdown
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.

Comment thread t/admin/schema-validate.t Outdated
upstream = {
type = "roundrobin",
nodes = {
{ host = "nghttp2.org", weight = 1,}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use 127.0.0.1:1980 instead

Comment thread t/admin/schema-validate.t Outdated
local code, body = t('/apisix/admin/routes',
ngx.HTTP_POST,
{
uri = "/ip",

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread t/admin/schema-validate.t Outdated

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

Copy link
Copy Markdown
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

@juststillthinking

Copy link
Copy Markdown
Contributor

@theweakgod Nice job!

@theweakgod

Copy link
Copy Markdown
Contributor Author

@theweakgod Nice job!

^ ^. thank you very much for your help.

@juststillthinking
juststillthinking merged commit 0581528 into apache:master Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

user responded wait for update wait for the author's response in this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants