Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing default semantic use case integration test #604

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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 @@ -706,4 +708,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,
"",
ImmutableList.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());
}
joshpalis marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ public void testDefaultCohereUseCase() throws Exception {
}

public void testDefaultSemanticSearchUseCaseWithFailureExpected() throws Exception {

// Hit Create Workflow API with original template
Response response = createWorkflowWithUseCase(client(), "semantic_search");
assertEquals(RestStatus.CREATED, TestHelpers.restStatus(response));
Expand All @@ -455,17 +454,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"
)
);
}
}

}
Loading