Search in sources :

Example 1 with CurrentClusterServer

use of com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer in project x-pipe by ctripcorp.

the class DefaultClusterServersTest method testStartServerWithSameConfig.

@SuppressWarnings("unused")
@Test
public void testStartServerWithSameConfig() throws Exception {
    Assert.assertEquals(1, servers.allClusterServers().size());
    logger.info(remarkableMessage("[testServers][start server2]"));
    UnitTestServerConfig config2 = new UnitTestServerConfig(2, randomPort());
    CurrentClusterServer current2 = createAndStart(config2);
    sleep(500);
    Assert.assertEquals(2, servers.allClusterServers().size());
    try {
        logger.info(remarkableMessage("[testServers][start server2 again]"));
        CurrentClusterServer current2Copy = createAndStart(config2);
        Assert.fail();
    } catch (IllegalStateException e) {
    }
    sleep(500);
    Assert.assertEquals(2, servers.allClusterServers().size());
}
Also used : UnitTestServerConfig(com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig) CurrentClusterServer(com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer) AbstractMetaServerContextTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerContextTest) Test(org.junit.Test)

Example 2 with CurrentClusterServer

use of com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer in project x-pipe by ctripcorp.

the class DefaultClusterServersTest method testStartServerWithDifferentConfig.

@Test
public void testStartServerWithDifferentConfig() throws Exception {
    Assert.assertEquals(1, servers.allClusterServers().size());
    UnitTestServerConfig config20 = new UnitTestServerConfig(2, randomPort());
    logger.info(remarkableMessage("[testServers][start server2]{}"), config20);
    @SuppressWarnings("unused") CurrentClusterServer current20 = createAndStart(config20);
    sleep(500);
    Assert.assertEquals(2, servers.allClusterServers().size());
    UnitTestServerConfig config21 = new UnitTestServerConfig(2, config20.getMetaServerPort() + 1);
    try {
        logger.info(remarkableMessage("[testServers][start server2 with another port again]{}"), config21);
        @SuppressWarnings("unused") CurrentClusterServer current21 = createAndStart(config21);
        Assert.fail();
    } catch (IllegalStateException e) {
    // pass
    }
}
Also used : UnitTestServerConfig(com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig) CurrentClusterServer(com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer) AbstractMetaServerContextTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerContextTest) Test(org.junit.Test)

Example 3 with CurrentClusterServer

use of com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer in project x-pipe by ctripcorp.

the class DefaultClusterServersTest method testRestart.

@Test
public void testRestart() throws Exception {
    CurrentClusterServer currentClusterServer = getCurrentClusterServer();
    Assert.assertEquals(1, servers.allClusterServers().size());
    logger.info("[testRestart][stop]");
    currentClusterServer.stop();
    sleep(300);
    Assert.assertEquals(0, servers.allClusterServers().size());
    logger.info("[testRestart][start again]");
    currentClusterServer.start();
    sleep(300);
    Assert.assertEquals(1, servers.allClusterServers().size());
}
Also used : CurrentClusterServer(com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer) AbstractMetaServerContextTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerContextTest) Test(org.junit.Test)

Aggregations

AbstractMetaServerContextTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerContextTest)3 CurrentClusterServer (com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer)3 Test (org.junit.Test)3 UnitTestServerConfig (com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig)2