Search in sources :

Example 1 with RedisCreateInfo

use of com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo in project x-pipe by ctripcorp.

the class MetaUpdateTest3 method createShard3.

@Test
public void createShard3() throws Exception {
    ShardCreateInfo shardCreateInfo1 = new ShardCreateInfo();
    shardCreateInfo1.setShardMonitorName(shardName);
    shardCreateInfo1.setShardName(shardName + 1);
    ShardCreateInfo shardCreateInfo2 = new ShardCreateInfo();
    shardCreateInfo2.setShardMonitorName(clusterName + "-" + shardName);
    shardCreateInfo2.setShardName(shardName + 2);
    metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo1, shardCreateInfo2));
    List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
    RetMessage result = metaUpdate.createShard(clusterName, shardName, createInfo);
    Assert.assertEquals(RetMessage.FAIL_STATE, result.getState());
    Assert.assertEquals(String.format("Both %s and %s is assigned as sentinel monitor name", shardName, clusterName + "-" + shardName), result.getMessage());
}
Also used : ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 2 with RedisCreateInfo

use of com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo in project x-pipe by ctripcorp.

the class MetaUpdateTest3 method createShard1.

@Test
public void createShard1() throws Exception {
    ShardCreateInfo shardCreateInfo = new ShardCreateInfo();
    shardCreateInfo.setShardMonitorName(shardName);
    shardCreateInfo.setShardName(shardName);
    metaUpdate.createShards(clusterName, Lists.newArrayList(new ShardCreateInfo()));
    List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
    metaUpdate.createShard(clusterName, shardName, createInfo);
    ShardTbl shardTbl = shardService.find(clusterName, shardName);
    List<RedisTbl> keepers = redisService.findKeepersByDcClusterShard(activeDC, clusterName, shardName);
    List<RedisTbl> redisTbls = redisService.findRedisesByDcClusterShard(activeDC, clusterName, shardName);
    logger.info("{}", shardTbl);
    logger.info("{}", keepers);
    logger.info("{}", redisTbls);
    Assert.assertTrue(listEquals(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), redisTbls.stream().map((redisTbl) -> {
        return redisTbl.getRedisIp() + ":" + redisTbl.getRedisPort();
    }).collect(Collectors.toList())));
    Assert.assertEquals(2, keepers.size());
}
Also used : ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RedisTbl(com.ctrip.xpipe.redis.console.model.RedisTbl) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) java.util.concurrent(java.util.concurrent) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) Collectors(java.util.stream.Collectors) ShardTbl(com.ctrip.xpipe.redis.console.model.ShardTbl) com.ctrip.xpipe.redis.console.service(com.ctrip.xpipe.redis.console.service) List(java.util.List) Lists(com.google.common.collect.Lists) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) StringUtil(com.ctrip.xpipe.utils.StringUtil) Assert(org.junit.Assert) Before(org.junit.Before) ShardTbl(com.ctrip.xpipe.redis.console.model.ShardTbl) RedisTbl(com.ctrip.xpipe.redis.console.model.RedisTbl) ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 3 with RedisCreateInfo

use of com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo in project x-pipe by ctripcorp.

the class MetaUpdateTest3 method createShard4.

@Test
public void createShard4() throws Exception {
    ShardCreateInfo shardCreateInfo1 = new ShardCreateInfo();
    shardCreateInfo1.setShardMonitorName(shardName);
    shardCreateInfo1.setShardName(shardName);
    metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo1));
    List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
    RetMessage result = metaUpdate.createShard(clusterName, shardName, createInfo);
    Assert.assertEquals(RetMessage.SUCCESS_STATE, result.getState());
}
Also used : ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 4 with RedisCreateInfo

use of com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo in project x-pipe by ctripcorp.

the class MetaUpdateTest3 method createShard2.

@Test
public void createShard2() throws Exception {
    ShardCreateInfo shardCreateInfo = new ShardCreateInfo();
    shardCreateInfo.setShardMonitorName(shardName);
    shardCreateInfo.setShardName(shardName);
    metaUpdate.createShards(clusterName, Lists.newArrayList(shardCreateInfo));
    List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
    RetMessage result = metaUpdate.createShard(clusterName, shardName, clusterName + "-" + shardName, createInfo);
    Assert.assertEquals(RetMessage.FAIL_STATE, result.getState());
    Assert.assertEquals(String.format("Post shard monitor name %s diff from previous %s", clusterName + "-" + shardName, shardName), result.getMessage());
}
Also used : ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 5 with RedisCreateInfo

use of com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo in project x-pipe by ctripcorp.

the class MetaUpdateTest3 method createShard.

@Test
public void createShard() throws Exception {
    List<RedisCreateInfo> createInfo = createInfo(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), Lists.newArrayList("192.168.0.2:6379", "192.168.0.2:6380"));
    metaUpdate.createShard(clusterName, shardName, createInfo);
    ShardTbl shardTbl = shardService.find(clusterName, shardName);
    List<RedisTbl> keepers = redisService.findKeepersByDcClusterShard(activeDC, clusterName, shardName);
    List<RedisTbl> redisTbls = redisService.findRedisesByDcClusterShard(activeDC, clusterName, shardName);
    logger.info("{}", shardTbl);
    logger.info("{}", keepers);
    logger.info("{}", redisTbls);
    Assert.assertTrue(listEquals(Lists.newArrayList("192.168.0.1:6379", "192.168.0.1:6380"), redisTbls.stream().map((redisTbl) -> {
        return redisTbl.getRedisIp() + ":" + redisTbl.getRedisPort();
    }).collect(Collectors.toList())));
    Assert.assertEquals(2, keepers.size());
}
Also used : ShardCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo) RedisTbl(com.ctrip.xpipe.redis.console.model.RedisTbl) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) java.util.concurrent(java.util.concurrent) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) Collectors(java.util.stream.Collectors) ShardTbl(com.ctrip.xpipe.redis.console.model.ShardTbl) com.ctrip.xpipe.redis.console.service(com.ctrip.xpipe.redis.console.service) List(java.util.List) Lists(com.google.common.collect.Lists) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) StringUtil(com.ctrip.xpipe.utils.StringUtil) Assert(org.junit.Assert) Before(org.junit.Before) ShardTbl(com.ctrip.xpipe.redis.console.model.ShardTbl) RedisTbl(com.ctrip.xpipe.redis.console.model.RedisTbl) RedisCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Aggregations

AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)5 RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)5 RedisCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo)5 ShardCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo)5 Test (org.junit.Test)5 ClusterCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo)2 RedisTbl (com.ctrip.xpipe.redis.console.model.RedisTbl)2 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)2 com.ctrip.xpipe.redis.console.service (com.ctrip.xpipe.redis.console.service)2 StringUtil (com.ctrip.xpipe.utils.StringUtil)2 Lists (com.google.common.collect.Lists)2 List (java.util.List)2 java.util.concurrent (java.util.concurrent)2 Collectors (java.util.stream.Collectors)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2