Skip to content

Commit eac438b

Browse files
authored
Optimize RcsCcsCommonYamlTestSuiteIT and unmute tests (#132720)
1 parent 7e69b29 commit eac438b

File tree

2 files changed

+46
-50
lines changed

2 files changed

+46
-50
lines changed

muted-tests.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,6 @@ tests:
354354
- class: org.elasticsearch.xpack.esql.inference.bulk.BulkInferenceExecutorTests
355355
method: testSuccessfulExecution
356356
issue: https://github.com/elastic/elasticsearch/issues/130306
357-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
358-
method: test {p0=msearch/20_typed_keys/Multisearch test with typed_keys parameter for sampler and significant terms}
359-
issue: https://github.com/elastic/elasticsearch/issues/130472
360357
- class: org.elasticsearch.gradle.LoggedExecFuncTest
361358
method: failed tasks output logged to console when spooling true
362359
issue: https://github.com/elastic/elasticsearch/issues/119509
@@ -378,9 +375,6 @@ tests:
378375
- class: org.elasticsearch.xpack.esql.ccq.MultiClustersIT
379376
method: testLookupJoinAliases
380377
issue: https://github.com/elastic/elasticsearch/issues/131166
381-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
382-
method: test {p0=field_caps/40_time_series/Get simple time series field caps}
383-
issue: https://github.com/elastic/elasticsearch/issues/131225
384378
- class: org.elasticsearch.packaging.test.DockerTests
385379
method: test090SecurityCliPackaging
386380
issue: https://github.com/elastic/elasticsearch/issues/131107
@@ -396,9 +390,6 @@ tests:
396390
- class: org.elasticsearch.packaging.test.DockerTests
397391
method: test171AdditionalCliOptionsAreForwarded
398392
issue: https://github.com/elastic/elasticsearch/issues/120925
399-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
400-
method: test {p0=search/110_field_collapsing/field collapsing, inner_hits and maxConcurrentGroupRequests}
401-
issue: https://github.com/elastic/elasticsearch/issues/131348
402393
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
403394
method: test {p0=ml/delete_expired_data/Test delete expired data with body parameters}
404395
issue: https://github.com/elastic/elasticsearch/issues/131364
@@ -420,9 +411,6 @@ tests:
420411
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
421412
method: testLookupExplosionNoFetch
422413
issue: https://github.com/elastic/elasticsearch/issues/128720
423-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
424-
method: test {p0=vector-tile/20_aggregations/stats agg}
425-
issue: https://github.com/elastic/elasticsearch/issues/131484
426414
- class: org.elasticsearch.packaging.test.DockerTests
427415
method: test050BasicApiTests
428416
issue: https://github.com/elastic/elasticsearch/issues/120911
@@ -441,9 +429,6 @@ tests:
441429
- class: org.elasticsearch.packaging.test.DockerTests
442430
method: test010Install
443431
issue: https://github.com/elastic/elasticsearch/issues/131376
444-
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
445-
method: test {p0=search/40_indices_boost/Indices boost with alias}
446-
issue: https://github.com/elastic/elasticsearch/issues/131598
447432
- class: org.elasticsearch.compute.lucene.read.SortedSetOrdinalsBuilderTests
448433
method: testReader
449434
issue: https://github.com/elastic/elasticsearch/issues/131573

qa/ccs-common-rest/src/yamlRestTest/java/org/elasticsearch/test/rest/yaml/RcsCcsCommonYamlTestSuiteIT.java

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.util.Map;
4848
import java.util.Optional;
4949
import java.util.Set;
50+
import java.util.concurrent.atomic.AtomicBoolean;
5051
import java.util.concurrent.atomic.AtomicReference;
5152
import java.util.stream.Collectors;
5253
import java.util.stream.Stream;
@@ -75,6 +76,11 @@ public class RcsCcsCommonYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
7576
// the remote cluster is the one we write index operations etc... to
7677
private static final String REMOTE_CLUSTER_NAME = "remote_cluster";
7778
private static final AtomicReference<Map<String, Object>> API_KEY_MAP_REF = new AtomicReference<>();
79+
private static final AtomicBoolean isRemoteConfigured = new AtomicBoolean(false);
80+
private static final AtomicBoolean isCombinedComputed = new AtomicBoolean(false);
81+
private static final AtomicReference<TestFeatureService> combinedTestFeatureServiceRef = new AtomicReference<>();
82+
private static final AtomicReference<Set<String>> combinedOsSetRef = new AtomicReference<>();
83+
private static final AtomicReference<Set<String>> combinedNodeVersionsRef = new AtomicReference<>();
7884

7985
private static LocalClusterConfigProvider commonClusterConfig = cluster -> cluster.module("x-pack-async-search")
8086
.module("aggregations")
@@ -217,7 +223,7 @@ public void initSearchClient() throws IOException {
217223
basicAuthHeaderValue("remote_search_user", new SecureString("x-pack-test-password".toCharArray()))
218224
)
219225
.build(),
220-
clusterHosts.toArray(new HttpHost[clusterHosts.size()])
226+
clusterHosts.toArray(new HttpHost[0])
221227
);
222228
adminSearchClient = buildClient(
223229
Settings.builder()
@@ -226,13 +232,18 @@ public void initSearchClient() throws IOException {
226232
basicAuthHeaderValue("test_admin", new SecureString("x-pack-test-password".toCharArray()))
227233
)
228234
.build(),
229-
clusterHosts.toArray(new HttpHost[clusterHosts.size()])
235+
clusterHosts.toArray(new HttpHost[0])
230236
);
231237

232238
searchYamlTestClient = new TestCandidateAwareClient(getRestSpec(), searchClient, hosts, this::getClientBuilderWithSniffedHosts);
239+
}
240+
241+
assert searchClient != null;
242+
assert adminSearchClient != null;
243+
assert clusterHosts != null;
233244

245+
if (isRemoteConfigured.compareAndSet(false, true)) {
234246
configureRemoteCluster();
235-
// check that we have an established CCS connection
236247
Request request = new Request("GET", "_remote/info");
237248
Response response = adminSearchClient.performRequest(request);
238249
assertOK(response);
@@ -241,11 +252,6 @@ public void initSearchClient() throws IOException {
241252
assertEquals("::es_redacted::", responseObject.evaluate(REMOTE_CLUSTER_NAME + ".cluster_credentials"));
242253
logger.info("Established connection to remote cluster [" + REMOTE_CLUSTER_NAME + "]");
243254
}
244-
245-
assert searchClient != null;
246-
assert adminSearchClient != null;
247-
assert clusterHosts != null;
248-
249255
searchYamlTestClient.setTestCandidate(getTestCandidate());
250256
}
251257

@@ -288,42 +294,47 @@ protected ClientYamlTestExecutionContext createRestTestExecutionContext(
288294
// Ensure the test specific initialization is run by calling it explicitly (@Before annotations on base-derived class may
289295
// be called in a different order)
290296
initSearchClient();
291-
// Reconcile and provide unified features, os, version(s), based on both clientYamlTestClient and searchYamlTestClient
292-
var searchOs = readOsFromNodesInfo(adminSearchClient);
293-
var searchNodeVersions = readVersionsFromNodesInfo(adminSearchClient);
294-
var semanticNodeVersions = searchNodeVersions.stream()
295-
.map(ESRestTestCase::parseLegacyVersion)
296-
.flatMap(Optional::stream)
297-
.collect(Collectors.toSet());
298-
final TestFeatureService searchTestFeatureService = createTestFeatureService(
299-
getClusterStateFeatures(adminSearchClient),
300-
semanticNodeVersions
301-
);
302-
final TestFeatureService combinedTestFeatureService = (featureId, any) -> {
303-
boolean adminFeature = testFeatureService.clusterHasFeature(featureId, any);
304-
boolean searchFeature = searchTestFeatureService.clusterHasFeature(featureId, any);
305-
return any ? adminFeature || searchFeature : adminFeature && searchFeature;
306-
};
307297

308-
final Set<String> combinedOsSet = Stream.concat(osSet.stream(), Stream.of(searchOs)).collect(Collectors.toSet());
309-
final Set<String> combinedNodeVersions = Stream.concat(nodesVersions.stream(), searchNodeVersions.stream())
310-
.collect(Collectors.toSet());
298+
// Compute & cache combined features/OS/versions
299+
if (isCombinedComputed.compareAndSet(false, true)) {
300+
var searchOs = readOsFromNodesInfo(adminSearchClient);
301+
var searchNodeVersions = readVersionsFromNodesInfo(adminSearchClient);
302+
303+
var semanticNodeVersions = searchNodeVersions.stream()
304+
.map(ESRestTestCase::parseLegacyVersion)
305+
.flatMap(Optional::stream)
306+
.collect(Collectors.toSet());
307+
308+
final TestFeatureService searchTestFeatureService = createTestFeatureService(
309+
getClusterStateFeatures(adminSearchClient),
310+
semanticNodeVersions
311+
);
312+
313+
final TestFeatureService combinedTestFeatureService = (featureId, any) -> {
314+
boolean adminFeature = testFeatureService.clusterHasFeature(featureId, any);
315+
boolean searchFeature = searchTestFeatureService.clusterHasFeature(featureId, any);
316+
return any ? (adminFeature || searchFeature) : (adminFeature && searchFeature);
317+
};
318+
final Set<String> combinedOsSet = Stream.concat(osSet.stream(), Stream.of(searchOs)).collect(Collectors.toSet());
319+
final Set<String> combinedNodeVersions = Stream.concat(nodesVersions.stream(), searchNodeVersions.stream())
320+
.collect(Collectors.toSet());
321+
322+
combinedTestFeatureServiceRef.set(combinedTestFeatureService);
323+
combinedOsSetRef.set(combinedOsSet);
324+
combinedNodeVersionsRef.set(combinedNodeVersions);
325+
}
311326

312327
return new ClientYamlTestExecutionContext(
313328
clientYamlTestCandidate,
314329
clientYamlTestClient,
315330
randomizeContentType(),
316-
combinedNodeVersions,
317-
combinedTestFeatureService,
318-
combinedOsSet
331+
combinedNodeVersionsRef.get(),
332+
combinedTestFeatureServiceRef.get(),
333+
combinedOsSetRef.get()
319334
) {
320335
// depending on the API called, we either return the client running against the "write" or the "search" cluster here
321336
protected ClientYamlTestClient clientYamlTestClient(String apiName) {
322-
if (CCS_APIS.contains(apiName)) {
323-
return searchYamlTestClient;
324-
} else {
325-
return super.clientYamlTestClient(apiName);
326-
}
337+
return CCS_APIS.contains(apiName) ? searchYamlTestClient : super.clientYamlTestClient(apiName);
327338
}
328339
};
329340
} catch (IOException e) {

0 commit comments

Comments
 (0)