use of com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster in project x-pipe by ctripcorp.
the class MultiShardMigrationTest method testCRedisCheckFailed.
@Test
@DirtiesContext
public void testCRedisCheckFailed() throws TimeoutException {
int failPos = randomInt(1, TEST_SHARD_CNT);
for (int cnt = 1; cnt != TEST_SHARD_CNT + 1; ++cnt) {
mockSuccessCheckCommand(migrationCommandBuilder, clusterName, getShardName(cnt), dcB, dcB);
mockSuccessPrevPrimaryDcCommand(migrationCommandBuilder, clusterName, getShardName(cnt), dcA);
mockSuccessNewPrimaryDcCommand(migrationCommandBuilder, clusterName, getShardName(cnt), dcB);
mockSuccessOtherDcCommand(migrationCommandBuilder, clusterName, getShardName(cnt), dcB, dcA);
}
((DefaultMigrationCluster) migrationCluster).setOuterClientService(new AbstractOuterClientService() {
@Override
public ClusterInfo getClusterInfo(String clusterName) throws Exception {
return null;
}
});
ClusterTbl originalCluster = clusterService.find(clusterId);
Assert.assertEquals(ClusterStatus.Lock.toString(), originalCluster.getStatus());
migrationCluster.process();
sleep(1000);
Assert.assertEquals(MigrationStatus.CheckingFail, migrationCluster.getStatus());
ClusterTbl currentCluster = clusterService.find(clusterId);
Assert.assertEquals(ClusterStatus.Lock.toString(), currentCluster.getStatus());
((DefaultMigrationCluster) migrationCluster).setOuterClientService(new AbstractOuterClientService() {
@Override
public ClusterInfo getClusterInfo(String clusterName) throws Exception {
ClusterInfo clusterInfo = new ClusterInfo();
clusterInfo.setGroups(Lists.newArrayList(new GroupInfo()));
return clusterInfo;
}
});
// again
migrationCluster.process();
waitConditionUntilTimeOut(() -> clusterService.find(clusterId).getStatus() == ClusterStatus.Normal.toString(), 2500);
currentCluster = clusterService.find(clusterId);
Assert.assertEquals(ClusterStatus.Normal.toString(), currentCluster.getStatus());
}
Aggregations