From d526dd89f66ddf43689ae544208b44a08ba04a40 Mon Sep 17 00:00:00 2001 From: Wenjun Ruan Date: Wed, 28 Sep 2022 09:17:12 +0800 Subject: [PATCH] [hotfix][UI] Remove SURVEIL and NEXT_LOOP in ui (#12160) * Remove SURVEIL and NEXT_LOOP in ui * Fix UT --- .../src/main/resources/task-type-config.yaml | 2 - .../server/master/BlockingTaskTest.java | 41 ++++++++++--------- .../server/master/SubProcessTaskTest.java | 36 ++++++---------- 3 files changed, 35 insertions(+), 44 deletions(-) diff --git a/dolphinscheduler-api/src/main/resources/task-type-config.yaml b/dolphinscheduler-api/src/main/resources/task-type-config.yaml index 23307d8a07..7ae0e1a225 100644 --- a/dolphinscheduler-api/src/main/resources/task-type-config.yaml +++ b/dolphinscheduler-api/src/main/resources/task-type-config.yaml @@ -37,8 +37,6 @@ task: - 'DEPENDENT' - 'CONDITIONS' - 'SWITCH' - - 'NEXT_LOOP' - - 'SURVEIL' dataIntegration: - 'SEATUNNEL' - 'DATAX' diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java index d9a4b8d705..567f7e99ec 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java @@ -19,16 +19,16 @@ package org.apache.dolphinscheduler.server.master; import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.TASK_TYPE_BLOCKING; -import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; -import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; -import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.common.enums.TimeoutFlag; +import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; import org.apache.dolphinscheduler.common.model.TaskNode; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.TaskDefinition; import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.plugin.task.api.enums.DependentRelation; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus; +import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy; import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters; @@ -47,14 +47,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.context.ApplicationContext; -@RunWith(MockitoJUnitRunner.Silent.class) public class BlockingTaskTest { /** @@ -68,22 +66,22 @@ public class BlockingTaskTest { private MasterConfig config; - @Before - public void before() { - // init spring context - ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class); - SpringApplicationContext springApplicationContext = new SpringApplicationContext(); - springApplicationContext.setApplicationContext(applicationContext); + private MockedStatic mockedStaticSpringApplicationContext; + @BeforeEach + public void before() { // mock master config = new MasterConfig(); - Mockito.when(applicationContext.getBean(MasterConfig.class)).thenReturn(config); config.setTaskCommitRetryTimes(3); config.setTaskCommitInterval(Duration.ofSeconds(1)); + mockedStaticSpringApplicationContext = Mockito.mockStatic(SpringApplicationContext.class); + Mockito.when(SpringApplicationContext.getBean(MasterConfig.class)).thenReturn(config); + // mock process service processService = Mockito.mock(ProcessService.class); - Mockito.when(applicationContext.getBean(ProcessService.class)).thenReturn(processService); + + Mockito.when(SpringApplicationContext.getBean(ProcessService.class)).thenReturn(processService); // mock process instance processInstance = getProcessInstance(); @@ -99,6 +97,11 @@ public class BlockingTaskTest { .thenReturn(taskDefinition); } + @AfterEach + public void after() { + mockedStaticSpringApplicationContext.close(); + } + private ProcessInstance getProcessInstance() { // mock process instance ProcessInstance processInstance = new ProcessInstance(); @@ -200,8 +203,8 @@ public class BlockingTaskTest { // for BlockingTaskExecThread.waitTaskQuit List conditions = getTaskInstanceForValidTaskList(expectResults); - Mockito.when(processService. - findValidTaskListByProcessId(processInstance.getId(),processInstance.getTestFlag())) + Mockito.when( + processService.findValidTaskListByProcessId(processInstance.getId(), processInstance.getTestFlag())) .thenReturn(conditions); return taskInstance; } diff --git a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java index a69435a576..cb2eb7afe3 100644 --- a/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java +++ b/dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java @@ -39,17 +39,13 @@ import java.time.Duration; import java.util.ArrayList; import java.util.List; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.context.ApplicationContext; -@RunWith(MockitoJUnitRunner.class) public class SubProcessTaskTest { /** @@ -62,23 +58,22 @@ public class SubProcessTaskTest { private ProcessInstance processInstance; private MockedStatic mockedStaticServerLifeCycleManager; + private MockedStatic mockedStaticSpringApplicationContext; - @Before + @BeforeEach public void before() { - ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class); - SpringApplicationContext springApplicationContext = new SpringApplicationContext(); - springApplicationContext.setApplicationContext(applicationContext); - MasterConfig config = new MasterConfig(); - Mockito.when(applicationContext.getBean(MasterConfig.class)).thenReturn(config); config.setTaskCommitRetryTimes(3); config.setTaskCommitInterval(Duration.ofSeconds(1)); - mockedStaticServerLifeCycleManager = Mockito.mockStatic(ServerLifeCycleManager.class); - Mockito.when(ServerLifeCycleManager.isStopped()).thenReturn(false); + mockedStaticSpringApplicationContext = Mockito.mockStatic(SpringApplicationContext.class); + Mockito.when(SpringApplicationContext.getBean(MasterConfig.class)).thenReturn(config); processService = Mockito.mock(ProcessService.class); - Mockito.when(applicationContext.getBean(ProcessService.class)).thenReturn(processService); + Mockito.when(SpringApplicationContext.getBean(ProcessService.class)).thenReturn(processService); + + mockedStaticServerLifeCycleManager = Mockito.mockStatic(ServerLifeCycleManager.class); + Mockito.when(ServerLifeCycleManager.isStopped()).thenReturn(false); processInstance = getProcessInstance(); Mockito.when(processService @@ -91,9 +86,10 @@ public class SubProcessTaskTest { taskDefinition.setTimeout(0); } - @After + @AfterEach public void after() { mockedStaticServerLifeCycleManager.close(); + mockedStaticSpringApplicationContext.close(); } private TaskInstance testBasicInit(WorkflowExecutionStatus expectResult) { @@ -166,12 +162,6 @@ public class SubProcessTaskTest { return processInstance; } - private TaskInstance getTaskInstance() { - TaskInstance taskInstance = new TaskInstance(); - taskInstance.setId(1000); - return taskInstance; - } - private ProcessInstance getSubProcessInstance(WorkflowExecutionStatus executionStatus) { ProcessInstance processInstance = new ProcessInstance(); processInstance.setId(102);