Skip to content

Commit 11a2a61

Browse files
Add force single data path option for integ tests (elastic#71868)
Some functionality will no longer work with multiple data paths and in order to run integration tests for that, we need the capability to force a single data path for those tests. Relates elastic#71844
1 parent 79f8987 commit 11a2a61

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ protected TestCluster buildTestCluster(Scope scope, long seed) throws IOExceptio
19691969
return new InternalTestCluster(seed, createTempDir(), supportsDedicatedMasters, getAutoManageMasterNodes(),
19701970
minNumDataNodes, maxNumDataNodes,
19711971
InternalTestCluster.clusterName(scope.name(), seed) + "-cluster", nodeConfigurationSource, getNumClientNodes(),
1972-
nodePrefix, mockPlugins, getClientWrapper(), forbidPrivateIndexSettings());
1972+
nodePrefix, mockPlugins, getClientWrapper(), forbidPrivateIndexSettings(), forceSingleDataPath());
19731973
}
19741974

19751975
private NodeConfigurationSource getNodeConfigSource() {
@@ -2325,6 +2325,13 @@ protected boolean forbidPrivateIndexSettings() {
23252325
return true;
23262326
}
23272327

2328+
/**
2329+
* Override to return true in tests that cannot handle multiple data paths.
2330+
*/
2331+
protected boolean forceSingleDataPath() {
2332+
return false;
2333+
}
2334+
23282335
/**
23292336
* Returns an instance of {@link RestClient} pointing to the current test cluster.
23302337
* Creates a new client if the method is invoked for the first time in the context of the current test scope.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ public InternalTestCluster(
287287
nodePrefix,
288288
mockPlugins,
289289
clientWrapper,
290-
true);
290+
true,
291+
false);
291292
}
292293

293294
public InternalTestCluster(
@@ -303,7 +304,8 @@ public InternalTestCluster(
303304
final String nodePrefix,
304305
final Collection<Class<? extends Plugin>> mockPlugins,
305306
final Function<Client, Client> clientWrapper,
306-
final boolean forbidPrivateIndexSettings) {
307+
final boolean forbidPrivateIndexSettings,
308+
final boolean forceSingleDataPath) {
307309
super(clusterSeed);
308310
this.autoManageMasterNodes = autoManageMasterNodes;
309311
this.clientWrapper = clientWrapper;
@@ -365,7 +367,8 @@ public InternalTestCluster(
365367
numSharedDedicatedMasterNodes, numSharedDataNodes, numSharedCoordOnlyNodes,
366368
autoManageMasterNodes ? "auto-managed" : "manual");
367369
this.nodeConfigurationSource = nodeConfigurationSource;
368-
numDataPaths = random.nextInt(5) == 0 ? 2 + random.nextInt(3) : 1;
370+
// use 1 data path if we are forced to, or 80% of the time that we are not, otherwise use between 2 and 4 data paths
371+
numDataPaths = forceSingleDataPath || random.nextDouble() < 0.8 ? 1 : RandomNumbers.randomIntBetween(random, 2, 4);
369372
Builder builder = Settings.builder();
370373
builder.put(Environment.PATH_HOME_SETTING.getKey(), baseDir);
371374
builder.put(Environment.PATH_REPO_SETTING.getKey(), baseDir.resolve("repos"));

0 commit comments

Comments
 (0)