mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(lambda): accept a durable update without ParentId and reword its consistency errors (#8249)
* fix(lambda): accept a durable update without ParentId and word its consistency errors like AWS
This commit is contained in:
1 parent
55a7d95146
commit
f0de926e02
2 files changed
+97
-10
No files matched your search
+84
-2
@@ -24,6 +24,15 @@ class DurableCheckpointApplierTest {
|
||||
private static final Function<String, AwsException> REACHABLE = functionName -> null;
|
||||
private static final String EXECUTION_ARN =
|
||||
"arn:aws:lambda:us-east-1:000000000000:function:fn:1/durable-execution/exec/exec-id";
|
||||
private static final String INVALID_PARENT_MESSAGE = "Invalid parent operation id.";
|
||||
private static final String TYPE_MESSAGE =
|
||||
"Type value in OperationUpdate is inconsistent with existing operation. Check for non-determinism.";
|
||||
private static final String SUB_TYPE_MESSAGE =
|
||||
"SubType value in OperationUpdate is inconsistent with existing operation. Check for non-determinism.";
|
||||
private static final String NAME_MESSAGE =
|
||||
"Name value in OperationUpdate is inconsistent with existing operation. Check for non-determinism.";
|
||||
private static final String PARENT_ID_MESSAGE =
|
||||
"ParentId value in OperationUpdate is inconsistent with existing operation. Check for non-determinism.";
|
||||
|
||||
@Test
|
||||
void executionUpdateMustBeTheOnlyOneAndTheLast() {
|
||||
@@ -67,11 +76,78 @@ class DurableCheckpointApplierTest {
|
||||
assertRejected(List.of(stepStart("s1", "missing")), "Invalid parent operation id.");
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(stepStart("s1", null)), NOW, REACHABLE);
|
||||
assertEquals("Inconsistent operation type.", reject(execution, List.of(waitStart("s1"))));
|
||||
assertEquals("Inconsistent parent operation id.", reject(execution, List.of(stepStart("ctx", null),
|
||||
assertEquals(TYPE_MESSAGE, reject(execution, List.of(waitStart("s1"))));
|
||||
assertEquals(PARENT_ID_MESSAGE, reject(execution, List.of(contextStart("ctx"),
|
||||
update("s1", "ctx", DurableOperationType.STEP, DurableOperationAction.SUCCEED, "1"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anExistingOperationClosedWithoutParentIdKeepsItsParent() {
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(contextStart("ctx"), stepStart("s1", "ctx"),
|
||||
typed("c1", "ctx", null, DurableOperationType.CONTEXT, "Parallel", DurableOperationAction.START)),
|
||||
NOW, REACHABLE);
|
||||
DurableCheckpointApplier.apply(execution, List.of(
|
||||
update("s1", null, DurableOperationType.STEP, DurableOperationAction.SUCCEED, "1"),
|
||||
update("c1", null, DurableOperationType.CONTEXT, DurableOperationAction.SUCCEED, "2")), NOW, REACHABLE);
|
||||
assertEquals(DurableOperationStatus.SUCCEEDED, execution.getOperations().get("s1").getStatus());
|
||||
assertEquals("ctx", execution.getOperations().get("s1").getParentId());
|
||||
assertEquals(DurableOperationStatus.SUCCEEDED, execution.getOperations().get("c1").getStatus());
|
||||
assertEquals("ctx", execution.getOperations().get("c1").getParentId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void eachInconsistentFieldHasItsOwnMessage() {
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(typed("s1", null, "n", DurableOperationType.STEP, "Step",
|
||||
DurableOperationAction.START)), NOW, REACHABLE);
|
||||
assertEquals(TYPE_MESSAGE, reject(execution, List.of(typed("s1", null, "n", DurableOperationType.WAIT, "Step",
|
||||
DurableOperationAction.SUCCEED))));
|
||||
assertEquals(SUB_TYPE_MESSAGE, reject(execution, List.of(typed("s1", null, "n", DurableOperationType.STEP,
|
||||
"Other", DurableOperationAction.SUCCEED))));
|
||||
assertEquals(NAME_MESSAGE, reject(execution, List.of(typed("s1", null, "other", DurableOperationType.STEP,
|
||||
"Step", DurableOperationAction.SUCCEED))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void inconsistentFieldsAreReportedInTypeSubTypeNameParentIdOrder() {
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(contextStart("ctx"), contextStart("ctx2"),
|
||||
typed("s1", "ctx", "n", DurableOperationType.STEP, "Step", DurableOperationAction.START)),
|
||||
NOW, REACHABLE);
|
||||
assertEquals(NAME_MESSAGE, reject(execution, List.of(typed("s1", "ctx2", "other",
|
||||
DurableOperationType.STEP, "Step", DurableOperationAction.SUCCEED))));
|
||||
assertEquals(TYPE_MESSAGE, reject(execution, List.of(typed("s1", "ctx2", "n", DurableOperationType.WAIT,
|
||||
"Step", DurableOperationAction.SUCCEED))));
|
||||
assertEquals(SUB_TYPE_MESSAGE, reject(execution, List.of(typed("s1", "ctx2", "n", DurableOperationType.STEP,
|
||||
"Other", DurableOperationAction.SUCCEED))));
|
||||
assertEquals(SUB_TYPE_MESSAGE, reject(execution, List.of(typed("s1", "ctx", "other",
|
||||
DurableOperationType.STEP, "Other", DurableOperationAction.SUCCEED))));
|
||||
assertEquals(TYPE_MESSAGE, reject(execution, List.of(typed("s1", null, "n", DurableOperationType.WAIT, null,
|
||||
DurableOperationAction.SUCCEED))));
|
||||
assertEquals(PARENT_ID_MESSAGE, reject(execution, List.of(update("s1", "ctx2", DurableOperationType.STEP,
|
||||
DurableOperationAction.SUCCEED, "1"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTopLevelOperationClosedWithAContextParentIsInconsistent() {
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(contextStart("ctx"), stepStart("s1", null)), NOW, REACHABLE);
|
||||
assertEquals(PARENT_ID_MESSAGE, reject(execution, List.of(update("s1", "ctx", DurableOperationType.STEP,
|
||||
DurableOperationAction.SUCCEED, "1"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theParentIsCheckedBeforeTheOtherFieldsOfAnExistingOperation() {
|
||||
DurableExecution execution = execution();
|
||||
DurableCheckpointApplier.apply(execution, List.of(contextStart("ctx"), stepStart("s1", "ctx"),
|
||||
stepStart("s2", "ctx")), NOW, REACHABLE);
|
||||
assertEquals(INVALID_PARENT_MESSAGE, reject(execution, List.of(update("s1", "missing",
|
||||
DurableOperationType.WAIT, DurableOperationAction.SUCCEED, null))));
|
||||
assertEquals(INVALID_PARENT_MESSAGE, reject(execution, List.of(update("s1", "s2",
|
||||
DurableOperationType.WAIT, DurableOperationAction.SUCCEED, null))));
|
||||
}
|
||||
|
||||
@Test
|
||||
void stepTransitionsAreGuarded() {
|
||||
DurableExecution execution = execution();
|
||||
@@ -284,4 +360,10 @@ class DurableCheckpointApplierTest {
|
||||
return new DurableOperationUpdate(id, parentId, null, type, null, action, payload, null, null, null, null, null,
|
||||
null, null, null, null);
|
||||
}
|
||||
|
||||
private static DurableOperationUpdate typed(String id, String parentId, String name, DurableOperationType type,
|
||||
String subType, DurableOperationAction action) {
|
||||
return new DurableOperationUpdate(id, parentId, name, type, subType, action, null, null, null, null, null,
|
||||
null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user