Search in sources :

Example 1 with ClusterCreateInfo

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());
}
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 2 with ClusterCreateInfo

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());
}
Also used : 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 3 with ClusterCreateInfo

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());
}
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 4 with ClusterCreateInfo

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));
}
Also used : ClusterCreateInfo(com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 5 with ClusterCreateInfo

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

Aggregations

ClusterCreateInfo (com.ctrip.xpipe.redis.console.controller.api.data.meta.ClusterCreateInfo)6 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)5 Test (org.junit.Test)5 RetMessage (com.ctrip.xpipe.redis.console.controller.api.RetMessage)4 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)3