Search in sources :

Example 1 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.

the class MigrationClusterDaoTest method testFindUnfinishedByClusterId.

@Test
public void testFindUnfinishedByClusterId() throws SQLException, IOException {
    int count = 0;
    for (MigrationStatus migrationStatus : MigrationStatus.values()) {
        if (!migrationStatus.isTerminated()) {
            count++;
        }
        MigrationClusterTbl tbl = createMigrationClusterTbl(migrationStatus);
        tbl.setClusterId(clusterId);
        migrationClusterDao.insert(tbl);
    }
    List<MigrationClusterTbl> unfinished = migrationClusterDao.findUnfinishedByClusterId(clusterId);
    logger.debug("{}", unfinished);
    Assert.assertEquals(count, unfinished.size());
    long previousId = Long.MIN_VALUE;
    for (MigrationClusterTbl tbl : unfinished) {
        long currentId = tbl.getId();
        Assert.assertTrue(currentId > previousId);
        previousId = currentId;
    }
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationStatus(com.ctrip.xpipe.redis.console.migration.status.MigrationStatus) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 2 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.

the class MigrationClusterDaoTest method testUpdateStatusAndEndTimeById.

@Test
public void testUpdateStatusAndEndTimeById() {
    long id = randomInsert();
    MigrationClusterTbl before = migrationClusterDao.getById(id);
    sleep(5);
    Date endTime = new Date();
    migrationClusterDao.updateStatusAndEndTimeById(id, MigrationStatus.Checking, endTime);
    MigrationClusterTbl current = migrationClusterDao.getById(id);
    Assert.assertNotEquals(before.getEndTime(), current.getEndTime());
    Assert.assertEquals(MigrationStatus.Checking.toString(), current.getStatus());
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) Date(java.util.Date) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 3 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.

the class MigrationClusterDaoTest method testUpdateStartTime.

@Test
public void testUpdateStartTime() {
    long id = randomInsert();
    MigrationClusterTbl before = migrationClusterDao.getById(id);
    logger.debug("[before]{}", before);
    sleep(5);
    Date startTime = new Date();
    logger.debug("{}", startTime);
    migrationClusterDao.updateStartTime(id, startTime);
    MigrationClusterTbl current = migrationClusterDao.getById(id);
    logger.debug("{}", current);
    Assert.assertNotEquals(before.getStartTime(), current.getStartTime());
    Assert.assertEquals(before.getStatus(), current.getStatus());
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) Date(java.util.Date) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 4 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.

the class MigrationClusterDaoTest method randomInsert.

private long randomInsert() {
    MigrationStatus migrationStatus = MigrationStatus.Publish;
    MigrationClusterTbl tbl = createMigrationClusterTbl(migrationStatus);
    tbl.setClusterId(clusterId);
    migrationClusterDao.insert(tbl);
    return tbl.getId();
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationStatus(com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)

Example 5 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl in project x-pipe by ctripcorp.

the class MigrationClusterDaoTest method testUpdatePublishInfoById.

@Test
public void testUpdatePublishInfoById() {
    long id = randomInsert();
    String random = randomString();
    migrationClusterDao.updatePublishInfoById(id, random);
    MigrationClusterTbl byId = migrationClusterDao.getById(id);
    Assert.assertEquals(random, byId.getPublishInfo());
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Aggregations

MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)17 Test (org.junit.Test)9 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)6 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)5 DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)5 DirtiesContext (org.springframework.test.annotation.DirtiesContext)3 DalException (org.unidal.dal.jdbc.DalException)3 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)2 AbstractMigrationTest (com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest)2 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)2 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)2 MigrationStatus (com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 MigrationEventTbl (com.ctrip.xpipe.redis.console.model.MigrationEventTbl)1 MigrationShardTbl (com.ctrip.xpipe.redis.console.model.MigrationShardTbl)1 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 LinkedList (java.util.LinkedList)1