Convert :test projects to new testing framework (#125724)

This commit is contained in:
Mark Vieira 2025-03-26 16:11:50 -07:00 committed by GitHub
parent 689eaf20f4
commit e149a3e10d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 57 additions and 28 deletions

View file

@ -36,12 +36,6 @@ public abstract class RestrictedBuildApiService implements BuildService<Restrict
map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters"); map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters");
map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version"); map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version");
map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy"); map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-apm-integration");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-delayed-aggs");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-die-with-dignity");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-error-query");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-latency-simulating-directory");
map.put(LegacyRestTestBasePlugin.class, ":test:yaml-rest-runner");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:core"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:core");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet");
@ -60,8 +54,6 @@ public abstract class RestrictedBuildApiService implements BuildService<Restrict
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-plugins-ssl"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-plugins-ssl");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-security-with-mustache"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:smoke-test-security-with-mustache");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:xpack-prefix-rest-compat"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:xpack-prefix-rest-compat");
map.put(LegacyRestTestBasePlugin.class, ":modules:ingest-geoip:qa:file-based-update");
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-gce:qa:gce");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-basic-license"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-basic-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-full-license"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-full-license");
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-restricted-trust"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:multi-cluster-search-security:legacy-with-restricted-trust");

View file

@ -7,11 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-yaml-rest-test'
tasks.named('yamlRestTest').configure {
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}
esplugin { esplugin {
description = 'A test module that allows to delay aggregations on shards with a configurable time' description = 'A test module that allows to delay aggregations on shards with a configurable time'
@ -23,3 +19,8 @@ restResources {
include '_common', 'indices', 'index', 'cluster', 'search' include '_common', 'indices', 'index', 'cluster', 'search'
} }
} }
tasks.named('yamlRestTest') {
def isSnapshot = buildParams.snapshotBuild
it.onlyIf("snapshot build") { isSnapshot }
}

View file

@ -12,10 +12,16 @@ package org.elasticsearch.search.aggregations;
import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
public class DelayedShardAggregationClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public class DelayedShardAggregationClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("test-delayed-aggs").build();
public DelayedShardAggregationClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { public DelayedShardAggregationClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate); super(testCandidate);
} }
@ -24,4 +30,9 @@ public class DelayedShardAggregationClientYamlTestSuiteIT extends ESClientYamlSu
public static Iterable<Object[]> parameters() throws Exception { public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(); return ESClientYamlSuiteTestCase.createParameters();
} }
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
} }

View file

@ -7,18 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1". * License v3.0 only", or the "Server Side Public License, v 1".
*/ */
apply plugin: 'elasticsearch.legacy-yaml-rest-test' import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test' apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.named('javaRestTest') {
usesDefaultDistribution("to be triaged")
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}
tasks.named('yamlRestTest').configure {
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}
esplugin { esplugin {
description = 'A test module that exposes a way to simulate search shard failures and warnings' description = 'A test module that exposes a way to simulate search shard failures and warnings'
classname ='org.elasticsearch.test.errorquery.ErrorQueryPlugin' classname ='org.elasticsearch.test.errorquery.ErrorQueryPlugin'
@ -29,3 +22,14 @@ restResources {
include '_common', 'indices', 'index', 'cluster', 'search' include '_common', 'indices', 'index', 'cluster', 'search'
} }
} }
dependencies {
clusterModules project(':x-pack:plugin:esql')
clusterModules project(':x-pack:plugin:autoscaling')
clusterModules project(':x-pack:plugin:ilm')
}
tasks.withType(StandaloneRestIntegTestTask) {
def isSnapshot = buildParams.snapshotBuild
onlyIf("snapshot build") { isSnapshot }
}

View file

@ -16,7 +16,6 @@ import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.ClassRule; import org.junit.ClassRule;
@ -35,8 +34,9 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class EsqlPartialResultsIT extends ESRestTestCase { public class EsqlPartialResultsIT extends ESRestTestCase {
@ClassRule @ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local() public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.module("test-error-query") .module("test-error-query")
.module("x-pack-esql")
.module("x-pack-ilm")
.setting("xpack.security.enabled", "false") .setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial") .setting("xpack.license.self_generated.type", "trial")
.setting("esql.query.allow_partial_results", "true") .setting("esql.query.allow_partial_results", "true")

View file

@ -12,10 +12,16 @@ package org.elasticsearch.search.query;
import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
public class ErrorQueryClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public class ErrorQueryClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("test-error-query").build();
public ErrorQueryClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { public ErrorQueryClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate); super(testCandidate);
} }
@ -24,4 +30,9 @@ public class ErrorQueryClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
public static Iterable<Object[]> parameters() throws Exception { public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters(); return ESClientYamlSuiteTestCase.createParameters();
} }
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
} }

View file

@ -41,7 +41,7 @@ public class DefaultLocalClusterHandle implements LocalClusterHandle {
public static final AtomicInteger NEXT_DEBUG_PORT = new AtomicInteger(5007); public static final AtomicInteger NEXT_DEBUG_PORT = new AtomicInteger(5007);
private static final Logger LOGGER = LogManager.getLogger(DefaultLocalClusterHandle.class); private static final Logger LOGGER = LogManager.getLogger(DefaultLocalClusterHandle.class);
private static final Duration CLUSTER_UP_TIMEOUT = Duration.ofMinutes(5); private static final Duration CLUSTER_UP_TIMEOUT = Duration.ofMinutes(1);
public final ForkJoinPool executor = new ForkJoinPool( public final ForkJoinPool executor = new ForkJoinPool(
Math.max(Runtime.getRuntime().availableProcessors(), 4), Math.max(Runtime.getRuntime().availableProcessors(), 4),

View file

@ -1,6 +1,6 @@
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.yaml-rest-compat-test'
dependencies { dependencies {
api project(':test:framework') api project(':test:framework')

View file

@ -13,12 +13,17 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.elasticsearch.test.MockLog; import org.elasticsearch.test.MockLog;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.ClassRule;
import java.io.IOException; import java.io.IOException;
public class ESClientYamlSuiteTestCaseFailLogIT extends ESClientYamlSuiteTestCase { public class ESClientYamlSuiteTestCaseFailLogIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build();
public ESClientYamlSuiteTestCaseFailLogIT(final ClientYamlTestCandidate testCandidate) { public ESClientYamlSuiteTestCaseFailLogIT(final ClientYamlTestCandidate testCandidate) {
super(testCandidate); super(testCandidate);
} }
@ -65,4 +70,9 @@ public class ESClientYamlSuiteTestCaseFailLogIT extends ESClientYamlSuiteTestCas
mockLog.assertAllExpectationsMatched(); mockLog.assertAllExpectationsMatched();
} }
} }
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
} }