Search in sources :

Example 1 with MASTER_STATE

use of com.ctrip.xpipe.redis.core.protocal.MASTER_STATE in project x-pipe by ctripcorp.

the class RoleCommandTest method testSlave.

@Test
public void testSlave() throws Exception {
    for (MASTER_STATE masterState : MASTER_STATE.values()) {
        Server slave = startServer("*5\r\n" + "$5\r\nslave\r\n" + "$9\r\nlocalhost\r\n" + ":6379\r\n" + "$" + masterState.getDesc().length() + "\r\n" + masterState.getDesc() + "\r\n" + ":477\r\n");
        RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(slave.getPort())), 2000, false, scheduled);
        SlaveRole role = (SlaveRole) roleCommand.execute().get();
        Assert.assertEquals(SERVER_ROLE.SLAVE, role.getServerRole());
        Assert.assertEquals("localhost", role.getMasterHost());
        Assert.assertEquals(6379, role.getMasterPort());
        Assert.assertEquals(masterState, role.getMasterState());
        Assert.assertEquals(477, role.getMasterOffset());
    }
}
Also used : SlaveRole(com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole) Server(com.ctrip.xpipe.simpleserver.Server) RoleCommand(com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand) MASTER_STATE(com.ctrip.xpipe.redis.core.protocal.MASTER_STATE) Test(org.junit.Test)

Aggregations

MASTER_STATE (com.ctrip.xpipe.redis.core.protocal.MASTER_STATE)1 RoleCommand (com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand)1 SlaveRole (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole)1 Server (com.ctrip.xpipe.simpleserver.Server)1 Test (org.junit.Test)1