Skip to content

chore: consolidate various randomPort() implementations #12362

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 2 commits into from
Feb 29, 2024

Conversation

johnstcn
Copy link
Member

Consolidates our existing randomPort() implementations to testutil.RandomPort(NoListen)?.

@johnstcn johnstcn self-assigned this Feb 29, 2024
@johnstcn johnstcn changed the title chore: DRY up various randomPort() implementations chore: refactor and DRY various randomPort() implementations Feb 29, 2024
@johnstcn johnstcn changed the title chore: refactor and DRY various randomPort() implementations chore: consolidate various randomPort() implementations Feb 29, 2024
@johnstcn johnstcn requested review from mtojek and mafredri February 29, 2024 11:10
@johnstcn johnstcn enabled auto-merge (squash) February 29, 2024 12:37
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

just a digression on naming, otherwise 👍

@@ -838,7 +837,7 @@ func TestAgent_TCPRemoteForwarding(t *testing.T) {
var ll net.Listener
var err error
for {
randomPort = pickRandomPort()
randomPort = testutil.RandomPortNoListen(t)
Copy link
Member

Choose a reason for hiding this comment

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

nit: testutil.FreePort?

Copy link
Member Author

Choose a reason for hiding this comment

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

This one isn't guaranteed to be free and relies on pure randommess.
Regarding the other implementation, I just picked the existing name.
We can rename later if need be. 👍

@johnstcn johnstcn merged commit eba8cd7 into main Feb 29, 2024
@johnstcn johnstcn deleted the cj/dry-testutil-random-port branch February 29, 2024 12:51
@github-actions github-actions bot locked and limited conversation to collaborators Feb 29, 2024
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.

3 participants