use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest method testUpdateCLusterWithNoOrgIDFound.
@Test
public void testUpdateCLusterWithNoOrgIDFound() throws Exception {
String CLUSTER_NAME = "cluster-name";
long ORG_ID = 99L;
String EXPECTED_MESSAGE = String.format("Organization Id: %d, could not be found", ORG_ID);
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.FAIL_STATE, retMessage1.getState());
Assert.assertEquals(EXPECTED_MESSAGE, retMessage1.getMessage());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest method testUpdateClusterWithNoClusterFound.
@Test
public void testUpdateClusterWithNoClusterFound() throws Exception {
String CLUSTER_NAME = "cluster-not-exist";
String EXPECTED_MESSAGE = String.format("cluster not found: %s", CLUSTER_NAME);
ClusterCreateInfo clusterCreateInfo = new ClusterCreateInfo();
clusterCreateInfo.setClusterName(CLUSTER_NAME);
RetMessage retMessage = clusterController.updateCluster(clusterCreateInfo);
logger.info("{}", retMessage.getMessage());
Assert.assertEquals(RetMessage.FAIL_STATE, retMessage.getState());
Assert.assertEquals(EXPECTED_MESSAGE, retMessage.getMessage());
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo 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.data.meta.ClusterCreateInfo in project x-pipe by ctripcorp.
the class MetaUpdateTest3 method testGetCluster.
@Test
public void testGetCluster() throws Exception {
createCluster();
ClusterCreateInfo clusterCreateInfo = metaUpdate.getCluster(clusterName);
Assert.assertEquals(clusterName, clusterCreateInfo.getClusterName());
Assert.assertEquals(3L, (long) clusterCreateInfo.getOrganizationId());
Assert.assertEquals(2, clusterCreateInfo.getDcs().size());
Assert.assertEquals(activeDC, clusterCreateInfo.getDcs().get(0));
Assert.assertEquals(backupDC, clusterCreateInfo.getDcs().get(1));
}
use of com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo 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());
}
Aggregations