use of com.ctrip.xpipe.redis.console.migration.status.ClusterStatus in project x-pipe by ctripcorp.
the class ClusterServiceImplTest method testUpdateStatusById.
@Test
public void testUpdateStatusById() {
ClusterTbl clusterTbl = clusterService.find(clusterName);
ClusterStatus oldStatus = ClusterStatus.valueOf(clusterTbl.getStatus());
ClusterStatus newStatus = ClusterStatus.different(oldStatus);
clusterService.updateStatusById(clusterTbl.getId(), newStatus);
ClusterTbl newCluster = clusterService.find(clusterName);
Assert.assertEquals(newStatus.toString(), newCluster.getStatus().toString());
newCluster.setStatus(oldStatus.toString());
Assert.assertEquals(clusterTbl.toString(), newCluster.toString());
}
use of com.ctrip.xpipe.redis.console.migration.status.ClusterStatus 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));
}
}
use of com.ctrip.xpipe.redis.console.migration.status.ClusterStatus in project x-pipe by ctripcorp.
the class DefaultMigrationClusterTest2 method testUpdateStat2.
@Test(expected = ServerException.class)
public void testUpdateStat2() throws Exception {
AtomicInteger counter = new AtomicInteger(1);
when(clusterService.find(anyString())).thenReturn(clusterTbl);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
int currentCounter = counter.getAndIncrement();
if (currentCounter % 9 == 0) {
clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
}
return null;
}
}).when(clusterService).updateStatusById(anyLong(), any());
migrationCluster.updateStat(new MigrationMigratingState(migrationCluster));
}
use of com.ctrip.xpipe.redis.console.migration.status.ClusterStatus in project x-pipe by ctripcorp.
the class DefaultMigrationClusterTest2 method testUpdateStorageClusterStatus.
@Test
public void testUpdateStorageClusterStatus() throws Exception {
AtomicInteger counter = new AtomicInteger(1);
when(clusterService.find(anyString())).thenReturn(clusterTbl);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
int currentCounter = counter.getAndIncrement();
if (currentCounter % 3 == 0) {
clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
}
return null;
}
}).when(clusterService).updateStatusById(anyLong(), any());
migrationClusterTbl.setStatus("Checking");
migrationCluster.updateStorageClusterStatus();
Assert.assertEquals(MigrationStatus.Checking.getClusterStatus().toString(), clusterTbl.getStatus());
}
use of com.ctrip.xpipe.redis.console.migration.status.ClusterStatus in project x-pipe by ctripcorp.
the class DefaultMigrationClusterTest2 method testUpdateStat3.
@Test(expected = ServerException.class)
public void testUpdateStat3() throws Exception {
AtomicInteger counter = new AtomicInteger(1);
when(clusterService.find(anyString())).thenReturn(clusterTbl);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
int currentCounter = counter.getAndIncrement();
if (currentCounter % 7 == 0) {
clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
}
return null;
}
}).when(clusterService).updateStatusById(anyLong(), any());
migrationCluster.updateStat(new MigrationPublishState(migrationCluster));
}
Aggregations