|
|
@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.common.enums.NodeType; |
|
|
|
import org.apache.dolphinscheduler.common.model.Server; |
|
|
|
import org.apache.dolphinscheduler.common.model.Server; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.registry.api.ConnectionState; |
|
|
|
import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl; |
|
|
|
import org.apache.dolphinscheduler.server.master.cache.impl.ProcessInstanceExecCacheManagerImpl; |
|
|
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig; |
|
|
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
|
import org.apache.dolphinscheduler.service.process.ProcessService; |
|
|
@ -49,7 +50,7 @@ import org.springframework.test.util.ReflectionTestUtils; |
|
|
|
* MasterRegistryClientTest |
|
|
|
* MasterRegistryClientTest |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
@PrepareForTest({ RegistryClient.class }) |
|
|
|
@PrepareForTest({RegistryClient.class}) |
|
|
|
@PowerMockIgnore({"javax.management.*"}) |
|
|
|
@PowerMockIgnore({"javax.management.*"}) |
|
|
|
public class MasterRegistryClientTest { |
|
|
|
public class MasterRegistryClientTest { |
|
|
|
|
|
|
|
|
|
|
@ -76,6 +77,9 @@ public class MasterRegistryClientTest { |
|
|
|
given(registryClient.getLock(Mockito.anyString())).willReturn(true); |
|
|
|
given(registryClient.getLock(Mockito.anyString())).willReturn(true); |
|
|
|
given(registryClient.releaseLock(Mockito.anyString())).willReturn(true); |
|
|
|
given(registryClient.releaseLock(Mockito.anyString())).willReturn(true); |
|
|
|
given(registryClient.getHostByEventDataPath(Mockito.anyString())).willReturn("127.0.0.1:8080"); |
|
|
|
given(registryClient.getHostByEventDataPath(Mockito.anyString())).willReturn("127.0.0.1:8080"); |
|
|
|
|
|
|
|
given(registryClient.getStoppable()).willReturn(cause -> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
doNothing().when(registryClient).handleDeadServer(Mockito.anySet(), Mockito.any(NodeType.class), Mockito.anyString()); |
|
|
|
doNothing().when(registryClient).handleDeadServer(Mockito.anySet(), Mockito.any(NodeType.class), Mockito.anyString()); |
|
|
|
ReflectionTestUtils.setField(masterRegistryClient, "registryClient", registryClient); |
|
|
|
ReflectionTestUtils.setField(masterRegistryClient, "registryClient", registryClient); |
|
|
|
|
|
|
|
|
|
|
@ -105,6 +109,13 @@ public class MasterRegistryClientTest { |
|
|
|
masterRegistryClient.registry(); |
|
|
|
masterRegistryClient.registry(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void handleConnectionStateTest() { |
|
|
|
|
|
|
|
masterRegistryClient.handleConnectionState(ConnectionState.CONNECTED); |
|
|
|
|
|
|
|
masterRegistryClient.handleConnectionState(ConnectionState.RECONNECTED); |
|
|
|
|
|
|
|
masterRegistryClient.handleConnectionState(ConnectionState.SUSPENDED); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void removeNodePathTest() { |
|
|
|
public void removeNodePathTest() { |
|
|
|
masterRegistryClient.removeNodePath("/path", NodeType.MASTER, false); |
|
|
|
masterRegistryClient.removeNodePath("/path", NodeType.MASTER, false); |
|
|
|