Search in sources :

Example 16 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class DcMetaComparatorTest method testDeleted.

@Test
public void testDeleted() {
    ClusterMeta cluster = differentCluster(current);
    current.addCluster(cluster);
    DcMetaComparator dcMetaComparator = new DcMetaComparator(current, future);
    dcMetaComparator.compare();
    Assert.assertEquals(1, dcMetaComparator.getRemoved().size());
    Assert.assertEquals(cluster, dcMetaComparator.getRemoved().toArray()[0]);
    Assert.assertEquals(0, dcMetaComparator.getAdded().size());
    Assert.assertEquals(0, dcMetaComparator.getMofified().size());
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) Test(org.junit.Test)

Example 17 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class DcMetaComparatorTest method testModifyRedisConfig.

@Test
public void testModifyRedisConfig() {
    ClusterMeta clusterMeta = (ClusterMeta) future.getClusters().values().toArray()[0];
    ShardMeta shardMeta = (ShardMeta) clusterMeta.getShards().values().toArray()[0];
    RedisMeta redisMeta = shardMeta.getRedises().get(0);
    redisMeta.setPort(redisMeta.getPort() + 10000);
    DcMetaComparator dcMetaComparator = new DcMetaComparator(current, future);
    dcMetaComparator.compare();
    Assert.assertEquals(0, dcMetaComparator.getRemoved().size());
    Assert.assertEquals(0, dcMetaComparator.getAdded().size());
    Assert.assertEquals(1, dcMetaComparator.getMofified().size());
    ClusterMetaComparator comparator = (ClusterMetaComparator) dcMetaComparator.getMofified().toArray()[0];
    Assert.assertEquals(clusterMeta.getId(), comparator.getCurrent().getId());
    Assert.assertEquals(0, comparator.getAdded().size());
    Assert.assertEquals(0, comparator.getRemoved().size());
    Assert.assertEquals(1, comparator.getMofified().size());
    ShardMetaComparator shardMetaComparator = (ShardMetaComparator) comparator.getMofified().toArray()[0];
    Assert.assertEquals(1, shardMetaComparator.getAdded().size());
    Assert.assertEquals(1, shardMetaComparator.getRemoved().size());
    Assert.assertEquals(0, shardMetaComparator.getMofified().size());
    logger.debug("{}", dcMetaComparator);
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Test(org.junit.Test)

Example 18 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class DefaultDcMetaCacheTest method testChangeDcMetaLog.

@Test
public void testChangeDcMetaLog() {
    // just check exception
    EventMonitor.DEFAULT.logEvent("type", getTestName());
    XpipeMeta xpipeMeta = getXpipeMeta();
    DcMeta dcMeta = (DcMeta) xpipeMeta.getDcs().values().toArray()[0];
    DcMeta future = MetaClone.clone(dcMeta);
    ClusterMeta futureCluster = (ClusterMeta) future.getClusters().values().toArray()[0];
    futureCluster.addShard(new ShardMeta().setId(randomString(5)));
    future.addCluster(new ClusterMeta().setId(randomString(10)));
    dcMetaCache.changeDcMeta(dcMeta, future);
    dcMetaCache.clusterAdded(new ClusterMeta().setId("add_" + randomString(5)));
    dcMetaCache.clusterDeleted("del_" + randomString(5));
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 19 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class MetaInfoChange method testChangeClusterShard.

@Test
public void testChangeClusterShard() throws IOException {
    // change keeper
    try {
        ClusterMeta clusterMeta = getCluster(dc, clusterId);
        ShardMeta shardMeta = clusterMeta.getShards().get(shardId);
        shardMeta.setId(randomString(10));
        changeClusterKeeper(clusterMeta);
        clusterMeta.removeShard(shardId);
        clusterMeta.addShard(shardMeta);
        metaServerConsoleService.clusterModified(clusterMeta.getId(), clusterMeta);
    } catch (Exception e) {
        logger.error("[testChangeClusterKeeper]", e);
    }
    waitForAnyKeyToExit();
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) IOException(java.io.IOException) AbstractMetaServerClusterTest(com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest) Test(org.junit.Test)

Example 20 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class MetaInfoChange method testAddCluster.

@Test
public void testAddCluster() throws IOException {
    ClusterMeta clusterMeta = differentCluster(dc);
    metaServerConsoleService.clusterAdded(clusterId, clusterMeta);
    waitForAnyKeyToExit();
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) AbstractMetaServerClusterTest(com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest) Test(org.junit.Test)

Aggregations

ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)41 Test (org.junit.Test)25 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)13 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)10 DirtiesContext (org.springframework.test.annotation.DirtiesContext)10 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)8 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)5 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)4 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)4 ClusterMetaComparator (com.ctrip.xpipe.redis.core.meta.comparator.ClusterMetaComparator)3 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)3 AbstractMetaServerClusterTest (com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest)3 IOException (java.io.IOException)2 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)2 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 NodeAdded (com.ctrip.xpipe.observer.NodeAdded)1 NodeDeleted (com.ctrip.xpipe.observer.NodeDeleted)1 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)1 DataNotFoundException (com.ctrip.xpipe.redis.console.exception.DataNotFoundException)1 ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)1