Migrate legacy QA projects to new test clusters framework (#125545)

This commit is contained in:
Mark Vieira 2025-03-26 10:05:56 -07:00 committed by GitHub
parent 2204b4a13c
commit 0388a5980c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 151 additions and 98 deletions

View file

@ -48,11 +48,6 @@ public abstract class RestrictedBuildApiService implements BuildService<Restrict
map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters");
map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version");
map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy");
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-http");
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-ingest-disabled");
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-ingest-with-all-dependencies");
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-plugins");
map.put(LegacyRestTestBasePlugin.class, ":qa:system-indices");
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");

View file

@ -7,15 +7,12 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
apply plugin: 'elasticsearch.legacy-java-rest-test'
//apply plugin: 'elasticsearch.test-with-dependencies'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
dependencies {
javaRestTestImplementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
javaRestTestImplementation project(':modules:rest-root')
}
testClusters.configureEach {
module ':modules:rest-root'
setting 'xpack.security.enabled', 'false'
internalClusterTestImplementation project(":test:framework")
internalClusterTestImplementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
internalClusterTestImplementation project(':modules:rest-root')
clusterModules project(":modules:rest-root")
}

View file

@ -0,0 +1,25 @@
/*
* 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.http;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.ClassRule;
public abstract class AbstractHttpSmokeTestIT extends ESRestTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().module("rest-root").build();
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}

View file

@ -17,7 +17,6 @@ import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.ObjectPath;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.json.JsonXContent;
@ -29,7 +28,7 @@ import java.util.Map;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.Matchers.containsString;
public class AutoCreateIndexIT extends ESRestTestCase {
public class AutoCreateIndexIT extends AbstractHttpSmokeTestIT {
/**
* Check that setting {@link AutoCreateIndex#AUTO_CREATE_INDEX_SETTING} to <code>false</code>

View file

@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.test.rest.ESRestTestCase;
import java.io.IOException;
@ -23,7 +22,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
public class HttpCompressionIT extends ESRestTestCase {
public class HttpCompressionIT extends AbstractHttpSmokeTestIT {
private static final String GZIP_ENCODING = "gzip";
private static final String SAMPLE_DOCUMENT = """

View file

@ -13,7 +13,6 @@ import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.test.rest.ESRestTestCase;
import java.util.Arrays;
import java.util.List;
@ -29,7 +28,7 @@ import static org.hamcrest.Matchers.is;
* methods on REST endpoints should respond with status code 405</a> for more
* information.
*/
public class RestHttpResponseHeadersIT extends ESRestTestCase {
public class RestHttpResponseHeadersIT extends AbstractHttpSmokeTestIT {
/**
* For an OPTIONS request to a valid REST endpoint, verify that a 200 HTTP

View file

@ -6,13 +6,8 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* 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'
dependencies {
testImplementation project(':modules:ingest-common')
}
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
setting 'xpack.security.enabled', 'false'
setting 'node.roles', '[data,master,remote_cluster_client]'
clusterModules project(':modules:ingest-common')
}

View file

@ -12,11 +12,20 @@ package org.elasticsearch.smoketest;
import com.carrotsearch.randomizedtesting.annotations.Name;
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.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
public class SmokeTestIngestDisabledClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.module("ingest-common")
.setting("xpack.security.enabled", "false")
.setting("node.roles", "[data,master,remote_cluster_client]")
.build();
public SmokeTestIngestDisabledClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
@ -26,4 +35,8 @@ public class SmokeTestIngestDisabledClientYamlTestSuiteIT extends ESClientYamlSu
return ESClientYamlSuiteTestCase.createParameters();
}
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}

View file

@ -7,22 +7,16 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
dependencies {
yamlRestTestImplementation project(':modules:lang-mustache')
}
testClusters.configureEach {
setting 'xpack.security.enabled', 'false'
extraConfigFile 'ingest-geoip/GeoLite2-City.mmdb', file("src/yamlRestTest/resources/GeoLite2-City.mmdb")
}
tasks.named("yamlRestTestTestingConventions").configure {
baseClass 'org.elasticsearch.ingest.AbstractScriptTestCase'
baseClass 'org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase'
}
tasks.named("forbiddenPatterns").configure {
exclude '**/*.mmdb'
internalClusterTestImplementation project(':test:framework')
internalClusterTestImplementation project(':modules:lang-mustache')
clusterModules project(":modules:ingest-common")
clusterModules project(":modules:lang-mustache")
clusterModules project(":modules:reindex")
clusterModules project(":modules:data-streams")
clusterModules project(":modules:ingest-geoip")
clusterModules project(":modules:mapper-extras")
}

View file

@ -12,11 +12,25 @@ package org.elasticsearch.smoketest;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
public class SmokeTestIngestWithAllDepsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.module("ingest-common")
.module("lang-mustache")
.module("reindex")
.module("data-streams")
.module("ingest-geoip")
.module("mapper-extras")
.configFile("ingest-geoip/GeoLite2-City.mmdb", Resource.fromClasspath("GeoLite2-City.mmdb"))
.build();
public SmokeTestIngestWithAllDepsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
@ -26,4 +40,8 @@ public class SmokeTestIngestWithAllDepsClientYamlTestSuiteIT extends ESClientYam
return ESClientYamlSuiteTestCase.createParameters();
}
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}

