From d4ad4ec74fba92b74f07d48178e00228454a819a Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Thu, 17 Jul 2025 15:41:19 +0200 Subject: [PATCH 1/3] Migrating downsample with security yaml IT tests (cherry picked from commit 71fc3908bb325633a8fe2d2e8154d4c1084e6242) --- .../internal/RestrictedBuildApiService.java | 1 - .../downsample/qa/with-security/build.gradle | 17 +++--- .../xpack/downsample/DownsampleRestIT.java | 35 ------------ .../DownsampleWithSecurityRestIT.java | 53 +++++++++++++++++++ 4 files changed, 61 insertions(+), 45 deletions(-) delete mode 100644 x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java create mode 100644 x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java 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 205930133156c..b528e451ebcf8 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 @@ -58,7 +58,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:third-party:slack"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:early-deprecation-rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:deprecation:qa:rest"); - map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:downsample:qa:with-security"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest-with-advanced-security"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:enrich:qa:rest-with-security"); diff --git a/x-pack/plugin/downsample/qa/with-security/build.gradle b/x-pack/plugin/downsample/qa/with-security/build.gradle index 29980b95d0291..7417cccbac633 100644 --- a/x-pack/plugin/downsample/qa/with-security/build.gradle +++ b/x-pack/plugin/downsample/qa/with-security/build.gradle @@ -5,12 +5,11 @@ * 2.0. */ -import org.elasticsearch.gradle.Version - -apply plugin: 'elasticsearch.legacy-yaml-rest-test' -apply plugin: 'elasticsearch.legacy-yaml-rest-compat-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' +apply plugin: 'elasticsearch.yaml-rest-compat-test' dependencies { + testImplementation project(path: ':test:test-clusters') yamlRestTestImplementation project(path: xpackModule('rollup')) } @@ -20,11 +19,11 @@ restResources { } } -testClusters.configureEach { - testDistribution = 'DEFAULT' - setting 'xpack.license.self_generated.type', 'trial' - setting 'xpack.security.enabled', 'true' - user username: 'elastic_admin', password: 'admin-password' +tasks.named('yamlRestTest') { + usesDefaultDistribution("to be triaged") +} +tasks.named('yamlRestCompatTest') { + usesDefaultDistribution("to be triaged") } if (buildParams.inFipsJvm){ diff --git a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java b/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java deleted file mode 100644 index 7bdbd5e6b0937..0000000000000 --- a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java +++ /dev/null @@ -1,35 +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. - */ - -package org.elasticsearch.xpack.downsample; - -import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; - -import org.elasticsearch.common.settings.SecureString; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; -import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; - -public class DownsampleRestIT extends ESClientYamlSuiteTestCase { - - public DownsampleRestIT(final ClientYamlTestCandidate testCandidate) { - super(testCandidate); - } - - @Override - protected Settings restClientSettings() { - String authentication = basicAuthHeaderValue("elastic_admin", new SecureString("admin-password".toCharArray())); - return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", authentication).build(); - } - - @ParametersFactory - public static Iterable parameters() throws Exception { - return ESClientYamlSuiteTestCase.createParameters(); - } - -} diff --git a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java b/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java new file mode 100644 index 0000000000000..42d0995e8667b --- /dev/null +++ b/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java @@ -0,0 +1,53 @@ +/* + * 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.downsample; + +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; + +import org.elasticsearch.common.settings.SecureString; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.local.distribution.DistributionType; +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; +import org.junit.ClassRule; + +public class DownsampleWithSecurityRestIT extends ESClientYamlSuiteTestCase { + + public static final String USERNAME = "elastic_admin"; + public static final String PASSWORD = "admin-password"; + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .distribution(DistributionType.DEFAULT) + .setting("xpack.license.self_generated.type", "trial") + .setting("xpack.security.enabled", "true") + .user(USERNAME, PASSWORD) + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + + public DownsampleWithSecurityRestIT(final ClientYamlTestCandidate testCandidate) { + super(testCandidate); + } + + @Override + protected Settings restClientSettings() { + String authentication = basicAuthHeaderValue(USERNAME, new SecureString(PASSWORD.toCharArray())); + return Settings.builder().put(super.restClientSettings()).put(ThreadContext.PREFIX + ".Authorization", authentication).build(); + } + + @ParametersFactory + public static Iterable parameters() throws Exception { + return ESClientYamlSuiteTestCase.createParameters(new String[] {"downsample/10_basic"}); + } +} From 777b23e5c4dbc12a5a9c61f40f7ed398ae6bf721 Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Thu, 17 Jul 2025 16:19:59 +0200 Subject: [PATCH 2/3] Consolidate DownsampleWithSecurityRestIT under the same rest test suite (cherry picked from commit 001c3dada871951139c7508164ce1995061c71d7) --- .../xpack/downsample/DownsampleRestIT.java | 2 +- .../downsample/DownsampleWithBasicRestIT.java | 2 +- .../DownsampleWithSecurityRestIT.java | 2 +- .../downsample-with-security}/10_basic.yml | 0 .../downsample/qa/with-security/build.gradle | 32 ------------------- 5 files changed, 3 insertions(+), 35 deletions(-) rename x-pack/plugin/downsample/qa/{with-security => rest}/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java (98%) rename x-pack/plugin/downsample/qa/{with-security/src/yamlRestTest/resources/rest-api-spec/test/downsample => rest/src/yamlRestTest/resources/rest-api-spec/test/downsample-with-security}/10_basic.yml (100%) delete mode 100644 x-pack/plugin/downsample/qa/with-security/build.gradle diff --git a/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java index 6794bc47fa3cd..dfef469a27812 100644 --- a/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java +++ b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleRestIT.java @@ -35,7 +35,7 @@ public DownsampleRestIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return ESClientYamlSuiteTestCase.createParameters(); + return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample" }); } } diff --git a/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithBasicRestIT.java b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithBasicRestIT.java index 8f75e76315844..d9a44ab1508d6 100644 --- a/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithBasicRestIT.java +++ b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithBasicRestIT.java @@ -34,7 +34,7 @@ public DownsampleWithBasicRestIT(final ClientYamlTestCandidate testCandidate) { @ParametersFactory public static Iterable parameters() throws Exception { - return ESClientYamlSuiteTestCase.createParameters(); + return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample" }); } } diff --git a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java similarity index 98% rename from x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java rename to x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java index 42d0995e8667b..afde47b377400 100644 --- a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java +++ b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/java/org/elasticsearch/xpack/downsample/DownsampleWithSecurityRestIT.java @@ -48,6 +48,6 @@ protected Settings restClientSettings() { @ParametersFactory public static Iterable parameters() throws Exception { - return ESClientYamlSuiteTestCase.createParameters(new String[] {"downsample/10_basic"}); + return ESClientYamlSuiteTestCase.createParameters(new String[] { "downsample-with-security" }); } } diff --git a/x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/resources/rest-api-spec/test/downsample/10_basic.yml b/x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample-with-security/10_basic.yml similarity index 100% rename from x-pack/plugin/downsample/qa/with-security/src/yamlRestTest/resources/rest-api-spec/test/downsample/10_basic.yml rename to x-pack/plugin/downsample/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/downsample-with-security/10_basic.yml diff --git a/x-pack/plugin/downsample/qa/with-security/build.gradle b/x-pack/plugin/downsample/qa/with-security/build.gradle deleted file mode 100644 index 7417cccbac633..0000000000000 --- a/x-pack/plugin/downsample/qa/with-security/build.gradle +++ /dev/null @@ -1,32 +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' - -dependencies { - testImplementation project(path: ':test:test-clusters') - yamlRestTestImplementation project(path: xpackModule('rollup')) -} - -restResources { - restApi { - include '_common', 'bulk', 'cluster', 'indices', 'search', 'ingest.put_pipeline', 'ingest.delete_pipeline' - } -} - -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 } -} From 73d6877750f04634a4539f39a719a26dcbbeca3d Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Fri, 18 Jul 2025 12:49:45 +0200 Subject: [PATCH 3/3] Unmute --- muted-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 3ae56c1a19053..2f8d97e708524 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -472,9 +472,6 @@ tests: - class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT method: test issue: https://github.com/elastic/elasticsearch/issues/131508 -- class: org.elasticsearch.xpack.downsample.DownsampleWithBasicRestIT - method: test {p0=downsample-with-security/10_basic/Downsample index} - issue: https://github.com/elastic/elasticsearch/issues/131513 # Examples: #