DefaultKeeperManager extends AbstractCurrentMetaObserver implements KeeperManager, TopElement { @VisibleForTesting protected void setScheduled(ScheduledExecutorService scheduled) { this.scheduled = scheduled; }  @Override Set<ClusterType> getSupportClusterTypes();  }
@Test public void timeoutNotDoCorrectTest() throws Exception { String clusterId = "clsuter", shardId = "shard"; final CountDownLatch latch = new CountDownLatch(2); Server timeoutKeeper = startServer(new AbstractIoActionFactory() { @Override protected byte[] getToWrite(Object readResult) { try { sleep(10); } catch (Exception e) { } latch.countDown(); return ("+state:ACTIVE\nmaster_host:localhost\nmaster_port:"+randomInt()+"\r\n").getBytes(); } }); Server normalKeeper = startServer(new AbstractIoActionFactory() { @Override protected byte[] getToWrite(Object readResult) { latch.countDown(); return ("+state: BACKUP\nmaster_host:localhost\nmaster_port:"+timeoutKeeper.getPort()+"\r\n").getBytes(); } }); manager.setScheduled(scheduled); KeeperMeta timeoutKeeperMeta = new KeeperMeta().setIp("localhost").setPort(timeoutKeeper.getPort()).setActive(false); KeeperMeta normalKeeperMeta = new KeeperMeta().setIp("localhost").setPort(normalKeeper.getPort()).setActive(false); when(currentMetaManager.getSurviveKeepers(clusterId, shardId)) .thenReturn(Arrays.asList(timeoutKeeperMeta, normalKeeperMeta)); InfoCommand.DEFAULT_REDIS_COMMAND_TIME_OUT_MILLI = 1; DefaultKeeperManager.KeeperStateAlignChecker checker = spy(manager.new KeeperStateAlignChecker()); doNothing().when(checker).doCorrect(anyString(), anyString(), anyList()); checker.doCheckShard(clusterId, new ShardMeta().setId(shardId)); latch.await(1000, TimeUnit.MILLISECONDS); sleep(100); verify(checker, never()).doCorrect(anyString(), anyString(), anyList()); timeoutKeeper.stop(); normalKeeper.stop(); }