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;
}
}
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());
}
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());
}
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();
}
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());
}
Aggregations