use of com.alibaba.nacos.naming.core.Instance in project nacos by alibaba.
the class ClientBeatCheckTaskTest method testHeartBeatTimeout.
@Test
public void testHeartBeatTimeout() {
Instance instance = new Instance();
instance.setLastBeat(System.currentTimeMillis() - 1000);
instance.setMarked(false);
instance.setHealthy(true);
Map<String, String> metadata = new HashMap<>();
metadata.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "10");
instance.setMetadata(metadata);
List<Instance> instances = new ArrayList<>();
instances.add(instance);
Mockito.doReturn("test").when(serviceSpy).getName();
Mockito.doReturn(true).when(distroMapperSpy).responsible(Mockito.anyString());
Mockito.doReturn(true).when(switchDomain).isHealthCheckEnabled();
when(serviceSpy.allIPs(true)).thenReturn(instances);
clientBeatCheckTask.run();
Assert.assertFalse(instance.isHealthy());
}
Aggregations