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