Skip to content

Commit

Permalink
Increase ephemeral ports range for ServerTransportFilterIntegrationTe…
Browse files Browse the repository at this point in the history
…sts (#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.
  • Loading branch information
slobodanadamovic authored Aug 29, 2024
1 parent 5361235 commit 6e057bd
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.elasticsearch.xpack.security.transport;

import org.apache.lucene.util.Constants;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.PlainActionFuture;
Expand Down Expand Up @@ -53,11 +54,14 @@
import static org.hamcrest.CoreMatchers.instanceOf;

public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase {

private static final int NUMBER_OF_CLIENT_PORTS = Constants.WINDOWS ? 300 : 100;

private static int randomClientPort;

@BeforeClass
public static void getRandomPort() {
randomClientPort = randomIntBetween(49000, 65500); // ephemeral port
randomClientPort = randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS); // ephemeral port
}

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

0 comments on commit 6e057bd

Please sign in to comment.