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

Extract SAFE_AWAIT_TIMEOUT constant #108554

Merged

Conversation

DaveCTurner
Copy link
Contributor

@DaveCTurner DaveCTurner commented May 13, 2024

Mainly so we have a place to document why we have a 10s wait in these
methods.

Co-authored-by: Mikhail Berezovskiy mikhail@elastic.co

Mainly so we have a place to document why we have a 10s wait in these
methods.
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. v8.15.0 labels May 13, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team label May 13, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

* <p>
* A well-designed test should not need to wait for longer than this. If you think you need to do so, instead seek a better way to write
* the test such that it does not need to wait for so long. Tests that take 10s of seconds to complete are a big drag on CI times which
* slows everyone down.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could make it even more restrictive?
I would say a unit test should not last longer than a second even on possibly slow CI.
For integration tests 10s sounds more reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even integ tests generally should run faster than this IMO. I strengthened the wording a little in ca73c5b.

* fairly relaxed definition of "immediately".
* <p>
* A well-designed test should not need to wait for longer than this. If you think you need to do so, instead seek a better way to write
* the test such that it does not need to wait for so long. Tests that take 10s of seconds to complete are a big drag on CI times which
Copy link
Contributor

Choose a reason for hiding this comment

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

the test such that it does not need to wait for so long

May be we should give a hint(s) on those?
For example when waiting for an es timeout to happen we should generally ensure the test configures a custom fairly short timeout rather than relying on generous elasticsearch default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO tests which wait for a timeout should be using a fake clock so that we can set a realistic timeout duration without having to wait for that long in real time. I know we have quite a lot of tests that set, and wait for, a timeout in the region of ~100ms, but this is not really testing a realistic situation and might therefore miss some bugs, whilst still being an approach that does not scale well when we're talking about a test suite the size of ES's.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... but I'm not going to write that here, it's not always reasonable to require this, and yet nor do I want to write here that setting a 100ms timeout is a recommended practice.

Copy link
Contributor

@idegtiarenko idegtiarenko left a comment

Choose a reason for hiding this comment

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

Overall 👍

@DaveCTurner DaveCTurner added the auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label May 13, 2024
@DaveCTurner
Copy link
Contributor Author

Extracted from (or at least inspired by) #108531 hence the co-authored-by attribution.

@elasticsearchmachine elasticsearchmachine merged commit 1a8238c into elastic:main May 13, 2024
15 checks passed
@DaveCTurner DaveCTurner deleted the 2024/05/13/SAFE_AWAIT_TIMEOUT branch May 13, 2024 12:44
@DaveCTurner DaveCTurner restored the 2024/05/13/SAFE_AWAIT_TIMEOUT branch June 17, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. Team:Distributed Meta label for distributed team >test Issues or PRs that are addressing/adding tests v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants