Skip to content

Commit 362cb06

Browse files
committed
fix more tests
1 parent 29c654b commit 362cb06

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ public MultiClusterSpecIT(
111111
super(fileName, groupName, testName, lineNumber, convertToRemoteIndices(testCase), instructions, mode);
112112
}
113113

114+
// TODO: think how to handle this better
115+
public static final Set<String> LOOKUP_JOIN_AFTER_STATS_TESTS = Set.of(
116+
"StatsAndLookupIPAndMessageFromIndex",
117+
"JoinMaskingRegex",
118+
"StatsAndLookupIPFromIndex",
119+
"StatsAndLookupMessageFromIndex"
120+
);
121+
114122
@Override
115123
protected void shouldSkipTest(String testName) throws IOException {
116124
boolean remoteMetadata = testCase.requiredCapabilities.contains(METADATA_FIELDS_REMOTE_TEST.capabilityName());
@@ -138,6 +146,8 @@ protected void shouldSkipTest(String testName) throws IOException {
138146
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
139147
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));
140148
assumeFalse("FORK not yet supported in CCS", testCase.requiredCapabilities.contains(FORK_V7.capabilityName()));
149+
// Tests that use capabilities not supported in CCS
150+
assumeFalse("LOOKUP JOIN after stats not yet supported in CCS", LOOKUP_JOIN_AFTER_STATS_TESTS.contains(testName));
141151
}
142152

143153
@Override
@@ -186,8 +196,9 @@ protected RestClient buildClient(Settings settings, HttpHost[] localHosts) throw
186196
// These indices are used in metadata tests so we want them on remote only for consistency
187197
public static final List<String> METADATA_INDICES = List.of("employees", "apps", "ul_logs");
188198

189-
// These are loopkup indices, we want them on remotes and locals
190-
public static final Set<String> LOOKUP_INDICES = Stream.of(
199+
// These are lookup indices, we want them on both remotes and locals
200+
// TODO: can we somehow find it from the data loader?
201+
public static final Set<String> LOOKUP_INDICES = Set.of(
191202
"languages_nested_fields",
192203
"languages_lookup",
193204
"clientips_lookup",
@@ -199,7 +210,9 @@ protected RestClient buildClient(Settings settings, HttpHost[] localHosts) throw
199210
"languages_lookup_non_unique_key",
200211
"lookup_sample_data_ts_nanos",
201212
"service_owners"
202-
).map(i -> "/" + i + "/_bulk").collect(Collectors.toSet());
213+
);
214+
215+
public static final Set<String> LOOKUP_ENDPOINTS = LOOKUP_INDICES.stream().map(i -> "/" + i + "/_bulk").collect(Collectors.toSet());
203216

204217
public static final Set<String> ENRICH_ENDPOINTS = ENRICH_SOURCE_INDICES.stream()
205218
.map(i -> "/" + i + "/_bulk")
@@ -225,7 +238,7 @@ static RestClient twoClients(RestClient localClient, RestClient remoteClient) th
225238
return remoteClient.performRequest(request);
226239
} else if (endpoint.endsWith("/_bulk")
227240
&& ENRICH_ENDPOINTS.contains(endpoint) == false
228-
&& LOOKUP_INDICES.contains(endpoint) == false) {
241+
&& LOOKUP_ENDPOINTS.contains(endpoint) == false) {
229242
return bulkClient.performRequest(request);
230243
} else {
231244
Request[] clones = cloneRequests(request, 2);
@@ -277,13 +290,19 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
277290
String query = testCase.query;
278291
String[] commands = query.split("\\|");
279292
String first = commands[0].trim();
293+
// If true, we're using *:index, otherwise we're using *:index,index
294+
boolean onlyRemotes = canUseRemoteIndicesOnly() && randomBoolean();
280295
if (commands[0].toLowerCase(Locale.ROOT).startsWith("from")) {
281296
String[] parts = commands[0].split("(?i)metadata");
282297
assert parts.length >= 1 : parts;
283298
String fromStatement = parts[0];
284299
String[] localIndices = fromStatement.substring("FROM ".length()).split(",");
300+
if (Arrays.stream(localIndices).anyMatch(i -> LOOKUP_INDICES.contains(i.trim().toLowerCase()))) {
301+
// If the query contains lookup indices, use only remotes to avoid duplication
302+
onlyRemotes = true;
303+
}
285304
final String remoteIndices;
286-
if (canUseRemoteIndicesOnly() && randomBoolean()) {
305+
if (onlyRemotes) {
287306
remoteIndices = Arrays.stream(localIndices).map(index -> "*:" + index.trim()).collect(Collectors.joining(","));
288307
} else {
289308
remoteIndices = Arrays.stream(localIndices)
@@ -297,7 +316,7 @@ static CsvSpecReader.CsvTestCase convertToRemoteIndices(CsvSpecReader.CsvTestCas
297316
String[] parts = commands[0].split("\\s+");
298317
assert parts.length >= 2 : commands[0];
299318
String[] indices = parts[1].split(",");
300-
if (canUseRemoteIndicesOnly() && randomBoolean()) {
319+
if (onlyRemotes) {
301320
parts[1] = Arrays.stream(indices).map(index -> "*:" + index.trim()).collect(Collectors.joining(","));
302321
} else {
303322
parts[1] = Arrays.stream(indices).map(index -> "*:" + index.trim() + "," + index.trim()).collect(Collectors.joining(","));

x-pack/plugin/esql/qa/testFixtures/src/main/resources/lookup-join.csv-spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ salary_change.long:double|foo:long
15911591
joinMaskingEval
15921592
required_capability: join_lookup_v12
15931593
required_capability: fix_join_masking_eval
1594-
from languag*, -languages_mixed_numerics
1594+
from languages,languages_lookup,languages_lookup_non_unique_key,languages_nested_fields
15951595
| eval type = null
15961596
| rename language_name as message
15971597
| lookup join message_types_lookup on message

0 commit comments

Comments
 (0)