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

Response wrong status code for some situation for openAPI #11864

Merged
merged 7 commits into from
Apr 1, 2024
Merged

Response wrong status code for some situation for openAPI #11864

merged 7 commits into from
Apr 1, 2024

Conversation

publicize-y
Copy link
Contributor

link #11842

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.61%. Comparing base (b79d585) to head (fcf9982).
Report is 8 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             develop   #11864      +/-   ##
=============================================
+ Coverage      67.91%   68.61%   +0.69%     
- Complexity      8915     9027     +112     
=============================================
  Files           1236     1239       +3     
  Lines          40459    40584     +125     
  Branches        4292     4317      +25     
=============================================
+ Hits           27479    27845     +366     
+ Misses         11003    10746     -257     
- Partials        1977     1993      +16     
Files Coverage Δ
...onfig/server/exception/GlobalExceptionHandler.java 33.33% <100.00%> (+33.33%) ⬆️
...cos/console/exception/ConsoleExceptionHandler.java 28.57% <100.00%> (+28.57%) ⬆️
...os/console/exception/NacosApiExceptionHandler.java 15.38% <100.00%> (+15.38%) ⬆️
...cos/naming/exception/ResponseExceptionHandler.java 25.00% <100.00%> (+25.00%) ⬆️
...theus/exception/PrometheusApiExceptionHandler.java 66.66% <100.00%> (+66.66%) ⬆️

... and 28 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b79d585...fcf9982. Read the comment docs.

Copy link
Collaborator

@KomachiSion KomachiSion left a comment

Choose a reason for hiding this comment

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

Can you help add some unit test?

@publicize-y
Copy link
Contributor Author

ok,I will add

1 similar comment
@publicize-y
Copy link
Contributor Author

ok,I will add

@publicize-y
Copy link
Contributor Author

I would like to ask if there is already a NacosRuntimeExceptionTest. Is the unit test you mentioned specifically for defect # 11842

@publicize-y
Copy link
Contributor Author

@KomachiSion

@KomachiSion
Copy link
Collaborator

You change the code in many XXXExceptionHandler.java, so you should add some unit test to test you add or change logic is work well not relative NacosRuntimeExceptionTest.

@publicize-y
Copy link
Contributor Author

Why does my unit test affect other unit tests? I would like to seek help. This is my first PR @KomachiSion

@KomachiSion
Copy link
Collaborator

I retry the ci with several times, but every time can't pass with UdpConnectorTest.

It might some UT you added affect the UdpConnectorTest so that it can't pass, I will try it last time, if can't pass again with UdpConnectorTest, it should be fixed in this PR by you. Thanks.

@KomachiSion
Copy link
Collaborator

From the old information, some mock in UdpConnectorTest is marked useless, maybe you added UT has init some static variable and make the UdpConnectorTest mock useless.

If last time retry still failed by this reason, I suggest you see the error info and find out which mock is marked useless, and to make UT use the mock.

@publicize-y
Copy link
Contributor Author

Can I modify the UdpConnectorTest class?

@publicize-y
Copy link
Contributor Author

and I want to know if the logic of my unit testing is correct @KomachiSion

@KomachiSion
Copy link
Collaborator

Can I modify the UdpConnectorTest class?

How do you want to modify it?

@KomachiSion
Copy link
Collaborator

and I want to know if the logic of my unit testing is correct @KomachiSion

Your UT logic is ok, but you use WebMvc to start ut, the WebMvc will build the mock spring container, and spring container will build some bean and static variable.

When bean and static variable mock build by WebMvc and before UdpConnectorTest, it might cause mock in UdpConnectorTest not be used.

@publicize-y
Copy link
Contributor Author

and I want to know if the logic of my unit testing is correct @KomachiSion

Your UT logic is ok, but you use WebMvc to start ut, the WebMvc will build the mock spring container, and spring container will build some bean and static variable.

When bean and static variable mock build by WebMvc and before UdpConnectorTest, it might cause mock in UdpConnectorTest not be used.

Is there a better way not to use mockmvc? I'm trying other methods. The bean in the container does not have xxxxexceptionHandler, which makes it unable to handle exceptions

@publicize-y
Copy link
Contributor Author

and I want to know if the logic of my unit testing is correct @KomachiSion

Your UT logic is ok, but you use WebMvc to start ut, the WebMvc will build the mock spring container, and spring container will build some bean and static variable.
When bean and static variable mock build by WebMvc and before UdpConnectorTest, it might cause mock in UdpConnectorTest not be used.

Is there a better way not to use mockmvc? I'm trying other methods. The bean in the container does not have xxxxexceptionHandler, which makes it unable to handle exceptions

and currently, I have not found any unit tests for exception handling classes in the source code of Nacos

@shalk
Copy link
Contributor

shalk commented Mar 28, 2024

@publicize-y

You can just remove the webmvc

@publicize-y
Copy link
Contributor Author

@publicize-y

You can just remove the webmvc

Thks

@KomachiSion KomachiSion merged commit 2df335d into alibaba:develop Apr 1, 2024
7 checks passed
@KomachiSion KomachiSion added this to the 2.4.0 milestone Apr 1, 2024
@KomachiSion KomachiSion added kind/enhancement Category issues or prs related to enhancement. kind/bug Category issues or prs related to bug. labels Apr 1, 2024
@KomachiSion KomachiSion modified the milestones: 2.4.0, 2.3.2 Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug. kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants