Skip to content

Commit 79f8140

Browse files
authored
[8.19] Fix MixedClusterEsqlSpecIT 8.11 BWC (#129841)
1 parent 2735a21 commit 79f8140

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ public static void wipeTestData() throws IOException {
163163
}
164164

165165
deleteInferenceEndpoints(adminClient());
166-
167166
}
168167

169168
public boolean logResults() {
@@ -295,13 +294,12 @@ protected final void doTest() throws Throwable {
295294
* not to emit duplicate warnings but for now it isn't worth fighting with. So! In
296295
* those environments we override this to deduplicate.
297296
* <p>
298-
* Note: This only applies to warnings declared as {@code warning:}. Those
299-
* declared as {@code warningRegex:} are always a list of
300-
* <strong>allowed</strong> warnings. {@code warningRegex:} matches 0 or more
301-
* warnings. There is no need to deduplicate because there's no expectation
302-
* of an exact match.
297+
* Note: This only applies to warnings declared as {@code warning:}. Those
298+
* declared as {@code warningRegex:} are always a list of
299+
* <strong>allowed</strong> warnings. {@code warningRegex:} matches 0 or more
300+
* warnings. There is no need to deduplicate because there's no expectation
301+
* of an exact match.
303302
* </p>
304-
*
305303
*/
306304
protected boolean deduplicateExactWarnings() {
307305
return false;

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,22 @@ public static void createInferenceEndpoints(RestClient client) throws IOExceptio
342342
}
343343
}
344344

345+
@SuppressWarnings("unchecked")
345346
public static void deleteInferenceEndpoints(RestClient client) throws IOException {
347+
Response response = client.performRequest(new Request("GET", "_inference/_all"));
348+
349+
try (InputStream content = response.getEntity().getContent()) {
350+
XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType().getValue());
351+
Map<String, ?> responseMap = XContentHelper.convertToMap(xContentType.xContent(), content, false);
352+
List<Map<String, ?>> endpoints = (List<Map<String, ?>>) responseMap.get("endpoints");
353+
for (Map<String, ?> endpoint : endpoints) {
354+
String inferenceId = (String) endpoint.get("inference_id");
355+
String taskType = (String) endpoint.get("task_type");
356+
if (inferenceId != null && taskType != null && inferenceId.startsWith(".") == false) {
357+
deleteInferenceEndpoint(client, inferenceId, TaskType.fromString(taskType));
358+
}
359+
}
360+
}
346361
deleteSparseEmbeddingInferenceEndpoint(client);
347362
deleteRerankInferenceEndpoint(client);
348363
deleteCompletionInferenceEndpoint(client);
@@ -360,7 +375,7 @@ public static void createSparseEmbeddingInferenceEndpoint(RestClient client) thr
360375
}
361376

362377
public static void deleteSparseEmbeddingInferenceEndpoint(RestClient client) throws IOException {
363-
deleteInferenceEndpoint(client, "test_sparse_inference");
378+
deleteInferenceEndpoint(client, "test_sparse_inference", TaskType.SPARSE_EMBEDDING);
364379
}
365380

366381
public static boolean clusterHasSparseEmbeddingInferenceEndpoint(RestClient client) throws IOException {
@@ -378,7 +393,7 @@ public static void createRerankInferenceEndpoint(RestClient client) throws IOExc
378393
}
379394

380395
public static void deleteRerankInferenceEndpoint(RestClient client) throws IOException {
381-
deleteInferenceEndpoint(client, "test_reranker");
396+
deleteInferenceEndpoint(client, "test_reranker", TaskType.RERANK);
382397
}
383398

384399
public static boolean clusterHasRerankInferenceEndpoint(RestClient client) throws IOException {
@@ -396,7 +411,7 @@ public static void createCompletionInferenceEndpoint(RestClient client) throws I
396411
}
397412

398413
public static void deleteCompletionInferenceEndpoint(RestClient client) throws IOException {
399-
deleteInferenceEndpoint(client, "test_completion");
414+
deleteInferenceEndpoint(client, "test_completion", TaskType.COMPLETION);
400415
}
401416

402417
public static boolean clusterHasCompletionInferenceEndpoint(RestClient client) throws IOException {
@@ -423,9 +438,9 @@ private static boolean clusterHasInferenceEndpoint(RestClient client, TaskType t
423438
return true;
424439
}
425440

426-
private static void deleteInferenceEndpoint(RestClient client, String inferenceId) throws IOException {
441+
private static void deleteInferenceEndpoint(RestClient client, String inferenceId, TaskType taskType) throws IOException {
427442
try {
428-
client.performRequest(new Request("DELETE", "_inference/" + inferenceId));
443+
client.performRequest(new Request("DELETE", "_inference/" + taskType + "/" + inferenceId));
429444
} catch (ResponseException e) {
430445
// 404 here means the endpoint was not created
431446
if (e.getResponse().getStatusLine().getStatusCode() != 404) {

x-pack/plugin/esql/qa/testFixtures/src/main/resources/mapping-colors.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"type": "dense_vector",
1414
"similarity": "l2_norm",
1515
"index_options": {
16-
"type": "hnsw"
16+
"type": "hnsw",
17+
"m": 16,
18+
"ef_construction": 100
1719
}
1820
}
1921
}

0 commit comments

Comments
 (0)