-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Fix flaky tests with 'await' #3972
Conversation
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.
3 extra commands seems many. Isn't 1 enough?
@sazzad16 i agree with you it should have been ok with 1. Tried with 1 in the past which still get fails intermittently. Just want to get rid of this flakiness once and for all. |
@atakavci In that case, I'd take the Thread.sleep(); at least those would be easier to document and understand 😓 |
@sazzad16 i'm strongly against to use of sleep in unit tests. Since its not sensitive and responsive to the environment like resource utilization, latencies etc. there will be always an unpredictable requirement for how long we need to wait. |
Well, same thing can be said about the number of commands you're executing. It's possible that if we run the tests way too many times, we would find the flaky tests are failing which would've passed if 4 or 5 commands were executed instead of 3.
I respect that. But in my humble understanding, by executing dummy commands you're just doing Thread.sleep() without writing Thread.sleep(). By executing 3 commands, you're just using a larger sleep time compared to the equivalent time of executing 1 command.
This is what I indicated in my last comment. A line of of Thread.sleep() + comments would be much easier to understand than 3 lines of dummy command + comments. |
@sazzad16 i see your point, let me try to explain mine;
this is not correct. When you execute a similar task, you will get same kind of delay and they will always be proportional in average since it uses the same resources and impacted by same set of factors.
right in a sense, purpose is same but,, but i appricaite your stance with readability and really would like to improve it,,, without using |
Hello, I am seeing some of these tests fail in my own fork of Can this be resolved by implementing an assertion method that evaluates eventual consistency? For example, repeatedly querying the key with some small
|
hi @killergerbah, trying to figure out best options and i d like to have a way of addressing it without having to wait a fixed long period of time in case of a failure. |
I am also not a fan of doing either
What do you think? |
this requires another connection which leaves the test case possibly flaky again. If it is the original connection to subscribe, then it is no different then making a 'write' on same connection, which will block on a response read. first choice remains feasible while it is just a 'sleep' in the heart of it. there are options like tapping the port for incoming data or pending buffer, but wouldn't it be the perfect example of over engineering. |
src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java
Show resolved
Hide resolved
What do you think about using an already available lib for this? There is a nice one that integrates with assert, hamcrest.. like https://github.com/awaitility/awaitility |
Vote for that. It would only increase the dependencies in the test phase, so it does not have impact on the driver itself. |
src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java
Outdated
Show resolved
Hide resolved
@sazzad16 looks like there are other flaky tests existing in pipeline. |
Awaitility.await().atMost(5, TimeUnit.SECONDS).pollInterval(50, TimeUnit.MILLISECONDS) | ||
.untilAsserted(() -> assertEquals("aof", j.get("wait"))); |
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.
❤️
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.
Love it. Got to add it to Lettuce tests too at some point!
cfd9ee2
to
5cb7b30
Compare
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 this is the best solution for now.
Awaitility.await().atMost(5, TimeUnit.SECONDS).pollInterval(50, TimeUnit.MILLISECONDS) | ||
.untilAsserted(() -> assertEquals("aof", j.get("wait"))); |
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.
Love it. Got to add it to Lettuce tests too at some point!
* fix flaky test - dumy set-get to gain time * adding same commands for 'simple' * introdue tryAssert in CSC tests * remove leftovers * introduce awaitility for polling * nit * fix pipelining test untilasserted
* fix flaky test - dumy set-get to gain time * adding same commands for 'simple' * introdue tryAssert in CSC tests * remove leftovers * introduce awaitility for polling * nit * fix pipelining test untilasserted
No description provided.