Skip to content

Commit b7bc790

Browse files
committed
Use a non default port range in MockTransportService
We already use a per JVM port range in MockTransportService. Yet, it's possible that if we are executing in the JVM with ordinal 0 that other clusters reuse ports from the mock transport service and some tests try to simulate disconnects etc. By using a non-defautl port range (starting at 10300) we prevent internal test clusters from reusing any of the mock impls ports Relates to #25301
1 parent e81804c commit b7bc790

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static MockTransportService createNewService(Settings settings, Version v
106106
// concurrent tests could claim port that another JVM just released and if that test tries to simulate a disconnect it might
107107
// be smart enough to re-connect depending on what is tested. To reduce the risk, since this is very hard to debug we use
108108
// a different default port range per JVM unless the incoming settings override it
109-
int basePort = 9300 + (JVM_ORDINAL * 100);
109+
int basePort = 10300 + (JVM_ORDINAL * 100); // use a non-default port otherwise some cluster in this JVM might reuse a port
110110
settings = Settings.builder().put(TcpTransport.PORT.getKey(), basePort + "-" + (basePort+100)).put(settings).build();
111111
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
112112
final Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,

0 commit comments

Comments
 (0)