-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[Feature](test)Using Awaitility for Asynchronous Testing #37817
Labels
Comments
CalvinKirs
added
kind/feature
Categorizes issue or PR as related to a new feature.
kind/test
labels
Jul 15, 2024
I want to try this issue, can you assign it to me? |
Sure! |
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 2, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 2, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 3, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 3, 2024
@CalvinKirs Hi , i have raise few MR for this task. pls help to review. thanks. |
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 4, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 4, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 4, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 5, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 5, 2024
This was referenced Aug 5, 2024
dataroaring
pushed a commit
that referenced
this issue
Aug 5, 2024
dataroaring
pushed a commit
that referenced
this issue
Aug 5, 2024
dataroaring
pushed a commit
that referenced
this issue
Aug 6, 2024
## Proposed changes Issue Number: close #xxx #37817 use awaitility to replace thread.sleep in partial update regression testcases
dataroaring
pushed a commit
that referenced
this issue
Aug 6, 2024
## Proposed changes Issue Number: close #xxx #37817 use awaitility to replace thread.sleep in partial update regression testcases
yiguolei
pushed a commit
that referenced
this issue
Aug 6, 2024
airborne12
pushed a commit
to airborne12/apache-doris
that referenced
this issue
Aug 7, 2024
…art (apache#38816) ## Proposed changes Issue Number: close #xxx apache#37817 replace thread.sleep with awaitility util in some of neredis_syntax test cases.
dataroaring
pushed a commit
that referenced
this issue
Aug 11, 2024
dataroaring
pushed a commit
that referenced
this issue
Aug 16, 2024
dataroaring
pushed a commit
that referenced
this issue
Aug 21, 2024
Vallishp
added a commit
to Vallishp/doris
that referenced
this issue
Aug 28, 2024
yiguolei
pushed a commit
that referenced
this issue
Sep 18, 2024
## Proposed changes Issue Number: close #xxx #37817 use awaitility in few testcases
dataroaring
pushed a commit
that referenced
this issue
Oct 9, 2024
dataroaring
pushed a commit
that referenced
this issue
Oct 9, 2024
## Proposed changes Issue Number: close #xxx #37817 use awaitility in few testcases
hello-stephen
pushed a commit
that referenced
this issue
Oct 21, 2024
#37817 use awaitility in few testcases
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Search before asking
Description
Currently our test codes include a lot of thread.sleep test codes, but this is not a recommended test method.
On one hand, Thread.sleep can lead to unstable test cases. On the other hand, it can also cause test cases to run longer than necessary.
https://github.com/awaitility/awaitility
Thread.sleep vs Awaitility
Using Awaitility instead of Thread.sleep for asynchronous testing in Java offers several advantages:
Readability and Intent:
Awaitility: Using Awaitility makes the test code more readable and expressive. It clearly communicates the intention to wait for a certain condition to be met.
Thread.sleep(1000);
Reliability:
Awaitility: Waits until a specific condition is met, which makes the tests more reliable and less prone to intermittent failures. It ensures that the test only proceeds when the expected condition is true.
Thread.sleep: Introduces a fixed delay, which can lead to flaky tests. If the condition is met sooner than the sleep time, the test unnecessarily waits. Conversely, if the condition is met after the sleep time, the test will fail.
Timeout Management:
Awaitility: Allows for configuring timeouts and poll intervals, giving fine-grained control over how long to wait and how frequently to check the condition.
Thread.sleep:
Error Messages:
Awaitility: Provides clear error messages when a condition is not met within the specified timeout, making it easier to diagnose issues.
Thread.sleep: If the condition is not met, the test may fail without a clear explanation, making debugging more challenging.
Best Practices:
Awaitility: Encourages best practices for writing asynchronous tests, such as waiting for conditions rather than introducing arbitrary delays.
Thread.sleep: Using Thread.sleep is generally considered a bad practice in tests because it can lead to non-deterministic behavior and inefficiencies.
In summary, Awaitility improves test readability, reliability, and maintainability by allowing precise control over waiting for asynchronous conditions, making it a better choice than using Thread.sleep.
Related issues
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: