Skip to content

Commit cf58747

Browse files
committed
Add IT case
1 parent 82533fb commit cf58747

File tree

3 files changed

+105
-5
lines changed

3 files changed

+105
-5
lines changed

dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/cases/WorkflowStartTestCase.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ public void testStartWorkflow_with_oneSuccessTaskDryRun() {
124124
masterContainer.assertAllResourceReleased();
125125
}
126126

127+
@Test
128+
@DisplayName("Test start a workflow with two fake task(A) has the same name")
129+
public void testStartWorkflow_contains_duplicateTaskName() {
130+
final String yaml = "/it/start/workflow_with_duplicate_task_name.yaml";
131+
final WorkflowTestCaseContext context = workflowTestCaseContextFactory.initializeContextFromYaml(yaml);
132+
final WorkflowDefinition workflow = context.getOneWorkflow();
133+
134+
final WorkflowOperator.WorkflowTriggerDTO workflowTriggerDTO = WorkflowOperator.WorkflowTriggerDTO.builder()
135+
.workflowDefinition(workflow)
136+
.runWorkflowCommandParam(new RunWorkflowCommandParam())
137+
.build();
138+
final Integer workflowInstanceId = workflowOperator.manualTriggerWorkflow(workflowTriggerDTO);
139+
140+
await()
141+
.atMost(Duration.ofMinutes(1))
142+
.untilAsserted(() -> {
143+
assertThat(repository.queryWorkflowInstance(workflowInstanceId).getState())
144+
.isEqualTo(WorkflowExecutionStatus.FAILURE);
145+
assertThat(repository.queryTaskInstance(workflowInstanceId)).isEmpty();
146+
});
147+
148+
masterContainer.assertAllResourceReleased();
149+
}
150+
127151
@Test
128152
@DisplayName("Test start a workflow with one fake task(A) using serial wait strategy")
129153
public void testStartWorkflow_with_serialWaitStrategy() {
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
project:
19+
name: MasterIntegrationTest
20+
code: 1
21+
description: This is a fake project
22+
userId: 1
23+
userName: admin
24+
createTime: 2024-08-12 00:00:00
25+
updateTime: 2021-08-12 00:00:00
26+
27+
workflows:
28+
- name: workflow_with_duplicate_task_name
29+
code: 1
30+
version: 1
31+
projectCode: 1
32+
description: This is a fake workflow with two parallel failed tasks
33+
releaseState: ONLINE
34+
createTime: 2024-08-12 00:00:00
35+
updateTime: 2021-08-12 00:00:00
36+
userId: 1
37+
executionType: PARALLEL
38+
39+
tasks:
40+
- name: A
41+
code: 1
42+
version: 1
43+
projectCode: 1
44+
userId: 1
45+
taskType: LogicFakeTask
46+
taskParams: '{"localParams":null,"varPool":[],"shellScript":"sleep 5"}'
47+
workerGroup: default
48+
createTime: 2024-08-12 00:00:00
49+
updateTime: 2021-08-12 00:00:00
50+
taskExecuteType: BATCH
51+
- name: A
52+
code: 2
53+
version: 1
54+
projectCode: 1
55+
userId: 1
56+
taskType: LogicFakeTask
57+
taskParams: '{"localParams":null,"varPool":[],"shellScript":"sleep 5"}'
58+
workerGroup: default
59+
createTime: 2024-08-12 00:00:00
60+
updateTime: 2021-08-12 00:00:00
61+
taskExecuteType: BATCH
62+
63+
taskRelations:
64+
- projectCode: 1
65+
workflowDefinitionCode: 1
66+
workflowDefinitionVersion: 1
67+
preTaskCode: 0
68+
preTaskVersion: 0
69+
postTaskCode: 1
70+
postTaskVersion: 1
71+
createTime: 2024-08-12 00:00:00
72+
updateTime: 2024-08-12 00:00:00
73+
- projectCode: 1
74+
workflowDefinitionCode: 1
75+
workflowDefinitionVersion: 1
76+
preTaskCode: 0
77+
preTaskVersion: 0
78+
postTaskCode: 2
79+
postTaskVersion: 1
80+
createTime: 2024-08-12 00:00:00
81+
updateTime: 2024-08-12 00:00:00

dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/command/CommandServiceImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.dolphinscheduler.common.constants.Constants;
2323
import org.apache.dolphinscheduler.common.enums.CommandType;
24-
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
2524
import org.apache.dolphinscheduler.common.utils.JSONUtils;
2625
import org.apache.dolphinscheduler.dao.entity.Command;
2726
import org.apache.dolphinscheduler.dao.entity.ErrorCommand;
@@ -43,7 +42,6 @@
4342

4443
import org.springframework.beans.factory.annotation.Autowired;
4544
import org.springframework.stereotype.Component;
46-
import org.springframework.transaction.annotation.Transactional;
4745

4846
import com.fasterxml.jackson.databind.node.ObjectNode;
4947
import io.micrometer.core.annotation.Counted;
@@ -71,13 +69,10 @@ public class CommandServiceImpl implements CommandService {
7169
private WorkflowInstanceDao workflowInstanceDao;
7270

7371
@Override
74-
@Transactional
7572
public void moveToErrorCommand(Command command, String message) {
7673
final ErrorCommand errorCommand = new ErrorCommand(command, message);
7774
errorCommandMapper.insert(errorCommand);
7875
commandMapper.deleteById(command.getId());
79-
workflowInstanceDao.forceUpdateWorkflowInstanceState(command.getWorkflowInstanceId(),
80-
WorkflowExecutionStatus.FAILURE);
8176
log.info("Set workflow instance {} state to FAILURE", command.getWorkflowInstanceId());
8277
}
8378

0 commit comments

Comments
 (0)