test: replace Thread.sleep with sync primitives in tests#4639
test: replace Thread.sleep with sync primitives in tests#4639emmaeng700 wants to merge 3 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: emmaeng700 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Replace 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>
Co-Authored-By: Oz <oz-agent@warp.dev>
54f8b58 to
ebe9ea9
Compare
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>
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Replace 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 #1223.