From ecbd3992e730f78ebcf20721f9351c4df90af274 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Wed, 26 Mar 2025 17:04:59 -0700 Subject: [PATCH 1/3] Convert x-pack fleet project to new test framework --- .../internal/RestrictedBuildApiService.java | 1 - x-pack/plugin/fleet/build.gradle | 12 +++---- x-pack/plugin/fleet/qa/build.gradle | 0 x-pack/plugin/fleet/qa/rest/build.gradle | 31 ------------------- .../xpack/fleet/AbstractFleetIT.java | 31 +++++++++++++++++++ .../xpack/fleet/FleetDataStreamIT.java | 3 +- .../fleet/FleetSecretsSystemIndexIT.java | 3 +- .../xpack/fleet/FleetSystemIndicesIT.java | 3 +- .../xpack/fleet/FleetRestIT.java | 5 +-- .../test/fleet/10_global_checkpoints.yml | 0 .../test/fleet/20_wait_for_checkpoints.yml | 0 .../test/fleet/30_secrets_post.yml | 0 .../test/fleet/40_secrets_get.yml | 0 .../test/fleet/50_secrets_delete.yml | 0 .../src/yamlRestTest/resources/roles.yml | 0 15 files changed, 41 insertions(+), 48 deletions(-) delete mode 100644 x-pack/plugin/fleet/qa/build.gradle delete mode 100644 x-pack/plugin/fleet/qa/rest/build.gradle create mode 100644 x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/AbstractFleetIT.java rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java (94%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/rest-api-spec/test/fleet/10_global_checkpoints.yml (100%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/rest-api-spec/test/fleet/20_wait_for_checkpoints.yml (100%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml (100%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml (100%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/rest-api-spec/test/fleet/50_secrets_delete.yml (100%) rename x-pack/plugin/fleet/{qa/rest => }/src/yamlRestTest/resources/roles.yml (100%) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java index c7da5683ee413..4ec8bfddefd0b 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java @@ -38,7 +38,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":qa:rolling-upgrade-legacy"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:core"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster"); diff --git a/x-pack/plugin/fleet/build.gradle b/x-pack/plugin/fleet/build.gradle index 013d0acb4123b..177be963aa86e 100644 --- a/x-pack/plugin/fleet/build.gradle +++ b/x-pack/plugin/fleet/build.gradle @@ -7,7 +7,8 @@ apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' -apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' esplugin { name = 'x-pack-fleet' @@ -22,12 +23,7 @@ dependencies { javaRestTestImplementation(project(path: xpackModule('core'))) javaRestTestImplementation(testArtifact(project(xpackModule('core')))) compileOnly project(path: xpackModule('ilm')) -} -testClusters.configureEach { - testDistribution = 'DEFAULT' - setting 'xpack.security.enabled', 'true' - setting 'xpack.security.autoconfiguration.enabled', 'false' - user username: 'x_pack_rest_user', password: 'x-pack-test-password' - systemProperty 'es.queryable_built_in_roles_enabled', 'false' + clusterModules project(xpackModule('ilm')) + clusterModules project(':modules:data-streams') } diff --git a/x-pack/plugin/fleet/qa/build.gradle b/x-pack/plugin/fleet/qa/build.gradle deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/x-pack/plugin/fleet/qa/rest/build.gradle b/x-pack/plugin/fleet/qa/rest/build.gradle deleted file mode 100644 index 91e73be7b60b6..0000000000000 --- a/x-pack/plugin/fleet/qa/rest/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -apply plugin: 'elasticsearch.internal-yaml-rest-test' -apply plugin: 'elasticsearch.yaml-rest-compat-test' -apply plugin: 'elasticsearch.internal-test-artifact' - -restResources { - restApi { - include '_common', 'bulk', 'cluster', 'nodes', 'indices', 'index', 'xpack', 'security', 'fleet' - } -} - -artifacts { - restXpackTests(new File(projectDir, "src/yamlRestTest/resources/rest-api-spec/test")) -} - -tasks.named('yamlRestTest') { - usesDefaultDistribution("to be triaged") -} -tasks.named('yamlRestCompatTest') { - usesDefaultDistribution("to be triaged") -} -if (buildParams.inFipsJvm){ - // This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC - tasks.named("yamlRestTest").configure{enabled = false } -} diff --git a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/AbstractFleetIT.java b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/AbstractFleetIT.java new file mode 100644 index 0000000000000..a835b9caa7a65 --- /dev/null +++ b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/AbstractFleetIT.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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.fleet; + +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.junit.ClassRule; + +public abstract class AbstractFleetIT extends ESRestTestCase { + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .module("x-pack-fleet") + .module("x-pack-ilm") + .module("data-streams") + .setting("xpack.security.enabled", "true") + .setting("xpack.security.autoconfiguration.enabled", "false") + .user("x_pack_rest_user", "x-pack-test-password") + .systemProperty("es.queryable_built_in_roles_enabled", "false") + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } +} diff --git a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetDataStreamIT.java b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetDataStreamIT.java index c32b2119f0056..865c0b4af9d8a 100644 --- a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetDataStreamIT.java +++ b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetDataStreamIT.java @@ -15,7 +15,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.SecuritySettingsSourceField; -import org.elasticsearch.test.rest.ESRestTestCase; import java.util.List; @@ -26,7 +25,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -public class FleetDataStreamIT extends ESRestTestCase { +public class FleetDataStreamIT extends AbstractFleetIT { static final String BASIC_AUTH_VALUE = basicAuthHeaderValue( "x_pack_rest_user", diff --git a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSecretsSystemIndexIT.java b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSecretsSystemIndexIT.java index 2a90bad72de6b..eef062b8dd173 100644 --- a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSecretsSystemIndexIT.java +++ b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSecretsSystemIndexIT.java @@ -16,7 +16,6 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.test.SecuritySettingsSourceField; -import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.json.JsonXContent; @@ -26,7 +25,7 @@ import static org.hamcrest.Matchers.is; -public class FleetSecretsSystemIndexIT extends ESRestTestCase { +public class FleetSecretsSystemIndexIT extends AbstractFleetIT { static final String BASIC_AUTH_VALUE = basicAuthHeaderValue( "x_pack_rest_user", SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING diff --git a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSystemIndicesIT.java b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSystemIndicesIT.java index 62985eb328f51..99f04d2997608 100644 --- a/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSystemIndicesIT.java +++ b/x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSystemIndicesIT.java @@ -14,7 +14,6 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.test.SecuritySettingsSourceField; -import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.XContentType; import java.util.Map; @@ -23,7 +22,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -public class FleetSystemIndicesIT extends ESRestTestCase { +public class FleetSystemIndicesIT extends AbstractFleetIT { static final String BASIC_AUTH_VALUE = basicAuthHeaderValue( "x_pack_rest_user", diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java b/x-pack/plugin/fleet/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java similarity index 94% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java rename to x-pack/plugin/fleet/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java index bc49649bc1139..fd710373a95c4 100644 --- a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java +++ b/x-pack/plugin/fleet/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java @@ -13,7 +13,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.cluster.ElasticsearchCluster; -import org.elasticsearch.test.cluster.local.distribution.DistributionType; import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; @@ -27,7 +26,9 @@ public FleetRestIT(final ClientYamlTestCandidate testCandidate) { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() - .distribution(DistributionType.DEFAULT) + .module("x-pack-fleet") + .module("x-pack-ilm") + .module("data-streams") .setting("xpack.license.self_generated.type", "basic") .setting("xpack.security.enabled", "true") .rolesFile(Resource.fromClasspath("roles.yml")) diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/10_global_checkpoints.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/10_global_checkpoints.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/10_global_checkpoints.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/10_global_checkpoints.yml diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/20_wait_for_checkpoints.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/20_wait_for_checkpoints.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/20_wait_for_checkpoints.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/20_wait_for_checkpoints.yml diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/30_secrets_post.yml diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/40_secrets_get.yml diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/50_secrets_delete.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/50_secrets_delete.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/fleet/50_secrets_delete.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/rest-api-spec/test/fleet/50_secrets_delete.yml diff --git a/x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/roles.yml b/x-pack/plugin/fleet/src/yamlRestTest/resources/roles.yml similarity index 100% rename from x-pack/plugin/fleet/qa/rest/src/yamlRestTest/resources/roles.yml rename to x-pack/plugin/fleet/src/yamlRestTest/resources/roles.yml From f291b2ba4149f13c117baf4a1d928883c99adfd7 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 27 Mar 2025 10:03:26 -0700 Subject: [PATCH 2/3] Add internal test artifact plugin --- x-pack/plugin/fleet/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugin/fleet/build.gradle b/x-pack/plugin/fleet/build.gradle index 177be963aa86e..4b19ff849fad8 100644 --- a/x-pack/plugin/fleet/build.gradle +++ b/x-pack/plugin/fleet/build.gradle @@ -9,6 +9,7 @@ apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-cluster-test' apply plugin: 'elasticsearch.internal-java-rest-test' apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.internal-test-artifact' esplugin { name = 'x-pack-fleet' From 744c7c109184de3c923a115961fef4125fb64203 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Fri, 28 Mar 2025 08:02:36 -0700 Subject: [PATCH 3/3] Update RestrictedBuildApiService.java --- .../elasticsearch/gradle/internal/RestrictedBuildApiService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java index 2721ef76c24ae..2ffb72d56b9fd 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java @@ -76,7 +76,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:ccs-rolling-upgrade"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:correctness"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:eql:qa:mixed-node"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet:qa:rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:identity-provider:qa:idp-rest-tests"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:multi-cluster"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ilm:qa:multi-node");