Skip to content

Commit 6e057bd

Browse files
Increase ephemeral ports range for ServerTransportFilterIntegrationTests (#112279)
This PR increases client's port range for `ServerTransportFilterIntegrationTests` which are executed on Windows. This is needed 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.
1 parent 5361235 commit 6e057bd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

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

9+
import org.apache.lucene.util.Constants;
910
import org.elasticsearch.ElasticsearchSecurityException;
1011
import org.elasticsearch.Version;
1112
import org.elasticsearch.action.support.PlainActionFuture;
@@ -53,11 +54,14 @@
5354
import static org.hamcrest.CoreMatchers.instanceOf;
5455

5556
public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase {
57+
58+
private static final int NUMBER_OF_CLIENT_PORTS = Constants.WINDOWS ? 300 : 100;
59+
5660
private static int randomClientPort;
5761

5862
@BeforeClass
5963
public static void getRandomPort() {
60-
randomClientPort = randomIntBetween(49000, 65500); // ephemeral port
64+
randomClientPort = randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS); // ephemeral port
6165
}
6266

6367
@Override
@@ -68,7 +72,7 @@ public boolean transportSSLEnabled() {
6872
@Override
6973
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
7074
Settings.Builder settingsBuilder = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
71-
String randomClientPortRange = randomClientPort + "-" + (randomClientPort + 100);
75+
String randomClientPortRange = randomClientPort + "-" + (randomClientPort + NUMBER_OF_CLIENT_PORTS);
7276
addSSLSettingsForNodePEMFiles(settingsBuilder, "transport.profiles.client.xpack.security.", true);
7377
Path certPath = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt");
7478
settingsBuilder.putList(

0 commit comments

Comments
 (0)