Fix suite scope random initializaation (#37163)
The initialization of a suite scope cluster had some sideffects on subsequent runs which causes issues when tests must be reproduced. This moves the suite scope initialization to a privte random context. Closes #36202
This commit is contained in:
parent
21996f7690
commit
ac2e09b25a
|
@ -373,18 +373,24 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
||||||
|
|
||||||
protected final void beforeInternal() throws Exception {
|
protected final void beforeInternal() throws Exception {
|
||||||
final Scope currentClusterScope = getCurrentClusterScope();
|
final Scope currentClusterScope = getCurrentClusterScope();
|
||||||
|
Callable<Void> setup = () -> {
|
||||||
|
cluster().beforeTest(random(), getPerTestTransportClientRatio());
|
||||||
|
cluster().wipe(excludeTemplates());
|
||||||
|
randomIndexTemplate();
|
||||||
|
return null;
|
||||||
|
};
|
||||||
switch (currentClusterScope) {
|
switch (currentClusterScope) {
|
||||||
case SUITE:
|
case SUITE:
|
||||||
assert SUITE_SEED != null : "Suite seed was not initialized";
|
assert SUITE_SEED != null : "Suite seed was not initialized";
|
||||||
currentCluster = buildAndPutCluster(currentClusterScope, SUITE_SEED);
|
currentCluster = buildAndPutCluster(currentClusterScope, SUITE_SEED);
|
||||||
|
RandomizedContext.current().runWithPrivateRandomness(SUITE_SEED, setup);
|
||||||
break;
|
break;
|
||||||
case TEST:
|
case TEST:
|
||||||
currentCluster = buildAndPutCluster(currentClusterScope, randomLong());
|
currentCluster = buildAndPutCluster(currentClusterScope, randomLong());
|
||||||
|
setup.call();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cluster().beforeTest(random(), getPerTestTransportClientRatio());
|
|
||||||
cluster().wipe(excludeTemplates());
|
|
||||||
randomIndexTemplate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTestMessage(String message) {
|
private void printTestMessage(String message) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class SuiteScopeClusterIT extends ESIntegTestCase {
|
||||||
@Test
|
@Test
|
||||||
@SuppressForbidden(reason = "repeat is a feature here")
|
@SuppressForbidden(reason = "repeat is a feature here")
|
||||||
@Repeat(iterations = 10, useConstantSeed = true)
|
@Repeat(iterations = 10, useConstantSeed = true)
|
||||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/36202")
|
|
||||||
public void testReproducible() throws IOException {
|
public void testReproducible() throws IOException {
|
||||||
if (ITER++ == 0) {
|
if (ITER++ == 0) {
|
||||||
CLUSTER_SEED = cluster().seed();
|
CLUSTER_SEED = cluster().seed();
|
||||||
|
|
Loading…
Reference in New Issue