From 120c10cc5c07ad9ae92d0a9a36534d6372dc663f Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 22 Jul 2025 09:31:07 -0700 Subject: [PATCH 1/2] Migrate mixed cluster tests to new testing framework --- .../internal/RestrictedBuildApiService.java | 1 - qa/mixed-cluster/build.gradle | 85 +++++-------------- .../backwards/AbstractMixedClusterTest.java | 47 ++++++++++ .../elasticsearch/backwards/HotThreadsIT.java | 5 +- .../elasticsearch/backwards/IndexingIT.java | 42 ++++++++- .../backwards/MixedClusterTestNode.java | 0 .../backwards/MixedClusterTestNodes.java | 0 .../elasticsearch/backwards/RareTermsIT.java | 3 +- .../MixedClusterClientYamlTestSuiteIT.java | 35 -------- .../MixedClusterClientYamlTestSuiteIT.java | 64 ++++++++++++++ 10 files changed, 175 insertions(+), 107 deletions(-) create mode 100644 qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java rename qa/mixed-cluster/src/{test => javaRestTest}/java/org/elasticsearch/backwards/HotThreadsIT.java (90%) rename qa/mixed-cluster/src/{test => javaRestTest}/java/org/elasticsearch/backwards/IndexingIT.java (93%) rename qa/mixed-cluster/src/{test => javaRestTest}/java/org/elasticsearch/backwards/MixedClusterTestNode.java (100%) rename qa/mixed-cluster/src/{test => javaRestTest}/java/org/elasticsearch/backwards/MixedClusterTestNodes.java (100%) rename qa/mixed-cluster/src/{test => javaRestTest}/java/org/elasticsearch/backwards/RareTermsIT.java (96%) delete mode 100644 qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java create mode 100644 qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java index 205930133156c..24c1c5f0ae7d5 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java @@ -31,7 +31,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":distribution:docker"); map.put(LegacyRestTestBasePlugin.class, ":modules:reindex"); map.put(LegacyRestTestBasePlugin.class, ":qa:ccs-rolling-upgrade-remote-cluster"); - map.put(LegacyRestTestBasePlugin.class, ":qa:mixed-cluster"); map.put(LegacyRestTestBasePlugin.class, ":qa:multi-cluster-search"); map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters"); map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version"); diff --git a/qa/mixed-cluster/build.gradle b/qa/mixed-cluster/build.gradle index a591d4c590b27..77556cb2fff28 100644 --- a/qa/mixed-cluster/build.gradle +++ b/qa/mixed-cluster/build.gradle @@ -8,18 +8,14 @@ */ -import org.elasticsearch.gradle.Version -import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask -import org.elasticsearch.gradle.testclusters.TestClusterValueSource -import org.elasticsearch.gradle.testclusters.TestClustersRegistry -import org.elasticsearch.gradle.util.GradleUtils -import org.elasticsearch.gradle.testclusters.TestClustersPlugin -apply plugin: 'elasticsearch.internal-testclusters' -apply plugin: 'elasticsearch.standalone-rest-test' -apply plugin: 'elasticsearch.bwc-test' +import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.registerTestTask + +apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.rest-resources' +apply plugin: 'elasticsearch.bwc-test' dependencies { restTestConfig project(path: ':modules:aggregations', configuration: 'restTests') @@ -71,64 +67,27 @@ excludeList.add('aggregations/percentiles_hdr_metric/Negative values test') // sync_id is removed in 9.0 excludeList.add("cat.shards/10_basic/Help") -def clusterPath = getPath() - buildParams.bwcVersions.withWireCompatible { bwcVersion, baseName -> - if (bwcVersion != VersionProperties.getElasticsearchVersion()) { - /* This project runs the core REST tests against a 4 node cluster where two of - the nodes has a different minor. */ - def baseCluster = testClusters.register(baseName) { - versions = [bwcVersion.toString(), project.version] - numberOfNodes = 4 - setting 'path.repo', "${layout.buildDirectory.asFile.get()}/cluster/shared/repo/${baseName}" - setting 'xpack.security.enabled', 'false' - setting "xpack.license.self_generated.type", "trial" - /* There is a chance we have more master changes than "normal", so to avoid this test from failing, - we increase the threshold (as this purpose of this test isn't to test that specific indicator). */ - if (bwcVersion.onOrAfter(Version.fromString("8.4.0"))) { - setting 'health.master_history.no_master_transitions_threshold', '10' - } - requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0") - requiresFeature 'sub_objects_auto', Version.fromString("8.16.0") - if (bwcVersion.before(Version.fromString("8.18.0"))) { - jvmArgs '-da:org.elasticsearch.index.mapper.DocumentMapper' - jvmArgs '-da:org.elasticsearch.index.mapper.MapperService' - } + registerTestTask(project, sourceSets.yamlRestTest, "v${bwcVersion}#yamlBwcTest", StandaloneRestIntegTestTask).configure { + usesBwcDistribution(bwcVersion) + systemProperty("tests.old_cluster_version", bwcVersion) + if (excludeList.isEmpty() == false) { + systemProperty 'tests.rest.blacklist', excludeList.join(',') } + } - tasks.register("${baseName}#mixedClusterTest", StandaloneRestIntegTestTask) { - useCluster baseCluster - mustRunAfter("precommit") - def baseInfo = getClusterInfo(baseName).map { it.allHttpSocketURI.join(",") } - def baseInfoAfterOneNodeUpdate = getClusterInfo(baseName).map { it.allHttpSocketURI.join(",") } - def baseInfoAfterTwoNodesUpdate = getClusterInfo(baseName).map { it.allHttpSocketURI.join(",") } - def sharedRepoFolder = layout.buildDirectory.file("cluster/shared/repo/${baseName}").get().asFile - doFirst { - delete(sharedRepoFolder) - // Getting the endpoints causes a wait for the cluster - println "Test cluster endpoints are: ${-> baseInfo.get().join(",")}" - println "Upgrading one node to create a mixed cluster" - getRegistry().get().nextNodeToNextVersion(baseCluster) + registerTestTask(project, sourceSets.javaRestTest, "v${bwcVersion}#javaBwcTest", StandaloneRestIntegTestTask).configure { + usesBwcDistribution(bwcVersion) + systemProperty("tests.old_cluster_version", bwcVersion) + } - // Getting the endpoints causes a wait for the cluster - println "Upgrade complete, endpoints are: ${-> baseInfoAfterOneNodeUpdate.get()}" - println "Upgrading another node to create a mixed cluster" - getRegistry().get().nextNodeToNextVersion(baseCluster) - } - if (excludeList.isEmpty() == false) { - systemProperty 'tests.rest.blacklist', excludeList.join(',') - } - nonInputProperties.systemProperty('tests.rest.cluster', baseInfoAfterTwoNodesUpdate) - nonInputProperties.systemProperty('tests.clustername', baseName) - systemProperty 'tests.path.repo', "${layout.buildDirectory.file("cluster/shared/repo/${baseName}").get().asFile}" - systemProperty 'tests.bwc_nodes_version', bwcVersion.toString().replace('-SNAPSHOT', '') - systemProperty 'tests.new_nodes_version', project.version.toString().replace('-SNAPSHOT', '') - def bwcEnabled = project.bwc_tests_enabled - onlyIf("BWC tests disabled") { bwcEnabled } - } + tasks.register(bwcTaskName(bwcVersion)) { + dependsOn "v${bwcVersion}#yamlBwcTest", "v${bwcVersion}#javaBwcTest" + } - tasks.register(bwcTaskName(bwcVersion)) { - dependsOn "${baseName}#mixedClusterTest" - } + tasks.withType(Test).configureEach { + boolean bwcEnabled = project.bwc_tests_enabled + onlyIf("BWC tests enabled") { bwcEnabled } + nonInputProperties.systemProperty 'tests.bwc', 'true' } } diff --git a/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java new file mode 100644 index 0000000000000..b57d0df5f8e02 --- /dev/null +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.backwards; + +import org.elasticsearch.Version; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.junit.ClassRule; + +public abstract class AbstractMixedClusterTest extends ESRestTestCase { + protected static final String BWC_NODES_VERSION = System.getProperty("tests.old_cluster_version"); + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .distribution(DistributionType.DEFAULT) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(Version.CURRENT.toString())) + .withNode(n -> n.version(Version.CURRENT.toString())) + .setting("xpack.security.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + // There is a chance we have more master changes than "normal", so to avoid this test from failing, we increase the + // threshold (as this purpose of this test isn't to test that specific indicator). + .setting("health.master_history.no_master_transitions_threshold", () -> "10", s -> s.getVersion().onOrAfter("8.4.0")) + .apply(c -> { + if (Version.fromString(System.getProperty("tests.old_cluster_version")).before(Version.fromString("8.18.0"))) { + c.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper").jvmArg("-da:org.elasticsearch.index.mapper.MapperService"); + } + }) + .feature(FeatureFlag.TIME_SERIES_MODE) + .feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED) + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } +} diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/HotThreadsIT.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/HotThreadsIT.java similarity index 90% rename from qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/HotThreadsIT.java rename to qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/HotThreadsIT.java index 9df522f4d9111..72e4af197e664 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/HotThreadsIT.java +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/HotThreadsIT.java @@ -12,13 +12,10 @@ import org.apache.http.util.EntityUtils; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; -import org.elasticsearch.test.rest.ESRestTestCase; import static org.hamcrest.Matchers.equalTo; -public class HotThreadsIT extends ESRestTestCase { - - private static final String BWC_NODES_VERSION = System.getProperty("tests.bwc_nodes_version"); +public class HotThreadsIT extends AbstractMixedClusterTest { public void testHotThreads() throws Exception { final MixedClusterTestNodes nodes = MixedClusterTestNodes.buildNodes(client(), BWC_NODES_VERSION); diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java similarity index 93% rename from qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java rename to qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java index dc3e527d656cb..8f0ec67c53f2a 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java @@ -9,6 +9,7 @@ package org.elasticsearch.backwards; import org.apache.http.HttpHost; +import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; @@ -20,11 +21,17 @@ import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.index.seqno.SeqNoStats; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.ObjectPath; import org.elasticsearch.xcontent.MediaType; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; +import org.junit.ClassRule; +import org.junit.rules.RuleChain; +import org.junit.rules.TemporaryFolder; import java.io.IOException; import java.util.ArrayList; @@ -39,7 +46,38 @@ import static org.hamcrest.Matchers.oneOf; public class IndexingIT extends ESRestTestCase { - private static final String BWC_NODES_VERSION = System.getProperty("tests.bwc_nodes_version"); + private static final String BWC_NODES_VERSION = System.getProperty("tests.old_cluster_version"); + + public static TemporaryFolder repo = new TemporaryFolder(); + + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .distribution(DistributionType.DEFAULT) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(Version.CURRENT.toString())) + .withNode(n -> n.version(Version.CURRENT.toString())) + .setting("path.repo", () -> repo.getRoot().getAbsolutePath()) + .setting("xpack.security.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + // There is a chance we have more master changes than "normal", so to avoid this test from failing, we increase the + // threshold (as this purpose of this test isn't to test that specific indicator). + .setting("health.master_history.no_master_transitions_threshold", () -> "10", s -> s.getVersion().onOrAfter("8.4.0")) + .apply(c -> { + if (Version.fromString(System.getProperty("tests.old_cluster_version")).before(Version.fromString("8.18.0"))) { + c.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper").jvmArg("-da:org.elasticsearch.index.mapper.MapperService"); + } + }) + .feature(FeatureFlag.TIME_SERIES_MODE) + .feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED) + .build(); + + @ClassRule + public static RuleChain ruleChain = RuleChain.outerRule(repo).around(cluster); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { @@ -234,7 +272,7 @@ public void testUpdateSnapshotStatus() throws Exception { .field("type", "fs") .startObject("settings") .field("compress", randomBoolean()) - .field("location", System.getProperty("tests.path.repo")) + .field("location", repo.getRoot().getAbsolutePath()) .endObject() .endObject() ) diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterTestNode.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/MixedClusterTestNode.java similarity index 100% rename from qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterTestNode.java rename to qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/MixedClusterTestNode.java diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterTestNodes.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/MixedClusterTestNodes.java similarity index 100% rename from qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterTestNodes.java rename to qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/MixedClusterTestNodes.java diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/RareTermsIT.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/RareTermsIT.java similarity index 96% rename from qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/RareTermsIT.java rename to qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/RareTermsIT.java index 2ee769b54a09d..e60a872faf01b 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/RareTermsIT.java +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/RareTermsIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.core.Strings; -import org.elasticsearch.test.rest.ESRestTestCase; import org.hamcrest.Matchers; import java.io.IOException; @@ -23,7 +22,7 @@ /** * Test that index enough data to trigger the creation of Cuckoo filters. */ -public class RareTermsIT extends ESRestTestCase { +public class RareTermsIT extends AbstractMixedClusterTest { private static final String index = "idx"; diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java deleted file mode 100644 index a61d773bdba0f..0000000000000 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -package org.elasticsearch.backwards; - -import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; -import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; - -import org.apache.lucene.tests.util.TimeUnits; -import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; - -@TimeoutSuite(millis = 60 * TimeUnits.MINUTE) // some of the windows test VMs are slow as hell -public class MixedClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { - - public MixedClusterClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) { - super(testCandidate); - } - - @ParametersFactory - public static Iterable parameters() throws Exception { - return createParameters(); - } - - @Override - protected boolean randomizeContentType() { - return false; - } -} diff --git a/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java b/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java new file mode 100644 index 0000000000000..b885a9a66bad4 --- /dev/null +++ b/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java @@ -0,0 +1,64 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +package org.elasticsearch.backwards; + +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; + +import org.apache.lucene.tests.util.TimeUnits; +import org.elasticsearch.Version; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.ClassRule; + +@TimeoutSuite(millis = 60 * TimeUnits.MINUTE) // some of the windows test VMs are slow as hell +public class MixedClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .distribution(DistributionType.DEFAULT) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(Version.CURRENT.toString())) + .setting("xpack.security.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + // There is a chance we have more master changes than "normal", so to avoid this test from failing, we increase the + // threshold (as this purpose of this test isn't to test that specific indicator). + .setting("health.master_history.no_master_transitions_threshold", () -> "10", s -> s.getVersion().onOrAfter("8.4.0")) + .apply(c -> { + if (Version.fromString(System.getProperty("tests.old_cluster_version")).before(Version.fromString("8.18.0"))) { + c.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper").jvmArg("-da:org.elasticsearch.index.mapper.MapperService"); + } + }) + .feature(FeatureFlag.TIME_SERIES_MODE) + .feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED) + .build(); + + public MixedClusterClientYamlTestSuiteIT(ClientYamlTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws Exception { + return createParameters(); + } + + @Override + protected boolean randomizeContentType() { + return false; + } + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } +} From 1c2e4763c43d694f5d3fb06f61d253fd2d6c5794 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 22 Jul 2025 10:41:28 -0700 Subject: [PATCH 2/2] Just use 4 node clusters --- .../backwards/AbstractMixedClusterTest.java | 9 +++- .../elasticsearch/backwards/IndexingIT.java | 42 +------------------ .../MixedClusterClientYamlTestSuiteIT.java | 2 + 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java index b57d0df5f8e02..02dde1aa0c4bc 100644 --- a/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/AbstractMixedClusterTest.java @@ -15,17 +15,21 @@ import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.rest.ESRestTestCase; import org.junit.ClassRule; +import org.junit.rules.RuleChain; +import org.junit.rules.TemporaryFolder; public abstract class AbstractMixedClusterTest extends ESRestTestCase { protected static final String BWC_NODES_VERSION = System.getProperty("tests.old_cluster_version"); - @ClassRule + public static TemporaryFolder repo = new TemporaryFolder(); + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) .withNode(n -> n.version(Version.CURRENT.toString())) .withNode(n -> n.version(Version.CURRENT.toString())) + .setting("path.repo", () -> repo.getRoot().getAbsolutePath()) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial") // There is a chance we have more master changes than "normal", so to avoid this test from failing, we increase the @@ -40,6 +44,9 @@ public abstract class AbstractMixedClusterTest extends ESRestTestCase { .feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED) .build(); + @ClassRule + public static RuleChain ruleChain = RuleChain.outerRule(repo).around(cluster); + @Override protected String getTestRestCluster() { return cluster.getHttpAddresses(); diff --git a/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java index 8f0ec67c53f2a..78784780d6b8d 100644 --- a/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/backwards/IndexingIT.java @@ -9,7 +9,6 @@ package org.elasticsearch.backwards; import org.apache.http.HttpHost; -import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; @@ -21,17 +20,10 @@ import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.index.seqno.SeqNoStats; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.test.cluster.ElasticsearchCluster; -import org.elasticsearch.test.cluster.FeatureFlag; -import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.ObjectPath; import org.elasticsearch.xcontent.MediaType; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; -import org.junit.ClassRule; -import org.junit.rules.RuleChain; -import org.junit.rules.TemporaryFolder; import java.io.IOException; import java.util.ArrayList; @@ -45,39 +37,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.oneOf; -public class IndexingIT extends ESRestTestCase { - private static final String BWC_NODES_VERSION = System.getProperty("tests.old_cluster_version"); - - public static TemporaryFolder repo = new TemporaryFolder(); - - public static ElasticsearchCluster cluster = ElasticsearchCluster.local() - .distribution(DistributionType.DEFAULT) - .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) - .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) - .withNode(n -> n.version(Version.CURRENT.toString())) - .withNode(n -> n.version(Version.CURRENT.toString())) - .setting("path.repo", () -> repo.getRoot().getAbsolutePath()) - .setting("xpack.security.enabled", "false") - .setting("xpack.license.self_generated.type", "trial") - // There is a chance we have more master changes than "normal", so to avoid this test from failing, we increase the - // threshold (as this purpose of this test isn't to test that specific indicator). - .setting("health.master_history.no_master_transitions_threshold", () -> "10", s -> s.getVersion().onOrAfter("8.4.0")) - .apply(c -> { - if (Version.fromString(System.getProperty("tests.old_cluster_version")).before(Version.fromString("8.18.0"))) { - c.jvmArg("-da:org.elasticsearch.index.mapper.DocumentMapper").jvmArg("-da:org.elasticsearch.index.mapper.MapperService"); - } - }) - .feature(FeatureFlag.TIME_SERIES_MODE) - .feature(FeatureFlag.SUB_OBJECTS_AUTO_ENABLED) - .build(); - - @ClassRule - public static RuleChain ruleChain = RuleChain.outerRule(repo).around(cluster); - - @Override - protected String getTestRestCluster() { - return cluster.getHttpAddresses(); - } +public class IndexingIT extends AbstractMixedClusterTest { private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { diff --git a/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java b/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java index b885a9a66bad4..716f4958ad1db 100644 --- a/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java +++ b/qa/mixed-cluster/src/yamlRestTest/java/org/elasticsearch/backwards/MixedClusterClientYamlTestSuiteIT.java @@ -28,6 +28,8 @@ public class MixedClusterClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(System.getProperty("tests.old_cluster_version"))) + .withNode(n -> n.version(Version.CURRENT.toString())) .withNode(n -> n.version(Version.CURRENT.toString())) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial")