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

testsuite.StartDevServer: Respect timeout during dial #1498

Merged

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented May 31, 2024

What was changed

Background:
testsuite.StartDevServer accepts a context.Context
meant to indicate how long the caller is willing to wait for the result.
This context is used when downloading the Temporal CLI,
but is not considered when trying to dial to the server in
waitServerReady.

Change:
This changes waitServerReady to respect the timeout configured in the
context--checking in on it after each attempt, and returning early
if the context has expired.
Similarly, the Dial attempt now uses DialContext so that if the context
expires, the dial operation also returns early if it can.

Why?

Without this, if an attempt to start the server failed
(e.g. because of an invalid --log-format argument),
waitServerReady will block the test for 1 minute
before giving up and returning an error.
This is a pretty long time to wait for a test to fail,
when the caller is expecting, say, 5 seconds at most.

Checklist

  1. How was this tested:
    A unit test was added for the new functionality,
    and run with go test -run WaitServerReady -count 1000
    to verify that it's not flaky.

  2. Any docs updates needed?
    I don't think so.

@abhinav abhinav requested a review from a team as a code owner May 31, 2024 19:07
@CLAassistant
Copy link

CLAassistant commented May 31, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

LGTM, minor suggestion

testsuite/devserver.go Outdated Show resolved Hide resolved
@abhinav abhinav force-pushed the testserver-dial-timeout branch from 6afc684 to 57965b9 Compare May 31, 2024 19:39
@cretz
Copy link
Member

cretz commented May 31, 2024

LGTM, will let @Quinn-With-Two-Ns review

@Quinn-With-Two-Ns
Copy link
Contributor

CI failing looks like an issue with the server v1.24.0 docker images. Will follow up with the server team.

testsuite.StartDevServer accepts a context.Context
meant to indicate how long the caller is willing to wait for the result.
This context is used when downloading the Temporal CLI,
but is not considered when tryign to dial to the server in
`waitServerReady`.

Without this, if an attempt to start the server failed
(e.g. because of an invalid `--log-format` argument),
`waitServerReady` will wait for `600 * 100ms = 1 minute`
before returning the failure to the caller.

This changes `waitServerReady` to respect the timeout configured in the
context--checking in on it after each attempt.

This also changes the actual `Dial` attempt to use `DialContext`
with the same context so that if the context expires,
the dial operation also returns early if possible.
@Quinn-With-Two-Ns Quinn-With-Two-Ns force-pushed the testserver-dial-timeout branch from 57965b9 to a06cb14 Compare June 6, 2024 16:07
@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit bf29944 into temporalio:master Jun 6, 2024
13 checks passed
@abhinav abhinav deleted the testserver-dial-timeout branch June 6, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants