Search in sources :

Example 66 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitforMaster.

@Test
public void testWaitforMaster() throws Exception {
    MasterInfo masterInfo = new MasterInfo(RunidGenerator.DEFAULT.generateRunid(), 1L);
    startServer(port, toRedisProtocalString("# Replication\r\n" + "role:master\r\n" + "connected_slaves:1\r\n" + "slave0:ip=127.0.0.1,port=6479,state=online,offset=12936,lag=0\r\n" + "master_replid:ebe8dc36b4a9901af79ac117fa55d45e3dbb92a1\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:12936\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:12936"));
    Assert.assertFalse(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 67 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitAndSucceed.

@Test
public void testWaitAndSucceed() throws Exception {
    String masterReplId = RunidGenerator.DEFAULT.generateRunid();
    Long masterOffset = 10000L;
    MasterInfo masterInfo = new MasterInfo(masterReplId, masterOffset);
    startServer(port, new Callable<String>() {

        private Long offset = masterOffset - 200;

        @Override
        public String call() throws Exception {
            offset += 100;
            return toRedisProtocalString("# Replication\r\n" + "role:slave\r\n" + "master_host:127.0.0.1\r\n" + "master_port:6379\r\n" + "master_link_status:up\r\n" + "master_last_io_seconds_ago:8\r\n" + "master_sync_in_progress:0\r\n" + "slave_repl_offset:" + offset + "\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_replid:" + masterReplId + "\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:" + offset + "\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:13202");
        }
    });
    Assert.assertTrue(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 68 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitforSlaveDifferentReplid.

@Test
public void testWaitforSlaveDifferentReplid() throws Exception {
    MasterInfo masterInfo = new MasterInfo(RunidGenerator.DEFAULT.generateRunid(), 1L);
    startServer(port, toRedisProtocalString("# Replication\r\n" + "role:slave\r\n" + "master_host:127.0.0.1\r\n" + "master_port:6379\r\n" + "master_link_status:up\r\n" + "master_last_io_seconds_ago:8\r\n" + "master_sync_in_progress:0\r\n" + "slave_repl_offset:13202\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_replid:ebe8dc36b4a9901af79ac117fa55d45e3dbb92a1\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:13202\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:13202"));
    Assert.assertFalse(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 69 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultBacklogActiveCollectorTest method analysisInfoReplication2.

@Test
public void analysisInfoReplication2() throws Exception {
    doNothing().when(alertManager).alert(any(), any(), any(), any(), any());
    Assert.assertNotNull(redisConfManager);
    RedisConf redisConf = new RedisConf(new HostPort(), "", "");
    redisConf.setXredisVersion("1.0.0");
    redisConf.setRedisVersion("4.0.1");
    when(redisConfManager.findOrCreateConfig("127.0.0.1", 6379)).thenReturn(redisConf);
    collector.analysisInfoReplication("role:slave\n" + "master_host:10.2.54.233\n" + "master_port:7381\n" + "master_link_status:up\n" + "master_last_io_seconds_ago:0\n" + "master_sync_in_progress:1\n" + "slave_repl_offset:1439009182\n" + "slave_priority:100\n" + "slave_read_only:1\n" + "connected_slaves:0\n" + "master_replid:204b8d599765dd3dead6faa089aeb77d9d8726f5\n" + "master_replid2:0000000000000000000000000000000000000000\n" + "master_repl_offset:1439009182\n" + "second_repl_offset:-1\n" + "repl_backlog_active:0\n" + "repl_backlog_size:104857600\n" + "repl_backlog_first_byte_offset:1340037212\n" + "repl_backlog_histlen:98971971", "cluster", "shard", new HostPort("127.0.0.1", 6379));
    verify(alertManager, never()).alert(any(), any(), any(), any(), any());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) RedisConf(com.ctrip.xpipe.redis.console.health.redisconf.RedisConf) Test(org.junit.Test)

Example 70 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultSentinelMonitorsCheckTest method checkSentinel.

@Test
public void checkSentinel() throws Exception {
    when(metaCache.findClusterShardBySentinelMonitor(any())).thenReturn(null);
    checker.checkSentinel(new SentinelMeta().setAddress("127.0.0.1:5000,127.0.0.1:5001,127.0.0.1:5002"), new HostPort("127.0.0.1", 5000));
    verify(alertManager, atLeastOnce()).alert(eq(null), eq(null), eq(null), eq(ALERT_TYPE.SENTINEL_MONITOR_INCONSIS), anyString());
    verify(sentinelManager, atLeastOnce()).removeSentinelMonitor(any(), any());
}
Also used : SentinelMeta(com.ctrip.xpipe.redis.core.entity.SentinelMeta) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test)

Aggregations

HostPort (com.ctrip.xpipe.endpoint.HostPort)79 Test (org.junit.Test)31 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)7 LinkedList (java.util.LinkedList)7 ALERT_TYPE (com.ctrip.xpipe.redis.console.alert.ALERT_TYPE)6 MasterInfo (com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo)6 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)6 ClusterShardHostPort (com.ctrip.xpipe.endpoint.ClusterShardHostPort)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Map (java.util.Map)5 RedisConf (com.ctrip.xpipe.redis.console.health.redisconf.RedisConf)4 MasterNotFoundException (com.ctrip.xpipe.redis.console.resources.MasterNotFoundException)4 XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)4 Set (java.util.Set)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 AlertEntity (com.ctrip.xpipe.redis.console.alert.AlertEntity)3 AlertManager (com.ctrip.xpipe.redis.console.alert.AlertManager)3 DefaultRedisSessionManager (com.ctrip.xpipe.redis.console.health.DefaultRedisSessionManager)3 ClusterListClusterModel (com.ctrip.xpipe.redis.console.model.consoleportal.ClusterListClusterModel)3