From 2b7498571fd42c05d88a921ed709a341184c4a0c Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 14:31:25 +0300 Subject: [PATCH 1/6] update init code --- .../yaml/RcsCcsCommonYamlTestSuiteIT.java | 94 ++++++++++++------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java index 577bb4be8629b..0a12f4e9d15f3 100644 --- a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java +++ b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java @@ -36,6 +36,7 @@ import org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT.TestCandidateAwareClient; import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; @@ -47,6 +48,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -75,6 +77,19 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase { // the remote cluster is the one we write index operations etc... to private static final String REMOTE_CLUSTER_NAME = "remote_cluster"; private static final AtomicReference> API_KEY_MAP_REF = new AtomicReference<>(); + private static final AtomicBoolean isRemoteConfigured = new AtomicBoolean(false); + private static final AtomicBoolean isCombinedComputed = new AtomicBoolean(false); + private static final AtomicReference combinedTestFeatureServiceRef = new AtomicReference<>(); + private static final AtomicReference> combinedOsSetRef = new AtomicReference<>(); + private static final AtomicReference> combinedNodeVersionsRef = new AtomicReference<>(); + + private static long suiteStartNanos; + + @BeforeClass + public static void startSuiteTimer() { + suiteStartNanos = System.nanoTime(); + logger.info("Starting {}…", RcsCcsCommonYamlTestSuiteIT.class.getSimpleName()); + } private static LocalClusterConfigProvider commonClusterConfig = cluster -> cluster.module("x-pack-async-search") .module("aggregations") @@ -99,7 +114,7 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase { private static ElasticsearchCluster fulfillingCluster = ElasticsearchCluster.local() .name(REMOTE_CLUSTER_NAME) - .nodes(2) + .nodes(1) .setting("node.roles", "[data,ingest,master]") .setting("remote_cluster_server.enabled", "true") .setting("remote_cluster.port", "0") @@ -217,7 +232,7 @@ public void initSearchClient() throws IOException { basicAuthHeaderValue("remote_search_user", new SecureString("x-pack-test-password".toCharArray())) ) .build(), - clusterHosts.toArray(new HttpHost[clusterHosts.size()]) + clusterHosts.toArray(new HttpHost[0]) ); adminSearchClient = buildClient( Settings.builder() @@ -226,13 +241,18 @@ public void initSearchClient() throws IOException { basicAuthHeaderValue("test_admin", new SecureString("x-pack-test-password".toCharArray())) ) .build(), - clusterHosts.toArray(new HttpHost[clusterHosts.size()]) + clusterHosts.toArray(new HttpHost[0]) ); searchYamlTestClient = new TestCandidateAwareClient(getRestSpec(), searchClient, hosts, this::getClientBuilderWithSniffedHosts); + } + assert searchClient != null; + assert adminSearchClient != null; + assert clusterHosts != null; + + if (isRemoteConfigured.compareAndSet(false, true)) { configureRemoteCluster(); - // check that we have an established CCS connection Request request = new Request("GET", "_remote/info"); Response response = adminSearchClient.performRequest(request); assertOK(response); @@ -241,11 +261,6 @@ public void initSearchClient() throws IOException { assertEquals("::es_redacted::", responseObject.evaluate(REMOTE_CLUSTER_NAME + ".cluster_credentials")); logger.info("Established connection to remote cluster [" + REMOTE_CLUSTER_NAME + "]"); } - - assert searchClient != null; - assert adminSearchClient != null; - assert clusterHosts != null; - searchYamlTestClient.setTestCandidate(getTestCandidate()); } @@ -288,42 +303,47 @@ protected ClientYamlTestExecutionContext createRestTestExecutionContext( // Ensure the test specific initialization is run by calling it explicitly (@Before annotations on base-derived class may // be called in a different order) initSearchClient(); - // Reconcile and provide unified features, os, version(s), based on both clientYamlTestClient and searchYamlTestClient - var searchOs = readOsFromNodesInfo(adminSearchClient); - var searchNodeVersions = readVersionsFromNodesInfo(adminSearchClient); - var semanticNodeVersions = searchNodeVersions.stream() - .map(ESRestTestCase::parseLegacyVersion) - .flatMap(Optional::stream) - .collect(Collectors.toSet()); - final TestFeatureService searchTestFeatureService = createTestFeatureService( - getClusterStateFeatures(adminSearchClient), - semanticNodeVersions - ); - final TestFeatureService combinedTestFeatureService = (featureId, any) -> { - boolean adminFeature = testFeatureService.clusterHasFeature(featureId, any); - boolean searchFeature = searchTestFeatureService.clusterHasFeature(featureId, any); - return any ? adminFeature || searchFeature : adminFeature && searchFeature; - }; - final Set combinedOsSet = Stream.concat(osSet.stream(), Stream.of(searchOs)).collect(Collectors.toSet()); - final Set combinedNodeVersions = Stream.concat(nodesVersions.stream(), searchNodeVersions.stream()) - .collect(Collectors.toSet()); + // Compute & cache combined features/OS/versions + if (isCombinedComputed.compareAndSet(false, true)) { + var searchOs = readOsFromNodesInfo(adminSearchClient); + var searchNodeVersions = readVersionsFromNodesInfo(adminSearchClient); + + var semanticNodeVersions = searchNodeVersions.stream() + .map(ESRestTestCase::parseLegacyVersion) + .flatMap(Optional::stream) + .collect(Collectors.toSet()); + + final TestFeatureService searchTestFeatureService = createTestFeatureService( + getClusterStateFeatures(adminSearchClient), + semanticNodeVersions + ); + + final TestFeatureService combinedTestFeatureService = (featureId, any) -> { + boolean adminFeature = testFeatureService.clusterHasFeature(featureId, any); + boolean searchFeature = searchTestFeatureService.clusterHasFeature(featureId, any); + return any ? (adminFeature || searchFeature) : (adminFeature && searchFeature); + }; + final Set combinedOsSet = Stream.concat(osSet.stream(), Stream.of(searchOs)).collect(Collectors.toSet()); + final Set combinedNodeVersions = Stream.concat(nodesVersions.stream(), searchNodeVersions.stream()) + .collect(Collectors.toSet()); + + combinedTestFeatureServiceRef.set(combinedTestFeatureService); + combinedOsSetRef.set(combinedOsSet); + combinedNodeVersionsRef.set(combinedNodeVersions); + } return new ClientYamlTestExecutionContext( clientYamlTestCandidate, clientYamlTestClient, randomizeContentType(), - combinedNodeVersions, - combinedTestFeatureService, - combinedOsSet + combinedNodeVersionsRef.get(), + combinedTestFeatureServiceRef.get(), + combinedOsSetRef.get() ) { // depending on the API called, we either return the client running against the "write" or the "search" cluster here protected ClientYamlTestClient clientYamlTestClient(String apiName) { - if (CCS_APIS.contains(apiName)) { - return searchYamlTestClient; - } else { - return super.clientYamlTestClient(apiName); - } + return CCS_APIS.contains(apiName) ? searchYamlTestClient : super.clientYamlTestClient(apiName); } }; } catch (IOException e) { @@ -336,6 +356,8 @@ public static void closeSearchClients() throws IOException { try { IOUtils.close(searchClient, adminSearchClient); } finally { + long durMs = (System.nanoTime() - suiteStartNanos) / 1_000_000L; + logger.info("{} finished in {} ms", RcsCcsCommonYamlTestSuiteIT.class.getSimpleName(), durMs); clusterHosts = null; } } From 1da8813881ea23ac2caeb99d66bd813129d29f18 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 14:38:46 +0300 Subject: [PATCH 2/6] unmute tests --- muted-tests.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 0f318ec9e2122..569ae26fbfa8c 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -356,9 +356,6 @@ tests: - class: org.elasticsearch.xpack.esql.inference.bulk.BulkInferenceExecutorTests method: testSuccessfulExecution issue: https://github.com/elastic/elasticsearch/issues/130306 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=msearch/20_typed_keys/Multisearch test with typed_keys parameter for sampler and significant terms} - issue: https://github.com/elastic/elasticsearch/issues/130472 - class: org.elasticsearch.gradle.LoggedExecFuncTest method: failed tasks output logged to console when spooling true issue: https://github.com/elastic/elasticsearch/issues/119509 @@ -380,9 +377,6 @@ tests: - class: org.elasticsearch.xpack.esql.ccq.MultiClustersIT method: testLookupJoinAliases issue: https://github.com/elastic/elasticsearch/issues/131166 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=field_caps/40_time_series/Get simple time series field caps} - issue: https://github.com/elastic/elasticsearch/issues/131225 - class: org.elasticsearch.packaging.test.DockerTests method: test090SecurityCliPackaging issue: https://github.com/elastic/elasticsearch/issues/131107 @@ -398,9 +392,6 @@ tests: - class: org.elasticsearch.packaging.test.DockerTests method: test171AdditionalCliOptionsAreForwarded issue: https://github.com/elastic/elasticsearch/issues/120925 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests} - issue: https://github.com/elastic/elasticsearch/issues/131348 - class: org.elasticsearch.xpack.test.rest.XPackRestIT method: test {p0=ml/delete_expired_data/Test delete expired data with body parameters} issue: https://github.com/elastic/elasticsearch/issues/131364 @@ -422,9 +413,6 @@ tests: - class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT method: testLookupExplosionNoFetch issue: https://github.com/elastic/elasticsearch/issues/128720 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=vector-tile/20_aggregations/stats agg} - issue: https://github.com/elastic/elasticsearch/issues/131484 - class: org.elasticsearch.packaging.test.DockerTests method: test050BasicApiTests issue: https://github.com/elastic/elasticsearch/issues/120911 @@ -443,9 +431,6 @@ tests: - class: org.elasticsearch.packaging.test.DockerTests method: test010Install issue: https://github.com/elastic/elasticsearch/issues/131376 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=search/40_indices_boost/Indices boost with alias} - issue: https://github.com/elastic/elasticsearch/issues/131598 - class: org.elasticsearch.compute.lucene.read.SortedSetOrdinalsBuilderTests method: testReader issue: https://github.com/elastic/elasticsearch/issues/131573 @@ -458,9 +443,6 @@ tests: - class: org.elasticsearch.xpack.restart.FullClusterRestartIT method: testWatcherWithApiKey {cluster=UPGRADED} issue: https://github.com/elastic/elasticsearch/issues/131964 -- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT - method: test {p0=search/600_flattened_ignore_above/flattened ignore_above multi-value field} - issue: https://github.com/elastic/elasticsearch/issues/131967 - class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS1EnrichUnavailableRemotesIT method: testEsqlEnrichWithSkipUnavailable issue: https://github.com/elastic/elasticsearch/issues/132078 From c1302c99fb537f345a4af7118b61ee3985e7a5e1 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 16:04:34 +0300 Subject: [PATCH 3/6] Remove test code --- .../test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java index 0a12f4e9d15f3..143df75b9200f 100644 --- a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java +++ b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java @@ -83,14 +83,6 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase { private static final AtomicReference> combinedOsSetRef = new AtomicReference<>(); private static final AtomicReference> combinedNodeVersionsRef = new AtomicReference<>(); - private static long suiteStartNanos; - - @BeforeClass - public static void startSuiteTimer() { - suiteStartNanos = System.nanoTime(); - logger.info("Starting {}…", RcsCcsCommonYamlTestSuiteIT.class.getSimpleName()); - } - private static LocalClusterConfigProvider commonClusterConfig = cluster -> cluster.module("x-pack-async-search") .module("aggregations") .module("mapper-extras") @@ -356,8 +348,6 @@ public static void closeSearchClients() throws IOException { try { IOUtils.close(searchClient, adminSearchClient); } finally { - long durMs = (System.nanoTime() - suiteStartNanos) / 1_000_000L; - logger.info("{} finished in {} ms", RcsCcsCommonYamlTestSuiteIT.class.getSimpleName(), durMs); clusterHosts = null; } } From 608b86434ae468ca08b4481bb5b5b9d24c4dea37 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 16:08:29 +0300 Subject: [PATCH 4/6] Remove unused import --- .../test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java index 143df75b9200f..3459ef61536f9 100644 --- a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java +++ b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java @@ -36,7 +36,6 @@ import org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT.TestCandidateAwareClient; import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; From ba907d2593902d79e637db6eaa4a3e2acbb89c44 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 16:54:07 +0300 Subject: [PATCH 5/6] update after review --- .../test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java index 3459ef61536f9..e8fafada735a3 100644 --- a/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java +++ b/qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java @@ -105,7 +105,7 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase { private static ElasticsearchCluster fulfillingCluster = ElasticsearchCluster.local() .name(REMOTE_CLUSTER_NAME) - .nodes(1) + .nodes(2) .setting("node.roles", "[data,ingest,master]") .setting("remote_cluster_server.enabled", "true") .setting("remote_cluster.port", "0") From ff228885ef2704e8679d2b094f15591e3c4d50d3 Mon Sep 17 00:00:00 2001 From: Dimitris Rempapis Date: Tue, 12 Aug 2025 18:00:18 +0300 Subject: [PATCH 6/6] removed not muted test --- muted-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 6ab77f73f155f..298be387a0532 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -443,9 +443,6 @@ tests: - class: org.elasticsearch.xpack.restart.FullClusterRestartIT method: testWatcherWithApiKey {cluster=UPGRADED} issue: https://github.com/elastic/elasticsearch/issues/131964 -- class: org.elasticsearch.xpack.remotecluster.CrossClusterEsqlRCS1EnrichUnavailableRemotesIT - method: testEsqlEnrichWithSkipUnavailable - issue: https://github.com/elastic/elasticsearch/issues/132078 - class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT method: test {p0=search/600_flattened_ignore_above/flattened ignore_above multi-value field} issue: https://github.com/elastic/elasticsearch/issues/131967