Skip to content

Commit 2619149

Browse files
authored
[TEST] Work around race condition when starting clusters in parallel (#118145)
With #117820 we are starting clusters in parallel in CCS related tests. There is a race condition when calling RandomizedTest#isNightly, which is called as part of `InternalTestCluster#beforeTest`. See randomizedtesting/randomizedtesting#311. Until this is fixed upstream, we can simply call isNightly before forking, which is going to trigger the lazy initialization of the inner map that causes the race. From then on, all threads will have a consistent view of it. Closes #118124
1 parent 1106171 commit 2619149

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@ tests:
239239
- class: org.elasticsearch.packaging.test.ConfigurationTests
240240
method: test30SymlinkedDataPath
241241
issue: https://github.com/elastic/elasticsearch/issues/118111
242-
- class: org.elasticsearch.datastreams.ResolveClusterDataStreamIT
243-
method: testClusterResolveWithDataStreamsUsingAlias
244-
issue: https://github.com/elastic/elasticsearch/issues/118124
245242
- class: org.elasticsearch.packaging.test.KeystoreManagementTests
246243
method: test30KeystorePasswordFromFile
247244
issue: https://github.com/elastic/elasticsearch/issues/118123

test/framework/src/main/java/org/elasticsearch/test/AbstractMultiClustersTestCase.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.test;
1111

12+
import com.carrotsearch.randomizedtesting.RandomizedTest;
13+
1214
import org.apache.logging.log4j.LogManager;
1315
import org.apache.logging.log4j.Logger;
1416
import org.elasticsearch.action.admin.cluster.remote.RemoteInfoRequest;
@@ -108,6 +110,11 @@ public final void startClusters() throws Exception {
108110
MockTransportService.TestPlugin.class,
109111
getTestTransportPlugin()
110112
);
113+
// We are going to initialize multiple clusters concurrently, but there is a race condition around the lazy initialization of test
114+
// groups in GroupEvaluator across multiple threads. See https://github.com/randomizedtesting/randomizedtesting/issues/311.
115+
// Calling isNightly before parallelizing is enough to work around that issue.
116+
@SuppressWarnings("unused")
117+
boolean nightly = RandomizedTest.isNightly();
111118
runInParallel(clusterAliases.size(), i -> {
112119
String clusterAlias = clusterAliases.get(i);
113120
final String clusterName = clusterAlias.equals(LOCAL_CLUSTER) ? "main-cluster" : clusterAlias;

0 commit comments

Comments
 (0)