Skip to content

Commit 5aa1756

Browse files
authored
Fixing tests (#116032) (#116038)
(cherry picked from commit 0f38b2b)
1 parent cb2ac67 commit 5aa1756

File tree

1 file changed

+28
-10
lines changed
  • x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference

1 file changed

+28
-10
lines changed

x-pack/plugin/inference/qa/inference-service-tests/src/javaRestTest/java/org/elasticsearch/xpack/inference/InferenceCrudIT.java

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import org.elasticsearch.client.ResponseException;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.inference.TaskType;
16+
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature;
1617

1718
import java.io.IOException;
19+
import java.util.ArrayList;
1820
import java.util.Arrays;
1921
import java.util.List;
2022
import java.util.Map;
@@ -132,7 +134,11 @@ public void testApisWithoutTaskType() throws IOException {
132134
@SuppressWarnings("unchecked")
133135
public void testGetServicesWithoutTaskType() throws IOException {
134136
List<Object> services = getAllServices();
135-
assertThat(services.size(), equalTo(19));
137+
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
138+
assertThat(services.size(), equalTo(19));
139+
} else {
140+
assertThat(services.size(), equalTo(18));
141+
}
136142

137143
String[] providers = new String[services.size()];
138144
for (int i = 0; i < services.size(); i++) {
@@ -141,16 +147,15 @@ public void testGetServicesWithoutTaskType() throws IOException {
141147
}
142148

143149
Arrays.sort(providers);
144-
assertArrayEquals(
145-
providers,
146-
List.of(
150+
151+
var providerList = new ArrayList<>(
152+
Arrays.asList(
147153
"alibabacloud-ai-search",
148154
"amazonbedrock",
149155
"anthropic",
150156
"azureaistudio",
151157
"azureopenai",
152158
"cohere",
153-
"elastic",
154159
"elasticsearch",
155160
"googleaistudio",
156161
"googlevertexai",
@@ -163,8 +168,12 @@ public void testGetServicesWithoutTaskType() throws IOException {
163168
"test_service",
164169
"text_embedding_test_service",
165170
"watsonxai"
166-
).toArray()
171+
)
167172
);
173+
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
174+
providerList.add(6, "elastic");
175+
}
176+
assertArrayEquals(providers, providerList.toArray());
168177
}
169178

170179
@SuppressWarnings("unchecked")
@@ -248,7 +257,12 @@ public void testGetServicesWithCompletionTaskType() throws IOException {
248257
@SuppressWarnings("unchecked")
249258
public void testGetServicesWithSparseEmbeddingTaskType() throws IOException {
250259
List<Object> services = getServices(TaskType.SPARSE_EMBEDDING);
251-
assertThat(services.size(), equalTo(6));
260+
261+
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
262+
assertThat(services.size(), equalTo(6));
263+
} else {
264+
assertThat(services.size(), equalTo(5));
265+
}
252266

253267
String[] providers = new String[services.size()];
254268
for (int i = 0; i < services.size(); i++) {
@@ -257,10 +271,14 @@ public void testGetServicesWithSparseEmbeddingTaskType() throws IOException {
257271
}
258272

259273
Arrays.sort(providers);
260-
assertArrayEquals(
261-
providers,
262-
List.of("alibabacloud-ai-search", "elastic", "elasticsearch", "hugging_face", "hugging_face_elser", "test_service").toArray()
274+
275+
var providerList = new ArrayList<>(
276+
Arrays.asList("alibabacloud-ai-search", "elasticsearch", "hugging_face", "hugging_face_elser", "test_service")
263277
);
278+
if (ElasticInferenceServiceFeature.ELASTIC_INFERENCE_SERVICE_FEATURE_FLAG.isEnabled()) {
279+
providerList.add(1, "elastic");
280+
}
281+
assertArrayEquals(providers, providerList.toArray());
264282
}
265283

266284
public void testSkipValidationAndStart() throws IOException {

0 commit comments

Comments
 (0)