Skip to content
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

Hold onto randomly allocated ports to avoid port conflicts in concurrent tests #182

Merged

Conversation

mmollaverdi
Copy link
Contributor

No description provided.

ServerSocket(0).use { socket -> return socket.localPort }
fun allocateRandomPort(): ServerSocket {
val socket = ServerSocket(0) //use { socket -> return socket.localPort }
Runtime.getRuntime().addShutdownHook(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to make sure the port is released in case something fails before it's released in the test server.

Copy link
Collaborator

@kyeotic kyeotic left a comment

Choose a reason for hiding this comment

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

I like this, but the name on the public and internal API needs to be changed to reflect its function instead of its happen-stance implementation.

@mmollaverdi mmollaverdi changed the title For discussion - Hold onto randomly allocated ports to avoid port conflicts in concurrent tests Hold onto randomly allocated ports to avoid port conflicts in concurrent tests May 29, 2024
@kyeotic kyeotic merged commit 38c0913 into cashapp:main May 30, 2024
2 checks passed
mmollaverdi added a commit to mmollaverdi/tempest that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants