Skip to content

Commit

Permalink
[Backport 2.x] Set up Rest Integration Test framework (#302)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7986cbf)

Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Widdis <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 70f7c00 commit 9c538b9
Show file tree
Hide file tree
Showing 17 changed files with 950 additions and 11 deletions.
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ integTest {
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")

// Only rest case can run with remote cluster
if (System.getProperty("tests.rest.cluster") != null) {
filter {
includeTestsMatching "org.opensearch.flowframework.rest.*IT"
}
}


// doFirst delays this block until execution time
doFirst {
Expand Down Expand Up @@ -263,6 +270,25 @@ testClusters.integTest {
}
}

// Remote Integration Tests
task integTestRemote(type: RestIntegTestTask) {
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath

systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")
systemProperty 'cluster.number_of_nodes', "${_numNodes}"
systemProperty 'tests.security.manager', 'false'

// Run tests with remote cluster only if rest case is defined
if (System.getProperty("tests.rest.cluster") != null) {
filter {
includeTestsMatching "org.opensearch.flowframework.rest.*IT"
}
}
}

// Automatically sets up the integration test cluster locally
run {
useCluster testClusters.integTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ protected void doExecute(Task task, GetWorkflowStateRequest request, ActionListe
WorkflowState workflowState = WorkflowState.parse(parser);
listener.onResponse(new GetWorkflowStateResponse(workflowState, request.getAll()));
} catch (Exception e) {
logger.error("Failed to parse workflowState" + r.getId(), e);
listener.onFailure(new FlowFrameworkException("Failed to parse workflowState" + r.getId(), RestStatus.BAD_REQUEST));
logger.error("Failed to parse workflowState: " + r.getId(), e);
listener.onFailure(
new FlowFrameworkException("Failed to parse workflowState: " + r.getId(), RestStatus.BAD_REQUEST)
);
}
} else {
listener.onFailure(new FlowFrameworkException("Fail to find workflow", RestStatus.NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ protected void doExecute(Task task, WorkflowRequest request, ActionListener<Work
),
ActionListener.wrap(updateResponse -> {
logger.info("updated workflow {} state to PROVISIONING", request.getWorkflowId());
listener.onResponse(new WorkflowResponse(workflowId));
}, exception -> { logger.error("Failed to update workflow state : {}", exception.getMessage()); })
);

// Respond to rest action then execute provisioning workflow async
listener.onResponse(new WorkflowResponse(workflowId));
executeWorkflowAsync(workflowId, provisionProcessSequence, listener);

}, exception -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,13 @@ public void onFailure(Exception e) {
NAME_FIELD,
VERSION_FIELD,
MODEL_FORMAT,
MODEL_GROUP_ID,
MODEL_TYPE,
EMBEDDING_DIMENSION,
FRAMEWORK_TYPE,
MODEL_CONTENT_HASH_VALUE,
URL
);
Set<String> optionalKeys = Set.of(DESCRIPTION_FIELD, ALL_CONFIG);
Set<String> optionalKeys = Set.of(DESCRIPTION_FIELD, MODEL_GROUP_ID, ALL_CONFIG);

try {
Map<String, Object> inputs = ParseUtils.getInputsFromPreviousSteps(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ public void validateGraph(List<ProcessNode> processNodes, WorkflowValidator vali
if (!allInputs.containsAll(expectedInputs)) {
expectedInputs.removeAll(allInputs);
throw new FlowFrameworkException(
"Invalid graph, missing the following required inputs : " + expectedInputs.toString(),
"Invalid workflow, node ["
+ processNode.id()
+ "] missing the following required inputs : "
+ expectedInputs.toString(),
RestStatus.BAD_REQUEST
);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/mappings/workflow-steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"name",
"version",
"model_format",
"model_group_id",
"model_content_hash_value",
"model_type",
"embedding_dimension",
Expand Down
Loading

0 comments on commit 9c538b9

Please sign in to comment.