Search in sources :

Example 6 with ErrorResponse

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());
}
Also used : Node(org.apache.ignite.raft.jraft.Node) ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 7 with ErrorResponse

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());
}
Also used : ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 8 with ErrorResponse

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());
}
Also used : ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 9 with ErrorResponse

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());
}
Also used : Node(org.apache.ignite.raft.jraft.Node) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 10 with ErrorResponse

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());
}
Also used : ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ErrorResponse (org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse)24 Test (org.junit.jupiter.api.Test)20 Status (org.apache.ignite.raft.jraft.Status)5 Node (org.apache.ignite.raft.jraft.Node)4 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)4 Message (org.apache.ignite.raft.jraft.rpc.Message)4 PingRequest (org.apache.ignite.raft.jraft.rpc.RpcRequests.PingRequest)3 NodeId (org.apache.ignite.raft.jraft.entity.NodeId)2 InvokeTimeoutException (org.apache.ignite.raft.jraft.error.InvokeTimeoutException)2 JRaftException (org.apache.ignite.raft.jraft.error.JRaftException)2 RemotingException (org.apache.ignite.raft.jraft.error.RemotingException)2 RpcClient (org.apache.ignite.raft.jraft.rpc.RpcClient)2 ConnectException (java.net.ConnectException)1 ArrayList (java.util.ArrayList)1 Executor (java.util.concurrent.Executor)1 RaftMessagesFactory (org.apache.ignite.raft.jraft.RaftMessagesFactory)1 GetLeaderRequest (org.apache.ignite.raft.jraft.rpc.CliRequests.GetLeaderRequest)1 GetLeaderResponse (org.apache.ignite.raft.jraft.rpc.CliRequests.GetLeaderResponse)1 GetPeersRequest (org.apache.ignite.raft.jraft.rpc.CliRequests.GetPeersRequest)1 GetPeersResponse (org.apache.ignite.raft.jraft.rpc.CliRequests.GetPeersResponse)1