use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.
the class SingleShardMigrationTest method testMigrateOtherDcExceptionFail.
@Test
@DirtiesContext
public void testMigrateOtherDcExceptionFail() {
mockSuccessCheckCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcB);
mockSuccessPrevPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcA);
mockSuccessNewPrimaryDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB);
mockFailOtherDcCommand(migrationCommandBuilder, "cluster1", "shard1", dcB, dcA, new Throwable("mocked other fail"));
ClusterTbl originalCluster = clusterService.find(1);
Assert.assertEquals(ClusterStatus.Lock.toString(), originalCluster.getStatus());
Assert.assertEquals(1, originalCluster.getActivedcId());
Assert.assertEquals(1, migrationCluster.getMigrationCluster().getSourceDcId());
Assert.assertEquals(2, migrationCluster.getMigrationCluster().getDestinationDcId());
Assert.assertEquals("Initiated", migrationCluster.getStatus().toString());
Assert.assertEquals(ShardMigrationResultStatus.FAIL, migrationShard.getShardMigrationResult().getStatus());
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.CHECK));
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_PREVIOUS_PRIMARY_DC));
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC));
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_OTHER_DC));
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE));
migrationCluster.process();
sleep(1000);
ClusterTbl currentCluster = clusterService.find(1);
Assert.assertEquals(ClusterStatus.Normal.toString(), currentCluster.getStatus());
Assert.assertEquals(2, currentCluster.getActivedcId());
Assert.assertEquals(ShardMigrationResultStatus.SUCCESS, migrationShard.getShardMigrationResult().getStatus());
Assert.assertTrue(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.CHECK));
Assert.assertTrue(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_PREVIOUS_PRIMARY_DC));
Assert.assertTrue(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC));
Assert.assertFalse(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE_OTHER_DC));
Assert.assertTrue(migrationShard.getShardMigrationResult().stepSuccess(ShardMigrationStep.MIGRATE));
ClusterMeta prevPrimaryDcMeta = clusterMetaService.getClusterMeta(dcA, "cluster1");
Assert.assertEquals(dcB, prevPrimaryDcMeta.getActiveDc());
ClusterMeta newPrimaryDcMeta = clusterMetaService.getClusterMeta(dcB, "cluster1");
Assert.assertEquals(dcB, newPrimaryDcMeta.getActiveDc());
}
use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.
the class ClusterDaoTest method testCreateCluster.
@Test
public void testCreateCluster() throws DalException {
ClusterTbl newCluster = clusterDao.createCluster(clusterTbl);
Assert.assertEquals(clusterTbl.getId(), newCluster.getId());
}
use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.
the class ClusterDaoTest method testFindClusterAndOrgByName.
@Test
public void testFindClusterAndOrgByName() throws DalException {
String clusterName = "cluster2";
ClusterTbl clusterTbl1 = clusterDao.findClusterAndOrgByName(clusterName);
List<OrganizationTbl> orgs = organizationService.getAllOrganizations();
orgs.forEach(org -> logger.info("{}", org));
logger.info("{}", clusterTbl1);
Assert.assertEquals(2L, (long) clusterTbl1.getOrganizationInfo().getId());
Assert.assertEquals("org-1", clusterTbl1.getClusterOrgName());
}
use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.
the class KeepercontainerServiceImplTest method testFindKeeperCountByClusterWithAllKeeperDeleted.
@Test
@DirtiesContext
public void testFindKeeperCountByClusterWithAllKeeperDeleted() {
String clusterName = "cluster4";
ClusterTbl clusterTbl = clusterDao.findClusterAndOrgByName(clusterName);
List<KeepercontainerTbl> keeperCount = keepercontainerService.findBestKeeperContainersByDcCluster(dcNames[0], clusterName);
keeperCount.forEach(kc -> logger.info("{}", kc));
Assert.assertTrue(keeperCount.stream().allMatch(kc -> kc.getKeepercontainerOrgId() == clusterTbl.getClusterOrgId()));
}
use of com.ctrip.xpipe.redis.console.model.ClusterTbl in project x-pipe by ctripcorp.
the class ClusterMetaServiceImplTest method testGetClusterMetaCurrentPrimaryDcNotMigrating.
@Test
public void testGetClusterMetaCurrentPrimaryDcNotMigrating() {
long currentActiveDcId = randomInt();
long clusterId = randomInt();
long destinationDcId = currentActiveDcId + 1;
DcTbl dcTbl = new DcTbl();
ClusterTbl clusterTbl = new ClusterTbl();
clusterTbl.setId(clusterId);
clusterTbl.setActivedcId(currentActiveDcId);
when(migrationService.findLatestUnfinishedMigrationCluster(clusterId)).thenReturn(new MigrationClusterTbl().setDestinationDcId(destinationDcId));
dcTbl.setId(destinationDcId);
for (ClusterStatus clusterStatus : ClusterStatus.values()) {
if (clusterStatus == ClusterStatus.Migrating) {
continue;
}
clusterTbl.setStatus(clusterStatus.toString());
Assert.assertEquals(currentActiveDcId, clusterMetaServiceImpl.getClusterMetaCurrentPrimaryDc(dcTbl, clusterTbl));
}
}
Aggregations