TEST: Stablize Minio Free Port Search (#34894)
* 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
This commit is contained in:
parent
33345d96ef
commit
65edec0d42
|
@ -202,14 +202,11 @@ if (useFixture && minioDistribution) {
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
// get free port
|
// get free port
|
||||||
for (int port = 60920; port < 60940; port++) {
|
ServerSocket serverSocket = new ServerSocket(0, 1, InetAddress.getByName(minioAddress))
|
||||||
try {
|
try {
|
||||||
javax.net.ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName(minioAddress)).close()
|
minioPort = serverSocket.localPort
|
||||||
minioPort = port
|
} finally {
|
||||||
break
|
serverSocket.close()
|
||||||
} catch (BindException e) {
|
|
||||||
logger.info("Port " + port + " for Minio process is already taken", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (minioPort == 0) {
|
if (minioPort == 0) {
|
||||||
throw new GradleException("Could not find a free port for Minio")
|
throw new GradleException("Could not find a free port for Minio")
|
||||||
|
|
Loading…
Reference in New Issue