diff --git a/muted-tests.yml b/muted-tests.yml index c2d21e5327f6c..823ef396068a8 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -321,18 +321,12 @@ tests: - class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT method: test {csv-spec:unmapped-nullify.TsWithAggsByMissing} issue: https://github.com/elastic/elasticsearch/issues/142762 -- class: org.elasticsearch.xpack.inference.integration.AuthorizationTaskExecutorIT - method: testCreatesEisChatCompletionEndpoint - issue: https://github.com/elastic/elasticsearch/issues/140849 - class: org.elasticsearch.xpack.inference.external.http.sender.RequestExecutorServiceTests method: testExecute_Throws_WhenRateLimitedQueueIsFull issue: https://github.com/elastic/elasticsearch/issues/141231 - class: org.elasticsearch.xpack.esql.spatial.SpatialPushDownGeoShapeIT method: testQuantizedXY issue: https://github.com/elastic/elasticsearch/issues/141234 -- class: org.elasticsearch.xpack.inference.integration.AuthorizationTaskExecutorIT - method: testCreatesChatCompletion_AndThenCreatesTextEmbedding - issue: https://github.com/elastic/elasticsearch/issues/138012 - class: org.elasticsearch.compute.operator.topn.TopNOomRaceTests method: testRace {repeats = 15} issue: https://github.com/elastic/elasticsearch/issues/141471 diff --git a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/AuthorizationTaskExecutorIT.java b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/AuthorizationTaskExecutorIT.java index 2ed8102ab70dc..0011df6502ed2 100644 --- a/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/AuthorizationTaskExecutorIT.java +++ b/x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/AuthorizationTaskExecutorIT.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequestBuilder; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequestBuilder; +import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.internal.AdminClient; import org.elasticsearch.common.settings.Settings; @@ -53,6 +54,7 @@ import static org.elasticsearch.xpack.inference.services.elastic.response.ElasticInferenceServiceAuthorizationResponseEntityTests.RERANK_V1_ENDPOINT_ID; import static org.elasticsearch.xpack.inference.services.elastic.response.ElasticInferenceServiceAuthorizationResponseEntityTests.getEisRainbowSprinklesAuthorizationResponse; import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -83,9 +85,13 @@ public static void initClass() throws IOException { } @Before - public void createComponents() { + public void createComponents() throws Exception { modelRegistry = node().injector().getInstance(ModelRegistry.class); authorizationTaskExecutor = node().injector().getInstance(AuthorizationTaskExecutor.class); + + // Wait for inference indices to be created + assertBusy(() -> getEisEndpoints()); + ensureNoInitializingShards(); } @After @@ -212,8 +218,15 @@ static List getEisEndpoints(ModelRegistry modelRegistry) { var listener = new PlainActionFuture>(); modelRegistry.getAllModels(true, listener); - var endpoints = listener.actionGet(TimeValue.THIRTY_SECONDS); - return endpoints.stream().filter(m -> m.service().equals(ElasticInferenceService.NAME)).toList(); + try { + var endpoints = listener.actionGet(TimeValue.THIRTY_SECONDS); + return endpoints.stream().filter(m -> m.service().equals(ElasticInferenceService.NAME)).toList(); + } catch (SearchPhaseExecutionException e) { + // This can happen if the internal inference indices shards have not been initialized yet. + // We fail so that when this is called in assertBusy we can retry. + fail(); + return List.of(); + } } private void restartPollingTaskAndWaitForAuthResponse() throws Exception { @@ -329,6 +342,9 @@ public void testCreatesChatCompletion_AndThenCreatesTextEmbedding() throws Excep restartPollingTaskAndWaitForAuthResponse(); assertWebServerReceivedRequest(); + // Wait for the text embedding endpoint to be created + assertBusy(() -> assertThat(getEisEndpoints(), hasSize(2))); + var eisEndpoints = getEisEndpoints().stream().collect(Collectors.toMap(UnparsedModel::inferenceEntityId, Function.identity())); assertThat(eisEndpoints.size(), is(2));