Skip to content

Commit

Permalink
Set up Rest Integration Test framework (#251)
Browse files Browse the repository at this point in the history
* Setting up rest integration tests

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* removing stray log

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Cleaning up integration test example

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Fixing provision transport action to respond only after state has been updated to PROVISIONING

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Fixing flaky encryption test

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* cleaning up old logs

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Added helper methods to retrieve state and resources created, fixed integration test set up to wait for ml config index to become created, fixed settings update to oly occur once

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Adding another test for update API, input validation, local model registration. Persiting cluster settings between test runs to ensure plugin apis are enabled. Cleaning up resources after all test runs complete, rather than between test runs

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Adding test for search workflows API, ensures that returned credentials are encrypted

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* Update integ test TODOs to match current development progress

Signed-off-by: Daniel Widdis <widdis@gmail.com>

* Model Group step is not yet implemented

Signed-off-by: Daniel Widdis <widdis@gmail.com>

* Comment out tests for incomplete register local model implementation

Signed-off-by: Daniel Widdis <widdis@gmail.com>

* Fix unit tests broken with changes to fix integ tests

Signed-off-by: Daniel Widdis <widdis@gmail.com>

---------

Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Daniel Widdis <widdis@gmail.com>
Co-authored-by: Daniel Widdis <widdis@gmail.com>
(cherry picked from commit 7986cbf)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and dbwiddis committed Dec 19, 2023
1 parent 70f7c00 commit 3fb584a
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 3fb584a

Please sign in to comment.