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

Add Test Server Wait Helper Function #787

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

krapie
Copy link
Member

@krapie krapie commented Feb 7, 2024

What this PR does / why we need it:

Add test server wait helper function WaitForServerToStart() to resolve Connection Refused error in server-related tests.

Which issue(s) this PR fixes:

Fixes #784

Special notes for your reviewer:

To valify this, add time.Sleep(10 * time.Second) inside server's listenAndServe() goroutine to reproduce Connection Refused error and test it with and without WaitForServerToStart().

func (s *Server) listenAndServe() error {
	go func() {
		time.Sleep(5 * time.Second)
		logging.DefaultLogger().Infof(fmt.Sprintf("serving RPC on %d", s.conf.Port))
...

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

@krapie krapie added the bug 🐞 Something isn't working label Feb 7, 2024
@krapie krapie self-assigned this Feb 7, 2024
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (94d6e30) 50.71% compared to head (a270cf6) 50.71%.

❗ Current head a270cf6 differs from pull request most recent head 420488c. Consider uploading reports for the commit 420488c to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #787   +/-   ##
=======================================
  Coverage   50.71%   50.71%           
=======================================
  Files          70       70           
  Lines       10213    10213           
=======================================
  Hits         5180     5180           
  Misses       4512     4512           
  Partials      521      521           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@hackerwins hackerwins left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution.

I adjusted error messages by following the below guide:
https://github.com/uber-go/guide/blob/master/style.md#error-wrapping

test/helper/helper.go Outdated Show resolved Hide resolved
test/helper/helper.go Outdated Show resolved Hide resolved
@hackerwins hackerwins merged commit a8f6bc2 into main Feb 8, 2024
4 checks passed
@hackerwins hackerwins deleted the add-test-server-wait-func branch February 8, 2024 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent connection refused error in TestSDKRPCServerBackend
2 participants