Skip to content

Remove Thread.sleep() from port forward test class - #4911

Merged
kubernetes-prow[bot] merged 2 commits into
kubernetes-client:masterfrom
sarveshkaushal:sarveshkaushal/flaky-tests-1
Oct 13, 2026
Merged

kubernetes-prow[bot] merged 2 commits into
kubernetes-client:masterfrom
sarveshkaushal:sarveshkaushal/flaky-tests-1

Conversation

@sarveshkaushal

Copy link
Copy Markdown
Contributor

Summary

Replaces the fixed Thread.sleep() in PortForwardTest with semaphore-based synchronization.

The test needs to close the WebSocket handler only after PortForwardResult.init has created the input stream which it will block while reading the port identifier. A test-specific WebSocketStreamHandler subclass signals a semaphore when stream 0 is created, allowing the test to close the handler at the correct point.

A second semaphore waits for init() to finish after the handler is closed.

This is related to issue #1223

Testing

Ran mvn install on the root of the project.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 17, 2026
@sarveshkaushal
sarveshkaushal force-pushed the sarveshkaushal/flaky-tests-1 branch from 15c7c76 to 37e41cf Compare September 17, 2026 18:44
@kubernetes-prow kubernetes-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 17, 2026
@sarveshkaushal

Copy link
Copy Markdown
Contributor Author

/assign @brendandburns
/assign @yue9944882

@brendandburns

Copy link
Copy Markdown
Contributor

As with the previous one please minimize diff for easier reviewing.

@sarveshkaushal
sarveshkaushal force-pushed the sarveshkaushal/flaky-tests-1 branch from 37e41cf to 2461e14 Compare September 26, 2026 01:04
@sarveshkaushal

Copy link
Copy Markdown
Contributor Author

@brendandburns - I have fixed the formatting changes in this PR. It was my IntelliJ which didn't pick the google formatter configured for the project.

@brendandburns

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 13, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 13, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 433ff48 into kubernetes-client:master Oct 13, 2026
14 checks passed
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