Skip to content

remove some of thread.sleeps in test cases #1786

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

Merged
merged 4 commits into from
Jul 21, 2021

Conversation

karthikkondapally
Copy link
Contributor

@karthikkondapally karthikkondapally commented Jul 17, 2021

trying to remove some of Thread.sleep()
#1223

Update:
(Some of classes dont have Thread.sleep like ReflectorRunnableTest.java)
Some Thread.sleep(2000) are because of wiremock.stubFor wiremock/wiremock#97

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 17, 2021
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 17, 2021
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 17, 2021
@karthikkondapally
Copy link
Contributor Author

@brendandburns @yue9944882

leaderElectionWorker.submit(
() -> {
leaderElector.run(() -> {}, () -> {});
});
// TODO: Remove this sleep
Thread.sleep(Duration.ofSeconds(2).toMillis());
while (!sem.tryAcquire()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this loop? I would remove all this code and just do:

sem.acquire() like you did above.

Copy link
Contributor Author

@karthikkondapally karthikkondapally Jul 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wanted to print message on why we are waiting..
but i have changed semaphores to countdown latch, as i thought it would be better than sempahore in these situations


while (!sem.tryAcquire(2)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, why not just sem.acquire(2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to print message on why we are waiting..
but i have changed semaphores to countdown latch, as i thought it would be better than sempahore in these situations

@brendandburns
Copy link
Contributor

Thanks for the PR! Couple of small comments then I think this is ready to merge.

@karthikkondapally
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

@karthikkondapally: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions 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/test-infra repository.

@@ -103,7 +103,6 @@ private boolean waitForAdded(DefaultDelayingQueue queue, int size) {
}

private boolean waitForWaitingQueueToFill(DefaultDelayingQueue queue) {
return Wait.poll(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these are the same test. (and it seems unrelated) can you revert this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it back...

@brendandburns
Copy link
Contributor

/lgtm
/approve

Thanks for the PR!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 21, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, karthikkondapally

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit a985167 into kubernetes-client:master Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants