Skip to content

Commit 59f0e6f

Browse files
[Test] Fix SslMultiPortTests by increasing the number of ephemeral ports on windows (#106540)
This PR increases client's port ranges for tests which are executed on Windows in order to avoid failures due to some port ranges being excluded from use. The larger ports range (300) is chosen based on the observation where a random consecutive range of 200 ports can be excluded on Windows test workers. Relates to #103894, which fixed similar issues but this one seems to have been missed. Resolves: #106537
1 parent b0cd02b commit 59f0e6f

File tree

1 file changed

+13
-5
lines changed
  • x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl

1 file changed

+13
-5
lines changed

x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl/SslMultiPortTests.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.xpack.security.transport.ssl;
88

9+
import org.apache.lucene.util.Constants;
910
import org.elasticsearch.client.transport.NoNodeAvailableException;
1011
import org.elasticsearch.client.transport.TransportClient;
1112
import org.elasticsearch.common.network.NetworkAddress;
@@ -39,14 +40,24 @@
3940

4041
public class SslMultiPortTests extends SecurityIntegTestCase {
4142

43+
private static final int NUMBER_OF_CLIENT_PORTS = Constants.WINDOWS ? 300 : 100;
44+
4245
private static int randomClientPort;
46+
private static String randomClientPortRange;
4347
private static int randomNoClientAuthPort;
48+
private static String randomNoClientAuthPortRange;
4449
private static InetAddress localAddress;
4550

4651
@BeforeClass
4752
public static void getRandomPort() {
48-
randomClientPort = randomIntBetween(49000, 65500); // ephemeral port
49-
randomNoClientAuthPort = randomIntBetween(49000, 65500);
53+
randomClientPort = randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS);
54+
randomClientPortRange = randomClientPort + "-" + (randomClientPort + NUMBER_OF_CLIENT_PORTS);
55+
56+
randomNoClientAuthPort = randomValueOtherThanMany(
57+
port -> port >= randomClientPort - NUMBER_OF_CLIENT_PORTS && port <= randomClientPort + NUMBER_OF_CLIENT_PORTS,
58+
() -> randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS)
59+
);
60+
randomNoClientAuthPortRange = randomNoClientAuthPort + "-" + (randomNoClientAuthPort + NUMBER_OF_CLIENT_PORTS);
5061
localAddress = InetAddress.getLoopbackAddress();
5162
}
5263

@@ -60,9 +71,6 @@ public static void getRandomPort() {
6071
*/
6172
@Override
6273
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
63-
String randomClientPortRange = randomClientPort + "-" + (randomClientPort + 100);
64-
String randomNoClientAuthPortRange = randomNoClientAuthPort + "-" + (randomNoClientAuthPort + 100);
65-
6674
Path trustCert;
6775
try {
6876
trustCert = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt");

0 commit comments

Comments
 (0)