View file

@ -1,7 +1,6 @@
---
"Test invalid name warnings":
- requires:
cluster_features: [ "ingest.pipeline_name_special_chars_warning" ]
test_runner_features: [ "warnings" ]
reason: verifying deprecation warnings from 9.0 onwards for invalid pipeline names
@ -24,5 +23,5 @@
}]
}
warnings:
- "Invalid pipeline id: Invalid*-pipeline:id"
- "Pipeline name [Invalid*-pipeline:id] will be disallowed in a future version for the following reason: must not contain the following characters [' ','\"','*',',','/','<','>','?','\\','|']"
- match: { acknowledged: true }

View file

@ -9,26 +9,32 @@
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-yaml-rest-test'
ext.pluginPaths = []
ext.pluginNames = []
project(':plugins').getChildProjects().each { pluginName, pluginProject ->
pluginPaths << pluginProject.path
pluginNames << pluginName
}
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
dependencies {
clusterModules project(":modules:lang-painless")
pluginPaths.each { pluginPath ->
plugin pluginPath
clusterPlugins(project(pluginPath))
}
setting 'xpack.security.enabled', 'false'
}
ext.expansions = [
'expected.plugins.count': pluginPaths.size()
]
tasks.named("processYamlRestTestResources").configure {
tasks.named("processYamlRestTestResources") {
assert pluginPaths.size() > 0
inputs.properties(expansions)
filter("tokens" : expansions.collectEntries {k, v -> [k, v.toString()]} /* must be a map of strings */, ReplaceTokens.class)
}
tasks.named("yamlRestTest") {
systemProperty('tests.plugin.names', pluginNames.join(','))
}

View file

@ -12,11 +12,20 @@ package org.elasticsearch.smoketest;
import com.carrotsearch.randomizedtesting.annotations.Name;
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.ESClientYamlSuiteTestCase;
import org.junit.ClassRule;
public class SmokeTestPluginsClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().apply(c -> {
for (String plugin : System.getProperty("tests.plugin.names").split(",")) {
c.plugin(plugin);
}
}).module("lang-painless").setting("xpack.security.enabled", "false").build();
public SmokeTestPluginsClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
@ -25,4 +34,9 @@ public class SmokeTestPluginsClientYamlTestSuiteIT extends ESClientYamlSuiteTest
public static Iterable<Object[]> parameters() throws Exception {
return ESClientYamlSuiteTestCase.createParameters();
}
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
}

View file

@ -8,7 +8,7 @@
*/
apply plugin: 'elasticsearch.base-internal-es-plugin'
apply plugin: 'elasticsearch.legacy-java-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
esplugin {
name = 'system-indices-qa'
@ -17,10 +17,3 @@ esplugin {
licenseFile = layout.settingsDirectory.file('licenses/AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt').asFile
noticeFile = layout.settingsDirectory.file('NOTICE.txt').asFile
}
testClusters.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'true'
setting 'xpack.security.autoconfiguration.enabled', 'false'
user username: 'rest_user', password: 'rest-user-password'
}

View file

