This is an automated email from the ASF dual-hosted git repository.
wangyang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 6844c659bf Fix ErrorCommand loss some fields in Command (#15847)
6844c659bf is described below
commit 6844c659bf44f7f027adbe7a64723a1ca0f1cd89
Author: Wenjun Ruan <[email protected]>
AuthorDate: Mon Apr 15 16:14:32 2024 +0800
Fix ErrorCommand loss some fields in Command (#15847)
---
.../dolphinscheduler/dao/entity/ErrorCommand.java | 17 +++--
.../dao/entity/ErrorCommandTest.java | 82 ++++++++++++++++++++++
2 files changed, 95 insertions(+), 4 deletions(-)
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ErrorCommand.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ErrorCommand.java
index aa4d3d4782..d52984b61f 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ErrorCommand.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ErrorCommand.java
@@ -52,6 +52,10 @@ public class ErrorCommand {
*/
private long processDefinitionCode;
+ private int processDefinitionVersion;
+
+ private int processInstanceId;
+
/**
* executor id
*/
@@ -73,7 +77,7 @@ public class ErrorCommand {
private FailureStrategy failureStrategy;
/**
- * warning type
+ * warning type
*/
private WarningType warningType;
@@ -135,21 +139,26 @@ public class ErrorCommand {
public ErrorCommand() {
}
+
public ErrorCommand(Command command, String message) {
this.id = command.getId();
this.commandType = command.getCommandType();
this.executorId = command.getExecutorId();
this.processDefinitionCode = command.getProcessDefinitionCode();
+ this.processDefinitionVersion = command.getProcessDefinitionVersion();
+ this.processInstanceId = command.getProcessInstanceId();
this.commandParam = command.getCommandParam();
+ this.taskDependType = command.getTaskDependType();
+ this.failureStrategy = command.getFailureStrategy();
this.warningType = command.getWarningType();
this.warningGroupId = command.getWarningGroupId();
this.scheduleTime = command.getScheduleTime();
- this.taskDependType = command.getTaskDependType();
- this.failureStrategy = command.getFailureStrategy();
this.startTime = command.getStartTime();
this.updateTime = command.getUpdateTime();
- this.environmentCode = command.getEnvironmentCode();
this.processInstancePriority = command.getProcessInstancePriority();
+ this.workerGroup = command.getWorkerGroup();
+ this.tenantCode = command.getTenantCode();
+ this.environmentCode = command.getEnvironmentCode();
this.message = message;
this.dryRun = command.getDryRun();
this.testFlag = command.getTestFlag();
diff --git
a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ErrorCommandTest.java
b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ErrorCommandTest.java
new file mode 100644
index 0000000000..057d6578e6
--- /dev/null
+++
b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/entity/ErrorCommandTest.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.dao.entity;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.dolphinscheduler.common.enums.CommandType;
+import org.apache.dolphinscheduler.common.enums.FailureStrategy;
+import org.apache.dolphinscheduler.common.enums.Flag;
+import org.apache.dolphinscheduler.common.enums.Priority;
+import org.apache.dolphinscheduler.common.enums.TaskDependType;
+import org.apache.dolphinscheduler.common.enums.WarningType;
+
+import java.util.Date;
+
+import org.junit.jupiter.api.Test;
+
+class ErrorCommandTest {
+
+ @Test
+ void testConstructor() {
+ Command command = new Command();
+ command.setId(1);
+ command.setCommandType(CommandType.PAUSE);
+ command.setExecutorId(1);
+ command.setProcessDefinitionCode(123);
+ command.setProcessDefinitionVersion(1);
+ command.setProcessInstanceId(1);
+ command.setCommandParam("param");
+ command.setTaskDependType(TaskDependType.TASK_POST);
+ command.setFailureStrategy(FailureStrategy.CONTINUE);
+ command.setWarningType(WarningType.ALL);
+ command.setWarningGroupId(1);
+ command.setScheduleTime(new Date());
+ command.setStartTime(new Date());
+ command.setUpdateTime(new Date());
+ command.setProcessInstancePriority(Priority.HIGHEST);
+ command.setWorkerGroup("default");
+ command.setTenantCode("root");
+ command.setEnvironmentCode(1L);
+ command.setDryRun(1);
+ command.setTestFlag(Flag.NO.getCode());
+
+ ErrorCommand errorCommand = new ErrorCommand(command, "test");
+ assertEquals(command.getCommandType(), errorCommand.getCommandType());
+ assertEquals(command.getExecutorId(), errorCommand.getExecutorId());
+ assertEquals(command.getProcessDefinitionCode(),
errorCommand.getProcessDefinitionCode());
+ assertEquals(command.getProcessDefinitionVersion(),
errorCommand.getProcessDefinitionVersion());
+ assertEquals(command.getProcessInstanceId(),
errorCommand.getProcessInstanceId());
+ assertEquals(command.getCommandParam(),
errorCommand.getCommandParam());
+ assertEquals(command.getTaskDependType(),
errorCommand.getTaskDependType());
+ assertEquals(command.getFailureStrategy(),
errorCommand.getFailureStrategy());
+ assertEquals(command.getWarningType(), errorCommand.getWarningType());
+ assertEquals(command.getWarningGroupId(),
errorCommand.getWarningGroupId());
+ assertEquals(command.getScheduleTime(),
errorCommand.getScheduleTime());
+ assertEquals(command.getStartTime(), errorCommand.getStartTime());
+ assertEquals(command.getUpdateTime(), errorCommand.getUpdateTime());
+ assertEquals(command.getProcessInstancePriority(),
errorCommand.getProcessInstancePriority());
+ assertEquals(command.getWorkerGroup(), errorCommand.getWorkerGroup());
+ assertEquals(command.getTenantCode(), errorCommand.getTenantCode());
+ assertEquals(command.getEnvironmentCode(),
errorCommand.getEnvironmentCode());
+ assertEquals(command.getDryRun(), errorCommand.getDryRun());
+ assertEquals(command.getTestFlag(), errorCommand.getTestFlag());
+ assertEquals("test", errorCommand.getMessage());
+ }
+
+}