-
Notifications
You must be signed in to change notification settings - Fork 3k
Thread.sleep() method is replaced with Awaitility #8715
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
Conversation
nk1506
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, we should use https://github.com/apache/iceberg/blob/master/api/src/test/java/org/apache/iceberg/TestHelpers.java#L57
Or create a utility with parameter as duration where callable is always returning true.
api/src/test/java/org/apache/iceberg/metrics/TestDefaultTimer.java
Outdated
Show resolved
Hide resolved
|
Oh i see, the code uses a while loop checks the current time until the condition is met.But its asked to replace Thread.sleep method with awaitility, should i implement your suggestion as it don't uses awaitility.@nk1506 |
nk1506
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think idea here is to replace all the thread usage with Awaitility. But we need to understand why the thread is sleeping first.
- If there is intentional sleep to add some delay. It should be handled with corresponding poll-delay and timestamp diff check.
- If there is a sleep for another process to be finished, it should check for the corresponding job.
Make surepollDelay,atLeast,atMostare being configured correctly.
...k/v1.15/flink/src/test/java/org/apache/iceberg/flink/source/TestIcebergSourceContinuous.java
Outdated
Show resolved
Hide resolved
...k/v1.15/flink/src/test/java/org/apache/iceberg/flink/source/TestIcebergSourceContinuous.java
Outdated
Show resolved
Hide resolved
|
Thanks for the suggestion @nk1506 ,I'll update that |
|
I've made the changes@nk1506 |
|
The goal of #7154 is to convert Typically, Here is a good example where the test was made more stable by the use of Awaitility: iceberg/core/src/test/java/org/apache/iceberg/actions/TestCommitService.java Lines 99 to 102 in cff2ff9
We wait at most 5 seconds until the given assertion is met. For this PR that means a good starting point might be Line 153 in f9f85e7
|
|
I've made the changes :)@nastra |
api/src/test/java/org/apache/iceberg/metrics/TestDefaultTimer.java
Outdated
Show resolved
Hide resolved
| () -> { | ||
| try { | ||
| Thread.sleep(200); | ||
| Awaitility.await().atLeast(Duration.ofMillis(200)).until(() -> true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense here to switch to awaitility?
|
|
||
| for (int i = 1; i < 5; i++) { | ||
| Thread.sleep(10); | ||
| Awaitility.await().atLeast(Duration.ofMillis(10)).until(() -> true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense here to switch to awaitility?
|
|
||
| // sleep for 1 second to ensure files will be old enough | ||
| Thread.sleep(1000); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these changes here necessary?
|
wait let me check.... |
|
I tried to fix the issues :) @nastra |
|
@shreyanshR7 there are still many unrelated changes to files. Can you please fix all of those? |
|
Let me check, I will try my best to undo these unrelated changes, these changes may be occurred due to adding awaitility method. sorry for inconvenience @nastra |
|
@nastra I made another pull request addressing the issue with some more clean changes, please consider that. |
#7154@nastra