use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class ConsoleNotifycationTaskTest method testDispose.
@Test(expected = RejectedExecutionException.class)
public void testDispose() throws Exception {
consoleNotifycationTask.dispose();
consoleNotifycationTask.keeperActiveElected("cluster1", "shard1", new KeeperMeta());
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class ConsoleNotifycationTaskTest method testSuccess.
@Test
public void testSuccess() throws Exception {
int times = 100;
for (int i = 0; i < times; i++) {
consoleNotifycationTask.keeperActiveElected("cluster1", "shard1", new KeeperMeta());
sleep(10);
verify(consoleService, times(i + 1)).keeperActiveChanged(anyString(), anyString(), anyString(), any(KeeperMeta.class));
}
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class DefaultKeeperStateControllerTest method testAdd.
@Test
public void testAdd() {
Assert.assertFalse(addCommand.isBeginExecute());
defaultKeeperStateController.addKeeper(new KeeperTransMeta(getClusterId(), getShardId(), new KeeperMeta()));
sleep(10);
Assert.assertTrue(addCommand.isBeginExecute());
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class DefaultKeeperStateControllerTest method testDelete.
@Test
public void testDelete() throws TimeoutException {
Assert.assertFalse(deleteCommand.isBeginExecute());
defaultKeeperStateController.removeKeeper(new KeeperTransMeta(getClusterId(), getShardId(), new KeeperMeta()));
waitConditionUntilTimeOut(() -> deleteCommand.isBeginExecute(), 1000);
}
use of com.ctrip.xpipe.redis.core.entity.KeeperMeta in project x-pipe by ctripcorp.
the class CurrentMetaTest method testSetInfo.
@Test
public void testSetInfo() {
// set survice keepers
Assert.assertEquals(0, currentMeta.getSurviveKeepers(clusterId, shardId).size());
Assert.assertEquals(null, currentMeta.getKeeperActive(clusterId, shardId));
List<KeeperMeta> allKeepers = getDcKeepers(getDc(), clusterId, shardId);
KeeperMeta active = allKeepers.get(0);
currentMeta.setSurviveKeepers(clusterId, shardId, allKeepers, active);
Assert.assertEquals(allKeepers.size(), currentMeta.getSurviveKeepers(clusterId, shardId).size());
active.setActive(true);
Assert.assertEquals(active, currentMeta.getKeeperActive(clusterId, shardId));
// set keeper active
KeeperMeta keeperMeta = getDcKeepers(getDc(), clusterId, shardId).get(1);
boolean result = currentMeta.setKeeperActive(clusterId, shardId, keeperMeta);
Assert.assertTrue(result);
keeperMeta.setActive(true);
Assert.assertEquals(keeperMeta, currentMeta.getKeeperActive(clusterId, shardId));
Assert.assertFalse(currentMeta.setKeeperActive(clusterId, shardId, keeperMeta));
// set keeper active not exist
keeperMeta.setIp(randomString(10));
try {
currentMeta.setKeeperActive(clusterId, shardId, keeperMeta);
Assert.fail();
} catch (Exception e) {
}
Assert.assertEquals(new Pair<String, Integer>("127.0.0.1", 6379), currentMeta.getKeeperMaster(clusterId, shardId));
Pair<String, Integer> keeperMaster = new Pair<String, Integer>("localhost", randomPort());
currentMeta.setKeeperMaster(clusterId, shardId, keeperMaster);
Assert.assertEquals(keeperMaster, currentMeta.getKeeperMaster(clusterId, shardId));
}
Aggregations