Skip to content

fix: test: use monotonical port numbers #13999

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

Closed
wants to merge 4 commits into from
Closed

fix: test: use monotonical port numbers #13999

wants to merge 4 commits into from

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Jul 24, 2024

Related: #13931

This PR modifies the logic to assign a potentially empty part starting from the high boundary of the ephemeral range.

Note:

I don't guarantee it helps, but at least I couldn't reproduce it in CI.

@mtojek mtojek self-assigned this Jul 24, 2024
@mtojek mtojek requested a review from dannykopping July 24, 2024 12:11
@mtojek mtojek marked this pull request as ready for review July 24, 2024 12:11
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

I'm not sure this will fix the flake.

We're not "reserving" this port for use exclusively in this test.
There's no guarantee here that no other test is not already listening on this port.

To fix, we probably need to assign a "well-known" port to this test, and ensure that no other test can acquire it. We can assign a port outside of the ephemeral port range for this.

@mtojek
Copy link
Member Author

mtojek commented Jul 24, 2024

To fix, we probably need to assign a "well-known" port to this test

I assume that this should go together with skipping t.Parallel in case count > 1?

and ensure that no other test can acquire it

Is there any specific method you have in mind?

@dannykopping
Copy link
Contributor

I assume that this should go together with skipping t.Parallel in case count > 1?

Yeah we can skip t.Parallel.

Is there any specific method you have in mind?

You could just pick one like 30000, which would at least be outside the MacOS & Linux ephemeral port ranges:

# on my Mac
$ sysctl net.inet.ip.portrange.{first,last}
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
# on a linux host
$ ssh coder@greenhill.jnb.cdr.dev 'sysctl net.ipv4.ip_local_port_range'
net.ipv4.ip_local_port_range = 32768	60999

Provided no other test explicitly uses port 30000, you should be ok.
If someone picks that port in the future, there will be a collision, which is what we want.

@mtojek
Copy link
Member Author

mtojek commented Jul 24, 2024

Closing in favor of #14000

@mtojek mtojek closed this Jul 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2024
@github-actions github-actions bot deleted the 13931-port-2 branch January 25, 2025 00:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants