Browse Source

[Migrate][Test] Migrate all UT cases from jUnit 4 to 5 in master, worker, and remote modules (#12362)

* migrate junit4 -> junit5 in master, worker, and remote modules
3.2.0-release
Yann Ann 2 years ago committed by GitHub
parent
commit
bc80f34056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java
  2. 41
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java
  3. 28
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java
  4. 6
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java
  5. 2
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ParamsTest.java
  6. 4
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java
  7. 33
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java
  8. 33
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/cache/impl/ProcessInstanceExecCacheManagerImplTest.java
  9. 12
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/config/MasterConfigTest.java
  10. 38
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java
  11. 19
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java
  12. 22
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java
  13. 16
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/RoundRobinHostManagerTest.java
  14. 20
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/HostWorkerTest.java
  15. 36
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobinTest.java
  16. 14
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelectorTest.java
  17. 40
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelectorTest.java
  18. 12
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java
  19. 16
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java
  20. 10
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java
  21. 18
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java
  22. 15
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java
  23. 16
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java
  24. 35
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnableTest.java
  25. 34
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java
  26. 10
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/TaskProcessorFactoryTest.java
  27. 33
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/service/FailoverServiceTest.java
  28. 16
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java
  29. 7
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommandTest.java
  30. 7
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommandTest.java
  31. 7
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireCommandTest.java
  32. 7
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/future/ResponseFutureTest.java
  33. 8
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommandTest.java
  34. 8
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java
  35. 8
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommandTest.java
  36. 8
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommandTest.java
  37. 8
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommandTest.java
  38. 10
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/utils/HostTest.java
  39. 10
      dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/rpc/RpcTest.java
  40. 13
      dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/config/BeanConfigTest.java
  41. 14
      dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java
  42. 4
      dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/runner/DefaultWorkerDelayTaskExecuteRunnableTest.java

10
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/BlockingTaskTest.java

@ -46,8 +46,8 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
@ -231,7 +231,7 @@ public class BlockingTaskTest {
BlockingTaskProcessor blockingTaskProcessor = new BlockingTaskProcessor();
blockingTaskProcessor.init(taskInstance, processInstance);
boolean res = blockingTaskProcessor.action(TaskAction.SUBMIT);
Assert.assertEquals(true, res);
Assertions.assertTrue(res);
}
@Test
@ -243,7 +243,7 @@ public class BlockingTaskTest {
blockingTaskProcessor.action(TaskAction.SUBMIT);
blockingTaskProcessor.action(TaskAction.PAUSE);
TaskExecutionStatus status = taskInstance.getState();
Assert.assertEquals(TaskExecutionStatus.PAUSE, status);
Assertions.assertEquals(TaskExecutionStatus.PAUSE, status);
}
@Test
@ -255,7 +255,7 @@ public class BlockingTaskTest {
blockingTaskProcessor.action(TaskAction.SUBMIT);
blockingTaskProcessor.action(TaskAction.RUN);
WorkflowExecutionStatus status = processInstance.getState();
Assert.assertEquals(WorkflowExecutionStatus.READY_BLOCK, status);
Assertions.assertEquals(WorkflowExecutionStatus.READY_BLOCK, status);
}
@Test
@ -267,6 +267,6 @@ public class BlockingTaskTest {
blockingTaskProcessor.action(TaskAction.SUBMIT);
blockingTaskProcessor.action(TaskAction.RUN);
WorkflowExecutionStatus status = processInstance.getState();
Assert.assertEquals(WorkflowExecutionStatus.RUNNING_EXECUTION, status);
Assertions.assertEquals(WorkflowExecutionStatus.RUNNING_EXECUTION, status);
}
}

41
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ConditionsTaskTest.java

