Search in sources :

Example 1 with UnitTestServerConfig

use of com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig 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 UnitTestServerConfig

use of com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig 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 UnitTestServerConfig

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

the class TestMetaServer method doStart.

@Override
public void doStart() throws Exception {
    System.setProperty(DefaultDcMetaCache.MEMORY_META_SERVER_DAO_KEY, configFile);
    System.setProperty("TOTAL_SLOTS", String.valueOf(total_slots));
    SpringApplication application = new SpringApplication(TestMetaServer.class);
    application.setBannerMode(Mode.OFF);
    application.setEnvironment(createEnvironment());
    context = application.run(new String[] {});
    TestZkClient client = context.getBean(TestZkClient.class);
    DefaultZkConfig zkConfig = new DefaultZkConfig();
    zkConfig.setZkSessionTimeoutMillis(zkSessionTimeoutMillis);
    client.setZkConfig(zkConfig);
    client.setZkAddress(zkConnectionStr);
    UnitTestServerConfig config = context.getBean(UnitTestServerConfig.class);
    config.setZkAddress(zkConnectionStr);
    config.setMetaServerId(serverId);
    config.setMetaServerPort(serverPort);
    ArrangeTaskTrigger arrangeTaskTrigger = context.getBean(ArrangeTaskTrigger.class);
    arrangeTaskTrigger.setWaitForRestartTimeMills(waitForRestartTimeMills);
    manager = context.getBean(SpringComponentRegistry.class);
    manager.initialize();
    manager.start();
}
Also used : ArrangeTaskTrigger(com.ctrip.xpipe.redis.meta.server.cluster.impl.ArrangeTaskTrigger) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) SpringApplication(org.springframework.boot.SpringApplication) UnitTestServerConfig(com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig) DefaultZkConfig(com.ctrip.xpipe.zk.impl.DefaultZkConfig) TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient)

Example 4 with UnitTestServerConfig

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

the class DefaultOffsetwaiterTest method beforeDefaultOffsetwaiterTest.

@Before
public void beforeDefaultOffsetwaiterTest() throws Exception {
    offsetwaiter = new DefaultOffsetwaiter();
    offsetwaiter.setKeyedObjectPool(getXpipeNettyClientKeyedObjectPool());
    offsetwaiter.setMetaServerConfig(new UnitTestServerConfig().setWaitforOffsetMilli(waitforOffsetMilli));
    offsetwaiter.setScheduled(scheduled);
    executionLog = new ExecutionLog(currentTestName());
    host = "127.0.0.1";
    port = randomPort();
}
Also used : ExecutionLog(com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog) DefaultOffsetwaiter(com.ctrip.xpipe.redis.meta.server.dcchange.impl.DefaultOffsetwaiter) UnitTestServerConfig(com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig) Before(org.junit.Before)

Aggregations

UnitTestServerConfig (com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig)4 AbstractMetaServerContextTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerContextTest)2 CurrentClusterServer (com.ctrip.xpipe.redis.meta.server.cluster.CurrentClusterServer)2 Test (org.junit.Test)2 SpringComponentRegistry (com.ctrip.xpipe.lifecycle.SpringComponentRegistry)1 ArrangeTaskTrigger (com.ctrip.xpipe.redis.meta.server.cluster.impl.ArrangeTaskTrigger)1 ExecutionLog (com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog)1 DefaultOffsetwaiter (com.ctrip.xpipe.redis.meta.server.dcchange.impl.DefaultOffsetwaiter)1 DefaultZkConfig (com.ctrip.xpipe.zk.impl.DefaultZkConfig)1 TestZkClient (com.ctrip.xpipe.zk.impl.TestZkClient)1 Before (org.junit.Before)1 SpringApplication (org.springframework.boot.SpringApplication)1