use of com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult in project x-pipe by ctripcorp.
the class MigrationCheckingStateTest method testCheckRollback.
@Test
public void testCheckRollback() {
int shardSize = getShardSize();
when(migrationCluster.stepStatus(ShardMigrationStep.CHECK)).thenReturn(new ClusterStepResult(shardSize, shardSize, shardSize / 2));
checkingState.getStateActionState().tryAction();
checkingState.refresh();
sleep(50);
migrationCluster.getMigrationShards().forEach(migrationShard -> verify(migrationShard).doCheck());
verify(migrationCluster, times(0)).updateStat(isA(MigrationMigratingState.class));
verify(migrationCluster, times(0)).process();
checkingState.getStateActionState().tryRollback();
verify(migrationCluster).updateStat(isA(MigrationAbortedState.class));
verify(migrationCluster).process();
}
use of com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult in project x-pipe by ctripcorp.
the class StateMachineTest method testDone.
@Test
public void testDone() {
int shardSize = getShardSize();
migrationCheckingState.getStateActionState().tryAction();
when(migrationCluster.stepStatus(ShardMigrationStep.CHECK)).thenReturn(new ClusterStepResult(shardSize, shardSize - 1, shardSize - 1));
migrationCheckingState.refresh();
Assert.assertTrue(migrationCheckingState.getStateActionState() instanceof Doing);
mockCheckDone();
migrationCheckingState.refresh();
Assert.assertTrue(migrationCheckingState.getStateActionState() instanceof Done);
migrationCheckingState.refresh();
}
use of com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult in project x-pipe by ctripcorp.
the class MigrationCheckingState method refresh.
@Override
public void refresh() {
MigrationCluster holder = getHolder();
ClusterStepResult clusterStepResult = holder.stepStatus(ShardMigrationStep.CHECK);
if (clusterStepResult.isStepFinish()) {
if (clusterStepResult.isStepSuccess()) {
logger.debug("[refresh][check success]{}", this);
updateAndProcess(nextAfterSuccess());
} else {
logger.debug("[refresh][check fail]{}", this);
updateAndStop(nextAfterFail());
}
}
}
use of com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult in project x-pipe by ctripcorp.
the class MigrationCheckingStateTest method testCheckSuccess.
@Test
public void testCheckSuccess() {
int shardSize = getShardSize();
when(migrationCluster.stepStatus(ShardMigrationStep.CHECK)).thenReturn(new ClusterStepResult(shardSize, shardSize, shardSize));
checkingState.getStateActionState().tryAction();
checkingState.refresh();
sleep(50);
migrationCluster.getMigrationShards().forEach(migrationShard -> verify(migrationShard).doCheck());
verify(migrationCluster).updateStat(isA(MigrationMigratingState.class));
verify(migrationCluster).process();
}
Aggregations