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 2ffb72d56b9fd..2934cb2933928 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 @@ -37,8 +37,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":qa:repository-multi-version"); map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:repository-old-versions"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:rolling-upgrade"); @@ -92,8 +90,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:security:qa:tls-basic"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:multi-node"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:shutdown:qa:rolling-upgrade"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:multi-node"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:slm:qa:rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:fs"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-based-recoveries:qa:license-enforcing"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:snapshot-repo-test-kit:qa:hdfs"); @@ -106,12 +102,10 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:mixed-node"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:with-ssl"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:sql:qa:server:security:without-ssl"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:stack:qa:rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:text-structure:qa:text-structure-with-security"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-cluster-tests-with-security"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:multi-node-tests"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:transform:qa:single-node-tests"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile:qa:multi-cluster"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:watcher:qa:with-security"); return map; diff --git a/x-pack/plugin/logstash/build.gradle b/x-pack/plugin/logstash/build.gradle index 37bd972629aa2..69ab5b7f89c5e 100644 --- a/x-pack/plugin/logstash/build.gradle +++ b/x-pack/plugin/logstash/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' esplugin { name = 'x-pack-logstash' @@ -17,10 +17,6 @@ dependencies { testImplementation(testArtifact(project(xpackModule('core')))) javaRestTestImplementation(project(path: xpackModule('core'))) javaRestTestImplementation(testArtifact(project(xpackModule('core')))) -} -testClusters.configureEach { - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'true' - user username: 'x_pack_rest_user', password: 'x-pack-test-password' + clusterModules project(':modules:analysis-common') } diff --git a/x-pack/plugin/logstash/src/javaRestTest/java/org/elasticsearch/xpack/test/rest/LogstashSystemIndexIT.java b/x-pack/plugin/logstash/src/javaRestTest/java/org/elasticsearch/xpack/test/rest/LogstashSystemIndexIT.java index bf7f88d0fc86b..1ef4cbc3f2820 100644 --- a/x-pack/plugin/logstash/src/javaRestTest/java/org/elasticsearch/xpack/test/rest/LogstashSystemIndexIT.java +++ b/x-pack/plugin/logstash/src/javaRestTest/java/org/elasticsearch/xpack/test/rest/LogstashSystemIndexIT.java @@ -17,10 +17,12 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.test.SecuritySettingsSourceField; +import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; +import org.junit.ClassRule; import java.io.IOException; import java.util.ArrayList; @@ -31,6 +33,15 @@ import static org.hamcrest.Matchers.is; public class LogstashSystemIndexIT extends ESRestTestCase { + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("x-pack-logstash") + .module("analysis-common") + .setting("xpack.security.enabled", "true") + .user("x_pack_rest_user", "x-pack-test-password") + .build(); + static final String BASIC_AUTH_VALUE = basicAuthHeaderValue( "x_pack_rest_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING @@ -41,6 +52,11 @@ protected Settings restClientSettings() { return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", BASIC_AUTH_VALUE).build(); } + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + public void testPipelineCRUD() throws Exception { // put pipeline final String pipelineJson = getPipelineJson(); diff --git a/x-pack/plugin/slm/build.gradle b/x-pack/plugin/slm/build.gradle index a827891e4b167..dbf41aa404d94 100644 --- a/x-pack/plugin/slm/build.gradle +++ b/x-pack/plugin/slm/build.gradle @@ -7,15 +7,18 @@ apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' esplugin { name = 'x-pack-slm' description = 'Elasticsearch Expanded Pack Plugin - Snapshot Lifecycle Management' - classname ='org.elasticsearch.xpack.slm.SnapshotLifecycle' + classname = 'org.elasticsearch.xpack.slm.SnapshotLifecycle' extendedPlugins = ['x-pack-core'] - hasNativeController =false - requiresKeystore =true + hasNativeController = false + requiresKeystore = true } + base { archivesName = 'x-pack-slm' } @@ -26,6 +29,20 @@ dependencies { testImplementation project(xpackModule('ccr')) testImplementation project(xpackModule('ilm')) testImplementation project(':modules:data-streams') + javaRestTestImplementation(testArtifact(project(xpackModule('core')))) + javaRestTestImplementation project(xpackModule('slm')) + yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) + clusterModules project(xpackModule("ilm")) + clusterModules project(xpackModule("searchable-snapshots")) + clusterModules project(":modules:data-streams") +} + +restResources { + restApi { + include '_common', 'cluster', 'indices', 'index', 'snapshot', 'slm', 'health_report' + } } -addQaCheckDependencies(project) +tasks.named("javaRestTest") { + usesDefaultDistribution("uses _xpack/usage api") +} diff --git a/x-pack/plugin/slm/qa/build.gradle b/x-pack/plugin/slm/qa/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/x-pack/plugin/slm/qa/multi-node/build.gradle b/x-pack/plugin/slm/qa/multi-node/build.gradle deleted file mode 100644 index afbae8932e292..0000000000000 --- a/x-pack/plugin/slm/qa/multi-node/build.gradle +++ /dev/null @@ -1,43 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE - -apply plugin: 'elasticsearch.legacy-java-rest-test' - -dependencies { - javaRestTestImplementation(testArtifact(project(xpackModule('core')))) - javaRestTestImplementation project(xpackModule('slm')) -} - -File repoDir = file("$buildDir/testclusters/repo") - -tasks.named("javaRestTest").configure { - /* To support taking index snapshots, we have to set path.repo setting */ - nonInputProperties.systemProperty 'tests.path.repo', repoDir -} - -testClusters.configureEach { - testDistribution = 'DEFAULT' - numberOfNodes = 4 - - setting 'path.repo', repoDir.absolutePath, IGNORE_VALUE - setting 'xpack.searchable.snapshot.shared_cache.size', '16MB' - setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB' - setting 'xpack.security.enabled', 'false' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' - setting 'indices.lifecycle.poll_interval', '1000ms' - setting 'logger.org.elasticsearch.xpack.core.slm', 'TRACE' - setting 'logger.org.elasticsearch.xpack.slm', 'TRACE' -} - -if (buildParams.inFipsJvm){ - // Test clusters run with security disabled - tasks.named("javaRestTest").configure{enabled = false } -} diff --git a/x-pack/plugin/slm/qa/rest/build.gradle b/x-pack/plugin/slm/qa/rest/build.gradle deleted file mode 100644 index 3e23d52a291a9..0000000000000 --- a/x-pack/plugin/slm/qa/rest/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -apply plugin: 'elasticsearch.legacy-yaml-rest-test' -apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' -apply plugin: 'elasticsearch.authenticated-testclusters' - -dependencies { - yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) -} - -restResources { - restApi { - include '_common', 'cluster', 'indices', 'index', 'snapshot', 'slm', 'health_report' - } -} - -testClusters.configureEach { - testDistribution = 'DEFAULT' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.autoconfiguration.enabled', 'false' -} diff --git a/x-pack/plugin/slm/qa/with-security/build.gradle b/x-pack/plugin/slm/qa/with-security/build.gradle deleted file mode 100644 index aac8b424d99e3..0000000000000 --- a/x-pack/plugin/slm/qa/with-security/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' - -dependencies { - javaRestTestImplementation(testArtifact(project(xpackModule('core')))) -} - -tasks.named("javaRestTest").configure { - usesDefaultDistribution("to be triaged") -} diff --git a/x-pack/plugin/slm/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java b/x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java similarity index 100% rename from x-pack/plugin/slm/qa/with-security/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java rename to x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/security/PermissionsIT.java diff --git a/x-pack/plugin/slm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java b/x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java similarity index 96% rename from x-pack/plugin/slm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java rename to x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java index 6ee35086baf76..52a01c3bff12b 100644 --- a/x-pack/plugin/slm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java +++ b/x-pack/plugin/slm/src/javaRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleRestIT.java @@ -22,7 +22,10 @@ import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.junit.annotations.TestIssueLogging; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.ToXContent; @@ -35,6 +38,9 @@ import org.elasticsearch.xpack.core.slm.SnapshotLifecyclePolicy; import org.elasticsearch.xpack.core.slm.SnapshotLifecycleStats; import org.elasticsearch.xpack.core.slm.SnapshotRetentionConfiguration; +import org.junit.ClassRule; +import org.junit.rules.RuleChain; +import org.junit.rules.TemporaryFolder; import java.io.IOException; import java.io.InputStream; @@ -62,9 +68,31 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.startsWith; +@SuppressForbidden(reason = "TemporaryFolder uses java.io.File") public class SnapshotLifecycleRestIT extends ESRestTestCase { private static final String NEVER_EXECUTE_CRON_SCHEDULE = "* * * 31 FEB ? *"; + public static TemporaryFolder repoDir = new TemporaryFolder(); + + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + // TODO: Revert to integ-test distro once we sort out issues with usage and info xpack apis + .distribution(DistributionType.DEFAULT) + .nodes(2) + .module("x-pack-slm") + .module("x-pack-ilm") + .module("searchable-snapshots") + .module("data-streams") + .setting("path.repo", () -> repoDir.getRoot().getAbsolutePath()) + .setting("xpack.security.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + .setting("xpack.searchable.snapshot.shared_cache.size", "16MB") + .setting("xpack.searchable.snapshot.shared_cache.region_size", "256KB") + .setting("indices.lifecycle.poll_interval", "1000ms") + .build(); + + @ClassRule + public static RuleChain rules = RuleChain.outerRule(repoDir).around(cluster); + // as we are testing the SLM history entries we'll preserve the "slm-history-ilm-policy" policy as it'll be associated with the // .slm-history-* indices and we won't be able to delete it when we wipe out the cluster @Override @@ -72,6 +100,11 @@ protected boolean preserveILMPoliciesUponCompletion() { return true; } + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + public void testMissingRepo() throws Exception { SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy( "missing-repo-policy", @@ -919,7 +952,7 @@ private void initializeRepo(String repoName, String maxBytesPerSecond) throws IO .field("type", "fs") .startObject("settings") .field("compress", randomBoolean()) - .field("location", System.getProperty("tests.path.repo")) + .field("location", repoDir.getRoot().getAbsolutePath()) .field("max_snapshot_bytes_per_sec", maxBytesPerSecond) .endObject() .endObject() diff --git a/x-pack/plugin/slm/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java b/x-pack/plugin/slm/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java similarity index 72% rename from x-pack/plugin/slm/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java rename to x-pack/plugin/slm/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java index f3f542cde3365..d8f243121939f 100644 --- a/x-pack/plugin/slm/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java +++ b/x-pack/plugin/slm/src/yamlRestTest/java/org/elasticsearch/xpack/slm/SnapshotLifecycleYamlIT.java @@ -15,16 +15,27 @@ 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.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.ClassRule; import java.util.Objects; @TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs public class SnapshotLifecycleYamlIT extends ESClientYamlSuiteTestCase { - private static final String USER = Objects.requireNonNull(System.getProperty("tests.rest.cluster.username")); - private static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password")); + private static final String USER = Objects.requireNonNull(System.getProperty("tests.rest.cluster.username", "test_admin")); + private static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password", "x-pack-test-password")); + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("x-pack-slm") + .module("x-pack-ilm") + .setting("xpack.security.enabled", "true") + .setting("xpack.license.self_generated.type", "trial") + .user(USER, PASS) + .build(); public SnapshotLifecycleYamlIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); @@ -40,4 +51,9 @@ protected Settings restClientSettings() { String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build(); } + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } } diff --git a/x-pack/plugin/slm/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/slm/11_basic_slm.yml b/x-pack/plugin/slm/src/yamlRestTest/resources/rest-api-spec/test/slm/11_basic_slm.yml similarity index 100% rename from x-pack/plugin/slm/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/slm/11_basic_slm.yml rename to x-pack/plugin/slm/src/yamlRestTest/resources/rest-api-spec/test/slm/11_basic_slm.yml diff --git a/x-pack/plugin/slm/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/slm/20_health.yml b/x-pack/plugin/slm/src/yamlRestTest/resources/rest-api-spec/test/slm/20_health.yml similarity index 100% rename from x-pack/plugin/slm/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/slm/20_health.yml rename to x-pack/plugin/slm/src/yamlRestTest/resources/rest-api-spec/test/slm/20_health.yml diff --git a/x-pack/plugin/stack/build.gradle b/x-pack/plugin/stack/build.gradle index 1796ba334cdaf..58e08ecea07f4 100644 --- a/x-pack/plugin/stack/build.gradle +++ b/x-pack/plugin/stack/build.gradle @@ -1,13 +1,15 @@ apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.yaml-rest-compat-test' esplugin { name = 'x-pack-stack' description = 'Elasticsearch Expanded Pack Plugin - Stack' - classname ='org.elasticsearch.xpack.stack.StackPlugin' + classname = 'org.elasticsearch.xpack.stack.StackPlugin' extendedPlugins = ['x-pack-core'] - hasNativeController =false - requiresKeystore =true + hasNativeController = false + requiresKeystore = true } base { @@ -19,16 +21,31 @@ dependencies { testImplementation project(':modules:data-streams') javaRestTestImplementation(testArtifact(project(xpackModule('core')))) javaRestTestImplementation project(path: ':x-pack:plugin:stack') + yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) clusterModules project(':modules:mapper-extras') clusterModules project(xpackModule('wildcard')) + clusterModules project(xpackModule('ilm')) + clusterModules project(xpackModule('mapper-constant-keyword')) + clusterModules project(':modules:ingest-common') + clusterModules project(':modules:mapper-extras') + clusterModules project(':modules:data-streams') +} + +restResources { + restApi { + include '_common', 'cluster', 'indices', 'index', 'snapshot', 'ilm', 'slm', 'stack', 'indices' + } } // These tests are only invoked direclty as part of a dedicated build job -tasks.named('javaRestTest').configure {task -> - onlyIf("E2E test task must be invoked directly") { - gradle.startParameter.getTaskNames().contains(task.path) || - (gradle.startParameter.getTaskNames().contains(task.name) && gradle.startParameter.currentDir == project.projectDir) - } +tasks.named('javaRestTest') { task -> + onlyIf("E2E test task must be invoked directly") { + gradle.startParameter.getTaskNames().contains(task.path) || + (gradle.startParameter.getTaskNames().contains(task.name) && gradle.startParameter.currentDir == project.projectDir) + } } -addQaCheckDependencies(project) +tasks.named("yamlRestCompatTestTransform") { task -> + task.skipTest("stack/10_basic/Test kibana reporting index auto creation", "warning does not exist for compatibility") + task.skipTest("cat.shards/10_basic/Help", "sync_id is removed in 9.0") +} diff --git a/x-pack/plugin/stack/qa/build.gradle b/x-pack/plugin/stack/qa/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/x-pack/plugin/stack/qa/rest/build.gradle b/x-pack/plugin/stack/qa/rest/build.gradle deleted file mode 100644 index 86f1ef7055769..0000000000000 --- a/x-pack/plugin/stack/qa/rest/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -apply plugin: 'elasticsearch.legacy-yaml-rest-test' -apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' -apply plugin: 'elasticsearch.authenticated-testclusters' - -dependencies { - yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) -} - -restResources { - restApi { - include '_common', 'cluster', 'indices', 'index', 'snapshot', 'ilm', 'slm', 'stack', 'indices' - } -} - -testClusters.configureEach { - testDistribution = 'DEFAULT' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' -} - -tasks.named("yamlRestCompatTestTransform").configure({ task -> - task.skipTest("stack/10_basic/Test kibana reporting index auto creation", "warning does not exist for compatibility") - task.skipTest("cat.shards/10_basic/Help", "sync_id is removed in 9.0") -}) diff --git a/x-pack/plugin/stack/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java b/x-pack/plugin/stack/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java similarity index 68% rename from x-pack/plugin/stack/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java rename to x-pack/plugin/stack/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java index 4db1a6abe6da1..c86d059087530 100644 --- a/x-pack/plugin/stack/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java +++ b/x-pack/plugin/stack/src/yamlRestTest/java/org/elasticsearch/xpack/stack/StackYamlIT.java @@ -15,18 +15,32 @@ 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.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.ClassRule; import java.util.Objects; -import static org.elasticsearch.xpack.core.security.authc.support.UsernamePasswordToken.basicAuthHeaderValue; - @TimeoutSuite(millis = 30 * TimeUnits.MINUTE) // as default timeout seems not enough on the jenkins VMs public class StackYamlIT extends ESClientYamlSuiteTestCase { - private static final String USER = Objects.requireNonNull(System.getProperty("tests.rest.cluster.username")); - private static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password")); + private static final String USER = Objects.requireNonNull(System.getProperty("tests.rest.cluster.username", "test_admin")); + private static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password", "x-pack-test-password")); + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("x-pack-stack") + .module("x-pack-ilm") + .module("wildcard") + .module("constant-keyword") + .module("ingest-common") + .module("mapper-extras") + .module("data-streams") + .setting("xpack.security.enabled", "true") + .setting("xpack.license.self_generated.type", "trial") + .user(USER, PASS) + .build(); public StackYamlIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); @@ -42,4 +56,9 @@ protected Settings restClientSettings() { String token = basicAuthHeaderValue(USER, new SecureString(PASS.toCharArray())); return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", token).build(); } + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } } diff --git a/x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml b/x-pack/plugin/stack/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml similarity index 100% rename from x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml rename to x-pack/plugin/stack/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml diff --git a/x-pack/plugin/vector-tile/build.gradle b/x-pack/plugin/vector-tile/build.gradle index 4ff3240d239e8..a8fa43aeb4db6 100644 --- a/x-pack/plugin/vector-tile/build.gradle +++ b/x-pack/plugin/vector-tile/build.gradle @@ -13,7 +13,7 @@ */ apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' esplugin { name = 'vector-tile' @@ -34,12 +34,11 @@ dependencies { // runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}") https://github.com/elastic/elasticsearch/issues/93714 javaRestTestImplementation("com.wdtinc:mapbox-vector-tile:3.1.0") javaRestTestImplementation("com.google.protobuf:protobuf-java:${versions.protobuf}") -} -testClusters.configureEach { - setting 'xpack.license.self_generated.type', 'trial' - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'false' + clusterModules project(':modules:analysis-common') + clusterModules project(':modules:legacy-geo') + clusterModules project(':modules:lang-painless') + clusterModules project(':test:external-modules:test-error-query') } tasks.named("thirdPartyAudit").configure { diff --git a/x-pack/plugin/vector-tile/qa/build.gradle b/x-pack/plugin/vector-tile/qa/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle b/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle deleted file mode 100644 index 30b032c1cae1a..0000000000000 --- a/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle +++ /dev/null @@ -1,51 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask -import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.legacy-java-rest-test' - -dependencies { - javaRestTestImplementation project(':x-pack:plugin:vector-tile') -} - - -def remoteCluster = testClusters.register('remote') { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' -} - -def localCluster = testClusters.register('local') { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'admin', password: 'admin-password', role: 'superuser' - setting 'cluster.remote.other.seeds', - { "\"${remoteCluster.get().getAllTransportPortURI().join(",")}\"" }, IGNORE_VALUE -} - - -def startRemoteCluster = tasks.register("startRemoteCluster", DefaultTestClustersTask.class) { - useCluster remoteCluster - doLast { - "Starting remote cluster before integ tests and integTest cluster is started" - } -} - -tasks.named("javaRestTest").configure { - dependsOn startRemoteCluster - useCluster remoteCluster - useCluster localCluster - doFirst { - nonInputProperties.systemProperty 'tests.local', - "${-> localCluster.get().getAllHttpSocketURI().get(0)}" - nonInputProperties.systemProperty 'tests.remote', - "${-> remoteCluster.get().getAllHttpSocketURI().get(0)}" - } -} diff --git a/x-pack/plugin/vector-tile/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/vectortile/VectorTileCCSIT.java b/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileCCSIT.java similarity index 84% rename from x-pack/plugin/vector-tile/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/vectortile/VectorTileCCSIT.java rename to x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileCCSIT.java index d58e397704004..e8102630e287f 100644 --- a/x-pack/plugin/vector-tile/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/vectortile/VectorTileCCSIT.java +++ b/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileCCSIT.java @@ -5,7 +5,7 @@ * 2.0. */ -package org.elasticsearch.vectortile; +package org.elasticsearch.xpack.vectortile; import com.wdtinc.mapbox_vector_tile.VectorTile; @@ -19,20 +19,46 @@ 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.cluster.local.LocalClusterConfigProvider; import org.elasticsearch.test.rest.ESRestTestCase; import org.hamcrest.Matchers; +import org.junit.ClassRule; +import org.junit.rules.RuleChain; import java.io.IOException; import java.io.InputStream; public class VectorTileCCSIT extends ESRestTestCase { + public static LocalClusterConfigProvider commonConfig = c -> c.module("vector-tile") + .module("analysis-common") + .setting("xpack.license.self_generated.type", "trial") + .setting("xpack.security.enabled", "true") + .user("admin", "admin-password", "superuser", false); + + public static ElasticsearchCluster remoteCluster = ElasticsearchCluster.local().name("remote-cluster").apply(commonConfig).build(); + + public static ElasticsearchCluster localCluster = ElasticsearchCluster.local() + .name("local-cluster") + .apply(commonConfig) + .setting("cluster.remote.other.seeds", () -> "\"" + remoteCluster.getTransportEndpoints() + "\"") + .build(); + + @ClassRule + public static RuleChain ruleChain = RuleChain.outerRule(remoteCluster).around(localCluster); + @Override protected Settings restClientSettings() { final String token = basicAuthHeaderValue("admin", new SecureString("admin-password".toCharArray())); return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build(); } + @Override + protected String getTestRestCluster() { + return localCluster.getHttpAddresses(); + } + private int createIndex(RestClient client, String indexName) throws IOException { final Request createRequest = new Request(HttpPut.METHOD_NAME, indexName); Response response = client.performRequest(createRequest); @@ -113,11 +139,11 @@ private VectorTile.Tile execute(RestClient client, Request mvtRequest) throws IO } private RestClient buildLocalClusterClient() throws IOException { - return buildClient(System.getProperty("tests.local")); + return buildClient(localCluster.getHttpAddresses()); } private RestClient buildRemoteClusterClient() throws IOException { - return buildClient(System.getProperty("tests.remote")); + return buildClient(remoteCluster.getHttpAddresses()); } private RestClient buildClient(final String url) throws IOException { diff --git a/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileRestIT.java b/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileRestIT.java index 82b6a4382525a..a77178745d6be 100644 --- a/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileRestIT.java +++ b/x-pack/plugin/vector-tile/src/javaRestTest/java/org/elasticsearch/xpack/vectortile/VectorTileRestIT.java @@ -28,11 +28,13 @@ import org.elasticsearch.index.query.GeoShapeQueryBuilder; import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileUtils; +import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.ObjectPath; import org.hamcrest.Matchers; import org.junit.AfterClass; import org.junit.Before; +import org.junit.ClassRule; import java.io.IOException; import java.io.InputStream; @@ -47,6 +49,13 @@ */ public class VectorTileRestIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("vector-tile") + .module("test-error-query") + .setting("xpack.license.self_generated.type", "trial") + .build(); + private static final String INDEX_POINTS = "index-points"; private static final String INDEX_POLYGON = "index-polygon"; private static final String INDEX_COLLECTION = "index-collection"; @@ -74,6 +83,11 @@ public void indexDocuments() throws IOException { } } + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + private void indexPoints() throws IOException { final Request createRequest = new Request(HttpPut.METHOD_NAME, INDEX_POINTS); Response response = client().performRequest(createRequest);