@ -17,15 +17,15 @@
package org.apache.dolphinscheduler.server.master;
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.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.ConditionsParameters;
@ -34,20 +34,21 @@ import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import org.apache.dolphinscheduler.service.model.TaskNode;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.ApplicationContext;
@RunWith(MockitoJUnitRunner.Silent.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ConditionsTaskTest {
/**
@ -59,7 +60,7 @@ public class ConditionsTaskTest {
private ProcessInstance processInstance;
@Before
@BeforeEach
public void before() {
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
SpringApplicationContext springApplicationContext = new SpringApplicationContext();
@ -115,22 +116,6 @@ public class ConditionsTaskTest {
return taskInstance;
}
@Test
public void testBasicSuccess() {
TaskInstance taskInstance = testBasicInit(TaskExecutionStatus.SUCCESS);
// ConditionTaskProcessor taskExecThread = new onditionsTaskExecThread(taskInstance);
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.SUCCESS, taskExecThread.getTaskInstance().getState());
}
@Test
public void testBasicFailure() {
TaskInstance taskInstance = testBasicInit(TaskExecutionStatus.FAILURE);
// ConditionsTaskExecThread taskExecThread = new ConditionsTaskExecThread(taskInstance);
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.FAILURE, taskExecThread.getTaskInstance().getState());
}
private TaskNode getTaskNode() {
TaskNode taskNode = new TaskNode();
taskNode.setId("tasks-1000");

28
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/DependentTaskTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.server.master;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
@ -35,11 +35,13 @@ import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import org.apache.dolphinscheduler.service.model.TaskNode;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
import java.time.Duration;
@ -49,7 +51,8 @@ import java.util.stream.Stream;
/**
* DependentTaskTest
*/
@RunWith(MockitoJUnitRunner.Silent.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class DependentTaskTest {
/**
@ -77,7 +80,7 @@ public class DependentTaskTest {
private ProcessInstance processInstance;
private TaskInstance taskInstance;
@Before
@BeforeEach
public void before() {
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
SpringApplicationContext springApplicationContext = new SpringApplicationContext();
@ -239,9 +242,6 @@ public class DependentTaskTest {
processInstance300))
.collect(Collectors.toList()));
// DependentTaskExecThread taskExecThread = new DependentTaskExecThread(taskInstance);
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.SUCCESS, taskExecThread.getTaskInstance().getState());
}
/**
@ -273,9 +273,6 @@ public class DependentTaskTest {
.findLastRunningProcess(Mockito.eq(2L), Mockito.any(), Mockito.any(), Mockito.anyInt()))
.thenReturn(getProcessInstanceForFindLastRunningProcess(200, WorkflowExecutionStatus.SUCCESS));
// DependentTaskExecThread taskExecThread = new DependentTaskExecThread(taskInstance);
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.SUCCESS, taskExecThread.getTaskInstance().getState());
}
@Test
@ -286,9 +283,6 @@ public class DependentTaskTest {
.findLastRunningProcess(Mockito.eq(2L), Mockito.any(), Mockito.any(), Mockito.anyInt()))
.thenReturn(getProcessInstanceForFindLastRunningProcess(200, WorkflowExecutionStatus.FAILURE));
// DependentTaskExecThread dependentTask = new DependentTaskExecThread(taskInstance);
// dependentTask.call();
// Assert.assertEquals(ExecutionStatus.FAILURE, dependentTask.getTaskInstance().getState());
}
/**
@ -337,8 +331,6 @@ public class DependentTaskTest {
})
.thenThrow(new IllegalStateException("have not been stopped as expected"));
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.KILL, taskExecThread.getTaskInstance().getState());
}
private ProcessInstance getProcessInstance() {

6
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/MasterCommandTest.java

@ -24,15 +24,15 @@ import org.apache.dolphinscheduler.dao.entity.Command;
import org.apache.dolphinscheduler.dao.mapper.CommandMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* master test
*/
@Ignore
@Disabled
public class MasterCommandTest {
private final Logger logger = LoggerFactory.getLogger(MasterCommandTest.class);

2
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/ParamsTest.java

@ -25,7 +25,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

4
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SubProcessTaskTest.java

@ -39,8 +39,8 @@ import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
@ -124,7 +124,7 @@ public class SubProcessTaskTest {
subTaskProcessor.init(taskInstance, processInstance);
subTaskProcessor.action(TaskAction.RUN);
TaskExecutionStatus status = taskInstance.getState();
Assert.assertEquals(TaskExecutionStatus.SUCCESS, status);
Assertions.assertEquals(TaskExecutionStatus.SUCCESS, status);
}
private String getProperty() {

33
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/SwitchTaskTest.java

@ -18,19 +18,25 @@
package org.apache.dolphinscheduler.server.master;
import org.apache.dolphinscheduler.common.Constants;
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.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.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo;
import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
import java.time.Duration;
import java.util.ArrayList;
@ -38,21 +44,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.ApplicationContext;
@RunWith(MockitoJUnitRunner.Silent.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class SwitchTaskTest {
private ProcessService processService;
private ProcessInstance processInstance;
@Before
@BeforeEach
public void before() {
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
SpringApplicationContext springApplicationContext = new SpringApplicationContext();
@ -101,15 +101,6 @@ public class SwitchTaskTest {
return taskInstance;
}
@Test
public void testExe() throws Exception {
TaskInstance taskInstance = testBasicInit(WorkflowExecutionStatus.SUCCESS);
taskInstance.setState(TaskExecutionStatus.SUBMITTED_SUCCESS);
// SwitchTaskExecThread taskExecThread = new SwitchTaskExecThread(taskInstance);
// taskExecThread.call();
// Assert.assertEquals(ExecutionStatus.SUCCESS, taskExecThread.getTaskInstance().getState());
}
private SwitchParameters getTaskNode() {
SwitchParameters conditionsParameters = new SwitchParameters();

33
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/cache/impl/ProcessInstanceExecCacheManagerImplTest.java vendored

@ -21,16 +21,19 @@ import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable;
import java.util.Collection;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class ProcessInstanceExecCacheManagerImplTest {
@InjectMocks
@ -39,7 +42,7 @@ public class ProcessInstanceExecCacheManagerImplTest {
@Mock
private WorkflowExecuteRunnable workflowExecuteThread;
@Before
@BeforeEach
public void before() {
Mockito.when(workflowExecuteThread.getKey()).thenReturn("workflowExecuteThread1");
processInstanceExecCacheManager.cache(1, workflowExecuteThread);
@ -48,31 +51,33 @@ public class ProcessInstanceExecCacheManagerImplTest {
@Test
public void testGetByProcessInstanceId() {
WorkflowExecuteRunnable workflowExecuteThread = processInstanceExecCacheManager.getByProcessInstanceId(1);
Assert.assertEquals("workflowExecuteThread1", workflowExecuteThread.getKey());
Assertions.assertEquals("workflowExecuteThread1", workflowExecuteThread.getKey());
}
@Test
public void testContains() {
Assert.assertTrue(processInstanceExecCacheManager.contains(1));
Assertions.assertTrue(processInstanceExecCacheManager.contains(1));
}
@Test(expected = NullPointerException.class)
@Test
public void testCacheNull() {
processInstanceExecCacheManager.cache(2, null);
Assertions.assertThrows(NullPointerException.class, () -> {
processInstanceExecCacheManager.cache(2, null);
});
WorkflowExecuteRunnable workflowExecuteThread = processInstanceExecCacheManager.getByProcessInstanceId(2);
Assert.assertNull(workflowExecuteThread);
Assertions.assertNull(workflowExecuteThread);
}
@Test
public void testRemoveByProcessInstanceId() {
processInstanceExecCacheManager.removeByProcessInstanceId(1);
WorkflowExecuteRunnable workflowExecuteThread = processInstanceExecCacheManager.getByProcessInstanceId(1);
Assert.assertNull(workflowExecuteThread);
Assertions.assertNull(workflowExecuteThread);
}
@Test
public void testGetAll() {
Collection<WorkflowExecuteRunnable> workflowExecuteThreads = processInstanceExecCacheManager.getAll();
Assert.assertEquals(1, workflowExecuteThreads.size());
Assertions.assertEquals(1, workflowExecuteThreads.size());
}
}

12
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/config/MasterConfigTest.java

@ -17,16 +17,16 @@
package org.apache.dolphinscheduler.server.master.config;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ActiveProfiles("master")
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = MasterConfig.class)
public class MasterConfigTest {
@ -36,6 +36,6 @@ public class MasterConfigTest {
@Test
public void getMasterDispatchTaskNumber() {
int masterDispatchTaskNumber = masterConfig.getDispatchTaskNumber();
Assert.assertEquals(3, masterDispatchTaskNumber);
Assertions.assertEquals(3, masterDispatchTaskNumber);
}
}

38
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/consumer/TaskPriorityQueueConsumerTest.java

@ -37,18 +37,18 @@ import org.apache.dolphinscheduler.spi.enums.DbType;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@RunWith(SpringJUnit4ClassRunner.class)
@Ignore
@ExtendWith(SpringExtension.class)
@Disabled
public class TaskPriorityQueueConsumerTest {
@Autowired
@ -63,7 +63,7 @@ public class TaskPriorityQueueConsumerTest {
@Autowired
private ExecutorDispatcher dispatcher;
@Before
@BeforeEach
public void init() {
Tenant tenant = new Tenant();
@ -103,7 +103,7 @@ public class TaskPriorityQueueConsumerTest {
TimeUnit.SECONDS.sleep(10);
Assert.assertNotNull(taskInstance);
Assertions.assertNotNull(taskInstance);
}
@Test
@ -144,7 +144,7 @@ public class TaskPriorityQueueConsumerTest {
Mockito.doReturn(dataSource).when(processService).findDataSourceById(1);
TimeUnit.SECONDS.sleep(10);
Assert.assertNotNull(taskInstance);
Assertions.assertNotNull(taskInstance);
}
@Test
@ -183,7 +183,7 @@ public class TaskPriorityQueueConsumerTest {
dataSource.setUpdateTime(new Date());
Mockito.doReturn(dataSource).when(processService).findDataSourceById(80);
TimeUnit.SECONDS.sleep(10);
Assert.assertNotNull(taskInstance);
Assertions.assertNotNull(taskInstance);
}
@Test
@ -222,7 +222,7 @@ public class TaskPriorityQueueConsumerTest {
dataSource.setUpdateTime(new Date());
Mockito.doReturn(dataSource).when(processService).findDataSourceById(1);
TimeUnit.SECONDS.sleep(10);
Assert.assertNotNull(taskInstance);
Assertions.assertNotNull(taskInstance);
}
@Test
@ -239,7 +239,7 @@ public class TaskPriorityQueueConsumerTest {
Mockito.doReturn(taskInstance).when(processService).findTaskInstanceById(1);
Boolean state = taskPriorityQueueConsumer.taskInstanceIsFinalState(1);
Assert.assertNotNull(state);
Assertions.assertNotNull(state);
}
@Test
@ -271,7 +271,7 @@ public class TaskPriorityQueueConsumerTest {
TimeUnit.SECONDS.sleep(10);
Assert.assertNotNull(taskInstance);
Assertions.assertNotNull(taskInstance);
}
@ -308,7 +308,7 @@ public class TaskPriorityQueueConsumerTest {
taskPriority.setTaskId(1);
boolean res = taskPriorityQueueConsumer.dispatchTask(taskPriority);
Assert.assertFalse(res);
Assertions.assertFalse(res);
}
@Test
@ -341,11 +341,11 @@ public class TaskPriorityQueueConsumerTest {
taskPriorityQueueConsumer.run();
TimeUnit.SECONDS.sleep(10);
Assert.assertNotEquals(-1, taskPriorityQueue.size());
Assertions.assertNotEquals(-1, taskPriorityQueue.size());
}
@After
@AfterEach
public void close() {
ServerLifeCycleManager.toStopped();
}

19
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/ExecutorDispatcherTest.java

@ -26,18 +26,19 @@ import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
import org.apache.dolphinscheduler.server.worker.processor.TaskDispatchProcessor;
import org.apache.dolphinscheduler.server.worker.registry.WorkerRegistryClient;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* executor dispatch test
*/
@RunWith(SpringJUnit4ClassRunner.class)
@Ignore
@ExtendWith(SpringExtension.class)
@Disabled
public class ExecutorDispatcherTest {
@Autowired
@ -49,10 +50,12 @@ public class ExecutorDispatcherTest {
@Autowired
private WorkerConfig workerConfig;
@Test(expected = ExecuteException.class)
@Test
public void testDispatchWithException() throws ExecuteException {
ExecutionContext executionContext = ExecutionContextTestUtils.getExecutionContext(10000);
executorDispatcher.dispatch(executionContext);
Assertions.assertThrows(ExecuteException.class, () -> {
executorDispatcher.dispatch(executionContext);
});
}
@Test

22
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/executor/NettyExecutorManagerTest.java

@ -34,19 +34,19 @@ import org.apache.dolphinscheduler.server.master.dispatch.enums.ExecutorType;
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException;
import org.apache.dolphinscheduler.server.worker.processor.TaskDispatchProcessor;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* netty executor manager test
*/
@RunWith(SpringJUnit4ClassRunner.class)
@Ignore
@ExtendWith(SpringExtension.class)
@Disabled
public class NettyExecutorManagerTest {
@Autowired
private NettyExecutorManager nettyExecutorManager;
@ -71,11 +71,11 @@ public class NettyExecutorManagerTest {
ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER, taskInstance);
executionContext.setHost(Host.of(NetUtils.getAddr(serverConfig.getListenPort())));
Boolean execute = nettyExecutorManager.execute(executionContext);
Assert.assertTrue(execute);
Assertions.assertTrue(execute);
nettyRemotingServer.close();
}
@Test(expected = ExecuteException.class)
@Test
public void testExecuteWithException() throws ExecuteException {
TaskInstance taskInstance = Mockito.mock(TaskInstance.class);
ProcessDefinition processDefinition = Mockito.mock(ProcessDefinition.class);
@ -89,7 +89,9 @@ public class NettyExecutorManagerTest {
.create();
ExecutionContext executionContext = new ExecutionContext(toCommand(context), ExecutorType.WORKER, taskInstance);
executionContext.setHost(Host.of(NetUtils.getAddr(4444)));
nettyExecutorManager.execute(executionContext);
Assertions.assertThrows(ExecuteException.class, () -> {
nettyExecutorManager.execute(executionContext);
});
}
private Command toCommand(TaskExecutionContext taskExecutionContext) {

16
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/RoundRobinHostManagerTest.java

@ -23,20 +23,20 @@ import org.apache.dolphinscheduler.server.master.dispatch.ExecutionContextTestUt
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext;
import org.apache.dolphinscheduler.server.master.registry.ServerNodeManager;
import org.assertj.core.util.Strings;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import com.google.common.collect.Sets;
import org.mockito.junit.jupiter.MockitoExtension;
/**
* round robin host manager test
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class RoundRobinHostManagerTest {
@Mock
@ -50,7 +50,7 @@ public class RoundRobinHostManagerTest {
Mockito.when(serverNodeManager.getWorkerGroupNodes("default")).thenReturn(null);
ExecutionContext context = ExecutionContextTestUtils.getExecutionContext(10000);
Host emptyHost = roundRobinHostManager.select(context);
Assert.assertTrue(Strings.isNullOrEmpty(emptyHost.getAddress()));
Assertions.assertTrue(Strings.isNullOrEmpty(emptyHost.getAddress()));
}
@Test
@ -59,7 +59,7 @@ public class RoundRobinHostManagerTest {
Mockito.when(serverNodeManager.getWorkerNodeInfo("192.168.1.1:22")).thenReturn(new WorkerHeartBeat());
ExecutionContext context = ExecutionContextTestUtils.getExecutionContext(10000);
Host host = roundRobinHostManager.select(context);
Assert.assertTrue(!Strings.isNullOrEmpty(host.getAddress()));
Assert.assertTrue(host.getAddress().equalsIgnoreCase("192.168.1.1:22"));
Assertions.assertFalse(Strings.isNullOrEmpty(host.getAddress()));
Assertions.assertTrue(host.getAddress().equalsIgnoreCase("192.168.1.1:22"));
}
}

20
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/HostWorkerTest.java

@ -17,27 +17,27 @@
package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class HostWorkerTest {
@Test
public void testHostWorker1() {
HostWorker hostWorker = new HostWorker("192.158.2.2", 11, 20, "default");
Assert.assertEquals("192.158.2.2", hostWorker.getIp());
Assert.assertEquals(11, hostWorker.getPort());
Assert.assertEquals(20, hostWorker.getHostWeight());
Assert.assertEquals("default", hostWorker.getWorkerGroup());
Assertions.assertEquals("192.158.2.2", hostWorker.getIp());
Assertions.assertEquals(11, hostWorker.getPort());
Assertions.assertEquals(20, hostWorker.getHostWeight());
Assertions.assertEquals("default", hostWorker.getWorkerGroup());
}
@Test
public void testHostWorker2() {
HostWorker hostWorker = HostWorker.of("192.158.2.2:22", 80, "default");
Assert.assertEquals("192.158.2.2", hostWorker.getIp());
Assert.assertEquals(22, hostWorker.getPort());
Assert.assertEquals(80, hostWorker.getHostWeight());
Assert.assertEquals("default", hostWorker.getWorkerGroup());
Assertions.assertEquals("192.158.2.2", hostWorker.getIp());
Assertions.assertEquals(22, hostWorker.getPort());
Assertions.assertEquals(80, hostWorker.getHostWeight());
Assertions.assertEquals("default", hostWorker.getWorkerGroup());
}
}

36
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/LowerWeightRoundRobinTest.java

@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class LowerWeightRoundRobinTest {
@ -35,20 +35,20 @@ public class LowerWeightRoundRobinTest {
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin();
HostWeight result;
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.3", result.getHost().getIp());
Assert.assertEquals("192.158.2.3", result.getHost().getIp());
Assertions.assertEquals("192.158.2.3", result.getHost().getIp());
Assertions.assertEquals("192.158.2.3", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
}
@Test
@ -62,15 +62,15 @@ public class LowerWeightRoundRobinTest {
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin();
HostWeight result;
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.4", result.getHost().getIp());
Assertions.assertEquals("192.158.2.4", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.2", result.getHost().getIp());
Assertions.assertEquals("192.158.2.2", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.4", result.getHost().getIp());
Assertions.assertEquals("192.158.2.4", result.getHost().getIp());
result = roundRobin.select(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
}
@Test
@ -79,12 +79,12 @@ public class LowerWeightRoundRobinTest {
LowerWeightRoundRobin roundRobin = new LowerWeightRoundRobin();
HostWeight result;
result = roundRobin.doSelect(sources);
Assert.assertEquals(null, result);
Assertions.assertNull(result);
sources.add(new HostWeight(HostWorker.of("192.158.2.1:11", 100, "default"), 0.06, 0.44, 3.14, 1, System.currentTimeMillis() - 60 * 8 * 1000));
sources.add(new HostWeight(HostWorker.of("192.158.2.2:22", 100, "default"), 0.06, 0.56, 3.24, 2, System.currentTimeMillis() - 60 * 5 * 1000));
sources.add(new HostWeight(HostWorker.of("192.158.2.3:33", 100, "default"), 0.06, 0.80, 3.15, 1, System.currentTimeMillis() - 60 * 2 * 1000));
result = roundRobin.doSelect(sources);
Assert.assertEquals("192.158.2.1", result.getHost().getIp());
Assertions.assertEquals("192.158.2.1", result.getHost().getIp());
}
}

14
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RandomSelectorTest.java

@ -19,31 +19,33 @@ package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
import java.util.Arrays;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* random selector
*/
public class RandomSelectorTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void testSelectWithIllegalArgumentException() {
RandomSelector selector = new RandomSelector();
selector.select(null);
Assertions.assertThrows(IllegalArgumentException.class, () -> {
selector.select(null);
});
}
@Test
public void testSelect1() {
RandomSelector selector = new RandomSelector();
HostWorker result = selector.select(Arrays.asList(new HostWorker("192.168.1.1:11", 100, "default"), new HostWorker("192.168.1.2:22", 80, "default")));
Assert.assertNotNull(result);
Assertions.assertNotNull(result);
}
@Test
public void testSelect() {
RandomSelector selector = new RandomSelector();
HostWorker result = selector.select(Arrays.asList(new HostWorker("192.168.1.1", 11, 100, "default"), new HostWorker("192.168.1.2:", 22, 20, "default")));
Assert.assertNotNull(result);
Assertions.assertNotNull(result);
}
}

40
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/dispatch/host/assign/RoundRobinSelectorTest.java

@ -20,18 +20,20 @@ package org.apache.dolphinscheduler.server.master.dispatch.host.assign;
import java.util.Arrays;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* round robin selector
*/
public class RoundRobinSelectorTest {
@Test(expected = IllegalArgumentException.class)
@Test
public void testSelectWithIllegalArgumentException() {
RoundRobinSelector selector = new RoundRobinSelector();
selector.select(null);
Assertions.assertThrows(IllegalArgumentException.class, () -> {
selector.select(null);
});
}
@Test
@ -48,47 +50,47 @@ public class RoundRobinSelectorTest {
HostWorker result;
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.2", result.getIp());
Assertions.assertEquals("192.168.1.2", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.2", result.getIp());
Assertions.assertEquals("192.168.1.2", result.getIp());
// add new host
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.3", result.getIp());
Assertions.assertEquals("192.168.1.3", result.getIp());
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.2", result.getIp());
Assertions.assertEquals("192.168.1.2", result.getIp());
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostTwoList);
Assert.assertEquals("192.168.1.3", result.getIp());
Assertions.assertEquals("192.168.1.3", result.getIp());
// remove host3
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.2", result.getIp());
Assertions.assertEquals("192.168.1.2", result.getIp());
result = selector.select(hostOneList);
Assert.assertEquals("192.168.1.1", result.getIp());
Assertions.assertEquals("192.168.1.1", result.getIp());
}
@Test
@ -97,7 +99,7 @@ public class RoundRobinSelectorTest {
HostWorker result;
result = selector.select(
Arrays.asList(new HostWorker("192.168.1.1", 11, 20, "kris"), new HostWorker("192.168.1.2", 22, 80, "kris")));
Assert.assertEquals("192.168.1.2", result.getIp());
Assertions.assertEquals("192.168.1.2", result.getIp());
}
}

12
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/CacheProcessorTest.java

@ -22,13 +22,13 @@ import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
import org.apache.dolphinscheduler.remote.command.Command;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
@ -37,7 +37,7 @@ import io.netty.channel.Channel;
/**
* task ack processor test
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CacheProcessorTest {
@InjectMocks
@ -52,7 +52,7 @@ public class CacheProcessorTest {
@Mock
private Cache cache;
@Before
@BeforeEach
public void before() {
Mockito.when(cacheManager.getCache(CacheType.TENANT.getCacheName())).thenReturn(cache);
}

16
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskAckProcessorTest.java

@ -24,20 +24,20 @@ import org.apache.dolphinscheduler.server.master.processor.queue.TaskEventServic
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.junit.After;
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.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import io.netty.channel.Channel;
import org.mockito.junit.jupiter.MockitoExtension;
/**
* task ack processor test
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TaskAckProcessorTest {
private TaskExecuteRunningProcessor taskExecuteRunningProcessor;
@ -49,7 +49,7 @@ public class TaskAckProcessorTest {
private MockedStatic<SpringApplicationContext> mockedStaticSpringApplicationContext;
@Before
@BeforeEach
public void before() {
mockedStaticSpringApplicationContext = Mockito.mockStatic(SpringApplicationContext.class);
@ -78,7 +78,7 @@ public class TaskAckProcessorTest {
taskExecuteRunningMessage.setProcessInstanceId(1);
}
@After
@AfterEach
public void after() {
mockedStaticSpringApplicationContext.close();
}

10
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/TaskKillResponseProcessorTest.java

@ -24,9 +24,9 @@ import org.apache.dolphinscheduler.remote.command.TaskKillResponseCommand;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import io.netty.channel.Channel;
@ -42,7 +42,7 @@ public class TaskKillResponseProcessorTest {
private Channel channel;
@Before
@BeforeEach
public void before() {
taskKillResponseProcessor = new TaskKillResponseProcessor();
channel = Mockito.mock(Channel.class);
@ -64,7 +64,7 @@ public class TaskKillResponseProcessorTest {
@Test
public void testProcess() {
Command command = taskKillResponseCommand.convert2Command();
Assert.assertEquals(CommandType.TASK_KILL_RESPONSE, command.getType());
Assertions.assertEquals(CommandType.TASK_KILL_RESPONSE, command.getType());
taskKillResponseProcessor.process(channel, command);
}
}

18
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/processor/queue/TaskResponseServiceTest.java

@ -27,19 +27,17 @@ import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPoo
import org.apache.dolphinscheduler.server.master.utils.DataQualityResultOperator;
import org.apache.dolphinscheduler.service.process.ProcessService;
import java.util.Date;
import org.junit.After;
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.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import io.netty.channel.Channel;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TaskResponseServiceTest {
@Mock(name = "processService")
@ -69,7 +67,7 @@ public class TaskResponseServiceTest {
@Mock
private TaskExecuteThreadPool taskExecuteThreadPool;
@Before
@BeforeEach
public void before() {
taskEventService.start();
@ -113,7 +111,7 @@ public class TaskResponseServiceTest {
taskEventService.addEvent(resultEvent);
}
@After
@AfterEach
public void after() {
if (taskEventService != null) {
taskEventService.stop();

15
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java

@ -31,19 +31,22 @@ import org.apache.dolphinscheduler.service.registry.RegistryClient;
import java.util.Date;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.test.util.ReflectionTestUtils;
/**
* MasterRegistryClientTest
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class MasterRegistryClientTest {
@InjectMocks
@ -61,7 +64,7 @@ public class MasterRegistryClientTest {
@Mock
private MasterConfig masterConfig;
@Before
@BeforeEach
public void before() throws Exception {
given(registryClient.getHostByEventDataPath(Mockito.anyString())).willReturn("127.0.0.1:8080");
ReflectionTestUtils.setField(masterRegistryClient, "registryClient", registryClient);

16
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThreadTest.java

@ -28,21 +28,21 @@ import org.apache.dolphinscheduler.service.process.ProcessService;
import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.ApplicationContext;
@RunWith(MockitoJUnitRunner.class)
@Ignore
@ExtendWith(MockitoExtension.class)
@Disabled
public class MasterTaskExecThreadTest {
private SpringApplicationContext springApplicationContext;
@Before
@BeforeEach
public void setUp() {
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
this.springApplicationContext = new SpringApplicationContext();

35
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteRunnableTest.java

@ -52,15 +52,18 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class WorkflowExecuteRunnableTest {
private WorkflowExecuteRunnable workflowExecuteThread;
@ -79,7 +82,7 @@ public class WorkflowExecuteRunnableTest {
private CuringParamsService curingGlobalParamsService;
@Before
@BeforeEach
public void init() throws Exception {
applicationContext = Mockito.mock(ApplicationContext.class);
SpringApplicationContext springApplicationContext = new SpringApplicationContext();
@ -119,9 +122,9 @@ public class WorkflowExecuteRunnableTest {
method.setAccessible(true);
List<String> nodeNames =
(List<String>) method.invoke(workflowExecuteThread, JSONUtils.toJsonString(cmdParam));
Assert.assertEquals(3, nodeNames.size());
Assertions.assertEquals(3, nodeNames.size());
} catch (Exception e) {
Assert.fail();
Assertions.fail();
}
}
@ -147,15 +150,15 @@ public class WorkflowExecuteRunnableTest {
method.setAccessible(true);
List<TaskInstance> taskInstances =
workflowExecuteThread.getRecoverTaskInstanceList(JSONUtils.toJsonString(cmdParam));
Assert.assertEquals(4, taskInstances.size());
Assertions.assertEquals(4, taskInstances.size());
cmdParam.put(CMD_PARAM_RECOVERY_START_NODE_STRING, "1");
List<TaskInstance> taskInstanceEmpty =
(List<TaskInstance>) method.invoke(workflowExecuteThread, JSONUtils.toJsonString(cmdParam));
Assert.assertTrue(taskInstanceEmpty.isEmpty());
Assertions.assertTrue(taskInstanceEmpty.isEmpty());
} catch (Exception e) {
Assert.fail();
Assertions.fail();
}
}
@ -199,7 +202,7 @@ public class WorkflowExecuteRunnableTest {
taskInstanceMapField.set(workflowExecuteThread, taskInstanceMap);
workflowExecuteThread.getPreVarPool(taskInstance, preTaskName);
Assert.assertNotNull(taskInstance.getVarPool());
Assertions.assertNotNull(taskInstance.getVarPool());
taskInstance2.setVarPool("[{\"direct\":\"OUT\",\"prop\":\"test1\",\"type\":\"VARCHAR\",\"value\":\"2\"}]");
completeTaskList.put(taskInstance2.getTaskCode(), taskInstance2.getId());
@ -210,9 +213,9 @@ public class WorkflowExecuteRunnableTest {
taskInstanceMapField.set(workflowExecuteThread, taskInstanceMap);
workflowExecuteThread.getPreVarPool(taskInstance, preTaskName);
Assert.assertNotNull(taskInstance.getVarPool());
Assertions.assertNotNull(taskInstance.getVarPool());
} catch (Exception e) {
Assert.fail();
Assertions.fail();
}
}
@ -238,7 +241,7 @@ public class WorkflowExecuteRunnableTest {
Mockito.when(processService.findProcessInstanceById(222)).thenReturn(processInstance9);
workflowExecuteThread.checkSerialProcess(processDefinition1);
} catch (Exception e) {
Assert.fail();
Assertions.fail();
}
}

34
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessorTest.java

@ -17,8 +17,6 @@
package org.apache.dolphinscheduler.server.master.runner.task;
import static org.mockito.ArgumentMatchers.any;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
@ -29,30 +27,33 @@ import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import org.apache.dolphinscheduler.service.process.ProcessService;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.context.ApplicationContext;
import static org.mockito.ArgumentMatchers.any;
@RunWith(MockitoJUnitRunner.Silent.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class CommonTaskProcessorTest {
private ProcessService processService;
private CommonTaskProcessor commonTaskProcessor;
@Before
@BeforeEach
public void setUp() {
// init spring context
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
@ -103,7 +104,7 @@ public class CommonTaskProcessorTest {
taskInstance.setTaskDefine(taskDefinition);
Mockito.doReturn(taskInstance).when(processService).findTaskInstanceById(1);
TaskExecutionContext taskExecutionContext = commonTaskProcessor.getTaskExecutionContext(taskInstance);
Assert.assertNull(taskExecutionContext);
Assertions.assertNull(taskExecutionContext);
}
@Test
@ -126,7 +127,7 @@ public class CommonTaskProcessorTest {
resourcesList.add(resource);
Mockito.doReturn(resourcesList).when(processService).listResourceByIds(new Integer[]{123});
Mockito.doReturn("tenantCode").when(processService).queryTenantCodeByResName(resource.getFullName(), ResourceType.FILE);
Assert.assertNotNull(map);
Assertions.assertNotNull(map);
}
@ -144,7 +145,7 @@ public class CommonTaskProcessorTest {
taskInstance.setProcessInstance(processInstance);
boolean res = commonTaskProcessor.verifyTenantIsNull(tenant, taskInstance);
Assert.assertFalse(res);
Assertions.assertFalse(res);
tenant = new Tenant();
tenant.setId(1);
@ -154,7 +155,7 @@ public class CommonTaskProcessorTest {
tenant.setCreateTime(new Date());
tenant.setUpdateTime(new Date());
res = commonTaskProcessor.verifyTenantIsNull(tenant, taskInstance);
Assert.assertFalse(res);
Assertions.assertFalse(res);
}
@ -178,6 +179,5 @@ public class CommonTaskProcessorTest {
//The data source instance has bound test data source
Mockito.when(processService.queryTestDataSourceId(any(Integer.class))).thenReturn(2);
commonTaskProcessor1.convertExeEnvironmentOnlineToTest();
// Assert.assertTrue(result);
}
}

10
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/runner/task/TaskProcessorFactoryTest.java

@ -21,11 +21,11 @@ import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import java.lang.reflect.InvocationTargetException;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@Ignore
@Disabled
public class TaskProcessorFactoryTest {
@Test
@ -36,7 +36,7 @@ public class TaskProcessorFactoryTest {
ITaskProcessor iTaskProcessor = TaskProcessorFactory.getTaskProcessor(taskInstance.getTaskType());
Assert.assertNotNull(iTaskProcessor);
Assertions.assertNotNull(iTaskProcessor);
}
}

33
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/service/FailoverServiceTest.java

@ -45,18 +45,21 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.context.ApplicationContext;
import com.google.common.collect.Lists;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public class FailoverServiceTest {
private FailoverService failoverService;
@ -94,7 +97,7 @@ public class FailoverServiceTest {
private TaskInstance masterTaskInstance;
private TaskInstance workerTaskInstance;
@Before
@BeforeEach
public void before() throws Exception {
ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
SpringApplicationContext springApplicationContext = new SpringApplicationContext();
@ -116,8 +119,8 @@ public class FailoverServiceTest {
failoverService = new FailoverService(masterFailoverService, workerFailoverService);
String ip = testMasterHost.split(":")[0];
int port = Integer.valueOf(testMasterHost.split(":")[1]);
Assert.assertEquals(masterPort, port);
int port = Integer.parseInt(testMasterHost.split(":")[1]);
Assertions.assertEquals(masterPort, port);
testWorkerHost = ip + ":" + workerPort;
@ -172,19 +175,19 @@ public class FailoverServiceTest {
processInstance.setHost(Constants.NULL);
masterTaskInstance.setState(TaskExecutionStatus.RUNNING_EXECUTION);
failoverService.failoverServerWhenDown(testMasterHost, NodeType.MASTER);
Assert.assertNotEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
Assertions.assertNotEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
processInstance.setHost(testMasterHost);
masterTaskInstance.setState(TaskExecutionStatus.SUCCESS);
failoverService.failoverServerWhenDown(testMasterHost, NodeType.MASTER);
Assert.assertNotEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
Assert.assertEquals(Constants.NULL, processInstance.getHost());
Assertions.assertNotEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
Assertions.assertEquals(Constants.NULL, processInstance.getHost());
processInstance.setHost(testMasterHost);
masterTaskInstance.setState(TaskExecutionStatus.RUNNING_EXECUTION);
failoverService.failoverServerWhenDown(testMasterHost, NodeType.MASTER);
Assert.assertEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
Assert.assertEquals(Constants.NULL, processInstance.getHost());
Assertions.assertEquals(masterTaskInstance.getState(), TaskExecutionStatus.NEED_FAULT_TOLERANCE);
Assertions.assertEquals(Constants.NULL, processInstance.getHost());
}
@Test
@ -198,6 +201,6 @@ public class FailoverServiceTest {
Mockito.when(cacheManager.getByProcessInstanceId(Mockito.anyInt())).thenReturn(workflowExecuteRunnable);
failoverService.failoverServerWhenDown(testWorkerHost, NodeType.WORKER);
Assert.assertEquals(TaskExecutionStatus.NEED_FAULT_TOLERANCE, workerTaskInstance.getState());
Assertions.assertEquals(TaskExecutionStatus.NEED_FAULT_TOLERANCE, workerTaskInstance.getState());
}
}

16
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/NettyRemotingClientTest.java

@ -17,6 +17,9 @@
package org.apache.dolphinscheduler.remote;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
@ -25,18 +28,13 @@ import org.apache.dolphinscheduler.remote.future.InvokeCallback;
import org.apache.dolphinscheduler.remote.future.ResponseFuture;
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
import org.apache.dolphinscheduler.remote.utils.Host;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.io.Serializable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
/**
* netty remote client test
*/
@ -65,7 +63,7 @@ public class NettyRemotingClientTest {
Command commandPing = Ping.create();
try {
Command response = client.sendSync(new Host("127.0.0.1", serverConfig.getListenPort()), commandPing, 2000);
Assert.assertEquals(commandPing.getOpaque(), response.getOpaque());
Assertions.assertEquals(commandPing.getOpaque(), response.getOpaque());
} catch (Exception e) {
e.printStackTrace();
}
@ -103,7 +101,7 @@ public class NettyRemotingClientTest {
}
});
latch.await();
Assert.assertEquals(commandPing.getOpaque(), opaque.get());
Assertions.assertEquals(commandPing.getOpaque(), opaque.get());
} catch (Exception e) {
e.printStackTrace();
}

7
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendRequestCommandTest.java

@ -20,9 +20,8 @@ package org.apache.dolphinscheduler.remote.command.alert;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class AlertSendRequestCommandTest {
@ -33,7 +32,7 @@ public class AlertSendRequestCommandTest {
String content = "test-content";
AlertSendRequestCommand requestCommand = new AlertSendRequestCommand(groupId,title,content,WarningType.FAILURE.getCode());
Command command = requestCommand.convert2Command();
Assert.assertEquals(CommandType.ALERT_SEND_REQUEST,command.getType());
Assertions.assertEquals(CommandType.ALERT_SEND_REQUEST, command.getType());
AlertSendRequestCommand verifyCommand = new AlertSendRequestCommand();
verifyCommand.setGroupId(groupId);
verifyCommand.setContent(content);

7
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/alert/AlertSendResponseCommandTest.java

@ -19,13 +19,12 @@ package org.apache.dolphinscheduler.remote.command.alert;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
public class AlertSendResponseCommandTest {
@Test
@ -43,6 +42,6 @@ public class AlertSendResponseCommandTest {
alertSendResponseCommand.setResResults(responseResults);
Command command = alertSendResponseCommand.convert2Command(1);
Assert.assertEquals(CommandType.ALERT_SEND_RESPONSE, command.getType());
Assertions.assertEquals(CommandType.ALERT_SEND_RESPONSE, command.getType());
}
}

7
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/cache/CacheExpireCommandTest.java vendored

@ -21,9 +21,8 @@ import org.apache.dolphinscheduler.common.enums.CacheType;
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class CacheExpireCommandTest {
@ -31,6 +30,6 @@ public class CacheExpireCommandTest {
public void testConvert2Command() {
CacheExpireCommand cacheExpireCommand = new CacheExpireCommand(CacheType.TENANT, "1");
Command command = cacheExpireCommand.convert2Command();
Assert.assertEquals(CommandType.CACHE_EXPIRE, command.getType());
Assertions.assertEquals(CommandType.CACHE_EXPIRE, command.getType());
}
}

7
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/future/ResponseFutureTest.java

@ -20,15 +20,14 @@ package org.apache.dolphinscheduler.remote.command.future;
import org.apache.dolphinscheduler.remote.future.InvokeCallback;
import org.apache.dolphinscheduler.remote.future.ResponseFuture;
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
public class ResponseFutureTest {
@Test
@ -51,7 +50,7 @@ public class ResponseFutureTest {
ResponseFuture future = new ResponseFuture(1, 2000, invokeCallback, null);
try {
latch.await(5000, TimeUnit.MILLISECONDS);
Assert.assertNull(ResponseFuture.getFuture(1));
Assertions.assertNull(ResponseFuture.getFuture(1));
} catch (InterruptedException e) {
e.printStackTrace();
}

8
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesRequestCommandTest.java

@ -19,10 +19,8 @@ package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.junit.Test;
import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class GetLogBytesRequestCommandTest {
@ -30,6 +28,6 @@ public class GetLogBytesRequestCommandTest {
public void testConvert2Command() {
GetLogBytesRequestCommand getLogBytesRequestCommand = new GetLogBytesRequestCommand("/opt/test");
Command command = getLogBytesRequestCommand.convert2Command();
Assert.assertEquals(CommandType.GET_LOG_BYTES_REQUEST, command.getType());
Assertions.assertEquals(CommandType.GET_LOG_BYTES_REQUEST, command.getType());
}
}

8
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/GetLogBytesResponseCommandTest.java

@ -18,10 +18,8 @@
package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.remote.command.Command;
import org.junit.Test;
import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class GetLogBytesResponseCommandTest {
@ -31,6 +29,6 @@ public class GetLogBytesResponseCommandTest {
public void testConvert2Command() {
GetLogBytesResponseCommand getLogBytesResponseCommand = new GetLogBytesResponseCommand(data);
Command command = getLogBytesResponseCommand.convert2Command(122);
Assert.assertNotNull(command);
Assertions.assertNotNull(command);
}
}

8
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogRequestCommandTest.java

@ -18,10 +18,8 @@
package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.remote.command.Command;
import org.junit.Test;
import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class RemoveTaskLogRequestCommandTest {
@ -30,6 +28,6 @@ public class RemoveTaskLogRequestCommandTest {
RemoveTaskLogResponseCommand removeTaskLogResponseCommand = new RemoveTaskLogResponseCommand();
removeTaskLogResponseCommand.setStatus(true);
Command command = removeTaskLogResponseCommand.convert2Command(122);
Assert.assertNotNull(command);
Assertions.assertNotNull(command);
}
}

8
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RemoveTaskLogResponseCommandTest.java

@ -18,10 +18,8 @@
package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.remote.command.Command;
import org.junit.Test;
import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class RemoveTaskLogResponseCommandTest {
@ -30,6 +28,6 @@ public class RemoveTaskLogResponseCommandTest {
RemoveTaskLogRequestCommand removeTaskLogRequestCommand = new RemoveTaskLogRequestCommand();
removeTaskLogRequestCommand.setPath("/opt/zhangsan");
Command command = removeTaskLogRequestCommand.convert2Command();
Assert.assertNotNull(command);
Assertions.assertNotNull(command);
}
}

8
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/command/log/RollViewLogRequestCommandTest.java

@ -18,10 +18,8 @@
package org.apache.dolphinscheduler.remote.command.log;
import org.apache.dolphinscheduler.remote.command.Command;
import org.junit.Test;
import junit.framework.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class RollViewLogRequestCommandTest {
@ -32,6 +30,6 @@ public class RollViewLogRequestCommandTest {
rollViewLogRequestCommand.setSkipLineNum(1);
rollViewLogRequestCommand.setLimit(1);
Command command = rollViewLogRequestCommand.convert2Command();
Assert.assertNotNull(command);
Assertions.assertNotNull(command);
}
}

10
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/remote/utils/HostTest.java

@ -17,8 +17,8 @@
package org.apache.dolphinscheduler.remote.utils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* host test
@ -28,10 +28,10 @@ public class HostTest {
@Test
public void testHost() {
Host host = Host.of("192.158.2.2:22");
Assert.assertEquals(22, host.getPort());
Assertions.assertEquals(22, host.getPort());
host.setAddress("127.0.0.1:8888");
Assert.assertEquals("127.0.0.1", host.getIp());
Assert.assertEquals(8888, host.getPort());
Assertions.assertEquals("127.0.0.1", host.getIp());
Assertions.assertEquals(8888, host.getPort());
}
}

10
dolphinscheduler-remote/src/test/java/org/apache/dolphinscheduler/rpc/RpcTest.java

@ -24,10 +24,8 @@ import org.apache.dolphinscheduler.rpc.client.RpcClient;
import org.apache.dolphinscheduler.rpc.remote.NettyClient;
import org.apache.dolphinscheduler.rpc.remote.NettyServer;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
public class RpcTest {
private NettyServer nettyServer;
@ -36,7 +34,7 @@ public class RpcTest {
private Host host;
@Before
@BeforeEach
public void before() throws Exception {
nettyServer = new NettyServer(new NettyServerConfig());
IRpcClient rpcClient = new RpcClient();
@ -44,7 +42,7 @@ public class RpcTest {
userService = rpcClient.create(IUserService.class, host);
}
@After
@AfterEach
public void after() {
NettyClient.getInstance().close();
nettyServer.close();

13
dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/config/BeanConfigTest.java

@ -18,15 +18,14 @@
package org.apache.dolphinscheduler.server.worker.config;
import org.apache.dolphinscheduler.service.alert.AlertClientService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@RunWith(SpringJUnit4ClassRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {BeanConfig.class, WorkerConfig.class})
public class BeanConfigTest {
@ -35,6 +34,6 @@ public class BeanConfigTest {
@Test
public void alertClientService() {
Assert.assertNotNull(alertClientService);
Assertions.assertNotNull(alertClientService);
}
}

14
dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskDispatchProcessorTest.java

@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.server.worker.processor;
import io.netty.channel.Channel;
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
@ -27,22 +28,17 @@ import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
import org.apache.dolphinscheduler.service.alert.AlertClientService;
import org.apache.dolphinscheduler.service.storage.StorageOperate;
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import io.netty.channel.Channel;
import org.mockito.junit.jupiter.MockitoExtension;
/**
* test task execute processor
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TaskDispatchProcessorTest {
@InjectMocks

4
dolphinscheduler-worker/src/test/java/org/apache/dolphinscheduler/server/worker/runner/DefaultWorkerDelayTaskExecuteRunnableTest.java

@ -25,12 +25,10 @@ import org.apache.dolphinscheduler.server.worker.rpc.WorkerMessageSender;
import org.apache.dolphinscheduler.service.alert.AlertClientService;
import org.apache.dolphinscheduler.service.storage.StorageOperate;
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.mockito.Mockito;
import java.util.Date;
public class DefaultWorkerDelayTaskExecuteRunnableTest {
private TaskExecutionContext taskExecutionContext = Mockito.mock(TaskExecutionContext.class);

Loading…
Cancel
Save