Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #82 from aclavio/develop
Browse files Browse the repository at this point in the history
Release 0.6.1
  • Loading branch information
aclavio authored Jun 23, 2020
2 parents be10d6e + 49bd238 commit 028d847
Show file tree
Hide file tree
Showing 19 changed files with 579 additions and 409 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ State Conductor flows are defined using a subset of [Amazon States Language (ASL

The _State Conductor_ can be used to perform an arbitrary number of context-based processing actions on a subset of documents. Actions could include: invoking a [MarkLogic Data Hub](https://docs.marklogic.com/datahub/) flow, transforming a document, applying metadata, or calling an external process.

The _State Conductor_ requires a "Driver" to process documents and move them through the installed Flows' states. The _State Conductor_ currently (release 0.4.0) supports a [CoRB2](https://github.com/marklogic-community/corb2) driver, and [CPF](https://docs.marklogic.com/guide/cpf) driver.
The _State Conductor_ requires a "Driver" to process documents and move them through the installed Flows' states. The _State Conductor_ supports a [Data Services](https://github.com/aclavio/marklogic-state-conductor/tree/develop/state-conductor-dataservices) driver, a [CoRB2](https://github.com/marklogic-community/corb2) driver, and a [CPF](https://docs.marklogic.com/guide/cpf) driver.

1. [Installation](#installation)
2. [Usage](#usage)
Expand Down Expand Up @@ -36,8 +36,8 @@ repositories {
}
}
dependencies {
mlBundle "com.marklogic:marklogic-state-conductor:0.6.0"
mlBundle "com.marklogic:marklogic-state-conductor-cpf:0.6.0" // if using the cpf driver
mlBundle "com.marklogic:marklogic-state-conductor:0.6.1"
mlBundle "com.marklogic:marklogic-state-conductor-cpf:0.6.1" // if using the cpf driver
}
```

Expand Down Expand Up @@ -206,10 +206,10 @@ New (optional) temporal parameters `startDate` and `endDate` in v0.3.0.

## Roadmap <a name="roadmap"></a>

- 0.6.0+
- 0.7.0+
- DHS support
- Full support for Choice Rules
- Batch support
- Retention Policy for job documents
- Flush out the validator and validate flow files on deployment
- Support for Parallel and Map states
- Support for Retries
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ allprojects {
}

group = "com.marklogic"
version = "0.6.0"
version = "0.6.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public void testProcessBadJob() throws IOException {
assertEquals(null, errorResp);
assertNotNull(resp);
assertEquals("missing-flow", badJob1Doc.getFlowName());
assertEquals("new", badJob1Doc.getFlowStatus()); // TODO seems like this should be "failed"
assertEquals("failed", badJob1Doc.getFlowStatus());
}

@Test
Expand Down Expand Up @@ -317,15 +317,82 @@ public void testBatchProcessWithBadJob() throws IOException {
assertEquals("add-collection-2", jobDoc.getFlowState());
assertEquals(true, meta.getCollections().contains("testcol1"));

jobDoc = getJobDocument(badJob1Uri);
logger.info(jobDoc.toString());
assertEquals("missing-flow", jobDoc.getFlowName());
assertEquals("failed", jobDoc.getFlowStatus());

assertEquals(job1Uri, resp.get(0).get("job").asText());
assertEquals(true, resp.get(0).get("result").asBoolean());
assertEquals(job2Uri, resp.get(1).get("job").asText());
assertEquals(true, resp.get(1).get("result").asBoolean());
assertEquals(badJob1Uri, resp.get(2).get("job").asText());
assertEquals(false, resp.get(2).get("result").asBoolean());
assertNotNull(resp.get(2).get("error"));
assertEquals(true, resp.get(2).get("result").asBoolean());
assertEquals(job3Uri, resp.get(3).get("job").asText());
assertEquals(true, resp.get(3).get("result").asBoolean());
}

@Test
public void testProcessFailedJob() throws IOException {
// this bad job will go into 'failed' the first time through
// the second attempt should return 'false' for the failed job

ArrayNode resp = null;
Exception errorResp = null;
StateConductorJob badJob1Doc;

try {
resp = service.processJob(Arrays.stream(new String[]{badJob1Uri}));
} catch (Exception err) {
errorResp = err;
}

badJob1Doc = getJobDocument(badJob1Uri);
logger.info(badJob1Doc.toString());

assertEquals(null, errorResp);
assertNotNull(resp);
assertEquals(badJob1Uri, resp.get(0).get("job").asText());
assertEquals(true, resp.get(0).get("result").asBoolean());
assertEquals("missing-flow", badJob1Doc.getFlowName());
assertEquals("failed", badJob1Doc.getFlowStatus());

try {
resp = service.processJob(Arrays.stream(new String[]{badJob1Uri}));
} catch (Exception err) {
errorResp = err;
}

assertEquals(null, errorResp);
assertNotNull(resp);
assertEquals(badJob1Uri, resp.get(0).get("job").asText());
assertEquals(false, resp.get(0).get("result").asBoolean());
}

@Test
public void testExpectedExceptions() throws IOException {
ArrayNode resp = null;
Exception errorResp = null;
StateConductorJob badJob1Doc;

String[] jobs = new String[] {"/not/a/real/job1.json", "/not/a/real/job2.json"};

try {
resp = service.processJob(Arrays.stream(jobs));
} catch (Exception err) {
errorResp = err;
}

logger.info(resp.toString());

assertEquals(null, errorResp);
assertNotNull(resp);
assertEquals("/not/a/real/job1.json", resp.get(0).get("job").asText());
assertEquals(false, resp.get(0).get("result").asBoolean());
assertNotNull(resp.get(0).get("error").asText());
assertEquals("/not/a/real/job2.json", resp.get(1).get("job").asText());
assertEquals(false, resp.get(1).get("result").asBoolean());
assertNotNull(resp.get(1).get("error").asText());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ jobDoc = xdmp.toJSON({
provenance: [],
});

try {
respDoc = sc.executeStateByJobDoc(jobDoc, false);
} catch (err) {
error = err;
}

respDoc = sc.executeStateByJobDoc(jobDoc, false);
xdmp.log(respDoc);
assertions.push(
test.assertEqual('INVALID-STATE-DEFINITION', error.name, 'handled missing dhf flow')
test.assertEqual('failed', respDoc.flowStatus, 'status check'),
test.assertEqual('JS-JAVASCRIPT', respDoc.errors['runStep1'].name, 'handled missing dhf flow'),
test.assertTrue(
respDoc.errors['runStep1'].data.includes(
'Error: The flow with the name MissingFlow could not be found.'
),
'handled missing dhf flow'
)
);

// test executing flow step
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"Comment": "example of a branching flow using a 'Choice' type state",
"mlDomain": {
"context": [
{
"scope": "collection",
"value": "enrollee"
}
]
},
"StartAt": "find-gender",
"States": {
"find-gender": {
"Type": "Choice",
"Comment": "determine's enrollee's gender",
"Choices": [
{
"Resource": "/state-conductor/actions/branching-test-flow/gender-is-male.sjs",
"Next": "enroll-in-mens-health"
},
{
"Resource": "/state-conductor/actions/branching-test-flow/gender-is-female.sjs",
"Next": "enroll-in-womens-health"
}
],
"Default": "has-undetermined-gender"
},
"enroll-in-mens-health": {
"Type": "Task",
"End": true,
"Comment": "adds enrollee to the men's health program",
"Resource": "/state-conductor/actions/branching-test-flow/enroll-in-mens-health.sjs"
},
"enroll-in-womens-health": {
"Type": "Task",
"End": true,
"Comment": "adds enrollee to the womens's health program",
"Resource": "/state-conductor/actions/branching-test-flow/enroll-in-womens-health.sjs"
},
"has-undetermined-gender": {
"Type": "Task",
"End": true,
"Comment": "flags enrollee for follow-up",
"Resource": "/state-conductor/actions/branching-test-flow/flag-for-follow-up.sjs"
}
}
}
{
"Comment": "example of a branching flow using a 'Choice' type state",
"mlDomain": {
"context": [
{
"scope": "collection",
"value": "enrollee"
}
]
},
"StartAt": "find-gender",
"States": {
"find-gender": {
"Type": "Choice",
"Comment": "determine's enrollee's gender",
"Choices": [
{
"Resource": "/state-conductor/actions/custom/branching-test-flow/gender-is-male.sjs",
"Next": "enroll-in-mens-health"
},
{
"Resource": "/state-conductor/actions/custom/branching-test-flow/gender-is-female.sjs",
"Next": "enroll-in-womens-health"
}
],
"Default": "has-undetermined-gender"
},
"enroll-in-mens-health": {
"Type": "Task",
"End": true,
"Comment": "adds enrollee to the men's health program",
"Resource": "/state-conductor/actions/custom/branching-test-flow/enroll-in-mens-health.sjs"
},
"enroll-in-womens-health": {
"Type": "Task",
"End": true,
"Comment": "adds enrollee to the womens's health program",
"Resource": "/state-conductor/actions/custom/branching-test-flow/enroll-in-womens-health.sjs"
},
"has-undetermined-gender": {
"Type": "Task",
"End": true,
"Comment": "flags enrollee for follow-up",
"Resource": "/state-conductor/actions/custom/branching-test-flow/flag-for-follow-up.sjs"
}
}
}
Loading

0 comments on commit 028d847

Please sign in to comment.