use of org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method testOK.
@Test
public void testOK() {
Node node = mockNode(false);
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(this.processor.done);
assertSame(this.processor.ctx.node, node);
assertNotNull(resp);
assertEquals(0, resp.errorCode());
}
use of org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method testEmptyNodes.
@Test
public void testEmptyNodes() {
this.processor = new MockCliRequestProcessor(null, "test");
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.ENOENT.getNumber(), resp.errorCode());
assertEquals("Empty nodes in group test", resp.errorMsg());
}
use of org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method testPeerIdNotFound.
@Test
public void testPeerIdNotFound() {
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.ENOENT.getNumber(), resp.errorCode());
assertEquals("Fail to find node localhost:8081 in group test", resp.errorMsg());
}
use of org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method testManyNodes.
@Test
public void testManyNodes() {
Node node1 = Mockito.mock(Node.class);
Mockito.when(node1.getGroupId()).thenReturn("test");
Mockito.when(node1.getNodeId()).thenReturn(new NodeId("test", new PeerId("localhost", 8081)));
this.asyncContext.getNodeManager().add(node1);
Node node2 = Mockito.mock(Node.class);
Mockito.when(node2.getGroupId()).thenReturn("test");
Mockito.when(node2.getNodeId()).thenReturn(new NodeId("test", new PeerId("localhost", 8082)));
this.asyncContext.getNodeManager().add(node2);
this.processor = new MockCliRequestProcessor(null, "test");
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.EINVAL.getNumber(), resp.errorCode());
assertEquals("Peer must be specified since there're 2 nodes in group test", resp.errorMsg());
}
use of org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method testInvalidPeerId.
@Test
public void testInvalidPeerId() {
this.processor = new MockCliRequestProcessor("localhost", "test");
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(RaftError.EINVAL.getNumber(), resp.errorCode());
assertEquals("Fail to parse peer: localhost", resp.errorMsg());
}
Aggregations