Search in sources :

Example 1 with ClusterStepResult

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();
}
Also used : ClusterStepResult(com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult) Test(org.junit.Test)

Example 2 with ClusterStepResult

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();
}
Also used : ClusterStepResult(com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult) Test(org.junit.Test) AbstractMigrationStateTest(com.ctrip.xpipe.redis.console.migration.status.migration.AbstractMigrationStateTest)

Example 3 with ClusterStepResult

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());
        }
    }
}
Also used : MigrationCluster(com.ctrip.xpipe.redis.console.migration.model.MigrationCluster) ClusterStepResult(com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult)

Example 4 with ClusterStepResult

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();
}
Also used : ClusterStepResult(com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult) Test(org.junit.Test)

Aggregations

ClusterStepResult (com.ctrip.xpipe.redis.console.migration.model.ClusterStepResult)4 Test (org.junit.Test)3 MigrationCluster (com.ctrip.xpipe.redis.console.migration.model.MigrationCluster)1 AbstractMigrationStateTest (com.ctrip.xpipe.redis.console.migration.status.migration.AbstractMigrationStateTest)1