use of com.ctrip.xpipe.redis.console.migration.status.migration.MigrationMigratingState 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.migration.MigrationMigratingState in project x-pipe by ctripcorp.
the class MigrationStatTest method testCheckingToMigrating.
@Test
public void testCheckingToMigrating() {
when(mockedMigrationShard.getCurrentShard()).thenReturn((new ShardTbl()).setShardName("test-shard"));
Assert.assertEquals(MigrationStatus.Initiated, migrationCluster.getStatus());
migrationCluster.updateStat(new MigrationMigratingState(migrationCluster));
Assert.assertEquals(MigrationStatus.Migrating, migrationCluster.getStatus());
migrationCluster.process();
sleep(100);
verify(mockedMigrationShard, times(1)).doMigrate();
}
Aggregations