From c2eda511de8c793cec480a1a25683b40c0088f66 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Wed, 21 Dec 2022 15:33:46 -0800 Subject: [PATCH] Add JUnit rule based integration test cluster orchestration framework (#92379) 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 | 14 +- .../AbstractRestResourcesFuncTest.groovy | 1 + ...gConventionsPrecommitPluginFuncTest.groovy | 18 +- ...cyYamlRestCompatTestPluginFuncTest.groovy} | 10 +- ...> LegacyYamlRestTestPluginFuncTest.groovy} | 8 +- .../gradle/internal/doc/DocsTestPlugin.groovy | 2 +- .../internal/ResolveAllDependencies.java | 2 +- .../TestingConventionsPrecommitPlugin.java | 18 +- ...gin.java => LegacyRestTestBasePlugin.java} | 32 +- .../test/StandaloneRestTestPlugin.java | 10 +- .../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 | 227 ++++++++ .../internal/test/rest/RestTestUtil.java | 22 +- .../AbstractYamlRestCompatTestPlugin.java} | 35 +- .../LegacyYamlRestCompatTestPlugin.java | 44 ++ .../compat/RestCompatTestTransformTask.java | 2 +- .../compat/YamlRestCompatTestPlugin.java | 42 ++ .../StandaloneRestIntegTestTask.java | 5 - .../archives/integ-test-zip/build.gradle | 2 +- distribution/build.gradle | 12 +- distribution/docker/build.gradle | 2 +- modules/aggregations/build.gradle | 4 +- modules/aggs-matrix-stats/build.gradle | 4 +- modules/analysis-common/build.gradle | 4 +- modules/data-streams/build.gradle | 6 +- modules/ingest-attachment/build.gradle | 4 +- modules/ingest-common/build.gradle | 4 +- modules/ingest-geoip/build.gradle | 4 +- .../qa/file-based-update/build.gradle | 2 +- modules/ingest-user-agent/build.gradle | 4 +- modules/kibana/build.gradle | 2 +- modules/lang-expression/build.gradle | 4 +- modules/lang-mustache/build.gradle | 6 +- modules/lang-painless/build.gradle | 4 +- modules/mapper-extras/build.gradle | 4 +- modules/parent-join/build.gradle | 4 +- modules/percolator/build.gradle | 4 +- modules/rank-eval/build.gradle | 4 +- modules/reindex/build.gradle | 6 +- modules/repository-azure/build.gradle | 2 +- modules/repository-gcs/build.gradle | 8 +- modules/repository-s3/build.gradle | 10 +- modules/repository-url/build.gradle | 4 +- modules/runtime-fields-common/build.gradle | 4 +- modules/transport-netty4/build.gradle | 10 +- plugins/analysis-icu/build.gradle | 4 +- plugins/analysis-kuromoji/build.gradle | 4 +- plugins/analysis-nori/build.gradle | 4 +- plugins/analysis-phonetic/build.gradle | 4 +- plugins/analysis-smartcn/build.gradle | 4 +- plugins/analysis-stempel/build.gradle | 4 +- plugins/analysis-ukrainian/build.gradle | 4 +- 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/mapper-annotated-text/build.gradle | 4 +- plugins/mapper-murmur3/build.gradle | 4 +- .../size/MapperSizeClientYamlTestSuiteIT.java | 10 + plugins/repository-hdfs/build.gradle | 4 +- plugins/store-smb/build.gradle | 2 +- qa/ccs-unavailable-clusters/build.gradle | 2 +- qa/smoke-test-http/build.gradle | 2 +- qa/smoke-test-ingest-disabled/build.gradle | 2 +- .../build.gradle | 4 +- qa/smoke-test-multinode/build.gradle | 2 +- qa/smoke-test-plugins/build.gradle | 2 +- qa/system-indices/build.gradle | 2 +- qa/unconfigured-node-name/build.gradle | 2 +- rest-api-spec/build.gradle | 5 +- .../test/rest/ClientYamlTestSuiteIT.java | 14 + settings.gradle | 5 +- test/external-modules/build.gradle | 2 +- .../die-with-dignity/build.gradle | 2 +- test/test-clusters/build.gradle | 15 + .../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 | 152 ++++++ .../local/DefaultSettingsProvider.java | 74 +++ .../local/LocalClusterConfigProvider.java | 14 + .../cluster/local/LocalClusterFactory.java | 503 ++++++++++++++++++ .../cluster/local/LocalClusterHandle.java | 155 ++++++ .../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 | 153 ++++++ .../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 + test/yaml-rest-runner/build.gradle | 4 +- .../plugin/async-search/qa/rest/build.gradle | 4 +- .../async-search/qa/security/build.gradle | 2 +- .../plugin/autoscaling/qa/rest/build.gradle | 4 +- x-pack/plugin/build.gradle | 6 +- x-pack/plugin/ccr/qa/rest/build.gradle | 4 +- x-pack/plugin/core/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 | 6 +- 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 | 6 +- 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 | 4 +- .../plugin/ilm/qa/with-security/build.gradle | 2 +- x-pack/plugin/logstash/build.gradle | 2 +- .../mapper-constant-keyword/build.gradle | 2 +- .../plugin/mapper-unsigned-long/build.gradle | 4 +- x-pack/plugin/mapper-version/build.gradle | 4 +- .../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/semantic-search-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 | 4 +- .../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 | 6 +- .../searchable-snapshots/qa/s3/build.gradle | 2 +- .../searchable-snapshots/qa/url/build.gradle | 2 +- .../qa/basic-enable-security/build.gradle | 2 +- .../plugin/security/qa/jwt-realm/build.gradle | 2 +- .../qa/operator-privileges-tests/build.gradle | 2 +- .../plugin/security/qa/profile/build.gradle | 2 +- .../security/qa/security-basic/build.gradle | 2 +- .../qa/security-disabled/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/fs/build.gradle | 2 +- .../qa/gcs/build.gradle | 2 +- .../qa/license-enforcing/build.gradle | 2 +- .../qa/s3/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 | 4 +- .../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 | 6 +- .../watcher/qa/with-monitoring/build.gradle | 2 +- .../watcher/qa/with-security/build.gradle | 6 +- x-pack/plugin/wildcard/build.gradle | 2 +- .../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 | 13 +- .../GlobalCheckpointSyncActionIT.java | 19 + .../elasticsearch/multi_node/RollupIT.java | 17 + .../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 +- .../build.gradle | 2 +- .../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 +- .../qa/xpack-prefix-rest-compat/build.gradle | 2 +- 224 files changed, 4114 insertions(+), 313 deletions(-) rename build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/{YamlRestCompatTestPluginFuncTest.groovy => LegacyYamlRestCompatTestPluginFuncTest.groovy} (98%) 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} (83%) 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 rename build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/{rest/compat/YamlRestCompatTestPlugin.java => test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java} (91%) create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/LegacyYamlRestCompatTestPlugin.java rename build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/{rest => test/rest/compat}/compat/RestCompatTestTransformTask.java (99%) create mode 100644 build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/YamlRestCompatTestPlugin.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 707faf8749c1..92aed9cc9429 100644 --- a/build-tools-internal/build.gradle +++ b/build-tools-internal/build.gradle @@ -115,6 +115,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' @@ -167,9 +171,17 @@ gradlePlugin { id = 'elasticsearch.validate-rest-spec' implementationClass = 'org.elasticsearch.gradle.internal.precommit.ValidateRestSpecPlugin' } + legacyYamlRestCompatTest { + id = 'elasticsearch.legacy-yaml-rest-compat-test' + implementationClass = 'org.elasticsearch.gradle.internal.test.rest.compat.compat.LegacyYamlRestCompatTestPlugin' + } yamlRestCompatTest { id = 'elasticsearch.yaml-rest-compat-test' - implementationClass = 'org.elasticsearch.gradle.internal.rest.compat.YamlRestCompatTestPlugin' + implementationClass = 'org.elasticsearch.gradle.internal.test.rest.compat.compat.YamlRestCompatTestPlugin' + } + legacyYamlRestTest { + id = 'elasticsearch.legacy-yaml-rest-test' + implementationClass = 'org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin' } yamlRestTest { id = 'elasticsearch.internal-yaml-rest-test' 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 2fa7ed6faaee..2756b9745bc7 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(":test:yaml-rest-runner") << "apply plugin: 'elasticsearch.java'" subProject(":rest-api-spec") << """ 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 017b7333f8de..31ecffc07f63 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 @@ -174,12 +174,12 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl 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" yamlRestTestImplementation "org.junit:junit:4.42" - } + } """ clazz(dir("src/yamlRestTest/java"), "org.acme.valid.SomeMatchingIT", "org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase") { @@ -216,11 +216,11 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl buildFile << """ import org.elasticsearch.gradle.internal.precommit.TestingConventionsCheckTask apply plugin:'$pluginName' - + dependencies { ${sourceSetName}Implementation "org.apache.lucene:tests.util:1.0" ${sourceSetName}Implementation "org.junit:junit:4.42" - } + } tasks.withType(TestingConventionsCheckTask).configureEach { suffix 'IT' suffix 'Tests' @@ -252,19 +252,19 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl ) 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" } private void simpleJavaBuild() { buildFile << """ apply plugin:'java' - + dependencies { testImplementation "org.apache.lucene:tests.util:1.0" testImplementation "org.junit:junit:4.42" - } + } """ } } diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/YamlRestCompatTestPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestCompatTestPluginFuncTest.groovy similarity index 98% rename from build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/YamlRestCompatTestPluginFuncTest.groovy rename to build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestCompatTestPluginFuncTest.groovy index 58f894489ab7..cf0cab3b952f 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/YamlRestCompatTestPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/test/rest/LegacyYamlRestCompatTestPluginFuncTest.groovy @@ -17,7 +17,7 @@ import org.elasticsearch.gradle.fixtures.AbstractRestResourcesFuncTest import org.elasticsearch.gradle.VersionProperties import org.gradle.testkit.runner.TaskOutcome -class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { +class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { def compatibleVersion = Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() - 1 def specIntermediateDir = "restResources/v${compatibleVersion}/yamlSpecs" @@ -45,7 +45,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { buildFile << """ plugins { - id 'elasticsearch.yaml-rest-compat-test' + id 'elasticsearch.legacy-yaml-rest-compat-test' } """ @@ -71,7 +71,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { """ buildFile << """ - apply plugin: 'elasticsearch.yaml-rest-compat-test' + apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' // avoids a dependency problem in this test, the distribution in use here is inconsequential to the test import org.elasticsearch.gradle.testclusters.TestDistribution; @@ -151,7 +151,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { buildFile << """ plugins { - id 'elasticsearch.yaml-rest-compat-test' + id 'elasticsearch.legacy-yaml-rest-compat-test' } """ @@ -194,7 +194,7 @@ class YamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTest { """ buildFile << """ - apply plugin: 'elasticsearch.yaml-rest-compat-test' + apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' // avoids a dependency problem in this test, the distribution in use here is inconsequential to the test import org.elasticsearch.gradle.testclusters.TestDistribution; 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 e70be2b4de4d..1ad86d0174ef 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 @@ -15,7 +15,7 @@ import org.elasticsearch.gradle.fixtures.AbstractRestResourcesFuncTest import org.gradle.testkit.runner.TaskOutcome @IgnoreIf({ os.isWindows() }) -class InternalYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { +class LegacyYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { def "yamlRestTest does nothing when there are no tests"() { given: @@ -23,7 +23,7 @@ class InternalYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { configurationCacheCompatible = false buildFile << """ plugins { - id 'elasticsearch.internal-yaml-rest-test' + id 'elasticsearch.legacy-yaml-rest-test' } """ @@ -42,7 +42,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" @@ -96,7 +96,7 @@ class InternalYamlRestTestPluginFuncTest extends AbstractRestResourcesFuncTest { def subProjectBuildFile = subProject(pluginProjectPath) subProjectBuildFile << """ apply plugin: 'elasticsearch.esplugin' - 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/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy b/build-tools-internal/src/main/groovy/org/elasticsearch/gradle/internal/doc/DocsTestPlugin.groovy index f56a9fefceac..874141f2135a 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 @@ -38,7 +38,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/ResolveAllDependencies.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ResolveAllDependencies.java index d86ec9001d41..0afa675c9dfc 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ResolveAllDependencies.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ResolveAllDependencies.java @@ -21,7 +21,7 @@ import java.util.stream.Collectors; import javax.inject.Inject; import static org.elasticsearch.gradle.DistributionDownloadPlugin.DISTRO_EXTRACTED_CONFIG_PREFIX; -import static org.elasticsearch.gradle.internal.rest.compat.YamlRestCompatTestPlugin.BWC_MINOR_CONFIG_NAME; +import static org.elasticsearch.gradle.internal.test.rest.compat.compat.LegacyYamlRestCompatTestPlugin.BWC_MINOR_CONFIG_NAME; public class ResolveAllDependencies extends DefaultTask { 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 95d0ad2be4cc..6adf422133db 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 83% 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 fc27bfa43798..305af0865b9e 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 @@ -31,7 +31,11 @@ import javax.inject.Inject; import static org.elasticsearch.gradle.plugin.BasePluginBuildPlugin.BUNDLE_PLUGIN_TASK_NAME; import static org.elasticsearch.gradle.plugin.BasePluginBuildPlugin.EXPLODED_BUNDLE_PLUGIN_TASK_NAME; -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"; @@ -40,7 +44,7 @@ public class RestTestBasePlugin implements Plugin { private ProviderFactory providerFactory; @Inject - public RestTestBasePlugin(ProviderFactory providerFactory) { + public LegacyRestTestBasePlugin(ProviderFactory providerFactory) { this.providerFactory = providerFactory; } @@ -87,17 +91,19 @@ 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 -> { - if (GradleUtils.isModuleProject(project.getPath())) { - var bundle = project.getTasks().withType(Sync.class).named(EXPLODED_BUNDLE_PLUGIN_TASK_NAME); - t.getClusters().forEach(c -> c.module(bundle)); - } else { - var bundle = project.getTasks().withType(Zip.class).named(BUNDLE_PLUGIN_TASK_NAME); - t.getClusters().forEach(c -> c.plugin(bundle)); - } - })); + 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 -> { + if (GradleUtils.isModuleProject(project.getPath())) { + var bundle = project.getTasks().withType(Sync.class).named(EXPLODED_BUNDLE_PLUGIN_TASK_NAME); + t.getClusters().forEach(c -> c.module(bundle)); + } else { + var bundle = project.getTasks().withType(Zip.class).named(BUNDLE_PLUGIN_TASK_NAME); + t.getClusters().forEach(c -> c.plugin(bundle)); + } + }); + }); } 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 9ffaf396e7fb..163df6cc40e1 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/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 dacf119994f4..b0fd142705a0 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..4e781b3bf5ad --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java @@ -0,0 +1,227 @@ +/* + * 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.List; +import java.util.Map; +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.getDependencies().project(Map.of("path", project.getPath()))); + } 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 + for (Dependency dependency : dependencies) { + if (dependency instanceof ProjectDependency projectDependency) { + List extendedPlugins = projectDependency.getDependencyProject() + .getExtensions() + .getByType(PluginPropertiesExtension.class) + .getExtendedPlugins(); + + for (String extendedPlugin : extendedPlugins) { + findModulePath(project, extendedPlugin).ifPresent( + modulePath -> dependencies.add(project.getDependencies().project(Map.of("path", modulePath))) + ); + } + } + } + }); + }); + } + + 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 922157333d80..99c25b9e2570 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 @@ -15,6 +15,7 @@ import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.provider.Provider; 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. @@ -34,8 +35,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(taskName, 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"))); @@ -49,10 +59,20 @@ public class RestTestUtil { * Setup the dependencies needed for the YAML REST tests. */ public static void setupYamlRestTestDependenciesDefaults(Project project, SourceSet sourceSet) { + setupYamlRestTestDependenciesDefaults(project, sourceSet, false); + } + + /** + * Setup the dependencies needed for the YAML REST tests. + */ + public static void setupYamlRestTestDependenciesDefaults(Project project, SourceSet sourceSet, boolean useNewTestClusters) { Project yamlTestRunnerProject = project.findProject(":test:yaml-rest-runner"); // we shield the project dependency to make integration tests easier if (yamlTestRunnerProject != null) { project.getDependencies().add(sourceSet.getImplementationConfigurationName(), yamlTestRunnerProject); + if (useNewTestClusters) { + project.getDependencies().add(sourceSet.getImplementationConfigurationName(), project.project(":test:test-clusters")); + } } } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java similarity index 91% rename from build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java rename to build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java index bb245bec61b9..273a0a379318 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/AbstractYamlRestCompatTestPlugin.java @@ -6,19 +6,17 @@ * Side Public License, v 1. */ -package org.elasticsearch.gradle.internal.rest.compat; +package org.elasticsearch.gradle.internal.test.rest.compat.compat; import org.elasticsearch.gradle.Version; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin; -import org.elasticsearch.gradle.internal.test.RestIntegTestTask; -import org.elasticsearch.gradle.internal.test.RestTestBasePlugin; +import org.elasticsearch.gradle.internal.test.LegacyRestTestBasePlugin; import org.elasticsearch.gradle.internal.test.rest.CopyRestApiTask; import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask; -import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin; import org.elasticsearch.gradle.internal.test.rest.RestResourcesExtension; import org.elasticsearch.gradle.internal.test.rest.RestResourcesPlugin; -import org.elasticsearch.gradle.internal.test.rest.RestTestUtil; import org.elasticsearch.gradle.testclusters.TestClustersPlugin; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Plugin; @@ -37,6 +35,7 @@ import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.Sync; import org.gradle.api.tasks.TaskProvider; +import org.gradle.api.tasks.testing.Test; import java.io.File; import java.nio.file.Path; @@ -50,7 +49,7 @@ import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupYaml /** * Apply this plugin to run the YAML based REST tests from a prior major version against this version's cluster. */ -public class YamlRestCompatTestPlugin implements Plugin { +public abstract class AbstractYamlRestCompatTestPlugin implements Plugin { public static final String BWC_MINOR_CONFIG_NAME = "bwcMinor"; private static final String REST_COMPAT_CHECK_TASK_NAME = "checkRestCompat"; private static final String COMPATIBILITY_APIS_CONFIGURATION = "restCompatSpecs"; @@ -67,7 +66,7 @@ public class YamlRestCompatTestPlugin implements Plugin { private FileOperations fileOperations; @Inject - public YamlRestCompatTestPlugin(ProjectLayout projectLayout, FileOperations fileOperations) { + public AbstractYamlRestCompatTestPlugin(ProjectLayout projectLayout, FileOperations fileOperations) { this.projectLayout = projectLayout; this.fileOperations = fileOperations; } @@ -81,17 +80,17 @@ public class YamlRestCompatTestPlugin implements Plugin { project.getPluginManager().apply(ElasticsearchJavaBasePlugin.class); project.getPluginManager().apply(TestClustersPlugin.class); - project.getPluginManager().apply(RestTestBasePlugin.class); + project.getPluginManager().apply(LegacyRestTestBasePlugin.class); project.getPluginManager().apply(RestResourcesPlugin.class); - project.getPluginManager().apply(InternalYamlRestTestPlugin.class); + project.getPluginManager().apply(getBasePlugin()); RestResourcesExtension extension = project.getExtensions().getByType(RestResourcesExtension.class); // create source set SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet yamlCompatTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - SourceSet yamlTestSourceSet = sourceSets.getByName(InternalYamlRestTestPlugin.SOURCE_SET_NAME); - GradleUtils.extendSourceSet(project, InternalYamlRestTestPlugin.SOURCE_SET_NAME, SOURCE_SET_NAME); + SourceSet yamlTestSourceSet = sourceSets.getByName(LegacyYamlRestTestPlugin.SOURCE_SET_NAME); + GradleUtils.extendSourceSet(project, LegacyYamlRestTestPlugin.SOURCE_SET_NAME, SOURCE_SET_NAME); // copy compatible rest specs Configuration bwcMinorConfig = project.getConfigurations().create(BWC_MINOR_CONFIG_NAME); @@ -217,11 +216,9 @@ public class YamlRestCompatTestPlugin implements Plugin { .named(RestResourcesPlugin.COPY_YAML_TESTS_TASK) .flatMap(CopyRestTestsTask::getOutputResourceDir); - String testTaskName = "yamlRestTestV" + COMPATIBLE_VERSION + "CompatTest"; - // setup the test task - Provider yamlRestCompatTestTask = RestTestUtil.registerTestTask(project, yamlCompatTestSourceSet, testTaskName); - project.getTasks().withType(RestIntegTestTask.class).named(testTaskName).configure(testTask -> { + TaskProvider yamlRestCompatTestTask = registerTestTask(project, yamlCompatTestSourceSet); + yamlRestCompatTestTask.configure(testTask -> { testTask.systemProperty("tests.restCompat", true); // Use test runner and classpath from "normal" yaml source set testTask.setTestClassesDirs( @@ -236,11 +233,11 @@ public class YamlRestCompatTestPlugin implements Plugin { ); // run compatibility tests after "normal" tests - testTask.mustRunAfter(project.getTasks().named(InternalYamlRestTestPlugin.SOURCE_SET_NAME)); + testTask.mustRunAfter(project.getTasks().named(LegacyYamlRestTestPlugin.SOURCE_SET_NAME)); testTask.onlyIf(t -> isEnabled(extraProperties)); }); - setupYamlRestTestDependenciesDefaults(project, yamlCompatTestSourceSet); + setupYamlRestTestDependenciesDefaults(project, yamlCompatTestSourceSet, true); // setup IDE GradleUtils.setupIdeForTestSourceSet(project, yamlCompatTestSourceSet); @@ -259,6 +256,10 @@ public class YamlRestCompatTestPlugin implements Plugin { } + public abstract TaskProvider registerTestTask(Project project, SourceSet sourceSet); + + public abstract Class> getBasePlugin(); + private boolean isEnabled(ExtraPropertiesExtension extraProperties) { Object bwcEnabled = extraProperties.getProperties().get("bwc_tests_enabled"); return bwcEnabled == null || (Boolean) bwcEnabled; diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/LegacyYamlRestCompatTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/LegacyYamlRestCompatTestPlugin.java new file mode 100644 index 000000000000..e84c84cc426a --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/LegacyYamlRestCompatTestPlugin.java @@ -0,0 +1,44 @@ +/* + * 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.compat.compat; + +import org.elasticsearch.gradle.internal.test.rest.LegacyYamlRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.RestTestUtil; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.file.ProjectLayout; +import org.gradle.api.internal.file.FileOperations; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.TaskProvider; +import org.gradle.api.tasks.testing.Test; + +import javax.inject.Inject; + +/** + * Apply this plugin to run the YAML based REST tests from a prior major version against this version's cluster. + * + * @deprecated use {@link YamlRestCompatTestPlugin} + */ +@Deprecated +public class LegacyYamlRestCompatTestPlugin extends AbstractYamlRestCompatTestPlugin { + @Inject + public LegacyYamlRestCompatTestPlugin(ProjectLayout projectLayout, FileOperations fileOperations) { + super(projectLayout, fileOperations); + } + + @Override + public TaskProvider registerTestTask(Project project, SourceSet sourceSet) { + return RestTestUtil.registerTestTask(project, sourceSet, sourceSet.getTaskName(null, "test")); + } + + @Override + public Class> getBasePlugin() { + return LegacyYamlRestTestPlugin.class; + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/RestCompatTestTransformTask.java similarity index 99% rename from build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java rename to build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/RestCompatTestTransformTask.java index bfb53c23b5f1..eee1c4c21eb0 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/RestCompatTestTransformTask.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/RestCompatTestTransformTask.java @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -package org.elasticsearch.gradle.internal.rest.compat; +package org.elasticsearch.gradle.internal.test.rest.compat.compat; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/YamlRestCompatTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/YamlRestCompatTestPlugin.java new file mode 100644 index 000000000000..79588ca722ff --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/compat/compat/YamlRestCompatTestPlugin.java @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 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.compat.compat; + +import org.elasticsearch.gradle.internal.test.rest.InternalYamlRestTestPlugin; +import org.elasticsearch.gradle.internal.test.rest.RestTestUtil; +import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.file.ProjectLayout; +import org.gradle.api.internal.file.FileOperations; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.TaskProvider; +import org.gradle.api.tasks.testing.Test; + +import javax.inject.Inject; + +/** + * Apply this plugin to run the YAML based REST tests from a prior major version against this version's cluster. + */ +public class YamlRestCompatTestPlugin extends AbstractYamlRestCompatTestPlugin { + @Inject + public YamlRestCompatTestPlugin(ProjectLayout projectLayout, FileOperations fileOperations) { + super(projectLayout, fileOperations); + } + + @Override + public TaskProvider registerTestTask(Project project, SourceSet sourceSet) { + return RestTestUtil.registerTestTask(project, sourceSet, sourceSet.getTaskName(null, "test"), StandaloneRestIntegTestTask.class); + } + + @Override + public Class> getBasePlugin() { + return InternalYamlRestTestPlugin.class; + } +} 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 13d2c8b948d5..ab1436bb9a31 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 @@ -73,11 +73,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/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/build.gradle b/distribution/build.gradle index 6b8cdb128042..08920ed173d7 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -116,6 +116,14 @@ def processIntegTestOutputsTaskProvider = tasks.register("processIntegTestOutput into integTestOutputs } +def integTestConfigFiles = fileTree("${integTestOutputs}/config") { + builtBy processIntegTestOutputsTaskProvider +} + +def integTestBinFiles = fileTree("${integTestOutputs}/bin") { + builtBy processIntegTestOutputsTaskProvider +} + def defaultModulesFiles = fileTree("${defaultOutputs}/modules") { builtBy processDefaultOutputsTaskProvider } @@ -358,7 +366,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { filter("tokens" : expansionsForDistribution(distributionType, isTestDistro), ReplaceTokens.class) } from buildDefaultLog4jConfigTaskProvider - from defaultConfigFiles + from isTestDistro ? integTestConfigFiles : defaultConfigFiles } } @@ -388,7 +396,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { // module provided bin files with copySpec { eachFile { it.setMode(0755) } - from(defaultBinFiles) + from(testDistro ? integTestBinFiles : defaultBinFiles) if (distributionType != 'zip') { exclude '*.bat' } diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index fe4a1e8b48a7..47659080e2ba 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -15,7 +15,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' apply plugin: 'elasticsearch.dra-artifacts' diff --git a/modules/aggregations/build.gradle b/modules/aggregations/build.gradle index b3cc698a5542..15a95d96fca2 100644 --- a/modules/aggregations/build.gradle +++ b/modules/aggregations/build.gradle @@ -8,8 +8,8 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/aggs-matrix-stats/build.gradle b/modules/aggs-matrix-stats/build.gradle index e0621544c446..669739070caf 100644 --- a/modules/aggs-matrix-stats/build.gradle +++ b/modules/aggs-matrix-stats/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 d1345695d8a1..9988d70b6365 100644 --- a/modules/analysis-common/build.gradle +++ b/modules/analysis-common/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/data-streams/build.gradle b/modules/data-streams/build.gradle index 49136712b855..fa3346e26ab2 100644 --- a/modules/data-streams/build.gradle +++ b/modules/data-streams/build.gradle @@ -2,9 +2,9 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.test-with-dependencies' apply plugin: 'elasticsearch.internal-cluster-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' esplugin { description 'Elasticsearch Expanded Pack Plugin - Data Streams' diff --git a/modules/ingest-attachment/build.gradle b/modules/ingest-attachment/build.gradle index 4db193b6202a..36dfd027cd81 100644 --- a/modules/ingest-attachment/build.gradle +++ b/modules/ingest-attachment/build.gradle @@ -7,8 +7,8 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' esplugin { description 'Ingest processor that uses Apache Tika to extract contents' diff --git a/modules/ingest-common/build.gradle b/modules/ingest-common/build.gradle index 958e64d2ac4b..e48156ef98da 100644 --- a/modules/ingest-common/build.gradle +++ b/modules/ingest-common/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/ingest-geoip/build.gradle b/modules/ingest-geoip/build.gradle index 3211d88444cc..282d4a605923 100644 --- a/modules/ingest-geoip/build.gradle +++ b/modules/ingest-geoip/build.gradle @@ -8,8 +8,8 @@ import org.apache.tools.ant.taskdefs.condition.Os -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 bdf7fae42d84..5d3ae968b787 100644 --- a/modules/ingest-user-agent/build.gradle +++ b/modules/ingest-user-agent/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 d334fa380d7b..e57e16409495 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 1581de127427..771b4f7c0186 100644 --- a/modules/lang-expression/build.gradle +++ b/modules/lang-expression/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/lang-mustache/build.gradle b/modules/lang-mustache/build.gradle index 7536e2f76abf..c36275699e21 100644 --- a/modules/lang-mustache/build.gradle +++ b/modules/lang-mustache/build.gradle @@ -5,9 +5,9 @@ * 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.yaml-rest-compat-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 17e43a755bed..682802534438 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -9,8 +9,8 @@ import org.elasticsearch.gradle.testclusters.DefaultTestClustersTask; apply plugin: 'elasticsearch.validate-rest-spec' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 a9db8325e1db..62e7744bfa7f 100644 --- a/modules/mapper-extras/build.gradle +++ b/modules/mapper-extras/build.gradle @@ -8,8 +8,8 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/parent-join/build.gradle b/modules/parent-join/build.gradle index 66079cfd444c..903192e6ce25 100644 --- a/modules/parent-join/build.gradle +++ b/modules/parent-join/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index 785edc32c143..a871056539d3 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/rank-eval/build.gradle b/modules/rank-eval/build.gradle index 5ac9922a1e07..1268a40dd5bd 100644 --- a/modules/rank-eval/build.gradle +++ b/modules/rank-eval/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/reindex/build.gradle b/modules/reindex/build.gradle index 1496e32927f9..4cd12b44aaaa 100644 --- a/modules/reindex/build.gradle +++ b/modules/reindex/build.gradle @@ -17,9 +17,9 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/modules/repository-azure/build.gradle b/modules/repository-azure/build.gradle index 0101c0d4df7c..221325706297 100644 --- a/modules/repository-azure/build.gradle +++ b/modules/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/modules/repository-gcs/build.gradle b/modules/repository-gcs/build.gradle index 7b0f62b54d6d..b98a97cb34be 100644 --- a/modules/repository-gcs/build.gradle +++ b/modules/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' @@ -271,7 +271,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()) @@ -323,7 +323,7 @@ testClusters.matching { if (useFixture) { tasks.register("yamlRestTestApplicationDefaultCredentials", RestIntegTestTask.class) { 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/modules/repository-s3/build.gradle b/modules/repository-s3/build.gradle index c5e8341c0d8d..892c8c42903e 100644 --- a/modules/repository-s3/build.gradle +++ b/modules/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' @@ -244,7 +244,7 @@ if (useFixture) { tasks.register("yamlRestTestMinio", RestIntegTestTask) { description = "Runs REST tests using the Minio repository." 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()) @@ -272,7 +272,7 @@ if (useFixture) { tasks.register("yamlRestTestECS", RestIntegTestTask.class) { description = "Runs tests using the ECS repository." 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', [ @@ -298,7 +298,7 @@ if (useFixture) { tasks.register("yamlRestTestSTS", RestIntegTestTask.class) { description = "Runs tests with the STS (Secure Token Service)" 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/modules/repository-url/build.gradle b/modules/repository-url/build.gradle index 164c64ad1f61..7b671802f3a2 100644 --- a/modules/repository-url/build.gradle +++ b/modules/repository-url/build.gradle @@ -8,8 +8,8 @@ import org.elasticsearch.gradle.PropertyNormalization -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 5a2d268cf7a4..c4db67a89d36 100644 --- a/modules/runtime-fields-common/build.gradle +++ b/modules/runtime-fields-common/build.gradle @@ -7,8 +7,8 @@ */ apply plugin: 'elasticsearch.validate-rest-spec' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' esplugin { description 'Module for runtime fields features and extensions that have large dependencies' diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index d3ce40ad32f0..74fef7098eff 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -7,12 +7,12 @@ */ 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.yaml-rest-compat-test' -apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.publish' @@ -73,7 +73,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 b10ca2b6dd49..1c7db6d040be 100644 --- a/plugins/analysis-icu/build.gradle +++ b/plugins/analysis-icu/build.gradle @@ -7,8 +7,8 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { diff --git a/plugins/analysis-kuromoji/build.gradle b/plugins/analysis-kuromoji/build.gradle index 0a9cc629e7a4..a91e34018179 100644 --- a/plugins/analysis-kuromoji/build.gradle +++ b/plugins/analysis-kuromoji/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 4c545d4f72d4..51e93bf6cc2c 100644 --- a/plugins/analysis-nori/build.gradle +++ b/plugins/analysis-nori/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 96149295b496..7646c0ee874d 100644 --- a/plugins/analysis-phonetic/build.gradle +++ b/plugins/analysis-phonetic/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 dd577a550e8f..c75c5c304048 100644 --- a/plugins/analysis-smartcn/build.gradle +++ b/plugins/analysis-smartcn/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 363d923492e0..ca6d91df5cd1 100644 --- a/plugins/analysis-stempel/build.gradle +++ b/plugins/analysis-stempel/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 67aa47db8bbd..709b8831628b 100644 --- a/plugins/analysis-ukrainian/build.gradle +++ b/plugins/analysis-ukrainian/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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 de47739d382b..3db7c21309b5 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 1e48fa537e43..b21f6224c9fc 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 cfd1609078de..89e53f94853e 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/mapper-annotated-text/build.gradle b/plugins/mapper-annotated-text/build.gradle index 633cc3d3dcbb..275e7f5267e5 100644 --- a/plugins/mapper-annotated-text/build.gradle +++ b/plugins/mapper-annotated-text/build.gradle @@ -7,8 +7,8 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' esplugin { description 'The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index.' diff --git a/plugins/mapper-murmur3/build.gradle b/plugins/mapper-murmur3/build.gradle index 6243871ef3bd..7e93e6d29539 100644 --- a/plugins/mapper-murmur3/build.gradle +++ b/plugins/mapper-murmur3/build.gradle @@ -7,8 +7,8 @@ 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.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 5db8373dca8e..df8d3cdac1c4 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/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-http/build.gradle b/qa/smoke-test-http/build.gradle index c08194f7db87..6766823dc21e 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 1f043272b417..6181548757c6 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:lang-mustache') @@ -24,4 +24,4 @@ tasks.named("yamlRestTestTestingConventions").configure { tasks.named("forbiddenPatterns").configure { exclude '**/*.mmdb' -} \ No newline at end of file +} diff --git a/qa/smoke-test-multinode/build.gradle b/qa/smoke-test-multinode/build.gradle index 8fbe7229facd..cba95391cc31 100644 --- a/qa/smoke-test-multinode/build.gradle +++ b/qa/smoke-test-multinode/build.gradle @@ -10,7 +10,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' restResources { restTests { diff --git a/qa/smoke-test-plugins/build.gradle b/qa/smoke-test-plugins/build.gradle index 06a9d9a6613a..7ae46b8e0d68 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/system-indices/build.gradle b/qa/system-indices/build.gradle index a8be8e8374d5..4cb60860cca4 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 aae98def1db8..dd1dd0a2334f 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/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 { setting 'xpack.security.enabled', 'false' diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index e92d6767a803..e5049a117905 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -33,9 +33,8 @@ artifacts { restTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test")) } -testClusters.configureEach { - module ':modules:mapper-extras' - requiresFeature 'es.index_mode_feature_flag_registered', Version.fromString("8.0.0") +dependencies { + clusterModules project(":modules:mapper-extras") } tasks.named("yamlRestTestV7CompatTransform").configure { task -> 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 287c8a57627b..a10d53389af9 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.tests.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 0fbb994ec248..a157ba478435 100644 --- a/settings.gradle +++ b/settings.gradle @@ -83,8 +83,9 @@ List projects = [ 'test:fixtures:url-fixture', 'test:fixtures:nginx-fixture', 'test:logger-usage', - 'test:yaml-rest-runner', - 'test:x-content' + 'test:test-clusters', + 'test:x-content', + 'test:yaml-rest-runner' ] /** 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/test-clusters/build.gradle b/test/test-clusters/build.gradle new file mode 100644 index 000000000000..48f55931c510 --- /dev/null +++ b/test/test-clusters/build.gradle @@ -0,0 +1,15 @@ +import org.elasticsearch.gradle.internal.conventions.util.Util + +apply plugin: 'elasticsearch.java' +apply plugin: 'com.github.johnrengelman.shadow' + +dependencies { + shadow "junit:junit:${versions.junit}" + shadow "org.apache.logging.log4j:log4j-api:${versions.log4j}" + + implementation "org.elasticsearch.gradle:reaper" +} + +tasks.named("processResources").configure { + from(new File(Util.locateElasticsearchWorkspace(gradle), "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..20e06fcb8e9b --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterSpecBuilder.java @@ -0,0 +1,152 @@ +/* + * 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() { + List clusterUsers = users.isEmpty() ? List.of(User.DEFAULT_USER) : users; + LocalClusterSpec clusterSpec = new LocalClusterSpec(name, clusterUsers, 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..aaf2f786b543 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java @@ -0,0 +1,74 @@ +/* + * 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.INTEG_TEST) { + settings.put("xpack.security.enabled", "false"); + } else { + // 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..2a4223fc8ff5 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterFactory.java @@ -0,0 +1,503 @@ +/* + * 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"; + + 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) { + Pattern pattern = Pattern.compile("(.+)(?:-\\d\\.\\d\\.\\d-SNAPSHOT\\.zip)?"); + + 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(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().filter(path -> path.endsWith(moduleName)).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..3255e4c17914 --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterHandle.java @@ -0,0 +1,155 @@ +/* + * 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()); + 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..7d3d19a204cb --- /dev/null +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/ProcessReaper.java @@ -0,0 +1,153 @@ +/* + * 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.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ProcessReaper { + private static final String REAPER_CLASS = "org/elasticsearch/gradle/reaper/Reaper.class"; + private static final Pattern REAPER_JAR_PATH_PATTERN = Pattern.compile("file:(.*)!/" + REAPER_CLASS); + 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 + "-jar", + jarPath.toString(), + 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); + if (main != null) { + String mainPath = main.getFile(); + Matcher matcher = REAPER_JAR_PATH_PATTERN.matcher(mainPath); + + if (matcher.matches()) { + String path = matcher.group(1); + return Path.of(OS.conditional(c -> c.onWindows(() -> path.substring(1)).onUnix(() -> path))); + } + } + + throw new RuntimeException("Unable to locate " + REAPER_CLASS + " 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 = Path.of(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/test/yaml-rest-runner/build.gradle b/test/yaml-rest-runner/build.gradle index 1ae1315ac9ef..37d2a00a68dd 100644 --- a/test/yaml-rest-runner/build.gradle +++ b/test/yaml-rest-runner/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'elasticsearch.build' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' dependencies { api project(':test:framework') diff --git a/x-pack/plugin/async-search/qa/rest/build.gradle b/x-pack/plugin/async-search/qa/rest/build.gradle index 07659ad9360c..759c756ccd88 100644 --- a/x-pack/plugin/async-search/qa/rest/build.gradle +++ b/x-pack/plugin/async-search/qa/rest/build.gradle @@ -1,8 +1,8 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.base-internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 143e271412d4..19254880a708 100644 --- a/x-pack/plugin/autoscaling/qa/rest/build.gradle +++ b/x-pack/plugin/autoscaling/qa/rest/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' dependencies { yamlRestTestImplementation(testArtifact(project(xpackModule('core')))) diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index c293a46885e6..bb9bae10e573 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -3,11 +3,11 @@ import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.util.GradleUtils -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.validate-rest-spec' apply plugin: 'elasticsearch.internal-test-artifact' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' archivesBaseName = 'x-pack' diff --git a/x-pack/plugin/ccr/qa/rest/build.gradle b/x-pack/plugin/ccr/qa/rest/build.gradle index 98814f04d6c5..5f173b8831df 100644 --- a/x-pack/plugin/ccr/qa/rest/build.gradle +++ b/x-pack/plugin/ccr/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' restResources { restApi { diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index 0b548af7da43..e09c82fa27e4 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -6,9 +6,9 @@ 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.internal-java-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-test-artifact' archivesBaseName = 'x-pack-core' 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 697144fc81be..e8473d15ed9e 100644 --- a/x-pack/plugin/enrich/qa/rest/build.gradle +++ b/x-pack/plugin/enrich/qa/rest/build.gradle @@ -1,6 +1,6 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' import org.elasticsearch.gradle.Version diff --git a/x-pack/plugin/eql/qa/correctness/build.gradle b/x-pack/plugin/eql/qa/correctness/build.gradle index 890584d0055c..aeddca54d145 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 9aa0a93ff153..1e93ea035058 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 b637517b29dc..5fc247693c45 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 01a9b176a007..a49317ad8c4e 100644 --- a/x-pack/plugin/eql/qa/rest/build.gradle +++ b/x-pack/plugin/eql/qa/rest/build.gradle @@ -1,6 +1,6 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 f54ee022a744..9fef7a928bcf 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 75109373b400..6a4264477eaf 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 14e9b91edb1a..d44f4fa3ab3c 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 e60c772e5a59..523bf5d04ae4 100644 --- a/x-pack/plugin/ilm/qa/multi-node/build.gradle +++ b/x-pack/plugin/ilm/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' 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 92b5b4e77c20..a17c130d4bbb 100644 --- a/x-pack/plugin/ilm/qa/rest/build.gradle +++ b/x-pack/plugin/ilm/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 27a7da011c7e..7aaa43f14fe3 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 5ad1bcae1f1e..b8bfe255e152 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-constant-keyword/build.gradle b/x-pack/plugin/mapper-constant-keyword/build.gradle index fe57cdc4380f..ffcbc8ed45be 100644 --- a/x-pack/plugin/mapper-constant-keyword/build.gradle +++ b/x-pack/plugin/mapper-constant-keyword/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { name 'constant-keyword' diff --git a/x-pack/plugin/mapper-unsigned-long/build.gradle b/x-pack/plugin/mapper-unsigned-long/build.gradle index eaff7fe36255..adead5dc126b 100644 --- a/x-pack/plugin/mapper-unsigned-long/build.gradle +++ b/x-pack/plugin/mapper-unsigned-long/build.gradle @@ -11,8 +11,8 @@ import org.elasticsearch.gradle.internal.info.BuildParams evaluationDependsOn(xpackModule('core')) apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' esplugin { name 'unsigned-long' diff --git a/x-pack/plugin/mapper-version/build.gradle b/x-pack/plugin/mapper-version/build.gradle index 0558120c9578..437e03a42a4b 100644 --- a/x-pack/plugin/mapper-version/build.gradle +++ b/x-pack/plugin/mapper-version/build.gradle @@ -4,8 +4,8 @@ evaluationDependsOn(xpackModule('core')) apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' apply plugin: 'elasticsearch.internal-cluster-test' esplugin { 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 e74e61fdb7d5..4b34d6fae046 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 9baa7d38c529..2645a3f3fa0d 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/semantic-search-tests/build.gradle b/x-pack/plugin/ml/qa/semantic-search-tests/build.gradle index 52c532a5d654..42d47d0d700f 100644 --- a/x-pack/plugin/ml/qa/semantic-search-tests/build.gradle +++ b/x-pack/plugin/ml/qa/semantic-search-tests/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/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 82785d162121..b917c9907a56 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 0c833fcb6f2d..2db3bf4f64cd 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 83dbde8c0093..05dbe3d6bd8c 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 6e69f1e929d8..e91e56d2d1ba 100644 --- a/x-pack/plugin/rollup/qa/rest/build.gradle +++ b/x-pack/plugin/rollup/qa/rest/build.gradle @@ -8,8 +8,8 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 b4f60a7e09b0..73032e36679a 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 5c017b2e34eb..c9ce9c1e05a5 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 a6ef39dc6fe6..a1d4bd121160 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 d00b51c0c2da..860e42378dcd 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 75b62df35b55..a15f0b2b3c83 100644 --- a/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/rest/build.gradle @@ -1,6 +1,6 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 2b359f88f2d6..01a2dc065ec6 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 1ed92dff3381..5ed2aaea4d7e 100644 --- a/x-pack/plugin/security/qa/basic-enable-security/build.gradle +++ b/x-pack/plugin/security/qa/basic-enable-security/build.gradle @@ -8,7 +8,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' dependencies { javaRestTestImplementation(testArtifact(project(xpackModule('security')))) diff --git a/x-pack/plugin/security/qa/jwt-realm/build.gradle b/x-pack/plugin/security/qa/jwt-realm/build.gradle index 14fee4918645..9de0f5aabbc4 100644 --- a/x-pack/plugin/security/qa/jwt-realm/build.gradle +++ b/x-pack/plugin/security/qa/jwt-realm/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.internal.info.BuildParams -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/operator-privileges-tests/build.gradle b/x-pack/plugin/security/qa/operator-privileges-tests/build.gradle index ab3a80956d52..c42b8583e648 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/profile/build.gradle b/x-pack/plugin/security/qa/profile/build.gradle index ee59c985e12b..eae33a5ba587 100644 --- a/x-pack/plugin/security/qa/profile/build.gradle +++ b/x-pack/plugin/security/qa/profile/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.Version 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:plugin:core') 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-trial/build.gradle b/x-pack/plugin/security/qa/security-trial/build.gradle index b0f5a6da10d7..c2f13f2dae6e 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 4c9724d14704..3a599de8dddb 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 02e40b7c8cf4..ca33b61de4ca 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 a4c3554afd93..fbe91009011e 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 2e2f8e12d79e..74dbfeb5cbef 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-based-recoveries/qa/azure/build.gradle b/x-pack/plugin/snapshot-based-recoveries/qa/azure/build.gradle index 002ddfeaad8c..c9e312fe6361 100644 --- a/x-pack/plugin/snapshot-based-recoveries/qa/azure/build.gradle +++ b/x-pack/plugin/snapshot-based-recoveries/qa/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/x-pack/plugin/snapshot-based-recoveries/qa/fs/build.gradle b/x-pack/plugin/snapshot-based-recoveries/qa/fs/build.gradle index 3e53f734d736..0c0c1930f860 100644 --- a/x-pack/plugin/snapshot-based-recoveries/qa/fs/build.gradle +++ b/x-pack/plugin/snapshot-based-recoveries/qa/fs/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.rest-resources' dependencies { diff --git a/x-pack/plugin/snapshot-based-recoveries/qa/gcs/build.gradle b/x-pack/plugin/snapshot-based-recoveries/qa/gcs/build.gradle index 0249677a3504..3824906da3c4 100644 --- a/x-pack/plugin/snapshot-based-recoveries/qa/gcs/build.gradle +++ b/x-pack/plugin/snapshot-based-recoveries/qa/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/x-pack/plugin/snapshot-based-recoveries/qa/license-enforcing/build.gradle b/x-pack/plugin/snapshot-based-recoveries/qa/license-enforcing/build.gradle index b9f843ad2670..1c9a87750779 100644 --- a/x-pack/plugin/snapshot-based-recoveries/qa/license-enforcing/build.gradle +++ b/x-pack/plugin/snapshot-based-recoveries/qa/license-enforcing/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/x-pack/plugin/snapshot-based-recoveries/qa/s3/build.gradle b/x-pack/plugin/snapshot-based-recoveries/qa/s3/build.gradle index eccdc63386e4..dfac9046ec32 100644 --- a/x-pack/plugin/snapshot-based-recoveries/qa/s3/build.gradle +++ b/x-pack/plugin/snapshot-based-recoveries/qa/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/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle b/x-pack/plugin/snapshot-repo-test-kit/qa/azure/build.gradle index 887549241ab8..92fa1a662911 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 89f76a2f8e2b..31f8bb717741 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 4acc4b6415e8..a323d18afbb3 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 8e10165d243c..225e0146a6ec 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 a4609cd2cc2c..36b13ef8b12a 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 ad6e71dce594..65d074538361 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(project(':x-pack: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 73d02ef3c516..d7fa587dfc40 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 3e8903a97965..56ee4ef971f4 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 6755dd15badb..b56d8ff21199 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 770a52fde68b..a5bdb388d610 100644 --- a/x-pack/plugin/stack/qa/rest/build.gradle +++ b/x-pack/plugin/stack/qa/rest/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 4431351e5618..5fc76885aa7e 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 6cd6c529a879..4f1dfd334589 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 be073f64a2ef..c321b3aeb028 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 a8a72080736a..017685e32dd7 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 0a987a3faa1e..ea20c8eacd17 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 026ec7edb0fb..3f61bdcb3c2e 100644 --- a/x-pack/plugin/watcher/qa/rest/build.gradle +++ b/x-pack/plugin/watcher/qa/rest/build.gradle @@ -1,8 +1,8 @@ import org.elasticsearch.gradle.internal.info.BuildParams -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-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 d3b064b271b5..5c01573e0941 100644 --- a/x-pack/plugin/watcher/qa/with-security/build.gradle +++ b/x-pack/plugin/watcher/qa/with-security/build.gradle @@ -1,6 +1,6 @@ -apply plugin: 'elasticsearch.internal-java-rest-test' -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' dependencies { yamlRestTestImplementation project(path: ':x-pack:plugin:watcher:qa:common') diff --git a/x-pack/plugin/wildcard/build.gradle b/x-pack/plugin/wildcard/build.gradle index 82f2d33ac004..63437cb2f132 100644 --- a/x-pack/plugin/wildcard/build.gradle +++ b/x-pack/plugin/wildcard/build.gradle @@ -1,7 +1,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams apply plugin: 'elasticsearch.internal-es-plugin' -apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-test' esplugin { name 'wildcard' 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 87cb38469465..f5b6730a4411 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 c94175dcfc75..862b33a5402b 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 16aa1fc50053..f4af52b99459 100644 --- a/x-pack/qa/multi-node/build.gradle +++ b/x-pack/qa/multi-node/build.gradle @@ -2,16 +2,5 @@ apply plugin: 'elasticsearch.internal-java-rest-test' 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' - rolesFile file('roles.yml') - user username: "test-user", password: "x-pack-test-password", role: "test" - user username: "super-user", password: "x-pack-super-password" + clusterModules project(xpackModule('rollup')) } 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 f42b4681ed19..aa04d1cbeca9 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,28 @@ 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.util.resource.TextResource; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.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) + .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 +45,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 0e4fea305cfb..0e3a5c0c0c15 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 @@ -16,9 +16,11 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.ObjectPath; import org.elasticsearch.xcontent.XContentBuilder; +import org.junit.ClassRule; import java.io.IOException; import java.time.Instant; @@ -35,6 +37,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) + .module("x-pack-rollup") + .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() { @@ -46,6 +58,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 7e6dd4bade15..61d373b5a42e 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 bec7c8b1b0be..fdb61e02f818 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 4e9eb2d23905..d89ea041dda4 100644 --- a/x-pack/qa/runtime-fields/build.gradle +++ b/x-pack/qa/runtime-fields/build.gradle @@ -21,7 +21,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 project(":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 41ae03d6692d..e664ee888a31 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 813733c0b4aa..10e6848dfb73 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 = project(':x-pack: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-example-spi-extension/build.gradle b/x-pack/qa/security-example-spi-extension/build.gradle index cac57d78344b..3fb73d615b8c 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-setup-password-tests/build.gradle b/x-pack/qa/security-setup-password-tests/build.gradle index 29455fe41dd9..8f17e6d92291 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 bd0f9112e2a4..1e8e88b91c33 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 46ae4b9015db..427aa39f02e4 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/xpack-prefix-rest-compat/build.gradle b/x-pack/qa/xpack-prefix-rest-compat/build.gradle index b17463183bd2..d609ede0efd2 100644 --- a/x-pack/qa/xpack-prefix-rest-compat/build.gradle +++ b/x-pack/qa/xpack-prefix-rest-compat/build.gradle @@ -13,7 +13,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask import org.elasticsearch.gradle.util.GradleUtils -apply plugin: 'elasticsearch.yaml-rest-compat-test' +apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' /** * This project exists to test the _xpack prefix for REST compatibility. The _xpack prefix was removed from the specification, but still supported