Open brendandburns opened 4 years ago
@brendandburns thanks for sorting out these potentially flaking tests.. will fix them later!
/assign
I would like to help :-)
@sarveshkaushal we'd welcome the help. In most cases the Thread.sleep(foo)
is to wait for some other thread to complete it's work. Instead, we should create a Semaphore
, then acquire()
one or more permits for the executions we're waiting for, and then release()
them in the Thread, then attempt to acquire()
in the test thread to implement the wait.
See an example PR #1219
The reason that Thread.sleep()
is flaky is because in a CI/CD system like GitHub actions the machines can be massively overloaded, which leads to much longer delays than you might otherwise see when running tests, so the sleep(..)
ends up not being long enough. You can always make the sleep longer, but that makes the tests run longer (and it's still flaky in extreme cases) so using synchronization primitives is (almost) always the right answer.
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten
/lifecycle frozen
If still available I would like to contribute
well i am new to java and i would like to get in touch with you guys and try to do my best in solving all the issues hope you all will understand my curiosity and get in touch with me and help me to grow and learn.........
@brendandburns I have one doubt, I was working on util/src/test/java/io/kubernetes/client/informer/cache/SharedProcessorTest.java
, particularly on:
https://github.com/kubernetes-client/java/blob/536f72556899a5a951a9d1d000f4b5073429e017/util/src/test/java/io/kubernetes/client/informer/cache/SharedProcessorTest.java#L27-L60
I can create a semaphore and acquire it, blocking the main thread, but how will I release so that blocked main thread will continue the execution, I looked at many tests, facing similar problem in many of them.
Edit-
I cannot access ExecutorService
instance variable which would have been useful over here, please suggest.
what are the things I need to learn in order to start contributiing to this project?
what are the things I need to learn to start contributing to this project?
DSA, API, and Kubernetes or just contribute by documentation correction or making better changes
@brendandburns ping
/assign
Many of our tests simply have a
Thread.sleep(duration)
when testing multi-threaded code. This is inherently flaky.Instead we should use synchronization classes (generally
Semaphore
) to synchronized the tests which is both faster in the general case and not flaky in the extreme case.See for instance #1218 and #1219