Skip to content

Remove Thread.sleep from DefaultDelayingQueueTest - #4970

Open
therealemmanueloppong wants to merge 1 commit into
kubernetes-client:masterfrom
therealemmanueloppong:test/delaying-queue-remove-sleep
Open

therealemmanueloppong wants to merge 1 commit into
kubernetes-client:masterfrom
therealemmanueloppong:test/delaying-queue-remove-sleep

Conversation

@therealemmanueloppong

Copy link
Copy Markdown
Contributor

Notes

Thank you for maintaining this project.

simpleDelayingQueue in DefaultDelayingQueueTest ended with a fixed Thread.sleep(10 * 1000L) before checking that the queue stayed empty. That makes the test take about 10 seconds and is the kind of timing wait that #1223 asks to replace.

The only entry in that test has already been released and marked done by that point, so once nothing is left waiting to be added the queue cannot receive anything else. The test now polls for that with the existing waitForWaitingQueueToFill helper and then asserts the length, so there is no fixed wait.

I changed only this one test file, and nothing else in the class. An alternative would be to make the sleep shorter, but that would still depend on timing.

Related issue

Part of #1223

Testing

  • DefaultDelayingQueueTest (3 tests) passes. The class went from about 10.5 s to about 0.5 s, and I ran it 3 times with the same result.
  • mvn spotless:check passes for the extended module.

simpleDelayingQueue waited a fixed 10 seconds before checking that the
queue stayed empty. Poll until nothing is left waiting to be added
instead, which is deterministic and takes the test from about 10.5s to
about 0.5s.

Part of kubernetes-client#1223.
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 1, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: therealemmanueloppong
Once this PR has been reviewed and has the lgtm label, please assign brendandburns for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@therealemmanueloppong

Copy link
Copy Markdown
Contributor Author

/assign @brendandburns

Thank you for taking a look when you have time. I am happy to change anything you would like different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants