-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improvement-16612][Master] For logical tasks on the Master, there should be support for dry run #16616
[Improvement-16612][Master] For logical tasks on the Master, there should be support for dry run #16616
Changes from all commits
bdbea9c
67ff48f
1c9bb30
284fd38
1274234
fe4c3dd
cc5f1f5
80b0a43
891809d
5cbe83c
e36418d
6088d05
0c0d147
e0e096b
0badfcc
b2debee
03605d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,12 +87,50 @@ public void testStartWorkflow_with_oneSuccessTask() { | |
Assertions | ||
.assertThat(repository.queryWorkflowInstance(workflowInstanceId)) | ||
.matches( | ||
workflowInstance -> workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS); | ||
workflowInstance -> workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS) | ||
.matches( | ||
workflowInstance -> workflowInstance.getDryRun() == Flag.NO.getCode()); | ||
Assertions | ||
.assertThat(repository.queryTaskInstance(workflow)) | ||
.satisfiesExactly(taskInstance -> { | ||
assertThat(taskInstance.getName()).isEqualTo("A"); | ||
assertThat(taskInstance.getState()).isEqualTo(TaskExecutionStatus.SUCCESS); | ||
assertThat(taskInstance.getDryRun()).isEqualTo(Flag.NO.getCode()); | ||
}); | ||
}); | ||
|
||
assertThat(workflowRepository.getAll()).isEmpty(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test start a workflow with one fake task(A) dry run success") | ||
public void testStartWorkflow_with_oneSuccessTaskDryRun() { | ||
final String yaml = "/it/start/workflow_with_one_fake_task_success.yaml"; | ||
final WorkflowTestCaseContext context = workflowTestCaseContextFactory.initializeContextFromYaml(yaml); | ||
final WorkflowDefinition workflow = context.getWorkflows().get(0); | ||
|
||
final WorkflowOperator.WorkflowTriggerDTO workflowTriggerDTO = WorkflowOperator.WorkflowTriggerDTO.builder() | ||
.workflowDefinition(workflow) | ||
.runWorkflowCommandParam(new RunWorkflowCommandParam()) | ||
.dryRun(Flag.YES) | ||
.build(); | ||
final Integer workflowInstanceId = workflowOperator.manualTriggerWorkflow(workflowTriggerDTO); | ||
|
||
await() | ||
.atMost(Duration.ofMinutes(1)) | ||
.untilAsserted(() -> { | ||
Assertions | ||
.assertThat(repository.queryWorkflowInstance(workflowInstanceId)) | ||
.matches( | ||
workflowInstance -> workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS) | ||
.matches( | ||
workflowInstance -> workflowInstance.getDryRun() == Flag.YES.getCode()); | ||
Assertions | ||
.assertThat(repository.queryTaskInstance(workflow)) | ||
.satisfiesExactly(taskInstance -> { | ||
assertThat(taskInstance.getName()).isEqualTo("A"); | ||
assertThat(taskInstance.getState()).isEqualTo(TaskExecutionStatus.SUCCESS); | ||
assertThat(taskInstance.getDryRun()).isEqualTo(Flag.YES.getCode()); | ||
}); | ||
}); | ||
|
||
|
@@ -121,7 +159,9 @@ public void testStartWorkflow_with_subWorkflowTask_success() { | |
.matches( | ||
workflowInstance -> workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS) | ||
.matches( | ||
workflowInstance -> workflowInstance.getIsSubWorkflow() == Flag.NO); | ||
workflowInstance -> workflowInstance.getIsSubWorkflow() == Flag.NO) | ||
.matches( | ||
workflowInstance -> workflowInstance.getDryRun() == Flag.NO.getCode()); | ||
|
||
final List<WorkflowInstance> subWorkflowInstance = | ||
repository.queryWorkflowInstance(context.getWorkflows().get(1)); | ||
|
@@ -131,6 +171,7 @@ public void testStartWorkflow_with_subWorkflowTask_success() { | |
.satisfiesExactly(workflowInstance -> { | ||
assertThat(workflowInstance.getState()).isEqualTo(WorkflowExecutionStatus.SUCCESS); | ||
assertThat(workflowInstance.getIsSubWorkflow()).isEqualTo(Flag.YES); | ||
assertThat(workflowInstance.getDryRun()).isEqualTo(Flag.NO.getCode()); | ||
}); | ||
|
||
Assertions | ||
|
@@ -151,6 +192,51 @@ public void testStartWorkflow_with_subWorkflowTask_success() { | |
assertThat(workflowRepository.getAll()).isEmpty(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test start a workflow with one sub workflow task(A) dry run, will not execute") | ||
public void testStartWorkflow_with_subWorkflowTask_dryRunSuccess() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the parent workflow using dry run but still generate sub workflow instance? If use dry run then the SubWorkflow task will not generate sub workflow instance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Child workflow inherits the dry run configuration of the parent workflow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might make confusion, since physical task dry run will not go into the task plugin logic, you can find the implementation in You should do this change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK, I'll check it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Check whether it is dry run in AsyncMasterTaskDelayQueueLooper, it may also be necessary! |
||
final String yaml = "/it/start/workflow_with_sub_workflow_task_success.yaml"; | ||
final WorkflowTestCaseContext context = workflowTestCaseContextFactory.initializeContextFromYaml(yaml); | ||
final WorkflowDefinition parentWorkflow = context.getWorkflows().get(0); | ||
|
||
final WorkflowOperator.WorkflowTriggerDTO workflowTriggerDTO = WorkflowOperator.WorkflowTriggerDTO.builder() | ||
.workflowDefinition(parentWorkflow) | ||
.runWorkflowCommandParam(new RunWorkflowCommandParam()) | ||
.dryRun(Flag.YES) | ||
.build(); | ||
final Integer workflowInstanceId = workflowOperator.manualTriggerWorkflow(workflowTriggerDTO); | ||
|
||
await() | ||
.atMost(Duration.ofMinutes(1)) | ||
.untilAsserted(() -> { | ||
|
||
Assertions | ||
.assertThat(repository.queryWorkflowInstance(workflowInstanceId)) | ||
.matches( | ||
workflowInstance -> workflowInstance.getState() == WorkflowExecutionStatus.SUCCESS) | ||
.matches( | ||
workflowInstance -> workflowInstance.getIsSubWorkflow() == Flag.NO) | ||
.matches( | ||
workflowInstance -> workflowInstance.getDryRun() == Flag.YES.getCode()); | ||
|
||
final List<WorkflowInstance> subWorkflowInstance = | ||
repository.queryWorkflowInstance(context.getWorkflows().get(1)); | ||
Assertions | ||
.assertThat(subWorkflowInstance) | ||
.isEmpty(); | ||
|
||
Assertions | ||
.assertThat(repository.queryTaskInstance(workflowInstanceId)) | ||
.satisfiesExactly(taskInstance -> { | ||
assertThat(taskInstance.getName()).isEqualTo("sub_logic_task"); | ||
assertThat(taskInstance.getState()).isEqualTo(TaskExecutionStatus.SUCCESS); | ||
assertThat(taskInstance.getDryRun()).isEqualTo(Flag.YES.getCode()); | ||
}); | ||
}); | ||
|
||
assertThat(workflowRepository.getAll()).isEmpty(); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test start a workflow with one sub workflow task(A) failed") | ||
public void testStartWorkflow_with_subWorkflowTask_failed() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to move this after
beforeExecute
I am not sure if the statemachine will throw exception, since the task lifecycle might missrunning
event, so the task state will be dispatched, and dispatched task cannot be converted to success.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the implementation in
WorkerTaskExecutor
,this is beforebeforeExecute
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test Result:
This is not the effect we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have change, test is ok