@ -0,0 +1,42 @@
/*
* 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.system.indices;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.ClassRule;
public abstract class AbstractSystemIndicesIT extends ESRestTestCase {
protected static final String BASIC_AUTH_VALUE = basicAuthHeaderValue(
"rest_user",
new SecureString("rest-user-password".toCharArray())
);
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.plugin("system-indices-qa")
.setting("xpack.security.enabled", "true")
.setting("xpack.security.autoconfiguration.enabled", "false")
.user("rest_user", "rest-user-password")
.build();
@Override
protected String getTestRestCluster() {
return cluster.getHttpAddresses();
}
@Override
protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
}
}

View file

@ -12,12 +12,8 @@ package org.elasticsearch.system.indices;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.XContentTestUtils;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.After;
import java.util.Collections;
@ -29,20 +25,13 @@ import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
public class FeatureUpgradeApiIT extends ESRestTestCase {
static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("rest_user", new SecureString("rest-user-password".toCharArray()));
public class FeatureUpgradeApiIT extends AbstractSystemIndicesIT {
@After
public void resetFeatures() throws Exception {
client().performRequest(new Request("POST", "/_features/_reset"));
}
@Override
protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
}
public void testCreatingSystemIndex() throws Exception {
var request = new Request("PUT", "/_net_new_sys_index/_create");
request.setOptions(RequestOptions.DEFAULT.toBuilder().addHeader("X-elastic-product-origin", "elastic"));

View file

@ -15,24 +15,13 @@ import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.After;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
public class NetNewSystemIndicesIT extends ESRestTestCase {
static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("rest_user", new SecureString("rest-user-password".toCharArray()));
@Override
protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
}
public class NetNewSystemIndicesIT extends AbstractSystemIndicesIT {
public void testCreatingSystemIndex() throws Exception {
ResponseException e = expectThrows(

View file

@ -12,10 +12,6 @@ package org.elasticsearch.system.indices;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.After;
import java.io.IOException;
@ -26,19 +22,13 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
public class SystemAliasIT extends ESRestTestCase {
static final String BASIC_AUTH_VALUE = basicAuthHeaderValue("rest_user", new SecureString("rest-user-password".toCharArray()));
public class SystemAliasIT extends AbstractSystemIndicesIT {
@After
public void resetFeatures() throws Exception {
client().performRequest(new Request("POST", "/_features/_reset"));
}
@Override
protected Settings restClientSettings() {
return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build();
}
public void testCreatingSystemIndexWithAlias() throws Exception {
{
Request request = new Request("PUT", "/.internal-unmanaged-index-8");

View file

@ -67,7 +67,6 @@ import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.core.UpdateForV10;
import org.elasticsearch.env.Environment;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.grok.MatcherWatchdog;
import org.elasticsearch.index.IndexSettings;
@ -118,8 +117,6 @@ public class IngestService implements ClusterStateApplier, ReportingService<Inge
public static final String INGEST_ORIGIN = "ingest";
public static final NodeFeature PIPELINE_NAME_VALIDATION_WARNINGS = new NodeFeature("ingest.pipeline_name_special_chars_warning");
private static final Logger logger = LogManager.getLogger(IngestService.class);
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(IngestService.class);

View file

@ -689,7 +689,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
if (spec.getPlugins().isEmpty() == false) {
Pattern pattern = Pattern.compile("(.+)(?:-\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?\\.zip)");
LOGGER.info("Installing plugins {} into node '{}", spec.getPlugins(), name);
LOGGER.info("Installing plugins {} into node '{}", spec.getPlugins().keySet(), name);
List<Path> pluginPaths = Arrays.stream(System.getProperty(TESTS_CLUSTER_PLUGINS_PATH_SYSPROP).split(File.pathSeparator))
.map(Path::of)
.toList();
@ -767,7 +767,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
private void installModules() {
if (spec.getModules().isEmpty() == false) {
LOGGER.info("Installing modules {} into node '{}", spec.getModules(), name);
LOGGER.info("Installing modules {} into node '{}", spec.getModules().keySet(), name);
List<Path> modulePaths = Arrays.stream(System.getProperty(TESTS_CLUSTER_MODULES_PATH_SYSPROP).split(File.pathSeparator))
.map(Path::of)
.toList();