From 47c6fd34dadba5b71a9a939ca95a624e5ee073fb Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 22 Dec 2022 17:48:07 -0800 Subject: [PATCH] =?UTF-8?q?[7.17]=20Add=20JUnit=20rule=20based=20integrati?= =?UTF-8?q?on=20test=20cluster=20orchestration=20framework=E2=80=A6=20(#92?= =?UTF-8?q?517)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new test framework for configuring and orchestrating test clusters for both Java and YAML REST testing. This will eventually replace the existing "test-clusters" Gradle plugin and the build-time cluster orchestration. --- build-tools-internal/build.gradle | 8 + .../AbstractRestResourcesFuncTest.groovy | 1 + ...gConventionsPrecommitPluginFuncTest.groovy | 6 +- ...> LegacyYamlRestTestPluginFuncTest.groovy} | 4 +- .../elasticsearch.build-complete.gradle | 5 + ...elasticsearch.runtime-jdk-provision.gradle | 41 +- .../gradle/internal/doc/DocsTestPlugin.groovy | 2 +- .../TestingConventionsPrecommitPlugin.java | 18 +- ...gin.java => LegacyRestTestBasePlugin.java} | 32 +- .../test/StandaloneRestTestPlugin.java | 10 +- .../test/TestWithDependenciesPlugin.java | 6 + .../internal/test/TestWithSslPlugin.java | 6 +- .../test/rest/InternalJavaRestTestPlugin.java | 7 +- .../test/rest/InternalYamlRestTestPlugin.java | 6 +- .../test/rest/LegacyJavaRestTestPlugin.java | 48 ++ .../test/rest/LegacyYamlRestTestPlugin.java | 76 +++ .../test/rest/RestTestBasePlugin.java | 241 +++++++++ .../internal/test/rest/RestTestUtil.java | 19 +- .../elasticsearch/gradle/reaper/Reaper.java | 4 +- .../StandaloneRestIntegTestTask.java | 5 - client/rest-high-level/build.gradle | 2 +- .../archives/integ-test-zip/build.gradle | 2 +- distribution/docker/build.gradle | 2 +- modules/aggs-matrix-stats/build.gradle | 2 +- modules/analysis-common/build.gradle | 2 +- modules/ingest-common/build.gradle | 2 +- modules/ingest-geoip/build.gradle | 2 +- .../qa/file-based-update/build.gradle | 2 +- modules/ingest-user-agent/build.gradle | 2 +- modules/kibana/build.gradle | 2 +- modules/lang-expression/build.gradle | 2 +- modules/lang-mustache/build.gradle | 4 +- modules/lang-painless/build.gradle | 2 +- modules/mapper-extras/build.gradle | 4 +- modules/parent-join/build.gradle | 2 +- modules/percolator/build.gradle | 2 +- modules/rank-eval/build.gradle | 2 +- modules/reindex/build.gradle | 4 +- modules/repository-url/build.gradle | 2 +- modules/runtime-fields-common/build.gradle | 4 +- modules/transport-netty4/build.gradle | 8 +- plugins/analysis-icu/build.gradle | 2 +- plugins/analysis-kuromoji/build.gradle | 2 +- plugins/analysis-nori/build.gradle | 2 +- plugins/analysis-phonetic/build.gradle | 2 +- plugins/analysis-smartcn/build.gradle | 2 +- plugins/analysis-stempel/build.gradle | 2 +- plugins/analysis-ukrainian/build.gradle | 2 +- plugins/discovery-azure-classic/build.gradle | 2 +- plugins/discovery-ec2/build.gradle | 2 +- .../discovery-ec2/qa/amazon-ec2/build.gradle | 6 +- plugins/discovery-gce/build.gradle | 2 +- plugins/discovery-gce/qa/gce/build.gradle | 2 +- plugins/ingest-attachment/build.gradle | 2 +- plugins/mapper-annotated-text/build.gradle | 2 +- plugins/mapper-murmur3/build.gradle | 2 +- .../size/MapperSizeClientYamlTestSuiteIT.java | 10 + plugins/repository-azure/build.gradle | 2 +- plugins/repository-gcs/build.gradle | 8 +- plugins/repository-hdfs/build.gradle | 4 +- plugins/repository-s3/build.gradle | 8 +- plugins/store-smb/build.gradle | 2 +- qa/ccs-unavailable-clusters/build.gradle | 2 +- qa/smoke-test-client/build.gradle | 2 +- qa/smoke-test-http/build.gradle | 2 +- qa/smoke-test-ingest-disabled/build.gradle | 2 +- .../build.gradle | 2 +- qa/smoke-test-multinode/build.gradle | 2 +- qa/smoke-test-plugins/build.gradle | 2 +- .../azure/build.gradle | 2 +- qa/snapshot-based-recoveries/fs/build.gradle | 2 +- qa/snapshot-based-recoveries/gcs/build.gradle | 2 +- qa/snapshot-based-recoveries/s3/build.gradle | 2 +- qa/system-indices/build.gradle | 2 +- qa/unconfigured-node-name/build.gradle | 2 +- rest-api-spec/build.gradle | 4 +- .../test/rest/ClientYamlTestSuiteIT.java | 14 + settings.gradle | 3 +- test/external-modules/build.gradle | 2 +- .../die-with-dignity/build.gradle | 2 +- .../junit/listeners/ReproduceInfoPrinter.java | 6 +- .../test/rest/yaml/Features.java | 4 +- test/test-clusters/build.gradle | 19 + .../test/cluster/ClusterFactory.java | 14 + .../test/cluster/ClusterHandle.java | 45 ++ .../test/cluster/ClusterSpec.java | 11 + .../test/cluster/ElasticsearchCluster.java | 35 ++ .../test/cluster/EnvironmentProvider.java | 30 ++ .../test/cluster/FeatureFlag.java | 29 + .../test/cluster/MutableSettingsProvider.java | 31 ++ .../test/cluster/SettingsProvider.java | 30 ++ .../local/AbstractLocalSpecBuilder.java | 159 ++++++ .../local/DefaultEnvironmentProvider.java | 39 ++ .../local/DefaultLocalClusterSpecBuilder.java | 151 ++++++ .../local/DefaultSettingsProvider.java | 72 +++ .../local/LocalClusterConfigProvider.java | 14 + .../cluster/local/LocalClusterFactory.java | 507 ++++++++++++++++++ .../cluster/local/LocalClusterHandle.java | 157 ++++++ .../test/cluster/local/LocalClusterSpec.java | 190 +++++++ .../local/LocalClusterSpecBuilder.java | 58 ++ .../local/LocalElasticsearchCluster.java | 81 +++ .../cluster/local/LocalNodeSpecBuilder.java | 17 + .../test/cluster/local/LocalSpecBuilder.java | 57 ++ .../cluster/local/WaitForHttpResource.java | 219 ++++++++ .../DefaultDistributionDescriptor.java | 57 ++ .../distribution/DistributionDescriptor.java | 23 + .../distribution/DistributionResolver.java | 16 + .../local/distribution/DistributionType.java | 24 + .../LocalDistributionResolver.java | 68 +++ .../SnapshotDistributionResolver.java | 19 + .../test/cluster/local/model/User.java | 41 ++ .../test/cluster/util/ExceptionUtils.java | 22 + .../test/cluster/util/IOUtils.java | 199 +++++++ .../elasticsearch/test/cluster/util/OS.java | 79 +++ .../elasticsearch/test/cluster/util/Pair.java | 38 ++ .../test/cluster/util/ProcessReaper.java | 156 ++++++ .../test/cluster/util/ProcessUtils.java | 177 ++++++ .../test/cluster/util/Retry.java | 59 ++ .../test/cluster/util/Version.java | 177 ++++++ .../util/resource/ClasspathTextResource.java | 55 ++ .../util/resource/FileTextResource.java | 32 ++ .../util/resource/StringTextResource.java | 22 + .../cluster/util/resource/TextResource.java | 27 + .../src/main/resources/default_test_roles.yml | 13 + .../plugin/async-search/qa/rest/build.gradle | 2 +- .../async-search/qa/security/build.gradle | 2 +- .../plugin/autoscaling/qa/rest/build.gradle | 2 +- x-pack/plugin/build.gradle | 2 +- x-pack/plugin/ccr/qa/rest/build.gradle | 2 +- x-pack/plugin/core/build.gradle | 2 +- .../data-streams/qa/multi-node/build.gradle | 2 +- .../plugin/data-streams/qa/rest/build.gradle | 6 +- .../qa/early-deprecation-rest/build.gradle | 2 +- .../plugin/deprecation/qa/rest/build.gradle | 2 +- .../rest-with-advanced-security/build.gradle | 2 +- .../enrich/qa/rest-with-security/build.gradle | 2 +- x-pack/plugin/enrich/qa/rest/build.gradle | 4 +- x-pack/plugin/eql/qa/correctness/build.gradle | 2 +- x-pack/plugin/eql/qa/mixed-node/build.gradle | 2 +- .../multi-cluster-with-security/build.gradle | 2 +- x-pack/plugin/eql/qa/rest/build.gradle | 4 +- x-pack/plugin/eql/qa/security/build.gradle | 2 +- x-pack/plugin/fleet/build.gradle | 2 +- x-pack/plugin/fleet/qa/rest/build.gradle | 2 +- .../graph/qa/with-security/build.gradle | 2 +- .../qa/idp-rest-tests/build.gradle | 2 +- x-pack/plugin/ilm/qa/multi-node/build.gradle | 2 +- x-pack/plugin/ilm/qa/rest/build.gradle | 2 +- .../plugin/ilm/qa/with-security/build.gradle | 2 +- x-pack/plugin/logstash/build.gradle | 2 +- .../plugin/mapper-unsigned-long/build.gradle | 2 +- .../ml/qa/basic-multi-node/build.gradle | 2 +- x-pack/plugin/ml/qa/disabled/build.gradle | 2 +- .../ml/qa/ml-with-security/build.gradle | 2 +- .../qa/native-multi-node-tests/build.gradle | 2 +- .../ml/qa/single-node-tests/build.gradle | 2 +- .../qa/azure/build.gradle | 2 +- .../qa/gcs/build.gradle | 2 +- .../qa/s3/build.gradle | 2 +- x-pack/plugin/rollup/qa/rest/build.gradle | 2 +- .../qa/azure/build.gradle | 2 +- .../searchable-snapshots/qa/gcs/build.gradle | 2 +- .../searchable-snapshots/qa/hdfs/build.gradle | 2 +- .../qa/minio/build.gradle | 2 +- .../searchable-snapshots/qa/rest/build.gradle | 4 +- .../searchable-snapshots/qa/s3/build.gradle | 2 +- .../searchable-snapshots/qa/url/build.gradle | 2 +- .../qa/basic-enable-security/build.gradle | 2 +- .../qa/operator-privileges-tests/build.gradle | 2 +- .../security/qa/security-basic/build.gradle | 2 +- .../qa/security-disabled/build.gradle | 2 +- .../qa/security-not-enabled/build.gradle | 2 +- .../security/qa/security-trial/build.gradle | 2 +- .../security/qa/service-account/build.gradle | 2 +- .../qa/smoke-test-all-realms/build.gradle | 2 +- .../plugin/security/qa/tls-basic/build.gradle | 2 +- .../shutdown/qa/multi-node/build.gradle | 2 +- .../qa/azure/build.gradle | 2 +- .../qa/gcs/build.gradle | 2 +- .../qa/hdfs/build.gradle | 2 +- .../qa/minio/build.gradle | 2 +- .../qa/rest/build.gradle | 2 +- .../snapshot-repo-test-kit/qa/s3/build.gradle | 2 +- x-pack/plugin/sql/qa/jdbc/build.gradle | 2 +- x-pack/plugin/sql/qa/mixed-node/build.gradle | 2 +- x-pack/plugin/sql/qa/server/build.gradle | 2 +- .../multi-cluster-with-security/build.gradle | 2 +- x-pack/plugin/stack/qa/rest/build.gradle | 3 +- .../text-structure-with-security/build.gradle | 2 +- .../qa/multi-node-tests/build.gradle | 2 +- .../qa/single-node-tests/build.gradle | 2 +- x-pack/plugin/vector-tile/build.gradle | 2 +- .../vector-tile/qa/multi-cluster/build.gradle | 2 +- x-pack/plugin/watcher/qa/rest/build.gradle | 4 +- .../watcher/qa/with-monitoring/build.gradle | 2 +- .../watcher/qa/with-security/build.gradle | 4 +- .../build.gradle | 2 +- x-pack/qa/kerberos-tests/build.gradle | 2 +- x-pack/qa/mixed-tier-cluster/build.gradle | 2 +- x-pack/qa/multi-node/build.gradle | 12 +- .../GlobalCheckpointSyncActionIT.java | 21 + .../elasticsearch/multi_node/RollupIT.java | 18 + .../javaRestTest/resources}/roles.yml | 0 x-pack/qa/oidc-op-tests/build.gradle | 2 +- .../password-protected-keystore/build.gradle | 2 +- .../reindex-tests-with-security/build.gradle | 2 +- x-pack/qa/runtime-fields/build.gradle | 2 +- .../runtime-fields/with-security/build.gradle | 2 +- x-pack/qa/saml-idp-tests/build.gradle | 2 +- x-pack/qa/security-client-tests/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/security-migrate-tests/build.gradle | 4 +- .../build.gradle | 2 +- x-pack/qa/smoke-test-plugins-ssl/build.gradle | 2 +- x-pack/qa/smoke-test-plugins/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/third-party/jira/build.gradle | 2 +- x-pack/qa/third-party/pagerduty/build.gradle | 2 +- x-pack/qa/third-party/slack/build.gradle | 2 +- x-pack/qa/transport-client-tests/build.gradle | 2 +- 220 files changed, 4003 insertions(+), 248 deletions(-) rename build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/{InternalYamlRestTestPluginFuncTest.groovy => LegacyYamlRestTestPluginFuncTest.groovy} (96%) rename build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/{RestTestBasePlugin.java => LegacyRestTestBasePlugin.java} (82%) create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyJavaRestTestPlugin.java create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPlugin.java create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java create mode 100644 test/test-clusters/build.gradle create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterFactory.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterHandle.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterSpec.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ElasticsearchCluster.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/EnvironmentProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/MutableSettingsProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/SettingsProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultEnvironmentProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterConfigProvider.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterHandle.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpecBuilder.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalElasticsearchCluster.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/WaitForHttpResource.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DefaultDistributionDescriptor.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionDescriptor.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionResolver.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionType.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/model/User.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ExceptionUtils.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/IOUtils.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/OS.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Pair.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessReaper.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessUtils.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Retry.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/ClasspathTextResource.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/FileTextResource.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/StringTextResource.java create mode 100644 test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/TextResource.java create mode 100644 test/test-clusters/src/main/resources/default_test_roles.yml rename x-pack/qa/multi-node/{ => src/javaRestTest/resources}/roles.yml (100%) diff --git a/build-tools-internal/build.gradle b/build-tools-internal/build.gradle index 2bd3cc8c9da7..fc7cce3a071a 100644 --- a/build-tools-internal/build.gradle +++ b/build-tools-internal/build.gradle @@ -116,6 +116,10 @@ gradlePlugin { id = 'elasticsearch.java' implementationClass = 'org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin' } + legacyInternalJavaRestTest { + id = 'elasticsearch.legacy-java-rest-test' + implementationClass = 'org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin' + } internalJavaRestTest { id = 'elasticsearch.internal-java-rest-test' implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin' @@ -164,6 +168,10 @@ gradlePlugin { id = 'elasticsearch.validate-rest-spec' implementationClass = 'org.elasticsearch.gradle.internal.precommit.ValidateRestSpecPlugin' } + legacyYamlRestTest { + id = 'elasticsearch.legacy-yaml-rest-test' + implementationClass = 'org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin' + } yamlRestTest { id = 'elasticsearch.internal-yaml-rest-test' implementationClass = 'org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin' diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractRestResourcesFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractRestResourcesFuncTest.groovy index ebe72aea3e40..be8488c5162b 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractRestResourcesFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractRestResourcesFuncTest.groovy @@ -13,6 +13,7 @@ abstract class AbstractRestResourcesFuncTest extends AbstractGradleFuncTest { def setup() { subProject(":test:framework") << "apply plugin: 'elasticsearch.java'" + subProject(":test:test-clusters") << "apply plugin: 'elasticsearch.java'" subProject(":rest-api-spec") << """ configurations { restSpecs\nrestTests } artifacts { diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy index 8a1376cdbd91..0e1d27fb083c 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy @@ -195,7 +195,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradlePrecommitP given: clazz(dir('src/yamlRestTest/java'), "org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase") buildFile << """ - apply plugin:'elasticsearch.internal-yaml-rest-test' + apply plugin:'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation "org.apache.lucene:tests.util:1.0" @@ -273,8 +273,8 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradlePrecommitP ) where: - pluginName | taskName | sourceSetName - "elasticsearch.internal-java-rest-test" | ":javaRestTestTestingConventions" | "javaRestTest" + pluginName | taskName | sourceSetName + "elasticsearch.legacy-java-rest-test" | ":javaRestTestTestingConventions" | "javaRestTest" "elasticsearch.internal-cluster-test" | ":internalClusterTestTestingConventions" | "internalClusterTest" } diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPluginFuncTest.groovy similarity index 96% rename from build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPluginFuncTest.groovy rename to build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPluginFuncTest.groovy index a5dea813b9f3..234cffa87a6a 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPluginFuncTest.groovy @@ -19,7 +19,7 @@ class InternalYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { configurationCacheCompatible = false buildFile << """ plugins { - id 'elasticsearch.internal-yaml-rest-test' + id 'elasticsearch.legacy-yaml-rest-test' } """ @@ -38,7 +38,7 @@ class InternalYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { configurationCacheCompatible = false internalBuild() buildFile << """ - apply plugin: 'elasticsearch.internal-yaml-rest-test' + apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation "junit:junit:4.12" diff --git a/build-tools-internal/src/main/groovy/elasticsearch.build-complete.gradle b/build-tools-internal/src/main/groovy/elasticsearch.build-complete.gradle index 1627b9b32cce..bc756d5a98ab 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.build-complete.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.build-complete.gradle @@ -25,10 +25,15 @@ if (buildNumber) { include("**/*.hprof") include("**/build/test-results/**/*.xml") include("**/build/testclusters/**") + include("**/build/testrun/**") exclude("**/build/testclusters/**/data/**") exclude("**/build/testclusters/**/distro/**") exclude("**/build/testclusters/**/repo/**") exclude("**/build/testclusters/**/extract/**") + exclude("**/build/testrun/**/data/**") + exclude("**/build/testrun/**/distro/**") + exclude("**/build/testrun/**/repo/**") + exclude("**/build/testrun/**/extract/**") } .files .findAll { Files.isRegularFile(it.toPath()) } diff --git a/build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle b/build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle index 9582122b7e73..29e43f8ec564 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle @@ -10,34 +10,41 @@ import org.elasticsearch.gradle.Architecture import org.elasticsearch.gradle.OS import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.internal.info.BuildParams +import org.elasticsearch.gradle.internal.test.rest.RestTestBasePlugin +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask // gradle has an open issue of failing applying plugins in // precompiled script plugins (see https://github.com/gradle/gradle/issues/17004) // apply plugin: 'elasticsearch.jdk-download' -if (BuildParams.getIsRuntimeJavaHomeSet()) { - configure(allprojects) { - project.tasks.withType(Test).configureEach { Test test -> - if (BuildParams.getIsRuntimeJavaHomeSet()) { - test.executable = "${BuildParams.runtimeJavaHome}/bin/java" - } - } - } -} else { - jdks { - provisioned_runtime { - vendor = VersionProperties.bundledJdkVendor - version = VersionProperties.bundledJdkVersion - platform = OS.current().name().toLowerCase() - architecture = Architecture.current().name().toLowerCase() - } +jdks { + provisioned_runtime { + vendor = VersionProperties.bundledJdkVendor + version = VersionProperties.bundledJdkVersion + platform = OS.current().name().toLowerCase() + architecture = Architecture.current().name().toLowerCase() } +} configure(allprojects) { - project.tasks.withType(Test).configureEach { Test test -> + project.tasks.withType(Test).configureEach { Test test -> + if (BuildParams.getIsRuntimeJavaHomeSet()) { + test.executable = "${BuildParams.runtimeJavaHome}/bin/java" + } else { test.dependsOn(rootProject.jdks.provisioned_runtime) test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath() } } + project.plugins.withType(RestTestBasePlugin) { + // Use later JDK for new REST test plugins since :test:test-clusters requires Java 17+ + // The clusters under test still use the configured runtime java home + project.tasks.withType(StandaloneRestIntegTestTask).configureEach { StandaloneRestIntegTestTask test -> + test.dependsOn(rootProject.jdks.provisioned_runtime) + test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath() + // Pass actual runtime java version used for clusters under test + test.systemProperty("tests.runtime.java.version", BuildParams.runtimeJavaVersion) + } + } } + // if neither condition above is executed, tests will use the gradle jvm diff --git a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy index e97c02462cc3..572de2dc37f1 100644 --- a/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy +++ b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy @@ -25,7 +25,7 @@ class DocsTestPlugin implements Plugin { @Override void apply(Project project) { - project.pluginManager.apply('elasticsearch.internal-yaml-rest-test') + project.pluginManager.apply('elasticsearch.legacy-yaml-rest-test') String distribution = System.getProperty('tests.distribution', 'default') // The distribution can be configured with -Dtests.distribution on the command line diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPlugin.java index 7faa5df3e72b..b281cc548a69 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPlugin.java @@ -11,7 +11,8 @@ package org.elasticsearch.gradle.internal.precommit; import org.elasticsearch.gradle.internal.conventions.precommit.PrecommitPlugin; import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin; import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin; -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin; import org.gradle.api.Action; import org.gradle.api.NamedDomainObjectProvider; import org.gradle.api.Project; @@ -43,8 +44,8 @@ public class TestingConventionsPrecommitPlugin extends PrecommitPlugin { }); }); - project.getPlugins().withType(InternalYamlRestTestPlugin.class, yamlRestTestPlugin -> { - NamedDomainObjectProvider sourceSet = sourceSets.named(InternalYamlRestTestPlugin.SOURCE_SET_NAME); + project.getPlugins().withType(LegacyYamlRestTestPlugin.class, yamlRestTestPlugin -> { + NamedDomainObjectProvider sourceSet = sourceSets.named(LegacyYamlRestTestPlugin.SOURCE_SET_NAME); setupTaskForSourceSet(project, sourceSet, t -> { t.getSuffixes().convention(List.of("IT")); t.getBaseClasses().convention(List.of("org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase")); @@ -68,8 +69,17 @@ public class TestingConventionsPrecommitPlugin extends PrecommitPlugin { }); }); + project.getPlugins().withType(LegacyJavaRestTestPlugin.class, javaRestTestPlugin -> { + NamedDomainObjectProvider sourceSet = sourceSets.named(LegacyJavaRestTestPlugin.SOURCE_SET_NAME); + setupTaskForSourceSet(project, sourceSet, t -> { + t.getSuffixes().convention(List.of("IT")); + t.getBaseClasses() + .convention(List.of("org.elasticsearch.test.ESIntegTestCase", "org.elasticsearch.test.rest.ESRestTestCase")); + }); + }); + project.getPlugins().withType(InternalJavaRestTestPlugin.class, javaRestTestPlugin -> { - NamedDomainObjectProvider sourceSet = sourceSets.named(InternalJavaRestTestPlugin.SOURCE_SET_NAME); + NamedDomainObjectProvider sourceSet = sourceSets.named(LegacyJavaRestTestPlugin.SOURCE_SET_NAME); setupTaskForSourceSet(project, sourceSet, t -> { t.getSuffixes().convention(List.of("IT")); t.getBaseClasses() diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/RestTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/LegacyRestTestBasePlugin.java similarity index 82% rename from build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/RestTestBasePlugin.java rename to build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/LegacyRestTestBasePlugin.java index 058d7ba33ae9..aadd02a46132 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/RestTestBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/LegacyRestTestBasePlugin.java @@ -29,14 +29,18 @@ import org.gradle.api.tasks.bundling.Zip; import javax.inject.Inject; -public class RestTestBasePlugin implements Plugin { +/** + * @deprecated use {@link RestTestBasePlugin} instead + */ +@Deprecated +public class LegacyRestTestBasePlugin implements Plugin { private static final String TESTS_REST_CLUSTER = "tests.rest.cluster"; private static final String TESTS_CLUSTER = "tests.cluster"; private static final String TESTS_CLUSTER_NAME = "tests.clustername"; private ProviderFactory providerFactory; @Inject - public RestTestBasePlugin(ProviderFactory providerFactory) { + public LegacyRestTestBasePlugin(ProviderFactory providerFactory) { this.providerFactory = providerFactory; } @@ -82,18 +86,20 @@ public class RestTestBasePlugin implements Plugin { .withType(StandaloneRestIntegTestTask.class) .configureEach(t -> t.finalizedBy(project.getTasks().withType(FixtureStop.class))); - project.getTasks().withType(StandaloneRestIntegTestTask.class).configureEach(t -> - // if this a module or plugin, it may have an associated zip file with it's contents, add that to the test cluster - project.getPluginManager().withPlugin("elasticsearch.esplugin", plugin -> { - TaskProvider bundle = project.getTasks().withType(Zip.class).named("bundlePlugin"); - t.dependsOn(bundle); - if (GradleUtils.isModuleProject(project.getPath())) { - t.getClusters().forEach(c -> c.module(bundle.flatMap(AbstractArchiveTask::getArchiveFile))); - } else { - t.getClusters().forEach(c -> c.plugin(bundle.flatMap(AbstractArchiveTask::getArchiveFile))); - } + project.getTasks().withType(StandaloneRestIntegTestTask.class).configureEach(t -> { + t.setMaxParallelForks(1); + // if this a module or plugin, it may have an associated zip file with it's contents, add that to the test cluster + project.getPluginManager().withPlugin("elasticsearch.esplugin", plugin -> { + TaskProvider bundle = project.getTasks().withType(Zip.class).named("bundlePlugin"); + t.dependsOn(bundle); + if (GradleUtils.isModuleProject(project.getPath())) { + t.getClusters().forEach(c -> c.module(bundle.flatMap(AbstractArchiveTask::getArchiveFile))); + } else { + t.getClusters().forEach(c -> c.plugin(bundle.flatMap(AbstractArchiveTask::getArchiveFile))); + } - })); + }); + }); } private String systemProperty(String propName) { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java index 5a6ae1703c37..fb6ed7e10cb0 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java @@ -11,8 +11,8 @@ package org.elasticsearch.gradle.internal.test; import org.elasticsearch.gradle.internal.ExportElasticsearchBuildResourcesTask; import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin; import org.elasticsearch.gradle.internal.precommit.InternalPrecommitTasks; -import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin; -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin; import org.elasticsearch.gradle.internal.test.rest.RestTestUtil; import org.gradle.api.InvalidUserDataException; import org.gradle.api.Plugin; @@ -32,8 +32,8 @@ import java.util.Map; * and run REST tests. Use BuildPlugin if you want to build main code as well * as tests. * - * @deprecated use {@link InternalClusterTestPlugin}, {@link InternalJavaRestTestPlugin} or - * {@link InternalYamlRestTestPlugin} instead. + * @deprecated use {@link InternalClusterTestPlugin}, {@link LegacyJavaRestTestPlugin} or + * {@link LegacyYamlRestTestPlugin} instead. */ @Deprecated public class StandaloneRestTestPlugin implements Plugin { @@ -46,7 +46,7 @@ public class StandaloneRestTestPlugin implements Plugin { } project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); - project.getPluginManager().apply(RestTestBasePlugin.class); + project.getPluginManager().apply(LegacyRestTestBasePlugin.class); project.getTasks().register("buildResources", ExportElasticsearchBuildResourcesTask.class); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java index 6dd16f584c65..201659e6538c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java @@ -10,6 +10,7 @@ package org.elasticsearch.gradle.internal.test; import org.apache.commons.lang.StringUtils; import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin; import org.elasticsearch.gradle.plugin.PluginBuildPlugin; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -48,6 +49,11 @@ public class TestWithDependenciesPlugin implements Plugin { return; } SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets(); + project.getPlugins() + .withType( + LegacyJavaRestTestPlugin.class, + legacyJavaRestTestPlugin -> processConfiguration(sourceSets.getByName(LegacyJavaRestTestPlugin.SOURCE_SET_NAME)) + ); project.getPlugins() .withType( InternalJavaRestTestPlugin.class, diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithSslPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithSslPlugin.java index 9eb2efc77835..524f3dfedf95 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithSslPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithSslPlugin.java @@ -14,7 +14,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams; import org.elasticsearch.gradle.internal.precommit.FilePermissionsPrecommitPlugin; import org.elasticsearch.gradle.internal.precommit.ForbiddenPatternsPrecommitPlugin; import org.elasticsearch.gradle.internal.precommit.ForbiddenPatternsTask; -import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin; import org.elasticsearch.gradle.testclusters.ElasticsearchCluster; import org.elasticsearch.gradle.testclusters.TestClustersAware; import org.elasticsearch.gradle.testclusters.TestClustersPlugin; @@ -62,8 +62,8 @@ public class TestWithSslPlugin implements Plugin { .withType(RestIntegTestTask.class) .configureEach(runner -> runner.systemProperty("tests.ssl.enabled", "true")); }); - project.getPlugins().withType(InternalJavaRestTestPlugin.class).configureEach(restTestPlugin -> { - SourceSet testSourceSet = Util.getJavaSourceSets(project).getByName(InternalJavaRestTestPlugin.SOURCE_SET_NAME); + project.getPlugins().withType(LegacyJavaRestTestPlugin.class).configureEach(restTestPlugin -> { + SourceSet testSourceSet = Util.getJavaSourceSets(project).getByName(LegacyJavaRestTestPlugin.SOURCE_SET_NAME); testSourceSet.getResources().srcDir(new File(keyStoreDir, "test/ssl")); project.getTasks().named(testSourceSet.getProcessResourcesTaskName()).configure(t -> t.dependsOn(exportKeyStore)); project.getTasks().withType(TestClustersAware.class).configureEach(clusterAware -> clusterAware.dependsOn(exportKeyStore)); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java index 9dda731f7211..d18505ca4b11 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java @@ -8,7 +8,7 @@ package org.elasticsearch.gradle.internal.test.rest; -import org.elasticsearch.gradle.internal.test.RestTestBasePlugin; +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -33,8 +33,11 @@ public class InternalJavaRestTestPlugin implements Plugin { SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet javaTestSourceSet = sourceSets.create(SOURCE_SET_NAME); + project.getDependencies().add(javaTestSourceSet.getImplementationConfigurationName(), project.project(":test:test-clusters")); + // setup the javaRestTest task - registerTestTask(project, javaTestSourceSet); + // we use a StandloneRestIntegTestTask here so that the conventions of RestTestBasePlugin don't create a test cluster + registerTestTask(project, javaTestSourceSet, SOURCE_SET_NAME, StandaloneRestIntegTestTask.class); // setup dependencies setupJavaRestTestDependenciesDefaults(project, javaTestSourceSet); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java index 065c4e6bdacf..00b67c32d8a4 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java @@ -8,7 +8,7 @@ package org.elasticsearch.gradle.internal.test.rest; -import org.elasticsearch.gradle.internal.test.RestTestBasePlugin; +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -34,10 +34,10 @@ public class InternalYamlRestTestPlugin implements Plugin { SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet yamlTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - registerTestTask(project, yamlTestSourceSet); + registerTestTask(project, yamlTestSourceSet, SOURCE_SET_NAME, StandaloneRestIntegTestTask.class); // setup the dependencies - setupYamlRestTestDependenciesDefaults(project, yamlTestSourceSet); + setupYamlRestTestDependenciesDefaults(project, yamlTestSourceSet, true); // setup the copy for the rest resources project.getTasks().withType(CopyRestApiTask.class).configureEach(copyRestApiTask -> { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyJavaRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyJavaRestTestPlugin.java new file mode 100644 index 000000000000..a1b17c110b34 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyJavaRestTestPlugin.java @@ -0,0 +1,48 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.internal.test.rest; + +import org.elasticsearch.gradle.internal.test.LegacyRestTestBasePlugin; +import org.elasticsearch.gradle.util.GradleUtils; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; + +import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.registerTestTask; +import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupJavaRestTestDependenciesDefaults; + +/** + * Apply this plugin to run the Java based REST tests. + * + * @deprecated use {@link InternalJavaRestTestPlugin} + */ +@Deprecated +public class LegacyJavaRestTestPlugin implements Plugin { + + public static final String SOURCE_SET_NAME = "javaRestTest"; + + @Override + public void apply(Project project) { + project.getPluginManager().apply(LegacyRestTestBasePlugin.class); + + // create source set + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + SourceSet javaTestSourceSet = sourceSets.create(SOURCE_SET_NAME); + + // setup the javaRestTest task + registerTestTask(project, javaTestSourceSet); + + // setup dependencies + setupJavaRestTestDependenciesDefaults(project, javaTestSourceSet); + + // setup IDE + GradleUtils.setupIdeForTestSourceSet(project, javaTestSourceSet); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPlugin.java new file mode 100644 index 000000000000..4977c0924efb --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestTestPlugin.java @@ -0,0 +1,76 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.internal.test.rest; + +import org.elasticsearch.gradle.internal.test.LegacyRestTestBasePlugin; +import org.elasticsearch.gradle.util.GradleUtils; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.SourceSetContainer; + +import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.registerTestTask; +import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupYamlRestTestDependenciesDefaults; + +/** + * Apply this plugin to run the YAML based REST tests. + * + * @deprecated use {@link InternalYamlRestTestPlugin} + */ +@Deprecated +public class LegacyYamlRestTestPlugin implements Plugin { + + public static final String SOURCE_SET_NAME = "yamlRestTest"; + + @Override + public void apply(Project project) { + project.getPluginManager().apply(LegacyRestTestBasePlugin.class); + project.getPluginManager().apply(RestResourcesPlugin.class); + + // create source set + SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); + SourceSet yamlTestSourceSet = sourceSets.create(SOURCE_SET_NAME); + + registerTestTask(project, yamlTestSourceSet); + + // setup the dependencies + setupYamlRestTestDependenciesDefaults(project, yamlTestSourceSet); + + // setup the copy for the rest resources + project.getTasks().withType(CopyRestApiTask.class).configureEach(copyRestApiTask -> { + copyRestApiTask.setSourceResourceDir( + yamlTestSourceSet.getResources() + .getSrcDirs() + .stream() + .filter(f -> f.isDirectory() && f.getName().equals("resources")) + .findFirst() + .orElse(null) + ); + }); + + // Register rest resources with source set + yamlTestSourceSet.getOutput() + .dir( + project.getTasks() + .withType(CopyRestApiTask.class) + .named(RestResourcesPlugin.COPY_REST_API_SPECS_TASK) + .flatMap(CopyRestApiTask::getOutputResourceDir) + ); + + yamlTestSourceSet.getOutput() + .dir( + project.getTasks() + .withType(CopyRestTestsTask.class) + .named(RestResourcesPlugin.COPY_YAML_TESTS_TASK) + .flatMap(CopyRestTestsTask::getOutputResourceDir) + ); + + GradleUtils.setupIdeForTestSourceSet(project, yamlTestSourceSet); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java new file mode 100644 index 000000000000..25b8778cc7b5 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java @@ -0,0 +1,241 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.gradle.internal.test.rest; + +import groovy.lang.Closure; + +import org.elasticsearch.gradle.Architecture; +import org.elasticsearch.gradle.DistributionDownloadPlugin; +import org.elasticsearch.gradle.ElasticsearchDistribution; +import org.elasticsearch.gradle.VersionProperties; +import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes; +import org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin; +import org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin; +import org.elasticsearch.gradle.internal.info.BuildParams; +import org.elasticsearch.gradle.plugin.PluginBuildPlugin; +import org.elasticsearch.gradle.plugin.PluginPropertiesExtension; +import org.elasticsearch.gradle.test.SystemPropertyCommandLineArgumentProvider; +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask; +import org.elasticsearch.gradle.transform.UnzipTransform; +import org.elasticsearch.gradle.util.GradleUtils; +import org.gradle.api.Action; +import org.gradle.api.NamedDomainObjectContainer; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.Dependency; +import org.gradle.api.artifacts.ProjectDependency; +import org.gradle.api.artifacts.type.ArtifactTypeDefinition; +import org.gradle.api.file.FileTree; +import org.gradle.api.plugins.JavaBasePlugin; +import org.gradle.api.provider.ProviderFactory; +import org.gradle.api.tasks.ClasspathNormalizer; +import org.gradle.api.tasks.PathSensitivity; +import org.gradle.api.tasks.util.PatternFilterable; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; + +import javax.inject.Inject; + +/** + * Base plugin used for wiring up build tasks to REST testing tasks using new JUnit rule-based test clusters framework. + */ +public class RestTestBasePlugin implements Plugin { + + private static final String TESTS_RUNTIME_JAVA_SYSPROP = "tests.runtime.java"; + private static final String DEFAULT_DISTRIBUTION_SYSPROP = "tests.default.distribution"; + private static final String INTEG_TEST_DISTRIBUTION_SYSPROP = "tests.integ-test.distribution"; + private static final String TESTS_CLUSTER_MODULES_PATH_SYSPROP = "tests.cluster.modules.path"; + private static final String TESTS_CLUSTER_PLUGINS_PATH_SYSPROP = "tests.cluster.plugins.path"; + private static final String DEFAULT_REST_INTEG_TEST_DISTRO = "default_distro"; + private static final String INTEG_TEST_REST_INTEG_TEST_DISTRO = "integ_test_distro"; + private static final String MODULES_CONFIGURATION = "clusterModules"; + private static final String PLUGINS_CONFIGURATION = "clusterPlugins"; + private static final String EXTRACTED_PLUGINS_CONFIGURATION = "extractedPlugins"; + + private final ProviderFactory providerFactory; + + @Inject + public RestTestBasePlugin(ProviderFactory providerFactory) { + this.providerFactory = providerFactory; + } + + @Override + public void apply(Project project) { + project.getPluginManager().apply(ElasticsearchJavaPlugin.class); + project.getPluginManager().apply(InternalDistributionDownloadPlugin.class); + + // Register integ-test and default distributions + NamedDomainObjectContainer distributions = DistributionDownloadPlugin.getContainer(project); + ElasticsearchDistribution defaultDistro = distributions.create(DEFAULT_REST_INTEG_TEST_DISTRO, distro -> { + distro.setVersion(VersionProperties.getElasticsearch()); + distro.setArchitecture(Architecture.current()); + }); + ElasticsearchDistribution integTestDistro = distributions.create(INTEG_TEST_REST_INTEG_TEST_DISTRO, distro -> { + distro.setVersion(VersionProperties.getElasticsearch()); + distro.setArchitecture(Architecture.current()); + distro.setType(ElasticsearchDistributionTypes.INTEG_TEST_ZIP); + }); + + // Create configures for module and plugin dependencies + Configuration modulesConfiguration = createPluginConfiguration(project, MODULES_CONFIGURATION, true); + Configuration pluginsConfiguration = createPluginConfiguration(project, PLUGINS_CONFIGURATION, false); + Configuration extractedPluginsConfiguration = createPluginConfiguration(project, EXTRACTED_PLUGINS_CONFIGURATION, true); + extractedPluginsConfiguration.extendsFrom(pluginsConfiguration); + configureArtifactTransforms(project); + + // For plugin and module projects, register the current project plugin bundle as a dependency + project.getPluginManager().withPlugin("elasticsearch.esplugin", plugin -> { + if (GradleUtils.isModuleProject(project.getPath())) { + project.getDependencies().add(modulesConfiguration.getName(), project.files(project.getTasks().named("bundlePlugin"))); + } else { + project.getDependencies().add(pluginsConfiguration.getName(), project.files(project.getTasks().named("bundlePlugin"))); + } + + }); + + project.getTasks().withType(StandaloneRestIntegTestTask.class, task -> { + SystemPropertyCommandLineArgumentProvider nonInputSystemProperties = task.getExtensions() + .getByType(SystemPropertyCommandLineArgumentProvider.class); + + task.dependsOn(integTestDistro, modulesConfiguration); + registerDistributionInputs(task, integTestDistro); + + task.setMaxParallelForks(task.getProject().getGradle().getStartParameter().getMaxWorkerCount() / 2); + + // Disable the security manager and syscall filter since the test framework needs to fork processes + task.systemProperty("tests.security.manager", "false"); + task.systemProperty("tests.system_call_filter", "false"); + + // Register plugins and modules as task inputs and pass paths as system properties to tests + nonInputSystemProperties.systemProperty(TESTS_CLUSTER_MODULES_PATH_SYSPROP, modulesConfiguration::getAsPath); + registerConfigurationInputs(task, modulesConfiguration); + nonInputSystemProperties.systemProperty(TESTS_CLUSTER_PLUGINS_PATH_SYSPROP, pluginsConfiguration::getAsPath); + registerConfigurationInputs(task, extractedPluginsConfiguration); + + // Wire up integ-test distribution by default for all test tasks + nonInputSystemProperties.systemProperty( + INTEG_TEST_DISTRIBUTION_SYSPROP, + () -> integTestDistro.getExtracted().getSingleFile().getPath() + ); + nonInputSystemProperties.systemProperty(TESTS_RUNTIME_JAVA_SYSPROP, BuildParams.getRuntimeJavaHome()); + + // Add `usesDefaultDistribution()` extension method to test tasks to indicate they require the default distro + task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure(task) { + @Override + public Void call(Object... args) { + task.dependsOn(defaultDistro); + registerDistributionInputs(task, defaultDistro); + + nonInputSystemProperties.systemProperty( + DEFAULT_DISTRIBUTION_SYSPROP, + providerFactory.provider(() -> defaultDistro.getExtracted().getSingleFile().getPath()) + ); + return null; + } + }); + }); + + project.getTasks() + .named(JavaBasePlugin.CHECK_TASK_NAME) + .configure(check -> check.dependsOn(project.getTasks().withType(StandaloneRestIntegTestTask.class))); + } + + private FileTree getDistributionFiles(ElasticsearchDistribution distribution, Action patternFilter) { + return distribution.getExtracted().getAsFileTree().matching(patternFilter); + } + + private void registerConfigurationInputs(Task task, Configuration configuration) { + task.getInputs() + .files(providerFactory.provider(() -> configuration.getAsFileTree().filter(f -> f.getName().endsWith(".jar")))) + .withPropertyName(configuration.getName() + "-classpath") + .withNormalizer(ClasspathNormalizer.class); + + task.getInputs() + .files(providerFactory.provider(() -> configuration.getAsFileTree().filter(f -> f.getName().endsWith(".jar") == false))) + .withPropertyName(configuration.getName() + "-files") + .withPathSensitivity(PathSensitivity.RELATIVE); + } + + private void registerDistributionInputs(Task task, ElasticsearchDistribution distribution) { + task.getInputs() + .files(providerFactory.provider(() -> getDistributionFiles(distribution, filter -> filter.exclude("**/*.jar")))) + .withPropertyName(distribution.getName() + "-files") + .withPathSensitivity(PathSensitivity.RELATIVE); + + task.getInputs() + .files(providerFactory.provider(() -> getDistributionFiles(distribution, filter -> filter.include("**/*.jar")))) + .withPropertyName(distribution.getName() + "-classpath") + .withNormalizer(ClasspathNormalizer.class); + } + + private Optional findModulePath(Project project, String pluginName) { + return project.getRootProject() + .getAllprojects() + .stream() + .filter(p -> GradleUtils.isModuleProject(p.getPath())) + .filter(p -> p.getPlugins().hasPlugin(PluginBuildPlugin.class)) + .filter(p -> p.getExtensions().getByType(PluginPropertiesExtension.class).getName().equals(pluginName)) + .findFirst() + .map(Project::getPath); + } + + private Configuration createPluginConfiguration(Project project, String name, boolean useExploded) { + return project.getConfigurations().create(name, c -> { + if (useExploded) { + c.attributes(a -> a.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE)); + } else { + c.attributes(a -> a.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.ZIP_TYPE)); + } + c.withDependencies(dependencies -> { + // Add dependencies of any modules + Collection additionalDependencies = new HashSet<>(); + for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) { + Dependency dependency = iterator.next(); + if (dependency instanceof ProjectDependency projectDependency) { + Project dependencyProject = projectDependency.getDependencyProject(); + List extendedPlugins = dependencyProject.getExtensions() + .getByType(PluginPropertiesExtension.class) + .getExtendedPlugins(); + + // Replace project dependency with task artifact dependency so the unzip artifact transform will work + iterator.remove(); + additionalDependencies.add( + project.getDependencies().create(project.files(dependencyProject.getTasks().named("bundlePlugin"))) + ); + + for (String extendedPlugin : extendedPlugins) { + findModulePath(project, extendedPlugin).ifPresent( + modulePath -> additionalDependencies.add( + project.getDependencies() + .create(project.files(project.findProject(modulePath).getTasks().named("bundlePlugin"))) + ) + ); + } + } + } + + dependencies.addAll(additionalDependencies); + }); + }); + } + + private void configureArtifactTransforms(Project project) { + project.getDependencies().registerTransform(UnzipTransform.class, transformSpec -> { + transformSpec.getFrom().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.ZIP_TYPE); + transformSpec.getTo().attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); + transformSpec.getParameters().setAsFiletreeOutput(false); + }); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestUtil.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestUtil.java index 300dbd26a64d..b724e7b9f6a3 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestUtil.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestUtil.java @@ -14,6 +14,7 @@ import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.TaskProvider; +import org.gradle.api.tasks.testing.Test; /** * Utility class to configure the necessary tasks and dependencies. @@ -42,8 +43,17 @@ public class RestTestUtil { * Creates a {@link RestIntegTestTask} task with a custom name for the provided source set */ public static TaskProvider registerTestTask(Project project, SourceSet sourceSet, String taskName) { + return registerTestTask(project, sourceSet, taskName, RestIntegTestTask.class); + } + + /** + * Creates a {@link T} task with a custom name for the provided source set + * + * @param test task type + */ + public static TaskProvider registerTestTask(Project project, SourceSet sourceSet, String taskName, Class clazz) { // lazily create the test task - return project.getTasks().register(sourceSet.getName(), RestIntegTestTask.class, testTask -> { + return project.getTasks().register(taskName, clazz, testTask -> { testTask.setGroup(JavaBasePlugin.VERIFICATION_GROUP); testTask.setDescription("Runs the REST tests against an external cluster"); project.getPlugins().withType(JavaPlugin.class, t -> testTask.mustRunAfter(project.getTasks().named("test"))); @@ -61,10 +71,17 @@ public class RestTestUtil { } public static void setupYamlRestTestDependenciesDefaults(Project project, SourceSet sourceSet) { + setupYamlRestTestDependenciesDefaults(project, sourceSet, false); + } + + public static void setupYamlRestTestDependenciesDefaults(Project project, SourceSet sourceSet, boolean useNewTestClusters) { Project testFramework = project.findProject(":test:framework"); // we shield the project dependency to make integration tests easier if (testFramework != null) { project.getDependencies().add(sourceSet.getImplementationConfigurationName(), testFramework); + if (useNewTestClusters) { + project.getDependencies().add(sourceSet.getImplementationConfigurationName(), project.project(":test:test-clusters")); + } } } diff --git a/build-tools/reaper/src/main/java/org/elasticsearch/gradle/reaper/Reaper.java b/build-tools/reaper/src/main/java/org/elasticsearch/gradle/reaper/Reaper.java index e6c5b61e0a76..74456998e540 100644 --- a/build-tools/reaper/src/main/java/org/elasticsearch/gradle/reaper/Reaper.java +++ b/build-tools/reaper/src/main/java/org/elasticsearch/gradle/reaper/Reaper.java @@ -57,6 +57,8 @@ public class Reaper implements Closeable { try (Reaper reaper = new Reaper(inputDir)) { System.in.read(); reaper.reap(); + } catch (Throwable t) { + logFailure("Unexpected error occurred", t); } } @@ -89,7 +91,7 @@ public class Reaper implements Closeable { } } - private void logFailure(String message, Throwable e) { + private static void logFailure(String message, Throwable e) { System.err.println(message); if (e != null) { e.printStackTrace(System.err); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/StandaloneRestIntegTestTask.java b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/StandaloneRestIntegTestTask.java index 11ad0a29f5b8..b2f054860f6b 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/StandaloneRestIntegTestTask.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/StandaloneRestIntegTestTask.java @@ -69,11 +69,6 @@ public class StandaloneRestIntegTestTask extends Test implements TestClustersAwa this.debugServer = enabled; } - @Override - public int getMaxParallelForks() { - return 1; - } - @Nested @Override public Collection getClusters() { diff --git a/client/rest-high-level/build.gradle b/client/rest-high-level/build.gradle index e62703ca33f5..3cf647ba290d 100644 --- a/client/rest-high-level/build.gradle +++ b/client/rest-high-level/build.gradle @@ -9,7 +9,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams * Side Public License, v 1. */ apply plugin: 'elasticsearch.build' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.publish' apply plugin: 'elasticsearch.rest-resources' diff --git a/distribution/archives/integ-test-zip/build.gradle b/distribution/archives/integ-test-zip/build.gradle index e57c6cf32141..d91d919619ff 100644 --- a/distribution/archives/integ-test-zip/build.gradle +++ b/distribution/archives/integ-test-zip/build.gradle @@ -8,7 +8,7 @@ import org.apache.tools.ant.filters.ReplaceTokens -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' // The integ-test-distribution is published to maven apply plugin: 'elasticsearch.publish' diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 259318f5cb89..f07d5a6800ca 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -14,7 +14,7 @@ import org.elasticsearch.gradle.util.GradleUtils import java.nio.file.Path import java.time.temporal.ChronoUnit -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.test.fixtures' apply plugin: 'elasticsearch.internal-distribution-download' diff --git a/modules/aggs-matrix-stats/build.gradle b/modules/aggs-matrix-stats/build.gradle index 195254805d50..fdf4f53404c0 100644 --- a/modules/aggs-matrix-stats/build.gradle +++ b/modules/aggs-matrix-stats/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'Adds aggregations whose input are a list of numeric fields and output includes a matrix.' diff --git a/modules/analysis-common/build.gradle b/modules/analysis-common/build.gradle index b9f2d3a21446..0b7b16fae016 100644 --- a/modules/analysis-common/build.gradle +++ b/modules/analysis-common/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/ingest-common/build.gradle b/modules/ingest-common/build.gradle index 4687d60813e5..8fc400c3cb67 100644 --- a/modules/ingest-common/build.gradle +++ b/modules/ingest-common/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/ingest-geoip/build.gradle b/modules/ingest-geoip/build.gradle index 5d71ce9510cb..6b0fcb448f6a 100644 --- a/modules/ingest-geoip/build.gradle +++ b/modules/ingest-geoip/build.gradle @@ -8,7 +8,7 @@ import org.apache.tools.ant.taskdefs.condition.Os -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/ingest-geoip/qa/file-based-update/build.gradle b/modules/ingest-geoip/qa/file-based-update/build.gradle index f465172a55b7..0e396d62eb16 100644 --- a/modules/ingest-geoip/qa/file-based-update/build.gradle +++ b/modules/ingest-geoip/qa/file-based-update/build.gradle @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.configureEach { testDistribution = 'DEFAULT' diff --git a/modules/ingest-user-agent/build.gradle b/modules/ingest-user-agent/build.gradle index f5dc6151a8d3..e62b54c7bd60 100644 --- a/modules/ingest-user-agent/build.gradle +++ b/modules/ingest-user-agent/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'Ingest processor that extracts information from a user agent' diff --git a/modules/kibana/build.gradle b/modules/kibana/build.gradle index f30f155b02d6..75e093a45c33 100644 --- a/modules/kibana/build.gradle +++ b/modules/kibana/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { description 'Plugin exposing APIs for Kibana system indices' diff --git a/modules/lang-expression/build.gradle b/modules/lang-expression/build.gradle index 5e5a1cf3458d..a38e54ac3a53 100644 --- a/modules/lang-expression/build.gradle +++ b/modules/lang-expression/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/lang-mustache/build.gradle b/modules/lang-mustache/build.gradle index 7b0d76d55a77..de0b5d2b59ab 100644 --- a/modules/lang-mustache/build.gradle +++ b/modules/lang-mustache/build.gradle @@ -5,8 +5,8 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index 8e1b64fab52d..3e539afc4f7b 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask; apply plugin: 'elasticsearch.validate-rest-spec' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'An easy, safe and fast scripting language for Elasticsearch' diff --git a/modules/mapper-extras/build.gradle b/modules/mapper-extras/build.gradle index 89a1033faaed..a20511954423 100644 --- a/modules/mapper-extras/build.gradle +++ b/modules/mapper-extras/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { @@ -39,4 +39,4 @@ tasks.named('splitPackagesAudit').configure { tasks.named('internalClusterTestTestingConventions').configure { baseClass 'org.elasticsearch.index.mapper.MapperTestCase' baseClass 'org.elasticsearch.test.ESIntegTestCase' -} \ No newline at end of file +} diff --git a/modules/parent-join/build.gradle b/modules/parent-join/build.gradle index a8c175892d61..dad481ba7560 100644 --- a/modules/parent-join/build.gradle +++ b/modules/parent-join/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index 0070032f9afb..b116dc30984e 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/rank-eval/build.gradle b/modules/rank-eval/build.gradle index c6daf0ad5716..f0af0c6ca398 100644 --- a/modules/rank-eval/build.gradle +++ b/modules/rank-eval/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index 311b3432e05c..34493ee32768 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -16,8 +16,8 @@ import org.gradle.api.internal.artifacts.ArtifactAttributes apply plugin: 'elasticsearch.test-with-dependencies' apply plugin: 'elasticsearch.jdk-download' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/repository-url/build.gradle b/modules/repository-url/build.gradle index 874254d93b9f..202eb01c7d57 100644 --- a/modules/repository-url/build.gradle +++ b/modules/repository-url/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.PropertyNormalization -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.test.fixtures' diff --git a/modules/runtime-fields-common/build.gradle b/modules/runtime-fields-common/build.gradle index 01fa7c0c1c75..fb1c1b9e01bc 100644 --- a/modules/runtime-fields-common/build.gradle +++ b/modules/runtime-fields-common/build.gradle @@ -7,7 +7,7 @@ */ apply plugin: 'elasticsearch.validate-rest-spec' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'Module for runtime fields features and extensions that have large dependencies' @@ -19,4 +19,4 @@ dependencies { compileOnly project(':modules:lang-painless:spi') api project(':libs:elasticsearch-grok') api project(':libs:elasticsearch-dissect') -} \ No newline at end of file +} diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index c790030b7f77..d54cadb6eb28 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -7,11 +7,11 @@ */ import org.elasticsearch.gradle.internal.test.RestIntegTestTask -import org.elasticsearch.gradle.internal.test.rest.InternalJavaRestTestPlugin +import org.elasticsearch.gradle.internal.test.rest.LegacyJavaRestTestPlugin import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' /* @@ -63,7 +63,7 @@ TaskProvider pooledInternalClusterTest = tasks.register("pooledInternalClu TaskProvider pooledJavaRestTest = tasks.register("pooledJavaRestTest", RestIntegTestTask) { SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet javaRestTestSourceSet = sourceSets.getByName(InternalJavaRestTestPlugin.SOURCE_SET_NAME) + SourceSet javaRestTestSourceSet = sourceSets.getByName(LegacyJavaRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(javaRestTestSourceSet.getOutput().getClassesDirs()) setClasspath(javaRestTestSourceSet.getRuntimeClasspath()) diff --git a/plugins/analysis-icu/build.gradle b/plugins/analysis-icu/build.gradle index 6721844c640b..7b3253376dfc 100644 --- a/plugins/analysis-icu/build.gradle +++ b/plugins/analysis-icu/build.gradle @@ -7,7 +7,7 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/analysis-kuromoji/build.gradle b/plugins/analysis-kuromoji/build.gradle index e6b31f3d4d76..7d6598e1e724 100644 --- a/plugins/analysis-kuromoji/build.gradle +++ b/plugins/analysis-kuromoji/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch.' diff --git a/plugins/analysis-nori/build.gradle b/plugins/analysis-nori/build.gradle index ef6143787d3b..08b23b280e44 100644 --- a/plugins/analysis-nori/build.gradle +++ b/plugins/analysis-nori/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch.' diff --git a/plugins/analysis-phonetic/build.gradle b/plugins/analysis-phonetic/build.gradle index f3727b7c7e63..4fdd01a0f2a6 100644 --- a/plugins/analysis-phonetic/build.gradle +++ b/plugins/analysis-phonetic/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch.' diff --git a/plugins/analysis-smartcn/build.gradle b/plugins/analysis-smartcn/build.gradle index 88ffb15eee3f..6b26e75d2442 100644 --- a/plugins/analysis-smartcn/build.gradle +++ b/plugins/analysis-smartcn/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch.' diff --git a/plugins/analysis-stempel/build.gradle b/plugins/analysis-stempel/build.gradle index 115a3a050fda..38462e55c549 100644 --- a/plugins/analysis-stempel/build.gradle +++ b/plugins/analysis-stempel/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch.' diff --git a/plugins/analysis-ukrainian/build.gradle b/plugins/analysis-ukrainian/build.gradle index 006b46e4a263..f69de28c2b27 100644 --- a/plugins/analysis-ukrainian/build.gradle +++ b/plugins/analysis-ukrainian/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch.' diff --git a/plugins/discovery-azure-classic/build.gradle b/plugins/discovery-azure-classic/build.gradle index 738dd3aedeab..e385bc2a9c97 100644 --- a/plugins/discovery-azure-classic/build.gradle +++ b/plugins/discovery-azure-classic/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/discovery-ec2/build.gradle b/plugins/discovery-ec2/build.gradle index 3238040aebbc..898393615df3 100644 --- a/plugins/discovery-ec2/build.gradle +++ b/plugins/discovery-ec2/build.gradle @@ -7,7 +7,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle index e8afba63970c..c7c4ecba40fe 100644 --- a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle +++ b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle @@ -10,11 +10,11 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.internal.test.AntFixture import org.elasticsearch.gradle.internal.test.RestIntegTestTask -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':plugins:discovery-ec2') @@ -62,7 +62,7 @@ tasks.named("yamlRestTest").configure { enabled = false } def yamlRestTestTask = tasks.register("yamlRestTest${action}", RestIntegTestTask) { dependsOn fixture SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlRestTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME) + SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME) testClassesDirs = yamlRestTestSourceSet.getOutput().getClassesDirs() classpath = yamlRestTestSourceSet.getRuntimeClasspath() } diff --git a/plugins/discovery-gce/build.gradle b/plugins/discovery-gce/build.gradle index 5c5891cbcf4a..19c05113b431 100644 --- a/plugins/discovery-gce/build.gradle +++ b/plugins/discovery-gce/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/discovery-gce/qa/gce/build.gradle b/plugins/discovery-gce/qa/gce/build.gradle index c2cd26c2e928..7eb6e85903ba 100644 --- a/plugins/discovery-gce/qa/gce/build.gradle +++ b/plugins/discovery-gce/qa/gce/build.gradle @@ -13,7 +13,7 @@ import org.elasticsearch.gradle.internal.test.AntFixture import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' final int gceNumberOfNodes = 3 diff --git a/plugins/ingest-attachment/build.gradle b/plugins/ingest-attachment/build.gradle index 34604ac47b60..8c8aa38b9275 100644 --- a/plugins/ingest-attachment/build.gradle +++ b/plugins/ingest-attachment/build.gradle @@ -7,7 +7,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'Ingest processor that uses Apache Tika to extract contents' diff --git a/plugins/mapper-annotated-text/build.gradle b/plugins/mapper-annotated-text/build.gradle index 924d8307d5cc..34d8742a5822 100644 --- a/plugins/mapper-annotated-text/build.gradle +++ b/plugins/mapper-annotated-text/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/mapper-murmur3/build.gradle b/plugins/mapper-murmur3/build.gradle index d80c4b0970df..cd74ae2c978a 100644 --- a/plugins/mapper-murmur3/build.gradle +++ b/plugins/mapper-murmur3/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The Mapper Murmur3 plugin allows to compute hashes of a field\'s values at index-time and to store them in the index.' diff --git a/plugins/mapper-size/src/yamlRestTest/java/org/elasticsearch/index/mapper/size/MapperSizeClientYamlTestSuiteIT.java b/plugins/mapper-size/src/yamlRestTest/java/org/elasticsearch/index/mapper/size/MapperSizeClientYamlTestSuiteIT.java index a1bef57849f2..e9730418307e 100644 --- a/plugins/mapper-size/src/yamlRestTest/java/org/elasticsearch/index/mapper/size/MapperSizeClientYamlTestSuiteIT.java +++ b/plugins/mapper-size/src/yamlRestTest/java/org/elasticsearch/index/mapper/size/MapperSizeClientYamlTestSuiteIT.java @@ -11,11 +11,16 @@ package org.elasticsearch.index.mapper.size; 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 MapperSizeClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local().plugin("mapper-size").build(); + public MapperSizeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); } @@ -24,4 +29,9 @@ public class MapperSizeClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public static Iterable parameters() throws Exception { return createParameters(); } + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } } diff --git a/plugins/repository-azure/build.gradle b/plugins/repository-azure/build.gradle index 27e28573ff54..e98a45350c38 100644 --- a/plugins/repository-azure/build.gradle +++ b/plugins/repository-azure/build.gradle @@ -13,7 +13,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-test-artifact-base' diff --git a/plugins/repository-gcs/build.gradle b/plugins/repository-gcs/build.gradle index dfd1a0ff0ec1..acb6826b0177 100644 --- a/plugins/repository-gcs/build.gradle +++ b/plugins/repository-gcs/build.gradle @@ -1,7 +1,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.internal.test.RestIntegTestTask -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin import java.nio.file.Files @@ -16,7 +16,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-test-artifact-base' @@ -269,7 +269,7 @@ def largeBlobYamlRestTest = tasks.register("largeBlobYamlRestTest", RestIntegTes dependsOn "createServiceAccountFile" } SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlRestTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME) + SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs()) setClasspath(yamlRestTestSourceSet.getRuntimeClasspath()) @@ -320,7 +320,7 @@ if (useFixture) { tasks.register("yamlRestTestApplicationDefaultCredentials", RestIntegTestTask.class) { dependsOn('bundlePlugin') SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlRestTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME) + SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs()) setClasspath(yamlRestTestSourceSet.getRuntimeClasspath()) } diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index fb2d2343f11f..54107ddb7944 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -15,8 +15,8 @@ import java.nio.file.Path import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE apply plugin: 'elasticsearch.test.fixtures' -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { description 'The HDFS repository plugin adds support for Hadoop Distributed File-System (HDFS) repositories.' diff --git a/plugins/repository-s3/build.gradle b/plugins/repository-s3/build.gradle index fa88b20de352..566f1792efd4 100644 --- a/plugins/repository-s3/build.gradle +++ b/plugins/repository-s3/build.gradle @@ -1,7 +1,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.internal.test.RestIntegTestTask -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE @@ -13,7 +13,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-test-artifact-base' @@ -233,7 +233,7 @@ if (useFixture) { description = "Runs REST tests using the Minio repository." dependsOn tasks.named("bundlePlugin") SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlRestTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME) + SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs()) setClasspath(yamlRestTestSourceSet.getRuntimeClasspath()) @@ -260,7 +260,7 @@ if (useFixture) { description = "Runs tests using the ECS repository." dependsOn('bundlePlugin') SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlRestTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME) + SourceSet yamlRestTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs()) setClasspath(yamlRestTestSourceSet.getRuntimeClasspath()) systemProperty 'tests.rest.blacklist', [ diff --git a/plugins/store-smb/build.gradle b/plugins/store-smb/build.gradle index 91c7dcadf022..7147c7302733 100644 --- a/plugins/store-smb/build.gradle +++ b/plugins/store-smb/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/qa/ccs-unavailable-clusters/build.gradle b/qa/ccs-unavailable-clusters/build.gradle index 1b866385ecba..3b958bf9c8b9 100644 --- a/qa/ccs-unavailable-clusters/build.gradle +++ b/qa/ccs-unavailable-clusters/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.matching { it.name == "javaRestTest" }.configureEach { setting 'xpack.security.enabled', 'true' diff --git a/qa/smoke-test-client/build.gradle b/qa/smoke-test-client/build.gradle index 3e12a7b96a48..4e6fc862e5bd 100644 --- a/qa/smoke-test-client/build.gradle +++ b/qa/smoke-test-client/build.gradle @@ -9,7 +9,7 @@ import org.elasticsearch.gradle.internal.test.RestIntegTestTask */ // apply plugin: 'elasticsearch.standalone-rest-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' // TODO: this test works, but it isn't really a rest test...should we have another plugin for "non rest test that just needs N clusters?" diff --git a/qa/smoke-test-http/build.gradle b/qa/smoke-test-http/build.gradle index a65f181657ac..7038ae1b2e7f 100644 --- a/qa/smoke-test-http/build.gradle +++ b/qa/smoke-test-http/build.gradle @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test-with-dependencies' dependencies { diff --git a/qa/smoke-test-ingest-disabled/build.gradle b/qa/smoke-test-ingest-disabled/build.gradle index ad539bb515e1..5ffefed52b71 100644 --- a/qa/smoke-test-ingest-disabled/build.gradle +++ b/qa/smoke-test-ingest-disabled/build.gradle @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { testImplementation project(':modules:ingest-common') diff --git a/qa/smoke-test-ingest-with-all-dependencies/build.gradle b/qa/smoke-test-ingest-with-all-dependencies/build.gradle index 608b60b7c21f..ba84d9157374 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/build.gradle +++ b/qa/smoke-test-ingest-with-all-dependencies/build.gradle @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':modules:ingest-common') diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index 529568f0e420..6ff2e60af568 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' restResources { restTests { diff --git a/qa/smoke-test-plugins/build.gradle b/qa/smoke-test-plugins/build.gradle index 4ba6df8dc6d4..229fb1fc8287 100644 --- a/qa/smoke-test-plugins/build.gradle +++ b/qa/smoke-test-plugins/build.gradle @@ -9,7 +9,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' ext.pluginPaths = [] project(':plugins').getChildProjects().each { pluginName, pluginProject -> diff --git a/qa/snapshot-based-recoveries/azure/build.gradle b/qa/snapshot-based-recoveries/azure/build.gradle index 095d46ccf5bc..bd72ed741cc7 100644 --- a/qa/snapshot-based-recoveries/azure/build.gradle +++ b/qa/snapshot-based-recoveries/azure/build.gradle @@ -9,7 +9,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:azure-fixture') diff --git a/qa/snapshot-based-recoveries/fs/build.gradle b/qa/snapshot-based-recoveries/fs/build.gradle index 22ed1564e939..8fceb9436509 100644 --- a/qa/snapshot-based-recoveries/fs/build.gradle +++ b/qa/snapshot-based-recoveries/fs/build.gradle @@ -8,7 +8,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' dependencies { diff --git a/qa/snapshot-based-recoveries/gcs/build.gradle b/qa/snapshot-based-recoveries/gcs/build.gradle index 9a6e4cbbc86e..6cadd4d63691 100644 --- a/qa/snapshot-based-recoveries/gcs/build.gradle +++ b/qa/snapshot-based-recoveries/gcs/build.gradle @@ -6,7 +6,7 @@ import java.security.KeyPairGenerator import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:gcs-fixture') diff --git a/qa/snapshot-based-recoveries/s3/build.gradle b/qa/snapshot-based-recoveries/s3/build.gradle index 8f728d5f9d0b..379195f2347b 100644 --- a/qa/snapshot-based-recoveries/s3/build.gradle +++ b/qa/snapshot-based-recoveries/s3/build.gradle @@ -9,7 +9,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:s3-fixture') diff --git a/qa/system-indices/build.gradle b/qa/system-indices/build.gradle index 4a2987ae88cf..0f2e5d139124 100644 --- a/qa/system-indices/build.gradle +++ b/qa/system-indices/build.gradle @@ -7,7 +7,7 @@ */ apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { name 'system-indices-qa' diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 78a2006cfc44..fe0d310b61ca 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.OS * Side Public License, v 1. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.configureEach { setting 'xpack.security.enabled', 'false' diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 6f72bb1e5527..6ccddad2dcb3 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -32,8 +32,8 @@ artifacts { restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test")) } -testClusters.configureEach { - module ':modules:mapper-extras' +dependencies { + clusterModules project(":modules:mapper-extras") } tasks.named("test").configure {enabled = false } diff --git a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java index 795975a175ae..102dcc310c8b 100644 --- a/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java +++ b/rest-api-spec/src/yamlRestTest/java/org/elasticsearch/test/rest/ClientYamlTestSuiteIT.java @@ -13,8 +13,11 @@ import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite; import org.apache.lucene.util.TimeUnits; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.ClassRule; /** Rest integration test. Runs against a cluster started by {@code gradle integTest} */ @@ -22,6 +25,12 @@ import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; @TimeoutSuite(millis = 40 * TimeUnits.MINUTE) public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("mapper-extras") + .feature(FeatureFlag.TIME_SERIES_MODE) + .build(); + public ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { super(testCandidate); } @@ -30,4 +39,9 @@ public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { public static Iterable parameters() throws Exception { return createParameters(); } + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } } diff --git a/settings.gradle b/settings.gradle index 25d8f090e6d2..ddf1bb041b30 100644 --- a/settings.gradle +++ b/settings.gradle @@ -79,7 +79,8 @@ List projects = [ 'test:fixtures:geoip-fixture', 'test:fixtures:url-fixture', 'test:fixtures:nginx-fixture', - 'test:logger-usage' + 'test:logger-usage', + 'test:test-clusters' ] /** diff --git a/test/external-modules/build.gradle b/test/external-modules/build.gradle index 7b2c74918124..538a0439f88f 100644 --- a/test/external-modules/build.gradle +++ b/test/external-modules/build.gradle @@ -3,7 +3,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams subprojects { apply plugin: 'elasticsearch.base-internal-es-plugin' - apply plugin: 'elasticsearch.internal-yaml-rest-test' + apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { name it.name diff --git a/test/external-modules/die-with-dignity/build.gradle b/test/external-modules/die-with-dignity/build.gradle index 3466b7bb24ad..3046b045220a 100644 --- a/test/external-modules/die-with-dignity/build.gradle +++ b/test/external-modules/die-with-dignity/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.util.GradleUtils -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-es-plugin' esplugin { diff --git a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index 024eb08094e2..ab12c9458434 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -169,7 +169,11 @@ public class ReproduceInfoPrinter extends RunListener { appendOpt("tests.locale", Locale.getDefault().toLanguageTag()); appendOpt("tests.timezone", TimeZone.getDefault().getID()); appendOpt("tests.distribution", System.getProperty("tests.distribution")); - appendOpt("runtime.java", Integer.toString(JavaVersion.current().getVersion().get(0))); + + appendOpt( + "runtime.java", + System.getProperty("tests.runtime.java.version", Integer.toString(JavaVersion.current().getVersion().get(0))) + ); appendOpt("license.key", System.getProperty("licence.key")); appendOpt(ESTestCase.FIPS_SYSPROP, System.getProperty(ESTestCase.FIPS_SYSPROP)); return this; diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java index 46ddefedda8e..c883496cf99f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/Features.java @@ -73,7 +73,9 @@ public final class Features { } private static boolean isSupported(String feature) { - if (feature.equals(SPI_ON_CLASSPATH_SINCE_JDK_9) && JavaVersion.current().compareTo(JavaVersion.parse("9")) >= 0) { + String runtimeJavaProp = System.getProperty("tests.runtime.java.version"); + JavaVersion runtimeJava = runtimeJavaProp != null ? JavaVersion.parse(runtimeJavaProp) : JavaVersion.current(); + if (feature.equals(SPI_ON_CLASSPATH_SINCE_JDK_9) && runtimeJava.compareTo(JavaVersion.parse("9")) >= 0) { return true; } return SUPPORTED.contains(feature); diff --git a/test/test-clusters/build.gradle b/test/test-clusters/build.gradle new file mode 100644 index 000000000000..d88974f61f52 --- /dev/null +++ b/test/test-clusters/build.gradle @@ -0,0 +1,19 @@ +apply plugin: 'elasticsearch.java' +apply plugin: 'com.github.johnrengelman.shadow' + +dependencies { + shadow("junit:junit:${versions.junit}") { + exclude module: 'hamcrest-core' + } + shadow "org.apache.logging.log4j:log4j-api:${versions.log4j}" + + implementation files("$rootDir/build-tools/reaper/build/libs/reaper.jar") +} + +// We use updated APIs here and since this project is only used for REST testing it's ok to run with > Java 8 +sourceCompatibility = 17 +targetCompatibility = 17 + +tasks.named("processResources").configure { + from(new File(rootDir, "build-tools-internal/version.properties")) +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterFactory.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterFactory.java new file mode 100644 index 000000000000..313bfcc767fa --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterFactory.java @@ -0,0 +1,14 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +public interface ClusterFactory { + + H create(S spec); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterHandle.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterHandle.java new file mode 100644 index 000000000000..02a65aaeec7a --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterHandle.java @@ -0,0 +1,45 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import java.io.Closeable; + +/** + * A handle to an {@link ElasticsearchCluster}. + */ +public interface ClusterHandle extends Closeable { + /** + * Starts the cluster. This method will block until all nodes are started and cluster is ready to serve requests. + */ + void start(); + + /** + * Stops the cluster. This method will block until all cluster node processes have exited. This method is thread-safe and subsequent + * calls will wait for the exiting termination to complete. + * + * @param forcibly whether to forcibly terminate the cluster + */ + void stop(boolean forcibly); + + /** + * Whether the cluster is started or not. This method makes no guarantees on cluster availability, only that the node processes have + * been started. + * + * @return whether the cluster has been started + */ + boolean isStarted(); + + /** + * Returns a comma-separated list of HTTP transport endpoints for cluster. If this method is called on an unstarted cluster, the cluster + * will be started. This method is thread-safe and subsequent calls will wait for cluster start and availability. + * + * @return cluster node HTTP transport addresses + */ + String getHttpAddresses(); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterSpec.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterSpec.java new file mode 100644 index 000000000000..528a24509c3b --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ClusterSpec.java @@ -0,0 +1,11 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +public interface ClusterSpec {} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ElasticsearchCluster.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ElasticsearchCluster.java new file mode 100644 index 000000000000..02eb3fb73df6 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/ElasticsearchCluster.java @@ -0,0 +1,35 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import org.elasticsearch.test.cluster.local.DefaultLocalClusterSpecBuilder; +import org.elasticsearch.test.cluster.local.LocalClusterSpecBuilder; +import org.junit.rules.TestRule; + +/** + *

A JUnit test rule for orchestrating an Elasticsearch cluster for local integration testing. New clusters can be created via one of the + * various static builder methods. For example:

+ *
+ * @ClassRule
+ * public static ElasticsearchCluster myCluster = ElasticsearchCluster.local().build();
+ * 
+ */ +public interface ElasticsearchCluster extends TestRule, ClusterHandle { + + /** + * Creates a new {@link DefaultLocalClusterSpecBuilder} for defining a locally orchestrated cluster. Local clusters use a locally built + * Elasticsearch distribution. + * + * @return a builder for a local cluster + */ + static LocalClusterSpecBuilder local() { + return new DefaultLocalClusterSpecBuilder(); + } + +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/EnvironmentProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/EnvironmentProvider.java new file mode 100644 index 000000000000..a63151b42f8f --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/EnvironmentProvider.java @@ -0,0 +1,30 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; + +import java.util.Map; + +/** + * Functional interface for supplying environment variables to an Elasticsearch node. This interface is designed to be implemented by tests + * and fixtures wanting to provide settings to an {@link ElasticsearchCluster} in a dynamic fashion. Instances are evaluated lazily at + * cluster start time. + */ +public interface EnvironmentProvider { + + /** + * Returns a collection of environment variables to apply to an Elasticsearch cluster node. This method is called when the cluster is + * started so implementors can return dynamic environment values that may or may not be based on the given node spec. + * + * @param nodeSpec the specification for the given node to apply settings to + * @return environment variables to add to the node + */ + Map get(LocalNodeSpec nodeSpec); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java new file mode 100644 index 000000000000..62103dcf47e7 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/FeatureFlag.java @@ -0,0 +1,29 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import org.elasticsearch.test.cluster.util.Version; + +/** + * Elasticsearch feature flags. Used in conjunction with {@link org.elasticsearch.test.cluster.local.LocalSpecBuilder#feature(FeatureFlag)} + * to indicate that this feature is required and should be enabled when appropriate. + */ +public enum FeatureFlag { + TIME_SERIES_MODE("es.index_mode_feature_flag_registered=true", Version.fromString("8.0.0"), null); + + public final String systemProperty; + public final Version from; + public final Version until; + + FeatureFlag(String systemProperty, Version from, Version until) { + this.systemProperty = systemProperty; + this.from = from; + this.until = until; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/MutableSettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/MutableSettingsProvider.java new file mode 100644 index 000000000000..172a114bc04d --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/MutableSettingsProvider.java @@ -0,0 +1,31 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import org.elasticsearch.test.cluster.local.LocalClusterSpec; + +import java.util.HashMap; +import java.util.Map; + +public class MutableSettingsProvider implements SettingsProvider { + private final Map settings = new HashMap<>(); + + @Override + public Map get(LocalClusterSpec.LocalNodeSpec nodeSpec) { + return settings; + } + + public void put(String setting, String value) { + settings.put(setting, value); + } + + public void clear() { + settings.clear(); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/SettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/SettingsProvider.java new file mode 100644 index 000000000000..3d4c694fad6c --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/SettingsProvider.java @@ -0,0 +1,30 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster; + +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; + +import java.util.Map; + +/** + * Functional interface for supplying settings to an Elasticsearch node. This interface is designed to be implemented by tests and fixtures + * wanting to provide settings to an {@link ElasticsearchCluster} in a dynamic fashion. Instances are evaluated lazily at cluster + * start time. + */ +public interface SettingsProvider { + + /** + * Returns a collection of settings to apply to an Elasticsearch cluster node. This method is called when the cluster is started so + * implementors can return dynamic setting values that may or may not be based on the given node spec. + * + * @param nodeSpec the specification for the given node to apply settings to + * @return settings to add to the node + */ + Map get(LocalNodeSpec nodeSpec); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java new file mode 100644 index 000000000000..64888c39268c --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java @@ -0,0 +1,159 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.EnvironmentProvider; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.SettingsProvider; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Supplier; + +public abstract class AbstractLocalSpecBuilder> implements LocalSpecBuilder { + private final AbstractLocalSpecBuilder parent; + private final List settingsProviders = new ArrayList<>(); + private final Map settings = new HashMap<>(); + private final List environmentProviders = new ArrayList<>(); + private final Map environment = new HashMap<>(); + private final Set modules = new HashSet<>(); + private final Set plugins = new HashSet<>(); + private final Set features = new HashSet<>(); + private DistributionType distributionType; + + protected AbstractLocalSpecBuilder(AbstractLocalSpecBuilder parent) { + this.parent = parent; + } + + @Override + public T settings(SettingsProvider settingsProvider) { + this.settingsProviders.add(settingsProvider); + return cast(this); + } + + List getSettingsProviders() { + return inherit(() -> parent.getSettingsProviders(), settingsProviders); + } + + @Override + public T setting(String setting, String value) { + this.settings.put(setting, value); + return cast(this); + } + + Map getSettings() { + return inherit(() -> parent.getSettings(), settings); + } + + @Override + public T environment(EnvironmentProvider environmentProvider) { + this.environmentProviders.add(environmentProvider); + return cast(this); + } + + List getEnvironmentProviders() { + return inherit(() -> parent.getEnvironmentProviders(), environmentProviders); + + } + + @Override + public T environment(String key, String value) { + this.environment.put(key, value); + return cast(this); + } + + Map getEnvironment() { + return inherit(() -> parent.getEnvironment(), environment); + } + + @Override + public T distribution(DistributionType type) { + this.distributionType = type; + return cast(this); + } + + DistributionType getDistributionType() { + return inherit(() -> parent.getDistributionType(), distributionType); + } + + @Override + public T module(String moduleName) { + this.modules.add(moduleName); + return cast(this); + } + + Set getModules() { + return inherit(() -> parent.getModules(), modules); + } + + @Override + public T plugin(String pluginName) { + this.plugins.add(pluginName); + return cast(this); + } + + Set getPlugins() { + return inherit(() -> parent.getPlugins(), plugins); + } + + @Override + public T feature(FeatureFlag feature) { + this.features.add(feature); + return cast(this); + } + + Set getFeatures() { + return inherit(() -> parent.getFeatures(), features); + } + + private List inherit(Supplier> parent, List child) { + List combinedList = new ArrayList<>(); + if (this.parent != null) { + combinedList.addAll(parent.get()); + } + combinedList.addAll(child); + return combinedList; + } + + private Set inherit(Supplier> parent, Set child) { + Set combinedSet = new HashSet<>(); + if (this.parent != null) { + combinedSet.addAll(parent.get()); + } + combinedSet.addAll(child); + return combinedSet; + } + + private Map inherit(Supplier> parent, Map child) { + Map combinedMap = new HashMap<>(); + if (this.parent != null) { + combinedMap.putAll(parent.get()); + } + combinedMap.putAll(child); + return combinedMap; + } + + private T inherit(Supplier parent, T child) { + T value = null; + if (this.parent != null) { + value = parent.get(); + } + return child == null ? value : child; + } + + @SuppressWarnings("unchecked") + private static T cast(Object o) { + return (T) o; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultEnvironmentProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultEnvironmentProvider.java new file mode 100644 index 000000000000..a6e3ce1b63a6 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultEnvironmentProvider.java @@ -0,0 +1,39 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.EnvironmentProvider; +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.cluster.util.Version; + +import java.util.HashMap; +import java.util.Map; + +public class DefaultEnvironmentProvider implements EnvironmentProvider { + private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname"; + private static final String COMPUTERNAME_OVERRIDE = "WindowsComputername"; + private static final String TESTS_RUNTIME_JAVA_SYSPROP = "tests.runtime.java"; + + @Override + public Map get(LocalNodeSpec nodeSpec) { + Map environment = new HashMap<>(); + + // If we are testing the current version of Elasticsearch, use the configured runtime Java, otherwise use the bundled JDK + if (nodeSpec.getDistributionType() == DistributionType.INTEG_TEST || nodeSpec.getVersion().equals(Version.CURRENT)) { + environment.put("ES_JAVA_HOME", System.getProperty(TESTS_RUNTIME_JAVA_SYSPROP)); + } + + // Override the system hostname variables for testing + environment.put("HOSTNAME", HOSTNAME_OVERRIDE); + environment.put("COMPUTERNAME", COMPUTERNAME_OVERRIDE); + + return environment; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java new file mode 100644 index 000000000000..79353a43a02c --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java @@ -0,0 +1,151 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.cluster.local.model.User; +import org.elasticsearch.test.cluster.util.Version; +import org.elasticsearch.test.cluster.util.resource.TextResource; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.Consumer; + +public class DefaultLocalClusterSpecBuilder extends AbstractLocalSpecBuilder implements LocalClusterSpecBuilder { + private String name = "test-cluster"; + private final List nodeBuilders = new ArrayList<>(); + private final List users = new ArrayList<>(); + private final List roleFiles = new ArrayList<>(); + + public DefaultLocalClusterSpecBuilder() { + super(null); + this.settings(new DefaultSettingsProvider()); + this.environment(new DefaultEnvironmentProvider()); + this.rolesFile(TextResource.fromClasspath("default_test_roles.yml")); + } + + @Override + public DefaultLocalClusterSpecBuilder name(String name) { + this.name = name; + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder apply(LocalClusterConfigProvider configProvider) { + configProvider.apply(this); + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder nodes(int nodes) { + if (nodes < nodeBuilders.size()) { + throw new IllegalArgumentException( + "Cannot shrink cluster to " + nodes + ". " + nodeBuilders.size() + " nodes already configured" + ); + } + + int newNodes = nodes - nodeBuilders.size(); + for (int i = 0; i < newNodes; i++) { + nodeBuilders.add(new DefaultLocalNodeSpecBuilder(this)); + } + + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder withNode(Consumer config) { + DefaultLocalNodeSpecBuilder builder = new DefaultLocalNodeSpecBuilder(this); + config.accept(builder); + nodeBuilders.add(builder); + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder node(int index, Consumer config) { + try { + DefaultLocalNodeSpecBuilder builder = nodeBuilders.get(index); + config.accept(builder); + } catch (IndexOutOfBoundsException e) { + throw new IllegalArgumentException( + "No node at index + " + index + " exists. Only " + nodeBuilders.size() + " nodes have been configured" + ); + } + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder user(String username, String password) { + this.users.add(new User(username, password)); + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder user(String username, String password, String role) { + this.users.add(new User(username, password, role)); + return this; + } + + @Override + public DefaultLocalClusterSpecBuilder rolesFile(TextResource rolesFile) { + this.roleFiles.add(rolesFile); + return this; + } + + @Override + public ElasticsearchCluster build() { + LocalClusterSpec clusterSpec = new LocalClusterSpec(name, users, roleFiles); + List nodeSpecs; + + if (nodeBuilders.isEmpty()) { + // No node-specific configuration so assume a single-node cluster + nodeSpecs = List.of(new DefaultLocalNodeSpecBuilder(this).build(clusterSpec)); + } else { + nodeSpecs = nodeBuilders.stream().map(node -> node.build(clusterSpec)).toList(); + } + + clusterSpec.setNodes(nodeSpecs); + clusterSpec.validate(); + + return new LocalElasticsearchCluster(clusterSpec); + } + + public static class DefaultLocalNodeSpecBuilder extends AbstractLocalSpecBuilder implements LocalNodeSpecBuilder { + private String name; + + protected DefaultLocalNodeSpecBuilder(AbstractLocalSpecBuilder parent) { + super(parent); + } + + @Override + public DefaultLocalNodeSpecBuilder name(String name) { + this.name = name; + return this; + } + + private LocalNodeSpec build(LocalClusterSpec cluster) { + + return new LocalNodeSpec( + cluster, + name, + Version.CURRENT, + getSettingsProviders(), + getSettings(), + getEnvironmentProviders(), + getEnvironment(), + getModules(), + getPlugins(), + Optional.ofNullable(getDistributionType()).orElse(DistributionType.INTEG_TEST), + getFeatures() + ); + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java new file mode 100644 index 000000000000..ffe013a259a4 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java @@ -0,0 +1,72 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.SettingsProvider; +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +public class DefaultSettingsProvider implements SettingsProvider { + @Override + public Map get(LocalNodeSpec nodeSpec) { + Map settings = new HashMap<>(); + + settings.put("node.name", nodeSpec.getName()); + settings.put("node.attr.testattr", "test"); + settings.put("node.portsfile", "true"); + settings.put("http.port", "0"); + settings.put("transport.port", "0"); + + if (nodeSpec.getDistributionType() == DistributionType.DEFAULT) { + // Disable deprecation indexing which is enabled by default in 7.16 + if (nodeSpec.getVersion().onOrAfter("7.16.0")) { + settings.put("cluster.deprecation_indexing.enabled", "false"); + } + } + + // Default the watermarks to absurdly low to prevent the tests from failing on nodes without enough disk space + settings.put("cluster.routing.allocation.disk.watermark.low", "1b"); + settings.put("cluster.routing.allocation.disk.watermark.high", "1b"); + settings.put("cluster.routing.allocation.disk.watermark.flood_stage", "1b"); + + // increase script compilation limit since tests can rapid-fire script compilations + if (nodeSpec.getVersion().onOrAfter("7.9.0")) { + settings.put("script.disable_max_compilations_rate", "true"); + } else { + settings.put("script.max_compilations_rate", "2048/1m"); + } + + // Temporarily disable the real memory usage circuit breaker. It depends on real memory usage which we have no full control + // over and the REST client will not retry on circuit breaking exceptions yet (see #31986 for details). Once the REST client + // can retry on circuit breaking exceptions, we can revert again to the default configuration. + settings.put("indices.breaker.total.use_real_memory", "false"); + + // Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master + settings.put("discovery.initial_state_timeout", "0s"); + + if (nodeSpec.getVersion().getMajor() >= 8) { + settings.put("cluster.service.slow_task_logging_threshold", "5s"); + settings.put("cluster.service.slow_master_task_logging_threshold", "5s"); + } + + settings.put("action.destructive_requires_name", "false"); + + // Setup cluster discovery + String nodeNames = nodeSpec.getCluster().getNodes().stream().map(LocalNodeSpec::getName).collect(Collectors.joining(",")); + settings.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + settings.put("discovery.seed_providers", "file"); + settings.put("discovery.seed_hosts", "[]"); + + return settings; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterConfigProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterConfigProvider.java new file mode 100644 index 000000000000..7e802247709d --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterConfigProvider.java @@ -0,0 +1,14 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +public interface LocalClusterConfigProvider { + + void apply(LocalClusterSpecBuilder builder); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java new file mode 100644 index 000000000000..9ddb51de31da --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java @@ -0,0 +1,507 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.test.cluster.ClusterFactory; +import org.elasticsearch.test.cluster.local.LocalClusterSpec.LocalNodeSpec; +import org.elasticsearch.test.cluster.local.distribution.DistributionDescriptor; +import org.elasticsearch.test.cluster.local.distribution.DistributionResolver; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.cluster.local.model.User; +import org.elasticsearch.test.cluster.util.IOUtils; +import org.elasticsearch.test.cluster.util.OS; +import org.elasticsearch.test.cluster.util.Pair; +import org.elasticsearch.test.cluster.util.ProcessReaper; +import org.elasticsearch.test.cluster.util.ProcessUtils; +import org.elasticsearch.test.cluster.util.Retry; +import org.elasticsearch.test.cluster.util.Version; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class LocalClusterFactory implements ClusterFactory { + private static final Logger LOGGER = LogManager.getLogger(LocalClusterFactory.class); + private static final Duration NODE_UP_TIMEOUT = Duration.ofMinutes(2); + private static final Map, DistributionDescriptor> TEST_DISTRIBUTIONS = new ConcurrentHashMap<>(); + private static final String TESTS_CLUSTER_MODULES_PATH_SYSPROP = "tests.cluster.modules.path"; + private static final String TESTS_CLUSTER_PLUGINS_PATH_SYSPROP = "tests.cluster.plugins.path"; + public static final Pattern BUNDLE_ARTIFACT_PATTERN = Pattern.compile("(.+)(?:-\\d\\.\\d\\.\\d-SNAPSHOT\\.zip)?"); + + private final Path baseWorkingDir; + private final DistributionResolver distributionResolver; + + public LocalClusterFactory(Path baseWorkingDir, DistributionResolver distributionResolver) { + this.baseWorkingDir = baseWorkingDir; + this.distributionResolver = distributionResolver; + } + + @Override + public LocalClusterHandle create(LocalClusterSpec spec) { + return new LocalClusterHandle(spec.getName(), spec.getNodes().stream().map(Node::new).toList()); + } + + public class Node { + private final LocalNodeSpec spec; + private final Path workingDir; + private final Path distributionDir; + private final Path snapshotsDir; + private final Path dataDir; + private final Path logsDir; + private final Path configDir; + private final Path tempDir; + + private boolean initialized = false; + private Process process = null; + private DistributionDescriptor distributionDescriptor; + + public Node(LocalNodeSpec spec) { + this.spec = spec; + this.workingDir = baseWorkingDir.resolve(spec.getCluster().getName()).resolve(spec.getName()); + this.distributionDir = workingDir.resolve("distro"); // location of es distribution files, typically hard-linked + this.snapshotsDir = workingDir.resolve("repo"); + this.dataDir = workingDir.resolve("data"); + this.logsDir = workingDir.resolve("logs"); + this.configDir = workingDir.resolve("config"); + this.tempDir = workingDir.resolve("tmp"); // elasticsearch temporary directory + } + + public synchronized void start() { + LOGGER.info("Starting Elasticsearch node '{}'", spec.getName()); + + if (initialized == false) { + LOGGER.info("Creating installation for node '{}' in {}", spec.getName(), workingDir); + distributionDescriptor = resolveDistribution(); + LOGGER.info("Distribution for node '{}': {}", spec.getName(), distributionDescriptor); + initializeWorkingDirectory(); + writeConfiguration(); + createKeystore(); + configureSecurity(); + installPlugins(); + if (spec.getDistributionType() == DistributionType.INTEG_TEST) { + installModules(); + } + initialized = true; + } + + startElasticsearch(); + } + + public synchronized void stop(boolean forcibly) { + if (process != null) { + ProcessUtils.stopHandle(process.toHandle(), forcibly); + ProcessReaper.instance().unregister(getServiceName()); + } + } + + public void waitForExit() { + if (process != null) { + ProcessUtils.waitForExit(process.toHandle()); + } + } + + public String getHttpAddress() { + Path portFile = workingDir.resolve("logs").resolve("http.ports"); + if (Files.notExists(portFile)) { + waitUntilReady(); + } + return readPortsFile(portFile).get(0); + } + + public String getTransportEndpoint() { + Path portsFile = workingDir.resolve("logs").resolve("transport.ports"); + if (Files.notExists(portsFile)) { + waitUntilReady(); + } + return readPortsFile(portsFile).get(0); + } + + public LocalNodeSpec getSpec() { + return spec; + } + + Path getWorkingDir() { + return workingDir; + } + + public void waitUntilReady() { + try { + Retry.retryUntilTrue(NODE_UP_TIMEOUT, Duration.ofMillis(500), () -> { + if (process.isAlive() == false) { + throw new RuntimeException( + "Elasticsearch process died while waiting for ports file. See console output for details." + ); + } + + Path httpPorts = workingDir.resolve("logs").resolve("http.ports"); + Path transportPorts = workingDir.resolve("logs").resolve("transport.ports"); + + return Files.exists(httpPorts) && Files.exists(transportPorts); + }); + } catch (TimeoutException e) { + throw new RuntimeException("Timed out after " + NODE_UP_TIMEOUT + " waiting for ports files for: " + this); + } catch (ExecutionException e) { + throw new RuntimeException("An error occurred while waiting for ports file for: " + this, e); + } + } + + private List readPortsFile(Path file) { + try (Stream lines = Files.lines(file, StandardCharsets.UTF_8)) { + return lines.map(String::trim).collect(Collectors.toList()); + } catch (IOException e) { + throw new UncheckedIOException("Unable to read ports file: " + file, e); + } + } + + private void initializeWorkingDirectory() { + try { + IOUtils.deleteWithRetry(workingDir); + try { + IOUtils.syncWithLinks(distributionDescriptor.getDistributionDir(), distributionDir); + } catch (IOUtils.LinkCreationException e) { + // Note does not work for network drives, e.g. Vagrant + LOGGER.info("Failed to create working dir using hard links. Falling back to copy", e); + // ensure we get a clean copy + IOUtils.deleteWithRetry(distributionDir); + IOUtils.syncWithCopy(distributionDescriptor.getDistributionDir(), distributionDir); + } + Files.createDirectories(configDir); + Files.createDirectories(snapshotsDir); + Files.createDirectories(dataDir); + Files.createDirectories(logsDir); + Files.createDirectories(tempDir); + } catch (IOException e) { + throw new UncheckedIOException("Failed to create working directory for node '" + spec.getName() + "'", e); + } + } + + private DistributionDescriptor resolveDistribution() { + return TEST_DISTRIBUTIONS.computeIfAbsent( + Pair.of(spec.getVersion(), spec.getDistributionType()), + key -> distributionResolver.resolve(key.left, key.right) + ); + } + + private void writeConfiguration() { + Path configFile = configDir.resolve("elasticsearch.yml"); + Path jvmOptionsFile = configDir.resolve("jvm.options"); + + try { + // Write settings to elasticsearch.yml + Map pathSettings = new HashMap<>(); + pathSettings.put("path.repo", workingDir.resolve("repo").toString()); + pathSettings.put("path.data", workingDir.resolve("data").toString()); + pathSettings.put("path.logs", workingDir.resolve("logs").toString()); + + Files.writeString( + configFile, + Stream.concat(spec.resolveSettings().entrySet().stream(), pathSettings.entrySet().stream()) + .map(entry -> entry.getKey() + ": " + entry.getValue()) + .collect(Collectors.joining("\n")), + StandardOpenOption.TRUNCATE_EXISTING, + StandardOpenOption.CREATE + ); + + // Copy additional configuration from distribution + try (Stream configFiles = Files.list(distributionDir.resolve("config"))) { + for (Path file : configFiles.toList()) { + Path dest = configFile.getParent().resolve(file.getFileName()); + if (Files.exists(dest) == false) { + Files.copy(file, dest); + } + } + } + + // Patch jvm.options file to update paths + String content = Files.readString(jvmOptionsFile); + Map expansions = getJvmOptionsReplacements(); + for (String key : expansions.keySet()) { + if (content.contains(key) == false) { + throw new IOException("Template property '" + key + "' not found in template."); + } + content = content.replace(key, expansions.get(key)); + } + Files.writeString(jvmOptionsFile, content); + } catch (IOException e) { + throw new UncheckedIOException("Could not write config file: " + configFile, e); + } + } + + private void createKeystore() { + try { + ProcessUtils.exec( + workingDir, + OS.conditional( + c -> c.onWindows(() -> distributionDir.resolve("bin").resolve("elasticsearch-keystore.bat")) + .onUnix(() -> distributionDir.resolve("bin").resolve("elasticsearch-keystore")) + ), + getEnvironmentVariables(), + false, + "-v", + "create" + ).waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + private void configureSecurity() { + if (spec.isSecurityEnabled()) { + if (spec.getUsers().isEmpty() == false) { + LOGGER.info("Setting up roles.yml for node '{}'", spec.getName()); + + Path destination = workingDir.resolve("config").resolve("roles.yml"); + spec.getRolesFiles().forEach(rolesFile -> { + try { + Files.writeString( + destination, + rolesFile.getText() + System.lineSeparator(), + StandardCharsets.UTF_8, + StandardOpenOption.APPEND + ); + } catch (IOException e) { + throw new UncheckedIOException("Failed to append roles file " + rolesFile + " to " + destination, e); + } + }); + } + + LOGGER.info("Creating users for node '{}'", spec.getName()); + for (User user : spec.getUsers()) { + try { + ProcessUtils.exec( + workingDir, + distributionDir.resolve("bin").resolve("elasticsearch-users"), + getEnvironmentVariables(), + false, + "useradd", + user.getUsername(), + "-p", + user.getPassword(), + "-r", + user.getRole() + ).waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + } + + private void installPlugins() { + if (spec.getPlugins().isEmpty() == false) { + LOGGER.info("Installing plugins {} into node '{}", spec.getPlugins(), spec.getName()); + List pluginPaths = Arrays.stream(System.getProperty(TESTS_CLUSTER_PLUGINS_PATH_SYSPROP).split(File.pathSeparator)) + .map(Path::of) + .toList(); + + List toInstall = spec.getPlugins() + .stream() + .map( + pluginName -> pluginPaths.stream() + .map(path -> Pair.of(BUNDLE_ARTIFACT_PATTERN.matcher(path.getFileName().toString()), path)) + .filter(pair -> pair.left.matches()) + .map(p -> p.right.getParent().resolve(p.left.group(1))) + .findFirst() + .orElseThrow(() -> { + String taskPath = System.getProperty("tests.task"); + String project = taskPath.substring(0, taskPath.lastIndexOf(':')); + + throw new RuntimeException( + "Unable to locate plugin '" + + pluginName + + "'. Ensure you've added the following to the build script for project '" + + project + + "':\n\n" + + "dependencies {\n" + + " clusterModules " + + "project(':plugins:" + + pluginName + + "')" + + "\n}" + ); + }) + ) + .map(p -> p.toUri().toString()) + .toList(); + + Path pluginCommand = OS.conditional( + c -> c.onWindows(() -> distributionDir.resolve("bin").resolve("elasticsearch-plugin.bat")) + .onUnix(() -> distributionDir.resolve("bin").resolve("elasticsearch-plugin")) + ); + if (spec.getVersion().onOrAfter("7.6.0")) { + try { + ProcessUtils.exec( + workingDir, + pluginCommand, + getEnvironmentVariables(), + false, + Stream.concat(Stream.of("install", "--batch"), toInstall.stream()).toArray(String[]::new) + ).waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } else { + toInstall.forEach(plugin -> { + try { + ProcessUtils.exec(workingDir, pluginCommand, getEnvironmentVariables(), false, "install", "--batch", plugin) + .waitFor(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }); + } + } + } + + private void installModules() { + if (spec.getModules().isEmpty() == false) { + LOGGER.info("Installing modules {} into node '{}", spec.getModules(), spec.getName()); + List modulePaths = Arrays.stream(System.getProperty(TESTS_CLUSTER_MODULES_PATH_SYSPROP).split(File.pathSeparator)) + .map(Path::of) + .toList(); + + spec.getModules().forEach(module -> installModule(module, modulePaths)); + } + } + + private void installModule(String moduleName, List modulePaths) { + Path destination = distributionDir.resolve("modules").resolve(moduleName); + if (Files.notExists(destination)) { + Path modulePath = modulePaths.stream() + .map(path -> Pair.of(BUNDLE_ARTIFACT_PATTERN.matcher(path.getFileName().toString()), path)) + .filter(pair -> pair.left.matches()) + .map(p -> p.right.getParent().resolve(p.left.group(1))) + .findFirst() + .orElseThrow(() -> { + String taskPath = System.getProperty("tests.task"); + String project = taskPath.substring(0, taskPath.lastIndexOf(':')); + String moduleDependency = moduleName.startsWith("x-pack") + ? "project(xpackModule('" + moduleName.substring(7) + "'))" + : "project(':modules:" + moduleName + "')"; + + throw new RuntimeException( + "Unable to locate module '" + + moduleName + + "'. Ensure you've added the following to the build script for project '" + + project + + "':\n\n" + + "dependencies {\n" + + " clusterModules " + + moduleDependency + + "\n}" + ); + + }); + + IOUtils.syncWithCopy(modulePath.getParent(), destination); + + // Install any extended plugins + Properties pluginProperties = new Properties(); + try ( + InputStream in = new BufferedInputStream( + new FileInputStream(modulePath.resolve("plugin-descriptor.properties").toFile()) + ) + ) { + pluginProperties.load(in); + String extendedProperty = pluginProperties.getProperty("extended.plugins"); + if (extendedProperty != null) { + String[] extendedPlugins = extendedProperty.split(","); + for (String plugin : extendedPlugins) { + installModule(plugin, modulePaths); + } + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + + private void startElasticsearch() { + process = ProcessUtils.exec( + workingDir, + OS.conditional( + c -> c.onWindows(() -> distributionDir.resolve("bin").resolve("elasticsearch.bat")) + .onUnix(() -> distributionDir.resolve("bin").resolve("elasticsearch")) + ), + getEnvironmentVariables(), + true + ); + + ProcessReaper.instance().registerPid(getServiceName(), process.pid()); + } + + private Map getEnvironmentVariables() { + Map environment = new HashMap<>(spec.resolveEnvironment()); + environment.put("ES_PATH_CONF", workingDir.resolve("config").toString()); + environment.put("ES_TMPDIR", workingDir.resolve("tmp").toString()); + // Windows requires this as it defaults to `c:\windows` despite ES_TMPDIR + environment.put("TMP", workingDir.resolve("tmp").toString()); + + String featureFlagProperties = ""; + if (spec.getFeatures().isEmpty() == false && distributionDescriptor.isSnapshot() == false) { + featureFlagProperties = spec.getFeatures() + .stream() + .filter(f -> spec.getVersion().onOrAfter(f.from) && (f.until == null || spec.getVersion().before(f.until))) + .map(f -> "-D" + f.systemProperty) + .collect(Collectors.joining(" ")); + } + + String heapSize = System.getProperty("tests.heap.size", "512m"); + environment.put("ES_JAVA_OPTS", "-Xms" + heapSize + " -Xmx" + heapSize + " -ea -esa " + // Support passing in additional JVM arguments + + System.getProperty("tests.jvm.argline", "") + + " " + + featureFlagProperties); + + return environment; + } + + private Map getJvmOptionsReplacements() { + Path relativeLogsDir = workingDir.relativize(logsDir); + return Map.of( + "-XX:HeapDumpPath=data", + "-XX:HeapDumpPath=" + relativeLogsDir, + "logs/gc.log", + relativeLogsDir.resolve("gc.log").toString(), + "-XX:ErrorFile=logs/hs_err_pid%p.log", + "-XX:ErrorFile=" + relativeLogsDir.resolve("hs_err_pid%p.log") + ); + } + + private String getServiceName() { + return baseWorkingDir.getFileName() + "-" + spec.getCluster().getName() + "-" + spec.getName(); + } + + @Override + public String toString() { + return "{ cluster: '" + spec.getCluster().getName() + "', node: '" + spec.getName() + "' }"; + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterHandle.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterHandle.java new file mode 100644 index 000000000000..450c93761aaf --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterHandle.java @@ -0,0 +1,157 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.test.cluster.ClusterHandle; +import org.elasticsearch.test.cluster.local.LocalClusterFactory.Node; +import org.elasticsearch.test.cluster.local.model.User; +import org.elasticsearch.test.cluster.util.ExceptionUtils; +import org.elasticsearch.test.cluster.util.Retry; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Duration; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; + +public class LocalClusterHandle implements ClusterHandle { + private static final Logger LOGGER = LogManager.getLogger(LocalClusterHandle.class); + private static final Duration CLUSTER_UP_TIMEOUT = Duration.ofSeconds(30); + + public final ForkJoinPool executor = new ForkJoinPool( + Math.max(Runtime.getRuntime().availableProcessors(), 4), + new ForkJoinPool.ForkJoinWorkerThreadFactory() { + private final AtomicLong counter = new AtomicLong(0); + + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) { + ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + thread.setName(name + "-node-executor-" + counter.getAndIncrement()); + return thread; + } + }, + null, + false + ); + private final AtomicBoolean started = new AtomicBoolean(false); + private final String name; + private final List nodes; + + public LocalClusterHandle(String name, List nodes) { + this.name = name; + this.nodes = nodes; + } + + @Override + public void start() { + if (started.getAndSet(true) == false) { + LOGGER.info("Starting Elasticsearch test cluster '{}'", name); + execute(() -> nodes.parallelStream().forEach(Node::start)); + } + waitUntilReady(); + } + + @Override + public void stop(boolean forcibly) { + if (started.getAndSet(false)) { + LOGGER.info("Stopping Elasticsearch test cluster '{}', forcibly: {}", name, forcibly); + execute(() -> nodes.forEach(n -> n.stop(forcibly))); + } else { + // Make sure the process is stopped, otherwise wait + execute(() -> nodes.forEach(n -> n.waitForExit())); + } + } + + @Override + public boolean isStarted() { + return started.get(); + } + + @Override + public void close() { + stop(false); + + executor.shutdownNow(); + try { + executor.awaitTermination(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + @Override + public String getHttpAddresses() { + start(); + return execute(() -> nodes.parallelStream().map(Node::getHttpAddress).collect(Collectors.joining(","))); + } + + private void waitUntilReady() { + writeUnicastHostsFile(); + try { + Retry.retryUntilTrue(CLUSTER_UP_TIMEOUT, Duration.ZERO, () -> { + Node node = nodes.get(0); + String scheme = node.getSpec().isSettingTrue("xpack.security.http.ssl.enabled") ? "https" : "http"; + WaitForHttpResource wait = new WaitForHttpResource(scheme, node.getHttpAddress(), nodes.size()); + if (node.getSpec().getUsers().isEmpty() == false) { + User credentials = node.getSpec().getUsers().get(0); + wait.setUsername(credentials.getUsername()); + wait.setPassword(credentials.getPassword()); + } + return wait.wait(500); + }); + } catch (TimeoutException e) { + throw new RuntimeException("Timed out after " + CLUSTER_UP_TIMEOUT + " waiting for cluster '" + name + "' status to be yellow"); + } catch (ExecutionException e) { + throw new RuntimeException("An error occurred while checking cluster '" + name + "' status.", e); + } + } + + private void writeUnicastHostsFile() { + String transportUris = execute(() -> nodes.parallelStream().map(Node::getTransportEndpoint).collect(Collectors.joining("\n"))); + nodes.forEach(node -> { + try { + Path hostsFile = node.getWorkingDir().resolve("config").resolve("unicast_hosts.txt"); + if (Files.notExists(hostsFile)) { + Files.writeString(hostsFile, transportUris); + } + } catch (IOException e) { + throw new UncheckedIOException("Failed to write unicast_hosts for: " + node, e); + } + }); + } + + private T execute(Callable task) { + try { + return executor.submit(task).get(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + throw new RuntimeException("An error occurred orchestrating test cluster.", ExceptionUtils.findRootCause(e)); + } + } + + private void execute(Runnable task) { + execute(() -> { + task.run(); + return true; + }); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java new file mode 100644 index 000000000000..aac8c2794279 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java @@ -0,0 +1,190 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.ClusterSpec; +import org.elasticsearch.test.cluster.EnvironmentProvider; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.SettingsProvider; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.cluster.local.model.User; +import org.elasticsearch.test.cluster.util.Version; +import org.elasticsearch.test.cluster.util.resource.TextResource; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +public class LocalClusterSpec implements ClusterSpec { + private final String name; + private final List users; + private final List roleFiles; + private List nodes; + + public LocalClusterSpec(String name, List users, List roleFiles) { + this.name = name; + this.users = users; + this.roleFiles = roleFiles; + } + + public String getName() { + return name; + } + + public List getUsers() { + return users; + } + + public List getRoleFiles() { + return roleFiles; + } + + public List getNodes() { + return nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + } + + void validate() { + // Ensure we don't have nodes with duplicate names + List nodeNames = nodes.stream().map(LocalNodeSpec::getName).collect(Collectors.toList()); + Set uniqueNames = nodes.stream().map(LocalNodeSpec::getName).collect(Collectors.toSet()); + uniqueNames.forEach(name -> nodeNames.remove(nodeNames.indexOf(name))); + + if (nodeNames.isEmpty() == false) { + throw new IllegalArgumentException("Cluster cannot contain nodes with duplicates names: " + nodeNames); + } + } + + public static class LocalNodeSpec { + private final LocalClusterSpec cluster; + private final String name; + private final Version version; + private final List settingsProviders; + private final Map settings; + private final List environmentProviders; + private final Map environment; + private final Set modules; + private final Set plugins; + private final DistributionType distributionType; + private final Set features; + + public LocalNodeSpec( + LocalClusterSpec cluster, + String name, + Version version, + List settingsProviders, + Map settings, + List environmentProviders, + Map environment, + Set modules, + Set plugins, + DistributionType distributionType, + Set features + ) { + this.cluster = cluster; + this.name = name; + this.version = version; + this.settingsProviders = settingsProviders; + this.settings = settings; + this.environmentProviders = environmentProviders; + this.environment = environment; + this.modules = modules; + this.plugins = plugins; + this.distributionType = distributionType; + this.features = features; + } + + public LocalClusterSpec getCluster() { + return cluster; + } + + public String getName() { + return name == null ? cluster.getName() + "-" + cluster.getNodes().indexOf(this) : name; + } + + public Version getVersion() { + return version; + } + + public List getUsers() { + return cluster.getUsers(); + } + + public List getRolesFiles() { + return cluster.getRoleFiles(); + } + + public DistributionType getDistributionType() { + return distributionType; + } + + public Set getModules() { + return modules; + } + + public Set getPlugins() { + return plugins; + } + + public Set getFeatures() { + return features; + } + + public boolean isSecurityEnabled() { + return Boolean.parseBoolean( + resolveSettings().getOrDefault("xpack.security.enabled", getVersion().onOrAfter("8.0.0") ? "true" : "false") + ); + } + + public boolean isSettingTrue(String setting) { + return Boolean.parseBoolean(resolveSettings().getOrDefault(setting, "false")); + } + + /** + * Resolve node settings. Order of precedence is as follows: + *
    + *
  1. Settings from cluster configured {@link SettingsProvider}
  2. + *
  3. Settings from node configured {@link SettingsProvider}
  4. + *
  5. Explicit cluster settings
  6. + *
  7. Explicit node settings
  8. + *
+ * + * @return resolved settings for node + */ + public Map resolveSettings() { + Map resolvedSettings = new HashMap<>(); + settingsProviders.forEach(p -> resolvedSettings.putAll(p.get(this))); + resolvedSettings.putAll(settings); + return resolvedSettings; + } + + /** + * Resolve node environment variables. Order of precedence is as follows: + *
    + *
  1. Environment variables from cluster configured {@link EnvironmentProvider}
  2. + *
  3. Environment variables from node configured {@link EnvironmentProvider}
  4. + *
  5. Environment variables cluster settings
  6. + *
  7. Environment variables node settings
  8. + *
+ * + * @return resolved environment variables for node + */ + public Map resolveEnvironment() { + Map resolvedEnvironment = new HashMap<>(); + environmentProviders.forEach(p -> resolvedEnvironment.putAll(p.get(this))); + resolvedEnvironment.putAll(environment); + return resolvedEnvironment; + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpecBuilder.java new file mode 100644 index 000000000000..63b5ca00f248 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpecBuilder.java @@ -0,0 +1,58 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.util.resource.TextResource; + +import java.util.function.Consumer; + +public interface LocalClusterSpecBuilder extends LocalSpecBuilder { + /** + * Sets the node name. By default, "test-cluster" is used. + */ + LocalClusterSpecBuilder name(String name); + + LocalClusterSpecBuilder apply(LocalClusterConfigProvider configProvider); + + /** + * Sets the number of nodes for the cluster. + */ + LocalClusterSpecBuilder nodes(int nodes); + + /** + * Adds a new node to the cluster and configures the node. + */ + LocalClusterSpecBuilder withNode(Consumer config); + + /** + * Configures an existing node. + * + * @param index the index of the node to configure + * @param config configuration to apply to the node + */ + LocalClusterSpecBuilder node(int index, Consumer config); + + /** + * Register a user using the default test role. + */ + LocalClusterSpecBuilder user(String username, String password); + + /** + * Register a user using the given role. + */ + LocalClusterSpecBuilder user(String username, String password, String role); + + /** + * Register a roles file with cluster via the supplied {@link TextResource}. + */ + LocalClusterSpecBuilder rolesFile(TextResource rolesFile); + + ElasticsearchCluster build(); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalElasticsearchCluster.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalElasticsearchCluster.java new file mode 100644 index 000000000000..55e41255bb6e --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalElasticsearchCluster.java @@ -0,0 +1,81 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.local.distribution.LocalDistributionResolver; +import org.elasticsearch.test.cluster.local.distribution.SnapshotDistributionResolver; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.nio.file.Path; + +public class LocalElasticsearchCluster implements ElasticsearchCluster { + private final LocalClusterSpec spec; + private LocalClusterHandle handle; + + public LocalElasticsearchCluster(LocalClusterSpec spec) { + this.spec = spec; + } + + @Override + public Statement apply(Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + try { + handle = new LocalClusterFactory( + Path.of(System.getProperty("java.io.tmpdir")).resolve(description.getDisplayName()).toAbsolutePath(), + new LocalDistributionResolver(new SnapshotDistributionResolver()) + ).create(spec); + handle.start(); + base.evaluate(); + } finally { + close(); + } + } + }; + } + + @Override + public void start() { + checkHandle(); + handle.start(); + } + + @Override + public void stop(boolean forcibly) { + checkHandle(); + handle.stop(forcibly); + } + + @Override + public boolean isStarted() { + checkHandle(); + return handle.isStarted(); + } + + @Override + public void close() { + checkHandle(); + handle.close(); + } + + @Override + public String getHttpAddresses() { + checkHandle(); + return handle.getHttpAddresses(); + } + + private void checkHandle() { + if (handle == null) { + throw new IllegalStateException("Cluster handle has not been initialized. Did you forget the @ClassRule annotation?"); + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java new file mode 100644 index 000000000000..f9b28407aaa4 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java @@ -0,0 +1,17 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +public interface LocalNodeSpecBuilder extends LocalSpecBuilder { + + /** + * Sets the node name. By default, nodes are named after the cluster with an incrementing suffix (ex: my-cluster-0). + */ + LocalNodeSpecBuilder name(String name); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java new file mode 100644 index 000000000000..0f6fcebd30df --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java @@ -0,0 +1,57 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.elasticsearch.test.cluster.EnvironmentProvider; +import org.elasticsearch.test.cluster.FeatureFlag; +import org.elasticsearch.test.cluster.SettingsProvider; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; + +interface LocalSpecBuilder> { + /** + * Register a {@link SettingsProvider}. + */ + T settings(SettingsProvider settingsProvider); + + /** + * Add a new node setting. + */ + T setting(String setting, String value); + + /** + * Register a {@link EnvironmentProvider}. + */ + T environment(EnvironmentProvider environmentProvider); + + /** + * Add a new node environment variable. + */ + T environment(String key, String value); + + /** + * Set the cluster {@link DistributionType}. By default, the {@link DistributionType#INTEG_TEST} distribution is used. + */ + T distribution(DistributionType type); + + /** + * Ensure module is installed into the distribution when using the {@link DistributionType#INTEG_TEST} distribution. This is ignored + * when the {@link DistributionType#DEFAULT} is being used. + */ + T module(String moduleName); + + /** + * Ensure plugin is installed into the distribution. + */ + T plugin(String pluginName); + + /** + * Require feature to be enabled in the cluster. + */ + T feature(FeatureFlag feature); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/WaitForHttpResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/WaitForHttpResource.java new file mode 100644 index 000000000000..edab2cdf1e7e --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/WaitForHttpResource.java @@ -0,0 +1,219 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.util.Arrays; +import java.util.Base64; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +/** + * A utility to wait for a specific HTTP resource to be available, optionally with customized TLS trusted CAs. + * This is logically similar to using the Ant Get task to retrieve a resource, but with the difference that it can + * access resources that do not use the JRE's default trusted CAs. + */ +public class WaitForHttpResource { + + private static final Logger logger = LogManager.getLogger(WaitForHttpResource.class); + + private Set validResponseCodes = Collections.singleton(200); + private URL url; + private Set certificateAuthorities; + private File trustStoreFile; + private String trustStorePassword; + private String username; + private String password; + + public WaitForHttpResource(String protocol, String host, int numberOfNodes) throws MalformedURLException { + this(new URL(protocol + "://" + host + "/_cluster/health?wait_for_nodes=>=" + numberOfNodes + "&wait_for_status=yellow")); + } + + public WaitForHttpResource(URL url) { + this.url = url; + } + + public void setValidResponseCodes(int... validResponseCodes) { + this.validResponseCodes = new HashSet<>(validResponseCodes.length); + for (int rc : validResponseCodes) { + this.validResponseCodes.add(rc); + } + } + + public void setCertificateAuthorities(File... certificateAuthorities) { + this.certificateAuthorities = new HashSet<>(Arrays.asList(certificateAuthorities)); + } + + public void setTrustStoreFile(File trustStoreFile) { + this.trustStoreFile = trustStoreFile; + } + + public void setTrustStorePassword(String trustStorePassword) { + this.trustStorePassword = trustStorePassword; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean wait(int durationInMs) throws GeneralSecurityException, InterruptedException, IOException { + final long waitUntil = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(durationInMs); + final long sleep = Long.max(durationInMs / 10, 100); + + final SSLContext ssl; + final KeyStore trustStore = buildTrustStore(); + if (trustStore != null) { + ssl = createSslContext(trustStore); + } else { + ssl = null; + } + IOException failure = null; + while (true) { + try { + checkResource(ssl); + return true; + } catch (IOException e) { + logger.debug("Failed to access resource [{}]", url, e); + failure = e; + } + if (System.nanoTime() < waitUntil) { + Thread.sleep(sleep); + } else { + throw failure; + } + } + } + + protected void checkResource(SSLContext ssl) throws IOException { + final HttpURLConnection connection = buildConnection(ssl); + connection.connect(); + final Integer response = connection.getResponseCode(); + if (validResponseCodes.contains(response)) { + logger.info("Got successful response [{}] from URL [{}]", response, url); + return; + } else { + throw new IOException(response + " " + connection.getResponseMessage()); + } + } + + HttpURLConnection buildConnection(SSLContext ssl) throws IOException { + final HttpURLConnection connection = (HttpURLConnection) this.url.openConnection(); + configureSslContext(connection, ssl); + configureBasicAuth(connection); + connection.setRequestMethod("GET"); + return connection; + } + + private void configureSslContext(HttpURLConnection connection, SSLContext ssl) { + if (ssl != null) { + if (connection instanceof HttpsURLConnection) { + ((HttpsURLConnection) connection).setSSLSocketFactory(ssl.getSocketFactory()); + } else { + throw new IllegalStateException("SSL trust has been configured, but [" + url + "] is not a 'https' URL"); + } + } + } + + private void configureBasicAuth(HttpURLConnection connection) { + if (username != null) { + if (password == null) { + throw new IllegalStateException("Basic Auth user [" + username + "] has been set, but no password has been configured"); + } + connection.setRequestProperty( + "Authorization", + "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)) + ); + } + } + + KeyStore buildTrustStore() throws GeneralSecurityException, IOException { + if (this.certificateAuthorities != null) { + if (trustStoreFile != null) { + throw new IllegalStateException("Cannot specify both truststore and CAs"); + } + return buildTrustStoreFromCA(); + } else if (trustStoreFile != null) { + return buildTrustStoreFromFile(); + } else { + return null; + } + } + + private KeyStore buildTrustStoreFromFile() throws GeneralSecurityException, IOException { + KeyStore keyStore = KeyStore.getInstance(trustStoreFile.getName().endsWith(".jks") ? "JKS" : "PKCS12"); + try (InputStream input = new FileInputStream(trustStoreFile)) { + keyStore.load(input, trustStorePassword == null ? null : trustStorePassword.toCharArray()); + } + return keyStore; + } + + private KeyStore buildTrustStoreFromCA() throws GeneralSecurityException, IOException { + final KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType()); + store.load(null, null); + final CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); + int counter = 0; + for (File ca : certificateAuthorities) { + try (InputStream input = new FileInputStream(ca)) { + for (Certificate certificate : certFactory.generateCertificates(input)) { + store.setCertificateEntry("cert-" + counter, certificate); + counter++; + } + } + } + return store; + } + + private SSLContext createSslContext(KeyStore trustStore) throws GeneralSecurityException { + checkForTrustEntry(trustStore); + TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + tmf.init(trustStore); + SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); + sslContext.init(new KeyManager[0], tmf.getTrustManagers(), new SecureRandom()); + return sslContext; + } + + private void checkForTrustEntry(KeyStore trustStore) throws KeyStoreException { + Enumeration enumeration = trustStore.aliases(); + while (enumeration.hasMoreElements()) { + if (trustStore.isCertificateEntry(enumeration.nextElement())) { + // found trusted cert entry + return; + } + } + throw new IllegalStateException("Trust-store does not contain any trusted certificate entries"); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DefaultDistributionDescriptor.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DefaultDistributionDescriptor.java new file mode 100644 index 000000000000..ca0f92b9139a --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DefaultDistributionDescriptor.java @@ -0,0 +1,57 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +import org.elasticsearch.test.cluster.util.Version; + +import java.nio.file.Path; + +public class DefaultDistributionDescriptor implements DistributionDescriptor { + private final Version version; + private final boolean snapshot; + private final Path distributionDir; + private final DistributionType type; + + public DefaultDistributionDescriptor(Version version, boolean snapshot, Path distributionDir, DistributionType type) { + this.version = version; + this.snapshot = snapshot; + this.distributionDir = distributionDir; + this.type = type; + } + + public Version getVersion() { + return version; + } + + public boolean isSnapshot() { + return snapshot; + } + + public Path getDistributionDir() { + return distributionDir; + } + + public DistributionType getType() { + return type; + } + + @Override + public String toString() { + return "DefaultDistributionDescriptor{" + + "version=" + + version + + ", snapshot=" + + snapshot + + ", distributionDir=" + + distributionDir + + ", type=" + + type + + '}'; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionDescriptor.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionDescriptor.java new file mode 100644 index 000000000000..fb213a87d038 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionDescriptor.java @@ -0,0 +1,23 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +import org.elasticsearch.test.cluster.util.Version; + +import java.nio.file.Path; + +public interface DistributionDescriptor { + Version getVersion(); + + boolean isSnapshot(); + + Path getDistributionDir(); + + DistributionType getType(); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionResolver.java new file mode 100644 index 000000000000..93e6d20d7071 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionResolver.java @@ -0,0 +1,16 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +import org.elasticsearch.test.cluster.util.Version; + +public interface DistributionResolver { + + DistributionDescriptor resolve(Version version, DistributionType type); +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionType.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionType.java new file mode 100644 index 000000000000..6e19c0fa160d --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/DistributionType.java @@ -0,0 +1,24 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +public enum DistributionType { + INTEG_TEST("tests.integ-test.distribution"), + DEFAULT("tests.default.distribution"); + + private final String systemProperty; + + DistributionType(String systemProperty) { + this.systemProperty = systemProperty; + } + + public String getSystemProperty() { + return systemProperty; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java new file mode 100644 index 000000000000..3c09b75fe9f6 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java @@ -0,0 +1,68 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +import org.elasticsearch.test.cluster.util.Version; + +import java.nio.file.Files; +import java.nio.file.Path; + +public class LocalDistributionResolver implements DistributionResolver { + private final DistributionResolver delegate; + + public LocalDistributionResolver(DistributionResolver delegate) { + this.delegate = delegate; + } + + @Override + public DistributionDescriptor resolve(Version version, DistributionType type) { + if (version.equals(Version.CURRENT)) { + String testDistributionPath = System.getProperty(type.getSystemProperty()); + + if (testDistributionPath == null) { + if (type == DistributionType.DEFAULT) { + String taskPath = System.getProperty("tests.task"); + String project = taskPath.substring(0, taskPath.lastIndexOf(':')); + String taskName = taskPath.substring(taskPath.lastIndexOf(':') + 1); + + throw new IllegalStateException( + "Cannot locate Elasticsearch distribution. Ensure you've added the following to the build script for project '" + + project + + "':\n\n" + + "tasks.named('" + + taskName + + "').configure {\n" + + " usesDefaultDistribution()\n" + + "}" + ); + } else { + throw new IllegalStateException( + "Cannot locate Elasticsearch distribution. The '" + type.getSystemProperty() + "' system property is null." + ); + } + } + + Path testDistributionDir = Path.of(testDistributionPath); + if (Files.notExists(testDistributionDir)) { + throw new IllegalStateException( + "Cannot locate Elasticsearch distribution. Directory at '" + testDistributionDir + "' does not exist." + ); + } + + return new DefaultDistributionDescriptor( + version, + Boolean.parseBoolean(System.getProperty("build.snapshot", "true")), + testDistributionDir, + type + ); + } + + return delegate.resolve(version, type); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java new file mode 100644 index 000000000000..182dbe66a584 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java @@ -0,0 +1,19 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.distribution; + +import org.elasticsearch.test.cluster.util.Version; + +public class SnapshotDistributionResolver implements DistributionResolver { + @Override + public DistributionDescriptor resolve(Version version, DistributionType type) { + // Not yet implemented + throw new UnsupportedOperationException("Cannot resolve distribution for version " + version); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/model/User.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/model/User.java new file mode 100644 index 000000000000..f056bbb4d0bd --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/model/User.java @@ -0,0 +1,41 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.local.model; + +public class User { + public static final User DEFAULT_USER = new User("test_user", "x-pack-test-password", "_es_test_root"); + + private final String username; + private final String password; + private final String role; + + public User(String username, String password) { + this.username = username; + this.password = password; + this.role = "_es_test_root"; + } + + public User(String username, String password, String role) { + this.username = username; + this.password = password; + this.role = role; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + public String getRole() { + return role; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ExceptionUtils.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ExceptionUtils.java new file mode 100644 index 000000000000..dd3fc999d8b0 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ExceptionUtils.java @@ -0,0 +1,22 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +public final class ExceptionUtils { + private ExceptionUtils() {} + + public static Throwable findRootCause(Throwable t) { + Throwable cause = t.getCause(); + if (cause == null) { + return t; + } + + return findRootCause(cause); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/IOUtils.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/IOUtils.java new file mode 100644 index 000000000000..980aa6a272f3 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/IOUtils.java @@ -0,0 +1,199 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.Comparator; +import java.util.function.BiConsumer; +import java.util.stream.Stream; + +public final class IOUtils { + private static final int RETRY_DELETE_MILLIS = OS.current() == OS.WINDOWS ? 500 : 0; + private static final int MAX_RETRY_DELETE_TIMES = OS.current() == OS.WINDOWS ? 15 : 0; + + private IOUtils() {} + + /** + * Deletes a path, retrying if necessary. + * + * @param path the path to delete + * @throws IOException + * if an I/O error occurs + */ + public static void deleteWithRetry(Path path) throws IOException { + try { + deleteWithRetry0(path); + } catch (InterruptedException x) { + throw new IOException("Interrupted while deleting.", x); + } + } + + /** Unchecked variant of deleteWithRetry. */ + public static void uncheckedDeleteWithRetry(Path path) { + try { + deleteWithRetry0(path); + } catch (IOException e) { + throw new UncheckedIOException(e); + } catch (InterruptedException x) { + throw new UncheckedIOException("Interrupted while deleting.", new IOException()); + } + } + + /** + * Does the equivalent of `cp -lr` and `chmod -r a-w` to save space and improve speed. + * We remove write permissions to make sure files are note mistakenly edited ( e.x. the config file ) and changes + * reflected across all copies. Permissions are retained to be able to replace the links. + * + * @param sourceRoot where to copy from + * @param destinationRoot destination to link to + */ + public static void syncWithLinks(Path sourceRoot, Path destinationRoot) { + sync(sourceRoot, destinationRoot, (Path d, Path s) -> { + try { + Files.createLink(d, s); + } catch (IOException e) { + // Note does not work for network drives, e.g. Vagrant + throw new LinkCreationException("Failed to create hard link " + d + " pointing to " + s, e); + } + }); + } + + /** + * Sync source folder to destination folder. This method does an actual copy of file contents. When possible, + * {@link #syncWithLinks(Path, Path)} is preferred for better performance when the synced contents don't need to be subsequently + * modified. + * + * @param sourceRoot where to copy from + * @param destinationRoot destination to link to + */ + public static void syncWithCopy(Path sourceRoot, Path destinationRoot) { + sync(sourceRoot, destinationRoot, (Path d, Path s) -> { + try { + Files.copy(s, d); + } catch (IOException e) { + throw new UncheckedIOException("Failed to copy " + s + " to " + d, e); + } + }); + } + + public static String readStringFromStream(InputStream in) { + try { + return new String(in.readAllBytes(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new UncheckedIOException(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + } + } + + private static void sync(Path sourceRoot, Path destinationRoot, BiConsumer syncMethod) { + assert Files.exists(destinationRoot) == false; + try (Stream stream = Files.walk(sourceRoot)) { + stream.forEach(source -> { + Path relativeDestination = sourceRoot.relativize(source); + if (relativeDestination.getNameCount() <= 1) { + return; + } + // Throw away the first name as the archives have everything in a single top level folder we are not interested in + relativeDestination = relativeDestination.subpath(1, relativeDestination.getNameCount()); + + Path destination = destinationRoot.resolve(relativeDestination); + if (Files.isDirectory(source)) { + try { + Files.createDirectories(destination); + } catch (IOException e) { + throw new UncheckedIOException("Can't create directory " + destination.getParent(), e); + } + } else { + try { + Files.createDirectories(destination.getParent()); + } catch (IOException e) { + throw new UncheckedIOException("Can't create directory " + destination.getParent(), e); + } + syncMethod.accept(destination, source); + } + }); + } catch (UncheckedIOException e) { + if (e.getCause()instanceof NoSuchFileException cause) { + // Ignore these files that are sometimes left behind by the JVM + if (cause.getFile() == null || cause.getFile().contains(".attach_pid") == false) { + throw new UncheckedIOException(cause); + } + } else { + throw e; + } + } catch (IOException e) { + throw new UncheckedIOException("Can't walk source " + sourceRoot, e); + } + } + + // The exception handling here is loathsome, but necessary! + // TODO: Some of the loathsomeness here was copied from our Gradle plugin that was required because of Gradle exception wrapping. That + // may no longer be strictly necessary in this context. + private static void deleteWithRetry0(Path path) throws IOException, InterruptedException { + int times = 0; + IOException ioe = null; + while (true) { + try { + recursiveDelete(path); + times++; + // Checks for absence of the file. Semantics of Files.exists() is not the same. + while (Files.notExists(path) == false) { + if (times > MAX_RETRY_DELETE_TIMES) { + throw new IOException("File still exists after " + times + " waits."); + } + Thread.sleep(RETRY_DELETE_MILLIS); + // retry + recursiveDelete(path); + times++; + } + break; + } catch (NoSuchFileException ignore) { + // already deleted, ignore + break; + } catch (IOException x) { + if (x.getCause() instanceof NoSuchFileException) { + // already deleted, ignore + break; + } + // Backoff/retry in case another process is accessing the file + times++; + if (ioe == null) ioe = new IOException(); + ioe.addSuppressed(x); + if (times > MAX_RETRY_DELETE_TIMES) throw ioe; + Thread.sleep(RETRY_DELETE_MILLIS); + } + } + } + + private static void recursiveDelete(Path path) throws IOException { + try (Stream files = Files.walk(path)) { + files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + } + } + + public static class LinkCreationException extends UncheckedIOException { + LinkCreationException(String message, IOException cause) { + super(message, cause); + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/OS.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/OS.java new file mode 100644 index 000000000000..7ea0daaa3b24 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/OS.java @@ -0,0 +1,79 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Supplier; + +public enum OS { + WINDOWS, + MAC, + LINUX; + + public static OS current() { + String os = System.getProperty("os.name", ""); + if (os.startsWith("Windows")) { + return OS.WINDOWS; + } + if (os.startsWith("Linux") || os.startsWith("LINUX")) { + return OS.LINUX; + } + if (os.startsWith("Mac")) { + return OS.MAC; + } + throw new IllegalStateException("Can't determine OS from: " + os); + } + + public static class Conditional { + + private final Map> conditions = new HashMap<>(); + + public Conditional onWindows(Supplier supplier) { + conditions.put(WINDOWS, supplier); + return this; + } + + public Conditional onLinux(Supplier supplier) { + conditions.put(LINUX, supplier); + return this; + } + + public Conditional onMac(Supplier supplier) { + conditions.put(MAC, supplier); + return this; + } + + public Conditional onUnix(Supplier supplier) { + conditions.put(MAC, supplier); + conditions.put(LINUX, supplier); + return this; + } + + T supply() { + HashSet missingOS = new HashSet<>(Arrays.asList(OS.values())); + missingOS.removeAll(conditions.keySet()); + if (missingOS.isEmpty() == false) { + throw new IllegalArgumentException("No condition specified for " + missingOS); + } + return conditions.get(OS.current()).get(); + } + + } + + public static T conditional(Consumer> config) { + Conditional conditional = new Conditional<>(); + config.accept(conditional); + + return conditional.supply(); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Pair.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Pair.java new file mode 100644 index 000000000000..863cbce1c9e9 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Pair.java @@ -0,0 +1,38 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import java.util.Objects; + +public final class Pair { + public final L left; + public final R right; + + private Pair(L left, R right) { + this.left = left; + this.right = right; + } + + public static Pair of(L left, R right) { + return new Pair<>(left, right); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pair pair = (Pair) o; + return Objects.equals(left, pair.left) && Objects.equals(right, pair.right); + } + + @Override + public int hashCode() { + return Objects.hash(left, right); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessReaper.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessReaper.java new file mode 100644 index 000000000000..1f18115737ac --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessReaper.java @@ -0,0 +1,156 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ProcessReaper { + private static final String REAPER_CLASS_LOCATION = "org/elasticsearch/gradle/reaper/Reaper.class"; + private static final String REAPER_CLASS = "org.elasticsearch.gradle.reaper.Reaper"; + private static final Pattern REAPER_JAR_PATH_PATTERN = Pattern.compile("file:(.*)!/" + REAPER_CLASS_LOCATION); + private static final Logger LOGGER = LogManager.getLogger(ProcessReaper.class); + private static final ProcessReaper INSTANCE = new ProcessReaper(); + private final Path reaperDir; + + private volatile Process process; + + private ProcessReaper() { + try { + this.reaperDir = Files.createTempDirectory("reaper-"); + } catch (IOException e) { + throw new UncheckedIOException("Failed to create process reaper working directory.", e); + } + + Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown, "process-reaper-shutdown")); + } + + public static ProcessReaper instance() { + return INSTANCE; + } + + /** + * Register a pid that will be killed by the reaper. + */ + public void registerPid(String serviceId, long pid) { + String[] killPidCommand = OS.conditional( + c -> c.onWindows(() -> new String[] { "Taskkill", "/F", "/PID", String.valueOf(pid) }) + .onUnix(() -> new String[] { "kill", "-9", String.valueOf(pid) }) + ); + registerCommand(serviceId, killPidCommand); + } + + public void unregister(String serviceId) { + try { + Files.deleteIfExists(getCmdFile(serviceId)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private void registerCommand(String serviceId, String... command) { + ensureReaperStarted(); + + try { + Files.writeString(getCmdFile(serviceId), String.join(" ", command)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private Path getCmdFile(String serviceId) { + return reaperDir.resolve(serviceId.replaceAll("[^a-zA-Z0-9]", "-") + ".cmd"); + } + + void shutdown() { + if (process != null) { + ensureReaperAlive(); + try { + process.getOutputStream().close(); + LOGGER.info("Waiting for reaper to exit normally"); + if (process.waitFor() != 0) { + throw new RuntimeException("Reaper process failed. Check log at " + reaperDir.resolve("reaper.log") + " for details"); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + } + + private synchronized void ensureReaperStarted() { + if (process == null) { + try { + Path jarPath = locateReaperJar(); + + // ensure the input directory exists + Files.createDirectories(reaperDir); + // start the reaper + ProcessBuilder builder = new ProcessBuilder( + findJavaHome().resolve("bin") + .resolve(OS.conditional(c -> c.onWindows(() -> "java.exe").onUnix(() -> "java"))) + .toString(), // same jvm as gradle + "-Xms4m", + "-Xmx16m", // no need for a big heap, just need to read some files and execute + "-cp", + jarPath.toString(), + REAPER_CLASS, + reaperDir.toString() + ); + LOGGER.info("Launching reaper: " + String.join(" ", builder.command())); + // be explicit for stdin, we use closing of the pipe to signal shutdown to the reaper + builder.redirectInput(ProcessBuilder.Redirect.PIPE); + File logFile = reaperDir.resolve("reaper.log").toFile(); + builder.redirectOutput(logFile); + builder.redirectErrorStream(); + process = builder.start(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + ensureReaperAlive(); + } + } + + private Path locateReaperJar() { + URL main = this.getClass().getClassLoader().getResource(REAPER_CLASS_LOCATION); + if (main != null) { + String mainPath = main.getFile(); + Matcher matcher = REAPER_JAR_PATH_PATTERN.matcher(mainPath); + + if (matcher.matches()) { + String path = matcher.group(1); + return Paths.get(OS.conditional(c -> c.onWindows(() -> path.substring(1)).onUnix(() -> path))); + } + } + + throw new RuntimeException("Unable to locate " + REAPER_CLASS_LOCATION + " on classpath."); + } + + private void ensureReaperAlive() { + if (process.isAlive() == false) { + throw new IllegalStateException("Reaper process died unexpectedly! Check the log at " + reaperDir.resolve("reaper.log")); + } + } + + private Path findJavaHome() { + Path javaBase = Paths.get(System.getProperty("java.home")); + return javaBase.endsWith("jre") && Files.exists(javaBase.getParent().resolve("bin/java")) ? javaBase.getParent() : javaBase; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessUtils.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessUtils.java new file mode 100644 index 000000000000..2e41e89a3eca --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessUtils.java @@ -0,0 +1,177 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; + +public final class ProcessUtils { + private static final Logger LOGGER = LogManager.getLogger(ProcessUtils.class); + private static final Logger PROCESS_LOGGER = LogManager.getLogger("process-output"); + private static final Duration PROCESS_DESTROY_TIMEOUT = Duration.ofSeconds(20); + + private ProcessUtils() {} + + public static Process exec(Path workingDir, Path executable, Map environment, boolean inheritIO, String... args) { + return exec(null, workingDir, executable, environment, inheritIO, args); + } + + public static Process exec( + String input, + Path workingDir, + Path executable, + Map environment, + boolean inheritIO, + String... args + ) { + Process process; + Path inputFile = null; + + if (Files.exists(executable) == false) { + throw new IllegalArgumentException("Can't run executable: `" + executable + "` does not exist."); + } + + ProcessBuilder processBuilder = new ProcessBuilder(); + List command = new ArrayList<>(); + command.addAll( + OS.conditional( + c -> c.onWindows(() -> List.of("cmd", "/c", executable.toAbsolutePath().toString())) + .onUnix(() -> List.of(executable.toAbsolutePath().toString())) + ) + ); + command.addAll(Arrays.asList(args)); + + processBuilder.command(command); + processBuilder.directory(workingDir.toFile()); + processBuilder.environment().clear(); + processBuilder.environment().putAll(environment); + + if (input != null) { + try { + inputFile = Files.createTempFile("exec-input-", ".tmp"); + Files.writeString(inputFile, input); + processBuilder.redirectInput(inputFile.toFile()); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + try { + process = processBuilder.start(); + Process finalProcess = process; + + startLoggingThread( + finalProcess.getInputStream(), + inheritIO ? System.out::println : PROCESS_LOGGER::info, + executable.getFileName().toString() + ); + + startLoggingThread( + finalProcess.getErrorStream(), + inheritIO ? System.err::println : PROCESS_LOGGER::error, + executable.getFileName().toString() + ); + } catch (IOException e) { + throw new UncheckedIOException("Error executing process: " + executable.getFileName(), e); + } finally { + if (inputFile != null) { + IOUtils.uncheckedDeleteWithRetry(inputFile); + } + } + + return process; + } + + public static void stopHandle(ProcessHandle processHandle, boolean forcibly) { + // No-op if the process has already exited by itself. + if (processHandle.isAlive() == false) { + return; + } + + // Stop all children last - if the ML processes are killed before the ES JVM then + // they'll be recorded as having failed and won't restart when the cluster restarts. + // ES could actually be a child when there's some wrapper process like on Windows, + // and in that case the ML processes will be grandchildren of the wrapper. + List children = processHandle.children().toList(); + try { + LOGGER.info("Terminating Elasticsearch process {}: {}", forcibly ? " forcibly " : "gracefully", processHandle.info()); + + if (forcibly) { + processHandle.destroyForcibly(); + } else { + processHandle.destroy(); + waitForProcessToExit(processHandle); + if (processHandle.isAlive() == false) { + return; + } + LOGGER.info("Process did not terminate after {}, stopping it forcefully", PROCESS_DESTROY_TIMEOUT); + processHandle.destroyForcibly(); + } + + waitForProcessToExit(processHandle); + + if (processHandle.isAlive()) { + throw new RuntimeException("Failed to terminate terminate elasticsearch process."); + } + } finally { + children.forEach(each -> stopHandle(each, forcibly)); + } + } + + public static void waitForExit(ProcessHandle processHandle) { + // No-op if the process has already exited by itself. + if (processHandle.isAlive() == false) { + return; + } + + waitForProcessToExit(processHandle); + } + + private static void waitForProcessToExit(ProcessHandle processHandle) { + try { + Retry.retryUntilTrue(PROCESS_DESTROY_TIMEOUT, Duration.ofSeconds(1), () -> { + processHandle.destroy(); + return processHandle.isAlive() == false; + }); + } catch (ExecutionException e) { + LOGGER.info("Failure while waiting for process to exist", e); + } catch (TimeoutException e) { + LOGGER.info("Timed out waiting for process to exit", e); + } + } + + private static void startLoggingThread(InputStream is, Consumer logAppender, String name) { + new Thread(() -> { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { + String line; + while ((line = reader.readLine()) != null) { + logAppender.accept(line); + } + } catch (IOException e) { + throw new UncheckedIOException("Error reading output from process.", e); + } + }, name).start(); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Retry.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Retry.java new file mode 100644 index 000000000000..6ea36a38b717 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Retry.java @@ -0,0 +1,59 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util; + +import java.time.Duration; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public final class Retry { + private static final Executor EXECUTOR = new Executor() { + @Override + public void execute(Runnable command) { + new Thread(command).start(); + } + }; + + private Retry() {} + + public static void retryUntilTrue(Duration timeout, Duration delay, Callable predicate) throws TimeoutException, + ExecutionException { + getValueWithTimeout(timeout.toMillis(), TimeUnit.MILLISECONDS, () -> { + while (true) { + Boolean call = predicate.call(); + if (call) { + return true; + } + + Thread.sleep(delay.toMillis()); + } + }); + } + + private static T getValueWithTimeout(long timeout, TimeUnit timeUnit, Callable predicate) throws TimeoutException, + ExecutionException { + CompletableFuture future = CompletableFuture.supplyAsync(() -> { + try { + return predicate.call(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }, EXECUTOR); + + try { + return future.get(timeout, timeUnit); + } catch (InterruptedException e) { + throw new TimeoutException(); + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java new file mode 100644 index 000000000000..b83a6e8edf6c --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java @@ -0,0 +1,177 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ +package org.elasticsearch.test.cluster.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.io.UncheckedIOException; +import java.util.Objects; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Encapsulates comparison and printing logic for an x.y.z version. + */ +public final class Version implements Comparable, Serializable { + public static final Version CURRENT; + private static final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(?:-(alpha\\d+|beta\\d+|rc\\d+|SNAPSHOT))?"); + private static final Pattern relaxedPattern = Pattern.compile( + "v?(\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:[\\-+]+([a-zA-Z0-9_]+(?:-[a-zA-Z0-9]+)*))?" + ); + + private final int major; + private final int minor; + private final int revision; + private final int id; + private final String qualifier; + + static { + Properties versionProperties = new Properties(); + try (InputStream in = Version.class.getClassLoader().getResourceAsStream("version.properties")) { + versionProperties.load(in); + CURRENT = Version.fromString(versionProperties.getProperty("elasticsearch")); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Specifies how a version string should be parsed. + */ + public enum Mode { + /** + * Strict parsing only allows known suffixes after the patch number: "-alpha", "-beta" or "-rc". The + * suffix "-SNAPSHOT" is also allowed, either after the patch number, or after the other suffices. + */ + STRICT, + + /** + * Relaxed parsing allows any alphanumeric suffix after the patch number. + */ + RELAXED; + } + + public Version(int major, int minor, int revision) { + this(major, minor, revision, null); + } + + public Version(int major, int minor, int revision, String qualifier) { + this.major = major; + this.minor = minor; + this.revision = revision; + + // currently qualifier is not taken into account + this.id = major * 10000000 + minor * 100000 + revision * 1000; + + this.qualifier = qualifier; + } + + public static Version fromString(final String s) { + return fromString(s, Mode.STRICT); + } + + public static Version fromString(final String s, final Mode mode) { + Objects.requireNonNull(s); + Matcher matcher = mode == Mode.STRICT ? pattern.matcher(s) : relaxedPattern.matcher(s); + if (matcher.matches() == false) { + String expected = mode == Mode.STRICT + ? "major.minor.revision[-(alpha|beta|rc)Number|-SNAPSHOT]" + : "major.minor.revision[-extra]"; + throw new IllegalArgumentException("Invalid version format: '" + s + "'. Should be " + expected); + } + + String major = matcher.group(1); + String minor = matcher.group(2); + String revision = matcher.group(3); + String qualifier = matcher.group(4); + + return new Version(Integer.parseInt(major), Integer.parseInt(minor), revision == null ? 0 : Integer.parseInt(revision), qualifier); + } + + @Override + public String toString() { + return getMajor() + "." + getMinor() + "." + getRevision(); + } + + public boolean before(Version compareTo) { + return id < compareTo.getId(); + } + + public boolean before(String compareTo) { + return before(fromString(compareTo)); + } + + public boolean onOrBefore(Version compareTo) { + return id <= compareTo.getId(); + } + + public boolean onOrBefore(String compareTo) { + return onOrBefore(fromString(compareTo)); + } + + public boolean onOrAfter(Version compareTo) { + return id >= compareTo.getId(); + } + + public boolean onOrAfter(String compareTo) { + return onOrAfter(fromString(compareTo)); + } + + public boolean after(Version compareTo) { + return id > compareTo.getId(); + } + + public boolean after(String compareTo) { + return after(fromString(compareTo)); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Version version = (Version) o; + return major == version.major && minor == version.minor && revision == version.revision; + } + + @Override + public int hashCode() { + return Objects.hash(major, minor, revision, id); + } + + public int getMajor() { + return major; + } + + public int getMinor() { + return minor; + } + + public int getRevision() { + return revision; + } + + protected int getId() { + return id; + } + + public String getQualifier() { + return qualifier; + } + + @Override + public int compareTo(Version other) { + return Integer.compare(getId(), other.getId()); + } + +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/ClasspathTextResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/ClasspathTextResource.java new file mode 100644 index 000000000000..cdde9f10328d --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/ClasspathTextResource.java @@ -0,0 +1,55 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util.resource; + +import org.elasticsearch.test.cluster.util.IOUtils; + +import java.io.InputStream; +import java.util.HashSet; +import java.util.Set; + +class ClasspathTextResource implements TextResource { + private final String resourcePath; + + ClasspathTextResource(String resourcePath) { + this.resourcePath = resourcePath; + } + + @Override + public String getText() { + final Set classLoadersToSearch = new HashSet<>(); + // try context and system classloaders as well + classLoadersToSearch.add(Thread.currentThread().getContextClassLoader()); + classLoadersToSearch.add(ClassLoader.getSystemClassLoader()); + classLoadersToSearch.add(ClasspathTextResource.class.getClassLoader()); + + for (final ClassLoader classLoader : classLoadersToSearch) { + if (classLoader == null) { + continue; + } + + InputStream resource = classLoader.getResourceAsStream(resourcePath); + if (resource != null) { + return IOUtils.readStringFromStream(resource); + } + + // Be lenient if an absolute path was given + if (resourcePath.startsWith("/")) { + resource = classLoader.getResourceAsStream(resourcePath.replaceFirst("/", "")); + if (resource != null) { + return IOUtils.readStringFromStream(resource); + } + } + } + + throw new IllegalArgumentException( + "Resource with path " + resourcePath + " could not be found on any of these classloaders: " + classLoadersToSearch + ); + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/FileTextResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/FileTextResource.java new file mode 100644 index 000000000000..32929c8ec675 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/FileTextResource.java @@ -0,0 +1,32 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util.resource; + +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class FileTextResource implements TextResource { + private final Path file; + + FileTextResource(File file) { + this.file = file.toPath(); + } + + @Override + public String getText() { + try { + return Files.readString(file); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/StringTextResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/StringTextResource.java new file mode 100644 index 000000000000..1dacf5be8ed9 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/StringTextResource.java @@ -0,0 +1,22 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util.resource; + +class StringTextResource implements TextResource { + private final String text; + + StringTextResource(String text) { + this.text = text; + } + + @Override + public String getText() { + return text; + } +} diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/TextResource.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/TextResource.java new file mode 100644 index 000000000000..384dc09ba553 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/resource/TextResource.java @@ -0,0 +1,27 @@ +/* + * 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 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 or the Server + * Side Public License, v 1. + */ + +package org.elasticsearch.test.cluster.util.resource; + +import java.io.File; + +public interface TextResource { + String getText(); + + static TextResource fromString(String text) { + return new StringTextResource(text); + } + + static TextResource fromClasspath(String path) { + return new ClasspathTextResource(path); + } + + static TextResource fromFile(File file) { + return new FileTextResource(file); + } +} diff --git a/test/test-clusters/src/main/resources/default_test_roles.yml b/test/test-clusters/src/main/resources/default_test_roles.yml new file mode 100644 index 000000000000..433dfdf79719 --- /dev/null +++ b/test/test-clusters/src/main/resources/default_test_roles.yml @@ -0,0 +1,13 @@ + +# The roles below are automatically defined by the "testcluster" setup +_es_test_root: + cluster: [ "ALL" ] + indices: + - names: [ "*" ] + allow_restricted_indices: true + privileges: [ "ALL" ] + run_as: [ "*" ] + applications: + - application: "*" + privileges: [ "*" ] + resources: [ "*" ] diff --git a/x-pack/plugin/async-search/qa/rest/build.gradle b/x-pack/plugin/async-search/qa/rest/build.gradle index 276fdf3e19af..be36b5e3b4ab 100644 --- a/x-pack/plugin/async-search/qa/rest/build.gradle +++ b/x-pack/plugin/async-search/qa/rest/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { name 'x-pack-test-deprecated-query' diff --git a/x-pack/plugin/async-search/qa/security/build.gradle b/x-pack/plugin/async-search/qa/security/build.gradle index 0ae64a3bd81d..3e29a711b0a8 100644 --- a/x-pack/plugin/async-search/qa/security/build.gradle +++ b/x-pack/plugin/async-search/qa/security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/autoscaling/qa/rest/build.gradle b/x-pack/plugin/autoscaling/qa/rest/build.gradle index 304bbf0c6784..a8fce8e2b552 100644 --- a/x-pack/plugin/autoscaling/qa/rest/build.gradle +++ b/x-pack/plugin/autoscaling/qa/rest/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index 056a8c738f6c..9016ad33fc68 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -5,7 +5,7 @@ import org.elasticsearch.gradle.LoggedExec import org.elasticsearch.gradle.util.GradleUtils -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.validate-rest-spec' apply plugin: 'elasticsearch.internal-test-artifact' diff --git a/x-pack/plugin/ccr/qa/rest/build.gradle b/x-pack/plugin/ccr/qa/rest/build.gradle index de97ff7d6943..b4f6ae0b77c3 100644 --- a/x-pack/plugin/ccr/qa/rest/build.gradle +++ b/x-pack/plugin/ccr/qa/rest/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' restResources { restApi { diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index e941232da677..88394d4812e9 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -7,7 +7,7 @@ import java.nio.file.Paths apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.publish' apply plugin: 'elasticsearch.internal-cluster-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.internal-test-artifact' archivesBaseName = 'x-pack-core' diff --git a/x-pack/plugin/data-streams/qa/multi-node/build.gradle b/x-pack/plugin/data-streams/qa/multi-node/build.gradle index 429e4a01c593..da19980101fe 100644 --- a/x-pack/plugin/data-streams/qa/multi-node/build.gradle +++ b/x-pack/plugin/data-streams/qa/multi-node/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' File repoDir = file("$buildDir/testclusters/repo") diff --git a/x-pack/plugin/data-streams/qa/rest/build.gradle b/x-pack/plugin/data-streams/qa/rest/build.gradle index 5b8fd462d0ad..e512868e7e89 100644 --- a/x-pack/plugin/data-streams/qa/rest/build.gradle +++ b/x-pack/plugin/data-streams/qa/rest/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' restResources { restApi { @@ -26,4 +26,4 @@ if (BuildParams.inFipsJvm){ // Tracked in : tasks.named("javaRestTest").configure{enabled = false } tasks.named("yamlRestTest").configure{enabled = false } -} \ No newline at end of file +} diff --git a/x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle b/x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle index 65e571e9c284..3e0b02e8f71b 100644 --- a/x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle +++ b/x-pack/plugin/deprecation/qa/early-deprecation-rest/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { description 'Deprecated query plugin' diff --git a/x-pack/plugin/deprecation/qa/rest/build.gradle b/x-pack/plugin/deprecation/qa/rest/build.gradle index 33ada7c6a432..b7d4757f668c 100644 --- a/x-pack/plugin/deprecation/qa/rest/build.gradle +++ b/x-pack/plugin/deprecation/qa/rest/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { description 'Deprecated query plugin' diff --git a/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle b/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle index b2ddbc8aebf4..2e649e718b08 100644 --- a/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle +++ b/x-pack/plugin/enrich/qa/rest-with-advanced-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/enrich/qa/rest-with-security/build.gradle b/x-pack/plugin/enrich/qa/rest-with-security/build.gradle index a016c47de614..69fec4ad32c7 100644 --- a/x-pack/plugin/enrich/qa/rest-with-security/build.gradle +++ b/x-pack/plugin/enrich/qa/rest-with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/enrich/qa/rest/build.gradle b/x-pack/plugin/enrich/qa/rest/build.gradle index c3ee1e1b4dc6..3335cad6b4ac 100644 --- a/x-pack/plugin/enrich/qa/rest/build.gradle +++ b/x-pack/plugin/enrich/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/eql/qa/correctness/build.gradle b/x-pack/plugin/eql/qa/correctness/build.gradle index 8e096aa571d5..d0609790fc12 100644 --- a/x-pack/plugin/eql/qa/correctness/build.gradle +++ b/x-pack/plugin/eql/qa/correctness/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'elasticsearch.java' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-testclusters' import org.elasticsearch.gradle.testclusters.RunTask diff --git a/x-pack/plugin/eql/qa/mixed-node/build.gradle b/x-pack/plugin/eql/qa/mixed-node/build.gradle index ff2f268c5a0f..4b3bf06eeb91 100644 --- a/x-pack/plugin/eql/qa/mixed-node/build.gradle +++ b/x-pack/plugin/eql/qa/mixed-node/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.bwc-test' import org.elasticsearch.gradle.VersionProperties diff --git a/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle b/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle index a72095010aad..5dd7fcd59e75 100644 --- a/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle +++ b/x-pack/plugin/eql/qa/multi-cluster-with-security/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(path: xpackModule('eql:qa:common')) diff --git a/x-pack/plugin/eql/qa/rest/build.gradle b/x-pack/plugin/eql/qa/rest/build.gradle index cb816930ab6f..503cb1aaf604 100644 --- a/x-pack/plugin/eql/qa/rest/build.gradle +++ b/x-pack/plugin/eql/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/eql/qa/security/build.gradle b/x-pack/plugin/eql/qa/security/build.gradle index d13c3570ee61..bcc9d0cb4ef8 100644 --- a/x-pack/plugin/eql/qa/security/build.gradle +++ b/x-pack/plugin/eql/qa/security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/fleet/build.gradle b/x-pack/plugin/fleet/build.gradle index c1aea7339242..ce1f90651254 100644 --- a/x-pack/plugin/fleet/build.gradle +++ b/x-pack/plugin/fleet/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { name 'x-pack-fleet' diff --git a/x-pack/plugin/fleet/qa/rest/build.gradle b/x-pack/plugin/fleet/qa/rest/build.gradle index 8a9736c710b3..7dfbfaafa7d3 100644 --- a/x-pack/plugin/fleet/qa/rest/build.gradle +++ b/x-pack/plugin/fleet/qa/rest/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/graph/qa/with-security/build.gradle b/x-pack/plugin/graph/qa/with-security/build.gradle index cbe0c7740675..757230cd57bc 100644 --- a/x-pack/plugin/graph/qa/with-security/build.gradle +++ b/x-pack/plugin/graph/qa/with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(":x-pack:plugin:core") diff --git a/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle b/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle index 42ad77114511..ad0d23263689 100644 --- a/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle +++ b/x-pack/plugin/identity-provider/qa/idp-rest-tests/build.gradle @@ -1,5 +1,5 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/ilm/qa/multi-node/build.gradle b/x-pack/plugin/ilm/qa/multi-node/build.gradle index cf314f88f584..e1fdde749940 100644 --- a/x-pack/plugin/ilm/qa/multi-node/build.gradle +++ b/x-pack/plugin/ilm/qa/multi-node/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/ilm/qa/rest/build.gradle b/x-pack/plugin/ilm/qa/rest/build.gradle index dcee7e5f4880..d067e7332642 100644 --- a/x-pack/plugin/ilm/qa/rest/build.gradle +++ b/x-pack/plugin/ilm/qa/rest/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/plugin/ilm/qa/with-security/build.gradle b/x-pack/plugin/ilm/qa/with-security/build.gradle index 8f72a23d195f..1a7944fe92e4 100644 --- a/x-pack/plugin/ilm/qa/with-security/build.gradle +++ b/x-pack/plugin/ilm/qa/with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/plugin/logstash/build.gradle b/x-pack/plugin/logstash/build.gradle index 1ac4fb75be1c..9fc7e642820e 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.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { name 'x-pack-logstash' diff --git a/x-pack/plugin/mapper-unsigned-long/build.gradle b/x-pack/plugin/mapper-unsigned-long/build.gradle index 67fba601e14f..488dde9bffcc 100644 --- a/x-pack/plugin/mapper-unsigned-long/build.gradle +++ b/x-pack/plugin/mapper-unsigned-long/build.gradle @@ -8,7 +8,7 @@ evaluationDependsOn(xpackModule('core')) apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { name 'unsigned-long' diff --git a/x-pack/plugin/ml/qa/basic-multi-node/build.gradle b/x-pack/plugin/ml/qa/basic-multi-node/build.gradle index 2234f5e43d51..72793d1f9a41 100644 --- a/x-pack/plugin/ml/qa/basic-multi-node/build.gradle +++ b/x-pack/plugin/ml/qa/basic-multi-node/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.configureEach { testDistribution = 'DEFAULT' diff --git a/x-pack/plugin/ml/qa/disabled/build.gradle b/x-pack/plugin/ml/qa/disabled/build.gradle index b0690460115d..97a7b0eed73a 100644 --- a/x-pack/plugin/ml/qa/disabled/build.gradle +++ b/x-pack/plugin/ml/qa/disabled/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' //dependencies { // testImplementation project(":x-pack:plugin:core") diff --git a/x-pack/plugin/ml/qa/ml-with-security/build.gradle b/x-pack/plugin/ml/qa/ml-with-security/build.gradle index ca1baa3bb539..f9ae4f2cd156 100644 --- a/x-pack/plugin/ml/qa/ml-with-security/build.gradle +++ b/x-pack/plugin/ml/qa/ml-with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle index fe1c304c120b..76b2aaa7ebc8 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle @@ -1,5 +1,5 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/ml/qa/single-node-tests/build.gradle b/x-pack/plugin/ml/qa/single-node-tests/build.gradle index cf1d2571c2d9..eb86ca600d75 100644 --- a/x-pack/plugin/ml/qa/single-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/single-node-tests/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.configureEach { testDistribution = 'DEFAULT' diff --git a/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle b/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle index 1d8ac0a2c19d..23f71f1ecb2e 100644 --- a/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/azure/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:azure-fixture') diff --git a/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle b/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle index 7cdf00f9346b..cf4151ea6ad5 100644 --- a/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/gcs/build.gradle @@ -14,7 +14,7 @@ import java.security.KeyPairGenerator import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:gcs-fixture') diff --git a/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle b/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle index dad90cf20de6..2b66cc76976c 100644 --- a/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle +++ b/x-pack/plugin/repositories-metering-api/qa/s3/build.gradle @@ -1,7 +1,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:s3-fixture') diff --git a/x-pack/plugin/rollup/qa/rest/build.gradle b/x-pack/plugin/rollup/qa/rest/build.gradle index 799ac21583f2..5cb3fe73e627 100644 --- a/x-pack/plugin/rollup/qa/rest/build.gradle +++ b/x-pack/plugin/rollup/qa/rest/build.gradle @@ -6,7 +6,7 @@ */ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(path: xpackModule('rollup')) diff --git a/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle index 05723bd29d26..0368739b5aae 100644 --- a/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:azure-fixture') diff --git a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle index 7c20243b9ba9..10daf32e8ecb 100644 --- a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle @@ -7,7 +7,7 @@ import java.security.KeyPairGenerator import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:gcs-fixture') diff --git a/x-pack/plugin/searchable-snapshots/qa/hdfs/build.gradle b/x-pack/plugin/searchable-snapshots/qa/hdfs/build.gradle index 83770c5eacbf..f422cce0b539 100644 --- a/x-pack/plugin/searchable-snapshots/qa/hdfs/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/hdfs/build.gradle @@ -16,7 +16,7 @@ import java.nio.file.Paths import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE apply plugin: 'elasticsearch.test.fixtures' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.internal-available-ports' diff --git a/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle b/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle index 8f5f211454fc..43a89701f4d2 100644 --- a/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/minio/build.gradle @@ -1,6 +1,6 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test.fixtures' apply plugin: 'elasticsearch.rest-resources' diff --git a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle index 1587fc116070..532461cbb77c 100644 --- a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('searchable-snapshots')))) diff --git a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle index 03dbf3e5fd22..eebe33724ae0 100644 --- a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle @@ -1,7 +1,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:s3-fixture') diff --git a/x-pack/plugin/searchable-snapshots/qa/url/build.gradle b/x-pack/plugin/searchable-snapshots/qa/url/build.gradle index 0faab0acfe61..160eb8d28cbc 100644 --- a/x-pack/plugin/searchable-snapshots/qa/url/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/url/build.gradle @@ -1,6 +1,6 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:nginx-fixture') diff --git a/x-pack/plugin/security/qa/basic-enable-security/build.gradle b/x-pack/plugin/security/qa/basic-enable-security/build.gradle index 17b9e220e940..7fa75ff568df 100644 --- a/x-pack/plugin/security/qa/basic-enable-security/build.gradle +++ b/x-pack/plugin/security/qa/basic-enable-security/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' //randomise between implicitly and explicitly disabled security boolean implicitlyDisabledSecurity = (new Random(Long.parseUnsignedLong(BuildParams.testSeed.tokenize(':').get(0), 16))).nextBoolean() diff --git a/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle b/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle index 9e816aff5179..d39186906065 100644 --- a/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle +++ b/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.Version apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { name 'operator-privileges-test' diff --git a/x-pack/plugin/security/qa/security-basic/build.gradle b/x-pack/plugin/security/qa/security-basic/build.gradle index b6aed6bb26e9..10a808178965 100644 --- a/x-pack/plugin/security/qa/security-basic/build.gradle +++ b/x-pack/plugin/security/qa/security-basic/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/security/qa/security-disabled/build.gradle b/x-pack/plugin/security/qa/security-disabled/build.gradle index e1d850c4adb9..e3d9c2f4f65b 100644 --- a/x-pack/plugin/security/qa/security-disabled/build.gradle +++ b/x-pack/plugin/security/qa/security-disabled/build.gradle @@ -7,7 +7,7 @@ */ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('security')))) diff --git a/x-pack/plugin/security/qa/security-not-enabled/build.gradle b/x-pack/plugin/security/qa/security-not-enabled/build.gradle index d24d64994037..25a6a3a4e753 100644 --- a/x-pack/plugin/security/qa/security-not-enabled/build.gradle +++ b/x-pack/plugin/security/qa/security-not-enabled/build.gradle @@ -6,7 +6,7 @@ * defined, it should be not fail */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('security')))) diff --git a/x-pack/plugin/security/qa/security-trial/build.gradle b/x-pack/plugin/security/qa/security-trial/build.gradle index 6910525b56a9..7831e019b127 100644 --- a/x-pack/plugin/security/qa/security-trial/build.gradle +++ b/x-pack/plugin/security/qa/security-trial/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(path: xpackModule('core')) diff --git a/x-pack/plugin/security/qa/service-account/build.gradle b/x-pack/plugin/security/qa/service-account/build.gradle index 98253ef4643b..2cc2dda30d2a 100644 --- a/x-pack/plugin/security/qa/service-account/build.gradle +++ b/x-pack/plugin/security/qa/service-account/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(':x-pack:plugin:core') diff --git a/x-pack/plugin/security/qa/smoke-test-all-realms/build.gradle b/x-pack/plugin/security/qa/smoke-test-all-realms/build.gradle index be6a175dac6b..43c47a8f6285 100644 --- a/x-pack/plugin/security/qa/smoke-test-all-realms/build.gradle +++ b/x-pack/plugin/security/qa/smoke-test-all-realms/build.gradle @@ -6,7 +6,7 @@ * This test is also intended to work correctly on FIPS mode because we also want to know if a realm breaks on FIPS. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('security')))) diff --git a/x-pack/plugin/security/qa/tls-basic/build.gradle b/x-pack/plugin/security/qa/tls-basic/build.gradle index 5f638a247ec7..fee0b78c0bba 100644 --- a/x-pack/plugin/security/qa/tls-basic/build.gradle +++ b/x-pack/plugin/security/qa/tls-basic/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' import org.elasticsearch.gradle.internal.info.BuildParams diff --git a/x-pack/plugin/shutdown/qa/multi-node/build.gradle b/x-pack/plugin/shutdown/qa/multi-node/build.gradle index 262bd12a7e4f..de3a98635592 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/build.gradle +++ b/x-pack/plugin/shutdown/qa/multi-node/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.VersionProperties -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle index abf3a6b569ff..f0102a13b61e 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle @@ -8,7 +8,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:azure-fixture') diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/gcs/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/gcs/build.gradle index dd50e74aafd4..80ff80a82282 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/gcs/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/gcs/build.gradle @@ -13,7 +13,7 @@ import java.security.KeyPairGenerator import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:gcs-fixture') diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/hdfs/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/hdfs/build.gradle index 2b51ae6b785f..47b6cb5136de 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/hdfs/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/hdfs/build.gradle @@ -17,7 +17,7 @@ import java.nio.file.Paths import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE apply plugin: 'elasticsearch.test.fixtures' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' apply plugin: 'elasticsearch.internal-available-ports' diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/minio/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/minio/build.gradle index 2978e32e6648..c48c973a0216 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/minio/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/minio/build.gradle @@ -7,7 +7,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test.fixtures' apply plugin: 'elasticsearch.rest-resources' diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/rest/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/rest/build.gradle index dd5a54e828cd..6b32e11ef81d 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/rest/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/rest/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.rest-resources' dependencies { diff --git a/x-pack/plugin/snapshot-repo-test-kit/qa/s3/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/s3/build.gradle index 4779ce5ec77f..689beedb8e6d 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/qa/s3/build.gradle +++ b/x-pack/plugin/snapshot-repo-test-kit/qa/s3/build.gradle @@ -7,7 +7,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.rest-resources' final Project fixture = project(':test:fixtures:s3-fixture') diff --git a/x-pack/plugin/sql/qa/jdbc/build.gradle b/x-pack/plugin/sql/qa/jdbc/build.gradle index cf333e05fed8..c5343b50efc1 100644 --- a/x-pack/plugin/sql/qa/jdbc/build.gradle +++ b/x-pack/plugin/sql/qa/jdbc/build.gradle @@ -52,7 +52,7 @@ subprojects { if (project.name != 'security') { // The security project just configures its subprojects - apply plugin: 'elasticsearch.internal-java-rest-test' + apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(xpackProject('plugin:sql:qa:jdbc')) diff --git a/x-pack/plugin/sql/qa/mixed-node/build.gradle b/x-pack/plugin/sql/qa/mixed-node/build.gradle index eb17cdd0b9a0..d42cd428ee74 100644 --- a/x-pack/plugin/sql/qa/mixed-node/build.gradle +++ b/x-pack/plugin/sql/qa/mixed-node/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.bwc-test' import org.elasticsearch.gradle.VersionProperties diff --git a/x-pack/plugin/sql/qa/server/build.gradle b/x-pack/plugin/sql/qa/server/build.gradle index 493abcb92377..833f191adc52 100644 --- a/x-pack/plugin/sql/qa/server/build.gradle +++ b/x-pack/plugin/sql/qa/server/build.gradle @@ -41,7 +41,7 @@ subprojects { if (project.name != 'security') { // The security project just configures its subprojects - apply plugin: 'elasticsearch.internal-java-rest-test' + apply plugin: 'elasticsearch.legacy-java-rest-test' testClusters.matching { it.name == "javaRestTest" }.configureEach { testDistribution = 'DEFAULT' diff --git a/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle b/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle index 34436bf4e4be..ed2274b50eac 100644 --- a/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle +++ b/x-pack/plugin/sql/qa/server/multi-cluster-with-security/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(path: xpackModule('ql:test-fixtures')) diff --git a/x-pack/plugin/stack/qa/rest/build.gradle b/x-pack/plugin/stack/qa/rest/build.gradle index 99a53a576721..b94a5048ab20 100644 --- a/x-pack/plugin/stack/qa/rest/build.gradle +++ b/x-pack/plugin/stack/qa/rest/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle b/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle index 61e208b16762..f800da4fdc2c 100644 --- a/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle +++ b/x-pack/plugin/text-structure/qa/text-structure-with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle index 18e7344734dc..b5df43030bc0 100644 --- a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle +++ b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/transform/qa/single-node-tests/build.gradle b/x-pack/plugin/transform/qa/single-node-tests/build.gradle index ecff1554e1a8..1188b05b9dda 100644 --- a/x-pack/plugin/transform/qa/single-node-tests/build.gradle +++ b/x-pack/plugin/transform/qa/single-node-tests/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/vector-tile/build.gradle b/x-pack/plugin/vector-tile/build.gradle index 46c3e2830ffb..c4833440c24d 100644 --- a/x-pack/plugin/vector-tile/build.gradle +++ b/x-pack/plugin/vector-tile/build.gradle @@ -14,7 +14,7 @@ */ apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' esplugin { name 'vector-tile' diff --git a/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle b/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle index 7574e571ec32..40ae6babbebf 100644 --- a/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle +++ b/x-pack/plugin/vector-tile/qa/multi-cluster/build.gradle @@ -7,7 +7,7 @@ import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(':x-pack:plugin:vector-tile') diff --git a/x-pack/plugin/watcher/qa/rest/build.gradle b/x-pack/plugin/watcher/qa/rest/build.gradle index 9f0cb1bf47ae..77b2a7cef53b 100644 --- a/x-pack/plugin/watcher/qa/rest/build.gradle +++ b/x-pack/plugin/watcher/qa/rest/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(path: ':x-pack:plugin:watcher:qa:common') diff --git a/x-pack/plugin/watcher/qa/with-monitoring/build.gradle b/x-pack/plugin/watcher/qa/with-monitoring/build.gradle index b1f8d157394e..6a2ef6fbd7bd 100644 --- a/x-pack/plugin/watcher/qa/with-monitoring/build.gradle +++ b/x-pack/plugin/watcher/qa/with-monitoring/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(':x-pack:qa') diff --git a/x-pack/plugin/watcher/qa/with-security/build.gradle b/x-pack/plugin/watcher/qa/with-security/build.gradle index 8dffaad910f1..59b27e1446e1 100644 --- a/x-pack/plugin/watcher/qa/with-security/build.gradle +++ b/x-pack/plugin/watcher/qa/with-security/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(path: ':x-pack:plugin:watcher:qa:common') diff --git a/x-pack/qa/core-rest-tests-with-security/build.gradle b/x-pack/qa/core-rest-tests-with-security/build.gradle index 88ae1208b04b..bce1ad9a355d 100644 --- a/x-pack/qa/core-rest-tests-with-security/build.gradle +++ b/x-pack/qa/core-rest-tests-with-security/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/qa/kerberos-tests/build.gradle b/x-pack/qa/kerberos-tests/build.gradle index b04cdc8078d8..536758dcfb71 100644 --- a/x-pack/qa/kerberos-tests/build.gradle +++ b/x-pack/qa/kerberos-tests/build.gradle @@ -1,7 +1,7 @@ import java.nio.file.Path import java.nio.file.Paths -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test.fixtures' testFixtures.useFixture ":test:fixtures:krb5kdc-fixture", "peppa" diff --git a/x-pack/qa/mixed-tier-cluster/build.gradle b/x-pack/qa/mixed-tier-cluster/build.gradle index 09989e5121f3..dfee139d601c 100644 --- a/x-pack/qa/mixed-tier-cluster/build.gradle +++ b/x-pack/qa/mixed-tier-cluster/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.bwc-test' import org.elasticsearch.gradle.VersionProperties diff --git a/x-pack/qa/multi-node/build.gradle b/x-pack/qa/multi-node/build.gradle index 8e5b77e8afa0..996975999347 100644 --- a/x-pack/qa/multi-node/build.gradle +++ b/x-pack/qa/multi-node/build.gradle @@ -4,14 +4,6 @@ dependencies { javaRestTestImplementation project(':x-pack:qa') } -testClusters.matching { it.name == "javaRestTest" }.configureEach { - testDistribution = 'DEFAULT' - numberOfNodes = 2 - setting 'xpack.security.enabled', 'true' - setting 'xpack.watcher.enabled', 'false' - setting 'xpack.ml.enabled', 'false' - setting 'xpack.license.self_generated.type', 'trial' - extraConfigFile 'roles.yml', file('roles.yml') - user username: "test-user", password: "x-pack-test-password", role: "test" - user username: "super-user", password: "x-pack-super-password" +tasks.named("javaRestTest") { + usesDefaultDistribution() } diff --git a/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/GlobalCheckpointSyncActionIT.java b/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/GlobalCheckpointSyncActionIT.java index c17446c05d84..c4548c1712bb 100644 --- a/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/GlobalCheckpointSyncActionIT.java +++ b/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/GlobalCheckpointSyncActionIT.java @@ -12,14 +12,30 @@ import org.elasticsearch.common.Strings; 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.distribution.DistributionType; +import org.elasticsearch.test.cluster.util.resource.TextResource; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; import org.elasticsearch.xcontent.XContentBuilder; +import org.junit.ClassRule; import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.equalTo; public class GlobalCheckpointSyncActionIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .nodes(2) + .distribution(DistributionType.DEFAULT) + .setting("xpack.security.enabled", "true") + .setting("xpack.watcher.enabled", "false") + .setting("xpack.ml.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + .rolesFile(TextResource.fromClasspath("roles.yml")) + .user("test-user", "x-pack-test-password", "test") + .user("super-user", "x-pack-super-password") + .build(); @Override protected Settings restClientSettings() { @@ -31,6 +47,11 @@ public class GlobalCheckpointSyncActionIT extends ESRestTestCase { return getClientSettings("super-user", "x-pack-super-password"); } + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + private Settings getClientSettings(final String username, final String password) { final String token = basicAuthHeaderValue(username, new SecureString(password.toCharArray())); return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build(); diff --git a/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/RollupIT.java b/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/RollupIT.java index d6883b7d5929..b141fdded605 100644 --- a/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/RollupIT.java +++ b/x-pack/qa/multi-node/src/javaRestTest/java/org/elasticsearch/multi_node/RollupIT.java @@ -18,10 +18,13 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.ObjectPath; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.json.JsonXContent; +import org.junit.ClassRule; import java.io.IOException; import java.time.Instant; @@ -38,6 +41,16 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.oneOf; public class RollupIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .nodes(2) + .distribution(DistributionType.DEFAULT) + .setting("xpack.security.enabled", "true") + .setting("xpack.watcher.enabled", "false") + .setting("xpack.ml.enabled", "false") + .setting("xpack.license.self_generated.type", "trial") + .user("super-user", "x-pack-super-password") + .build(); @Override protected Settings restClientSettings() { @@ -49,6 +62,11 @@ public class RollupIT extends ESRestTestCase { return getClientSettings("super-user", "x-pack-super-password"); } + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + private Settings getClientSettings(final String username, final String password) { final String token = basicAuthHeaderValue(username, new SecureString(password.toCharArray())); return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", token).build(); diff --git a/x-pack/qa/multi-node/roles.yml b/x-pack/qa/multi-node/src/javaRestTest/resources/roles.yml similarity index 100% rename from x-pack/qa/multi-node/roles.yml rename to x-pack/qa/multi-node/src/javaRestTest/resources/roles.yml diff --git a/x-pack/qa/oidc-op-tests/build.gradle b/x-pack/qa/oidc-op-tests/build.gradle index d9394a8b3ce3..aa4c1e2d0d22 100644 --- a/x-pack/qa/oidc-op-tests/build.gradle +++ b/x-pack/qa/oidc-op-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test.fixtures' dependencies { diff --git a/x-pack/qa/password-protected-keystore/build.gradle b/x-pack/qa/password-protected-keystore/build.gradle index da57c7f09cc5..883ee37ec672 100644 --- a/x-pack/qa/password-protected-keystore/build.gradle +++ b/x-pack/qa/password-protected-keystore/build.gradle @@ -3,7 +3,7 @@ * is using a password protected keystore in its nodes. */ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(path: xpackModule('core')) diff --git a/x-pack/qa/reindex-tests-with-security/build.gradle b/x-pack/qa/reindex-tests-with-security/build.gradle index 987458349185..de9f87d75506 100644 --- a/x-pack/qa/reindex-tests-with-security/build.gradle +++ b/x-pack/qa/reindex-tests-with-security/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.rest-resources' dependencies { diff --git a/x-pack/qa/runtime-fields/build.gradle b/x-pack/qa/runtime-fields/build.gradle index 887c9018bbe0..3701508d74f1 100644 --- a/x-pack/qa/runtime-fields/build.gradle +++ b/x-pack/qa/runtime-fields/build.gradle @@ -9,7 +9,7 @@ tasks.named("test").configure { enabled = false } subprojects { if (project.name.startsWith('core-with-')) { - apply plugin: 'elasticsearch.internal-yaml-rest-test' + apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation xpackProject(":x-pack:qa:runtime-fields") diff --git a/x-pack/qa/runtime-fields/with-security/build.gradle b/x-pack/qa/runtime-fields/with-security/build.gradle index 95a874014ccb..e4577328c881 100644 --- a/x-pack/qa/runtime-fields/with-security/build.gradle +++ b/x-pack/qa/runtime-fields/with-security/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.authenticated-testclusters' dependencies { diff --git a/x-pack/qa/saml-idp-tests/build.gradle b/x-pack/qa/saml-idp-tests/build.gradle index b8b92f90c6ce..ef76f19b704f 100644 --- a/x-pack/qa/saml-idp-tests/build.gradle +++ b/x-pack/qa/saml-idp-tests/build.gradle @@ -2,7 +2,7 @@ import org.elasticsearch.gradle.LazyPropertyMap Project idpFixtureProject = xpackProject("test:idp-fixture") -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.test.fixtures' dependencies { diff --git a/x-pack/qa/security-client-tests/build.gradle b/x-pack/qa/security-client-tests/build.gradle index c74faa0eb659..ada6f1c4b810 100644 --- a/x-pack/qa/security-client-tests/build.gradle +++ b/x-pack/qa/security-client-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(xpackModule('core')) diff --git a/x-pack/qa/security-example-spi-extension/build.gradle b/x-pack/qa/security-example-spi-extension/build.gradle index 809dec14ae1d..a95f3fd42cd1 100644 --- a/x-pack/qa/security-example-spi-extension/build.gradle +++ b/x-pack/qa/security-example-spi-extension/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.base-internal-es-plugin' esplugin { diff --git a/x-pack/qa/security-migrate-tests/build.gradle b/x-pack/qa/security-migrate-tests/build.gradle index a6f0c5f07852..ee029ff1526b 100644 --- a/x-pack/qa/security-migrate-tests/build.gradle +++ b/x-pack/qa/security-migrate-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(xpackModule('core')) @@ -27,4 +27,4 @@ tasks.matching { it.name.equals('javaRestTest')}.configureEach {integTestTask -> tasks.named('javaRestTestTestingConventions').configure { baseClass 'org.elasticsearch.xpack.security.MigrateToolTestCase' -} \ No newline at end of file +} diff --git a/x-pack/qa/security-setup-password-tests/build.gradle b/x-pack/qa/security-setup-password-tests/build.gradle index fcbf3f745cc5..7d9f621bbd3f 100644 --- a/x-pack/qa/security-setup-password-tests/build.gradle +++ b/x-pack/qa/security-setup-password-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(path: xpackModule('security')) diff --git a/x-pack/qa/smoke-test-plugins-ssl/build.gradle b/x-pack/qa/smoke-test-plugins-ssl/build.gradle index d0d70007dc6f..92921722058a 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/build.gradle +++ b/x-pack/qa/smoke-test-plugins-ssl/build.gradle @@ -2,7 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':x-pack:plugin:core') diff --git a/x-pack/qa/smoke-test-plugins/build.gradle b/x-pack/qa/smoke-test-plugins/build.gradle index 407d00d9aeb6..0a848b787bb7 100644 --- a/x-pack/qa/smoke-test-plugins/build.gradle +++ b/x-pack/qa/smoke-test-plugins/build.gradle @@ -1,7 +1,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' apply plugin: 'elasticsearch.rest-resources' dependencies { diff --git a/x-pack/qa/smoke-test-security-with-mustache/build.gradle b/x-pack/qa/smoke-test-security-with-mustache/build.gradle index c3bebeb17817..373e6966df51 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/build.gradle +++ b/x-pack/qa/smoke-test-security-with-mustache/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':x-pack:qa') diff --git a/x-pack/qa/third-party/jira/build.gradle b/x-pack/qa/third-party/jira/build.gradle index 84e0d7dc50bb..b7268af80753 100644 --- a/x-pack/qa/third-party/jira/build.gradle +++ b/x-pack/qa/third-party/jira/build.gradle @@ -5,7 +5,7 @@ import java.nio.charset.StandardCharsets import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':x-pack:plugin:core') diff --git a/x-pack/qa/third-party/pagerduty/build.gradle b/x-pack/qa/third-party/pagerduty/build.gradle index b7adeb9c6e66..4b5a0bbeeeb4 100644 --- a/x-pack/qa/third-party/pagerduty/build.gradle +++ b/x-pack/qa/third-party/pagerduty/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':x-pack:plugin:core') diff --git a/x-pack/qa/third-party/slack/build.gradle b/x-pack/qa/third-party/slack/build.gradle index a298a1531a8d..b2b0478da047 100644 --- a/x-pack/qa/third-party/slack/build.gradle +++ b/x-pack/qa/third-party/slack/build.gradle @@ -1,6 +1,6 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' dependencies { yamlRestTestImplementation project(':x-pack:plugin:core') diff --git a/x-pack/qa/transport-client-tests/build.gradle b/x-pack/qa/transport-client-tests/build.gradle index ff48c5e6b93d..f16bfed0e5a6 100644 --- a/x-pack/qa/transport-client-tests/build.gradle +++ b/x-pack/qa/transport-client-tests/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' dependencies { javaRestTestImplementation project(xpackModule('core'))