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

Conversation

theweakgod
Copy link
Contributor

@theweakgod theweakgod commented Nov 11, 2023

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

cheers

@monkeyDluffy6017
Copy link
Contributor

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

@theweakgod
Copy link
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

@monkeyDluffy6017
Copy link
Contributor

@theweakgod
Copy link
Contributor Author

@theweakgod
Copy link
Contributor Author

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

done!

local schema_def = require("apisix.schema_def")
local core = require("apisix.core")


Copy link
Contributor

Choose a reason for hiding this comment

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

redundant blank

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@theweakgod
Copy link
Contributor Author

@monkeyDluffy6017 @shreemaan-abhishek all done

@monkeyDluffy6017
Copy link
Contributor

please make the ci pass

@monkeyDluffy6017 monkeyDluffy6017 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
Contributor Author

请让 ci 通过

ok,updated

@theweakgod
Copy link
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
Contributor

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

@theweakgod
Copy link
Contributor Author

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

Ok, I see.


=== 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.

upstream = {
type = "roundrobin",
nodes = {
{ host = "nghttp2.org", weight = 1,}
Copy link
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

local code, body = t('/apisix/admin/routes',
ngx.HTTP_POST,
{
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


=== 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.

We should check the response body, like this

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

@monkeyDluffy6017
Copy link
Contributor

@theweakgod Nice job!

@theweakgod
Copy link
Contributor Author

@theweakgod Nice job!

^ ^. thank you very much for your help.

@monkeyDluffy6017 monkeyDluffy6017 merged commit 0581528 into apache:master Nov 21, 2023
33 checks passed
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