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

test: add more test for pkg network #672

Merged
merged 9 commits into from Mar 24, 2023

Conversation

a631807682
Copy link
Member

@a631807682 a631807682 commented Mar 17, 2023

What type of PR is this?

test

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.

(Optional) Translate the PR title into Chinese.

添加pkg/network单测

(Optional) More detail description for this PR(en: English/zh: Chinese).

en: Supplement unit test for pkg/network, coverage increased from 68.14% to 95.2%.
I see that netpoll's DialTimeout doesn't check tlsConfig, I'm not sure if it's a bug

https://github.com/cloudwego/hertz/blob/develop/pkg/network/netpoll/dial.go#L48

zh(optional): 补充pkg/network的单元测试,覆盖率从68.14%提高到了95.2%.。
我看到netpoll的DialTimeout并没有检查tlsConfig,我不确定是不是个错误。

Which issue(s) this PR fixes:

related to #257

@a631807682 a631807682 requested review from a team as code owners March 17, 2023 07:37
@Duslia
Copy link
Member

Duslia commented Mar 17, 2023

Please fix CI

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch coverage has no change and project coverage change: +1.42 🎉

Comparison is base (c98aec7) 72.49% compared to head (3e11c16) 73.92%.

❗ Current head 3e11c16 differs from pull request most recent head e101162. Consider uploading reports for the commit e101162 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #672      +/-   ##
===========================================
+ Coverage    72.49%   73.92%   +1.42%     
===========================================
  Files           96       96              
  Lines         9392     9392              
===========================================
+ Hits          6809     6943     +134     
+ Misses        2154     2009     -145     
- Partials       429      440      +11     

see 5 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@a631807682 a631807682 changed the title test: add more test for pkg network test(WIP): add more test for pkg network Mar 17, 2023
@a631807682 a631807682 changed the title test(WIP): add more test for pkg network test: add more test for pkg network Mar 17, 2023
@Duslia
Copy link
Member

Duslia commented Mar 18, 2023

netpoll does not support tls, so there is no need to care about tls.config in netpoll.

@a631807682
Copy link
Member Author

netpoll does not support tls, so there is no need to care about tls.config in netpoll.

Yes, I'm not sure if we need to return errNotSupportTLS since it's a public package.

@Duslia
Copy link
Member

Duslia commented Mar 20, 2023

netpoll does not support tls, so there is no need to care about tls.config in netpoll.

Yes, I'm not sure if we need to return errNotSupportTLS since it's a public package.

I think it's ok to return this.

@welkeyever
Copy link
Member

welkeyever commented Mar 20, 2023

Thanks for your report!
It is better to return errors to be able to align - although this code will work properly - netpoll will return the "not support" error instead.

Optimize PR is welcome~

@a631807682
Copy link
Member Author

Thanks for your report! It is better to return errors to be able to align - although this code will work properly - netpoll will return the "not support" error instead.

Optimize PR is welcome~

Can I create an optimized PR after this PR is complete? because their tests may conflict. https://github.com/cloudwego/hertz/pull/672/files#diff-da9b81109f65e95b79b7f99cde6f9b44a23119bfe16028b3747b161b2e307bacR62

@welkeyever
Copy link
Member

Thanks for your report! It is better to return errors to be able to align - although this code will work properly - netpoll will return the "not support" error instead.
Optimize PR is welcome~

Can I create an optimized PR after this PR is complete? because their tests may conflict. https://github.com/cloudwego/hertz/pull/672/files#diff-da9b81109f65e95b79b7f99cde6f9b44a23119bfe16028b3747b161b2e307bacR62

Sure~

@welkeyever
Copy link
Member

Please check the failed UT in CI 🙏. Not sure whether it is related to this change or not.
Seems happened more than once.

@a631807682
Copy link
Member Author

a631807682 commented Mar 21, 2023

Please check the failed UT in CI 🙏. Not sure whether it is related to this change or not. Seems happened more than once.

TestPoolVariousSizesConcurrent is a test case for bytebufferpool, the changes here do not reference or modify bytebufferpool, they should not be related.
failed in other pr 1
failed in other pr 2

I tried to reproduce it locally or in docker, but all failed, and I didn't find relevant information in https://github.com/valyala/bytebufferpool.

It is very frequently reproduced in the github action, and it always times out in the first goroutine.
test action failed 1
test action failed 2
test action failed 3

I tried to calculate the time it takes in the action by executing testPoolVariousSizes once first (excluding the impact of optimistic locks), and the result failed at 5.98s, indicating that the first testPoolVariousSizes used 2.98s.

func TestPoolVariousSizesConcurrent(t *testing.T) {
+	testPoolVariousSizes(t)
	concurrency := 5
	...

I think it takes a lot of time for memory allocation in action even if sync.Pool is used (the machine provided by action is slower), maybe we should increase the timeout time.

Copy link
Member

@welkeyever welkeyever left a comment

Choose a reason for hiding this comment

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

LGTM, thx~

@Duslia Duslia merged commit 140053c into cloudwego:develop Mar 24, 2023
9 checks passed
@a631807682 a631807682 deleted the ut_common_network branch March 24, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants