use of com.walmartlabs.concord.client.ProcessCheckpointEntry in project concord by walmartlabs.
the class ProcessIT method testForkCheckpoints.
@Test
public void testForkCheckpoints() throws Exception {
String forkTag = "fork_" + randomString();
Payload payload = new Payload().arg("forkTag", forkTag).archive(resource("forkCheckpoints"));
ConcordProcess parent = concord.processes().start(payload);
expectStatus(parent, ProcessEntry.StatusEnum.FINISHED);
parent.assertLog(".*#1.*");
parent.assertLog(".*#2.*");
// ---
List<ProcessEntry> children = concord.processes().list(ProcessListQuery.builder().parentInstanceId(parent.instanceId()).limit(10).build());
assertEquals(1, children.size());
ProcessEntry fork = children.get(0);
assertEquals(fork.getTags().get(0), forkTag);
// ---
List<ProcessCheckpointEntry> checkpoints = parent.checkpoints();
assertEquals(1, checkpoints.size());
parent.restoreCheckpoint(checkpoints.get(0).getId());
expectStatus(parent, ProcessEntry.StatusEnum.FINISHED);
// ---
children = concord.processes().list(ProcessListQuery.builder().parentInstanceId(parent.instanceId()).limit(10).build());
assertEquals(2, children.size());
for (ProcessEntry child : children) {
ConcordProcess proc = concord.processes().get(child.getInstanceId());
proc.assertNoLog(".*#1.*");
proc.assertNoLog(".*#2.*");
proc.assertLog(".*#3.*");
}
}
use of com.walmartlabs.concord.client.ProcessCheckpointEntry in project concord by walmartlabs.
the class ProcessIT method testCheckpoints.
@Test
public void testCheckpoints() throws Exception {
Payload payload = new Payload().archive(resource("checkpoints"));
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
proc.assertLog(".*#1.*x=123.*");
proc.assertLog(".*#2.*y=234.*");
proc.assertLog(".*#3.*y=345.*");
proc.assertLog(".*same workDir: true.*");
// ---
List<ProcessCheckpointEntry> checkpoints = proc.checkpoints();
assertEquals(2, checkpoints.size());
checkpoints.sort(Comparator.comparing(ProcessCheckpointEntry::getCreatedAt));
ProcessCheckpointEntry firstCheckpoint = checkpoints.get(0);
assertEquals("first", firstCheckpoint.getName());
ProcessCheckpointEntry secondCheckpoint = checkpoints.get(1);
assertEquals("second", secondCheckpoint.getName());
// ---
// restore from the first checkpoint
proc.restoreCheckpoint(firstCheckpoint.getId());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
// we should see the second checkpoint being saved the second time
checkpoints = proc.checkpoints();
assertEquals(3, checkpoints.size());
checkpoints.sort(Comparator.comparing(ProcessCheckpointEntry::getCreatedAt));
assertEquals("second", checkpoints.get(1).getName());
assertEquals("second", checkpoints.get(2).getName());
proc.assertLog(".*#1.*x=123.*");
proc.assertLogAtLeast(".*#3.*y=345.*", 2);
proc.assertLog(".*same workDir: false.*");
}
use of com.walmartlabs.concord.client.ProcessCheckpointEntry in project concord by walmartlabs.
the class ProcessIT method testCheckpointsParallel.
@Test
public void testCheckpointsParallel() throws Exception {
Payload payload = new Payload().archive(resource("checkpointsParallel"));
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
proc.assertLogAtLeast(".*#1 \\{x=123}.*", 1);
proc.assertLogAtLeast(".*#2 \\{x=123, y=234}.*", 1);
proc.assertLogAtLeast(".*#3 \\{x=123, z=345}.*", 1);
proc.assertLogAtLeast(".*#4 \\{x=123}.*", 1);
// ---
List<ProcessCheckpointEntry> checkpoints = proc.checkpoints();
assertEquals(3, checkpoints.size());
checkpoints.sort(Comparator.comparing(ProcessCheckpointEntry::getName));
assertEquals("aaa", checkpoints.get(0).getName());
assertEquals("bbb", checkpoints.get(1).getName());
assertEquals("ccc", checkpoints.get(2).getName());
// ---
proc.restoreCheckpoint(checkpoints.get(1).getId());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
proc.assertLogAtLeast(".*#4 \\{x=123}.*", 2);
}
use of com.walmartlabs.concord.client.ProcessCheckpointEntry in project concord by walmartlabs.
the class ProcessIT method testNoStateAfterCheckpoint.
@Test
public void testNoStateAfterCheckpoint() throws Exception {
String concordYml = resourceToString(ProcessIT.class.getResource("checkpointState/concord.yml")).replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION);
Payload payload = new Payload().concordYml(concordYml);
ConcordProcess proc = concord.processes().start(payload);
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
// ---
List<ProcessCheckpointEntry> checkpoints = proc.checkpoints();
assertEquals(1, checkpoints.size());
proc.assertLog(".*#1 BEFORE: false.*");
proc.assertLog(".*#2 AFTER: false.*");
}
use of com.walmartlabs.concord.client.ProcessCheckpointEntry in project concord by walmartlabs.
the class ProcessIT method testCheckpointsWith3rdPartyClasses.
@Test
public void testCheckpointsWith3rdPartyClasses() throws Exception {
String concordYml = resourceToString(NodeRosterIT.class.getResource("checkpointClasses/concord.yml")).replaceAll("PROJECT_VERSION", ITConstants.PROJECT_VERSION);
ConcordProcess proc = concord.processes().start(new Payload().concordYml(concordYml));
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
// ---
List<ProcessCheckpointEntry> checkpoints = proc.checkpoints();
assertEquals(1, checkpoints.size());
proc.restoreCheckpoint(checkpoints.get(0).getId());
expectStatus(proc, ProcessEntry.StatusEnum.FINISHED);
// ---
proc.assertLog(".*1: Hello!.*");
proc.assertLogAtLeast(".*2: Hello!.*", 2);
}
Aggregations