Skip to content

Commit

Permalink
[Backport 2.13] Fixing default semantic use case integration test (#606)
Browse files Browse the repository at this point in the history
backport

Signed-off-by: Joshua Palis <[email protected]>
  • Loading branch information
joshpalis authored Mar 22, 2024
1 parent 1af14a0 commit 0f9eded
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.commons.rest.SecureRestClientBuilder;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.DeprecationHandler;
Expand Down Expand Up @@ -681,4 +683,22 @@ protected GetPipelineResponse getPipelines() throws IOException {
return GetPipelineResponse.fromXContent(parser);
}
}

@SuppressWarnings("unchecked")
protected List<String> catPlugins() throws IOException {
Response response = TestHelpers.makeRequest(
client(),
"GET",
"_cat/plugins?s=component&h=name,component,version,description&format=json",
null,
"",
List.of(new BasicHeader(HttpHeaders.USER_AGENT, ""))
);
List<Object> pluginsList = JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
response.getEntity().getContent()
).list();
return pluginsList.stream().map(o -> ((Map<String, Object>) o).get("component").toString()).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,22 @@ public void testDefaultSemanticSearchUseCaseWithFailureExpected() throws Excepti
response = provisionWorkflow(client(), workflowId);
}

// expecting a failure since there is no neural-search plugin in cluster to provide text-embedding processor
assertEquals(RestStatus.OK, TestHelpers.restStatus(response));
getAndAssertWorkflowStatus(client(), workflowId, State.FAILED, ProvisioningProgress.FAILED);

String error = getAndWorkflowStatusError(client(), workflowId);
assertTrue(
error.contains(
"org.opensearch.flowframework.exception.WorkflowStepException during step create_ingest_pipeline, restStatus: BAD_REQUEST"
)
);
// Distribution build contains all plugins, checking if plugins are part of the integration test cluster
List<String> plugins = catPlugins();
if (plugins.contains("opensearch-knn") && plugins.contains("neural-search")) {
getAndAssertWorkflowStatus(client(), workflowId, State.PROVISIONING, ProvisioningProgress.IN_PROGRESS);
} else {
// expecting a failure since there is no neural-search plugin in cluster to provide text-embedding processor
getAndAssertWorkflowStatus(client(), workflowId, State.FAILED, ProvisioningProgress.FAILED);
String error = getAndWorkflowStatusError(client(), workflowId);
assertTrue(
error.contains(
"org.opensearch.flowframework.exception.WorkflowStepException during step create_ingest_pipeline, restStatus: BAD_REQUEST"
)
);
}
}

public void testAllDefaultUseCasesCreation() throws Exception {
Expand Down

0 comments on commit 0f9eded

Please sign in to comment.