Skip to content

Commit

Permalink
TEST: Stablize Minio Free Port Search (#34894)
Browse files Browse the repository at this point in the history
* Binding to `0` gives us free ports that are assigned sequentially by Linux making collisions much less likely compared to manually finding a free port in a range
* Closes #32208
  • Loading branch information
original-brownbear authored Oct 26, 2018
1 parent 33345d9 commit 65edec0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions plugins/repository-s3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,11 @@ if (useFixture && minioDistribution) {

doLast {
// get free port
for (int port = 60920; port < 60940; port++) {
try {
javax.net.ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName(minioAddress)).close()
minioPort = port
break
} catch (BindException e) {
logger.info("Port " + port + " for Minio process is already taken", e)
}
ServerSocket serverSocket = new ServerSocket(0, 1, InetAddress.getByName(minioAddress))
try {
minioPort = serverSocket.localPort
} finally {
serverSocket.close()
}
if (minioPort == 0) {
throw new GradleException("Could not find a free port for Minio")
Expand Down

0 comments on commit 65edec0

Please sign in to comment.