Search in sources :

Example 6 with RetMessage

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

the class MetaUpdateTest method testUpdateCLusterWithNoNeedUpdate.

@Test
public void testUpdateCLusterWithNoNeedUpdate() throws Exception {
    String CLUSTER_NAME = "cluster-name";
    String EXPECTED_MESSAGE = String.format("No field changes for cluster: %s", CLUSTER_NAME);
    long ORG_ID = 5L;
    ClusterTbl clusterTbl = new ClusterTbl().setClusterName(CLUSTER_NAME).setClusterDescription("").setActivedcId(1).setIsXpipeInterested(true).setStatus("normal").setClusterLastModifiedTime(DateTimeUtils.currentTimeAsString());
    clusterDao.createCluster(clusterTbl);
    ClusterCreateInfo clusterInfo = new ClusterCreateInfo();
    clusterInfo.setClusterName(CLUSTER_NAME);
    clusterInfo.setClusterAdminEmails("test@ctrip.com");
    clusterInfo.setOrganizationId(ORG_ID);
    RetMessage retMessage = clusterController.updateCluster(clusterInfo);
    logger.info("{}", retMessage.getMessage());
    RetMessage retMessage1 = clusterController.updateCluster(clusterInfo);
    Assert.assertEquals(RetMessage.SUCCESS_STATE, retMessage1.getState());
    Assert.assertEquals(EXPECTED_MESSAGE, retMessage1.getMessage());
    ClusterTbl cluster = clusterDao.findClusterAndOrgByName(CLUSTER_NAME);
    Assert.assertEquals(ORG_ID, cluster.getOrganizationInfo().getOrgId());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 7 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage 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 8 with RetMessage

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

the class MetaUpdateTest method updateCluster.

@Test
public void updateCluster() throws Exception {
    String CLUSTER_NAME = "cluster-name";
    int SUCCESS_STATE = RetMessage.SUCCESS_STATE;
    long ORG_ID = 5L;
    ClusterTbl clusterTbl = new ClusterTbl().setClusterName(CLUSTER_NAME).setClusterDescription("").setActivedcId(1).setIsXpipeInterested(true).setStatus("normal").setClusterLastModifiedTime(DateTimeUtils.currentTimeAsString());
    clusterDao.createCluster(clusterTbl);
    ClusterCreateInfo clusterInfo = new ClusterCreateInfo();
    clusterInfo.setClusterName(CLUSTER_NAME);
    clusterInfo.setClusterAdminEmails("test@ctrip.com");
    clusterInfo.setOrganizationId(ORG_ID);
    RetMessage retMessage = clusterController.updateCluster(clusterInfo);
    logger.info("{}", retMessage.getMessage());
    Assert.assertEquals(SUCCESS_STATE, retMessage.getState());
    ClusterTbl cluster = clusterDao.findClusterAndOrgByName(CLUSTER_NAME);
    Assert.assertEquals(ORG_ID, cluster.getOrganizationInfo().getOrgId());
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) RetMessage(com.ctrip.xpipe.redis.console.controller.api.RetMessage) ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 9 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage 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 10 with RetMessage

use of com.ctrip.xpipe.redis.console.controller.api.RetMessage 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)

Aggregations

RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)13 Test (org.junit.Test)13 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)10 ClusterCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo)4 ShardCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ShardCreateInfo)4 RedisCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.RedisCreateInfo)3 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)3 ConfigModel (com.ctrip.xpipe.redis.console.model.ConfigModel)2 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 Matchers.anyString (org.mockito.Matchers.anyString)1