test: replace Thread.sleep with sync primitives in tests by emmaeng700 · Pull Request #4639 · kubernetes-client/java
k8s-ci-robot
added
size/S
labels
Mar 6, 2026Replace flaky Thread.sleep calls with proper synchronization: - SharedProcessorTest: use Semaphore(0).acquire() instead of Thread.sleep(10s) so the worker blocks until interrupted by shutdownNow(), making the test deterministic and instant. - KubernetesReconcilerCreatorTest: use Wait.poll() instead of Thread.sleep(500ms) to actively poll until the work queue is populated, making the test faster and non-flaky. Addresses part of kubernetes-client#1223. Co-Authored-By: Oz <oz-agent@warp.dev>
Address the remaining Thread.sleep usages from kubernetes-client#1223: - ExecCallbacksTest: replace Thread.sleep(30s) with Semaphore(0).acquire() so the simulated remote process blocks until the exec timeout fires, making the test instant and non-flaky. - CopyTest: replace Thread.sleep(2000) with Awaitility.await() polling WireMock's serve events, so we proceed as soon as the HTTP request is received rather than waiting a fixed 2 seconds. - PortForwardTest: remove Thread.sleep(2000) entirely; handler.close() is called while the main thread holds the monitor lock, so there is no race condition and no need for a timed wait. - DefaultDelayingQueueTest: remove Thread.sleep(10s) after queue.done(); the queue uses an injected (static) time source, so no items will be spontaneously enqueued and the assertion can be made immediately. - DefaultWorkQueueTest: remove Thread.sleep calls used to simulate producer/consumer work; the test correctness is governed by CountDownLatches, not by sleep timing. - EventCorrelatorTest: replace Thread.sleep(100) with an explicit timestamp offset (plusMillis(100)) so event timestamps are guaranteed to differ without any real-time wait. Co-Authored-By: Oz <oz-agent@warp.dev>
k8s-ci-robot
added
size/M
and removed size/S
Denotes a PR that changes 10-29 lines, ignoring generated files.labels
Mar 6, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters