|
|
|
@ -64,6 +64,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao; |
|
|
|
|
import org.apache.dolphinscheduler.remote.processor.StateEventCallbackService; |
|
|
|
|
import org.apache.dolphinscheduler.service.command.CommandService; |
|
|
|
@ -132,6 +133,9 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
@Mock |
|
|
|
|
private ProjectMapper projectMapper; |
|
|
|
|
|
|
|
|
|
@Mock |
|
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
|
|
@Mock |
|
|
|
|
private ProjectServiceImpl projectService; |
|
|
|
|
|
|
|
|
@ -167,7 +171,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
private int processInstanceId = 1; |
|
|
|
|
|
|
|
|
|
private int tenantId = 1; |
|
|
|
|
private String tenantCode = "root"; |
|
|
|
|
|
|
|
|
|
private int userId = 1; |
|
|
|
|
|
|
|
|
@ -199,7 +203,6 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
// processDefinition
|
|
|
|
|
processDefinition.setId(processDefinitionId); |
|
|
|
|
processDefinition.setReleaseState(ReleaseState.ONLINE); |
|
|
|
|
processDefinition.setTenantId(tenantId); |
|
|
|
|
processDefinition.setUserId(userId); |
|
|
|
|
processDefinition.setVersion(1); |
|
|
|
|
processDefinition.setCode(1L); |
|
|
|
@ -210,7 +213,6 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
processInstance.setProjectCode(projectCode); |
|
|
|
|
processInstance.setState(WorkflowExecutionStatus.FAILURE); |
|
|
|
|
processInstance.setExecutorId(userId); |
|
|
|
|
processInstance.setTenantId(tenantId); |
|
|
|
|
processInstance.setHost("127.0.0.1:5678"); |
|
|
|
|
processInstance.setProcessDefinitionVersion(1); |
|
|
|
|
processInstance.setProcessDefinitionCode(1L); |
|
|
|
@ -240,7 +242,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode, WORKFLOW_START)) |
|
|
|
|
.thenReturn(checkProjectAndAuth()); |
|
|
|
|
Mockito.when(processDefinitionMapper.queryByCode(processDefinitionCode)).thenReturn(this.processDefinition); |
|
|
|
|
Mockito.when(processService.getTenantForProcess(tenantId, userId)).thenReturn(new Tenant()); |
|
|
|
|
Mockito.when(processService.getTenantForProcess(tenantCode, userId)).thenReturn(tenantCode); |
|
|
|
|
doReturn(1).when(commandService).createCommand(argThat(c -> c.getId() == null)); |
|
|
|
|
doReturn(0).when(commandService).createCommand(argThat(c -> c.getId() != null)); |
|
|
|
|
Mockito.when(monitorService.getServerListFromRegistry(true)).thenReturn(getMasterServersList()); |
|
|
|
@ -270,6 +272,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -277,7 +280,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_SERIAL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 10, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 10, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -293,6 +296,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -300,7 +304,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, "123456789,987654321", |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_SERIAL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -312,6 +316,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
public void testComplementWithOldStartNodeList() { |
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
try { |
|
|
|
|
result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
@ -321,7 +326,8 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, "1123456789,987654321", |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_SERIAL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 0, |
|
|
|
|
Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
} catch (ServiceException e) { |
|
|
|
@ -381,6 +387,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2022-01-07 12:12:12\",\"complementEndDate\":\"2022-01-06 12:12:12\"}", |
|
|
|
@ -388,7 +395,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_SERIAL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.START_PROCESS_INSTANCE_ERROR, result.get(Constants.STATUS)); |
|
|
|
@ -403,6 +410,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -410,7 +418,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_SERIAL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -425,6 +433,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(zeroSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -432,7 +441,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_PARALLEL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 0, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -448,6 +457,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
|
|
|
|
|
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionCode(processDefinitionCode)) |
|
|
|
|
.thenReturn(oneSchedulerList()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -455,7 +465,8 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, null, |
|
|
|
|
RunMode.RUN_MODE_PARALLEL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 15, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 15, |
|
|
|
|
Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_NO, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -481,6 +492,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
RunMode.RUN_MODE_PARALLEL, |
|
|
|
|
Priority.LOW, |
|
|
|
|
Constants.DEFAULT_WORKER_GROUP, |
|
|
|
|
tenantCode, |
|
|
|
|
100L, |
|
|
|
|
110, |
|
|
|
|
null, |
|
|
|
@ -510,6 +522,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
Mockito.when(commandService.verifyIsNeedCreateCommand(any(Command.class))).thenReturn(true); |
|
|
|
|
Mockito.when(projectService.checkProjectAndAuth(loginUser, project, projectCode, RERUN)) |
|
|
|
|
.thenReturn(checkProjectAndAuth()); |
|
|
|
|
Mockito.when(tenantMapper.queryByTenantCode(tenantCode)).thenReturn(new Tenant()); |
|
|
|
|
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectCode, |
|
|
|
|
processDefinitionCode, |
|
|
|
|
"{\"complementStartDate\":\"2020-01-01 00:00:00\",\"complementEndDate\":\"2020-01-31 23:00:00\"}", |
|
|
|
@ -517,7 +530,8 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
null, null, |
|
|
|
|
null, null, 0, |
|
|
|
|
RunMode.RUN_MODE_PARALLEL, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 100L, 110, null, 15, Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, tenantCode, 100L, 110, null, 15, |
|
|
|
|
Constants.DRY_RUN_FLAG_NO, |
|
|
|
|
Constants.TEST_FLAG_YES, |
|
|
|
|
ComplementDependentMode.OFF_MODE, null); |
|
|
|
|
Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
|
|
|
@ -630,7 +644,7 @@ public class ExecuteFunctionServiceTest {
|
|
|
|
|
Mockito.when(processService.findProcessDefinition(Mockito.anyLong(), Mockito.anyInt())) |
|
|
|
|
.thenReturn(processDefinition); |
|
|
|
|
|
|
|
|
|
Mockito.when(processService.getTenantForProcess(Mockito.anyInt(), Mockito.anyInt())).thenReturn(new Tenant()); |
|
|
|
|
Mockito.when(processService.getTenantForProcess(Mockito.anyString(), Mockito.anyInt())).thenReturn(tenantCode); |
|
|
|
|
|
|
|
|
|
when(processInstanceMock.getState().isFinished()).thenReturn(false); |
|
|
|
|
WorkflowExecuteResponse responseInstanceIsNotFinished = |
|
|
|
|