Skip to content

Commit 7344da0

Browse files
Fix HuggingFaceMixedIT test sometimes failing when run on version before 8.16 (#114061)
* Fix HuggingFaceMixedIT test sometimes failing when run on version before 8.16 * Fixing typo in expected error message
1 parent 991cff9 commit 7344da0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/HuggingFaceServiceMixedIT.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import static org.hamcrest.Matchers.containsString;
2223
import static org.hamcrest.Matchers.empty;
2324
import static org.hamcrest.Matchers.hasSize;
2425
import static org.hamcrest.Matchers.not;
@@ -27,6 +28,7 @@ public class HuggingFaceServiceMixedIT extends BaseMixedTestCase {
2728

2829
private static final String HF_EMBEDDINGS_ADDED = "8.12.0";
2930
private static final String HF_ELSER_ADDED = "8.12.0";
31+
private static final String HF_EMBEDDINGS_CHUNKING_SETTINGS_ADDED = "8.16.0";
3032
private static final String MINIMUM_SUPPORTED_VERSION = "8.15.0";
3133

3234
private static MockWebServer embeddingsServer;
@@ -59,7 +61,24 @@ public void testHFEmbeddings() throws IOException {
5961
final String inferenceId = "mixed-cluster-embeddings";
6062

6163
embeddingsServer.enqueue(new MockResponse().setResponseCode(200).setBody(embeddingResponse()));
62-
put(inferenceId, embeddingConfig(getUrl(embeddingsServer)), TaskType.TEXT_EMBEDDING);
64+
65+
try {
66+
put(inferenceId, embeddingConfig(getUrl(embeddingsServer)), TaskType.TEXT_EMBEDDING);
67+
} catch (Exception e) {
68+
if (bwcVersion.before(Version.fromString(HF_EMBEDDINGS_CHUNKING_SETTINGS_ADDED))) {
69+
// Chunking settings were added in 8.16.0. if the version is before that, an exception will be thrown if the index mapping
70+
// was created based on a mapping from an old node
71+
assertThat(
72+
e.getMessage(),
73+
containsString(
74+
"One or more nodes in your cluster does not support chunking_settings. "
75+
+ "Please update all nodes in your cluster to the latest version to use chunking_settings."
76+
)
77+
);
78+
return;
79+
}
80+
}
81+
6382
var configs = (List<Map<String, Object>>) get(TaskType.TEXT_EMBEDDING, inferenceId).get("endpoints");
6483
assertThat(configs, hasSize(1));
6584
assertEquals("hugging_face", configs.get(0).get("service"));

0 commit comments

Comments
 (0)