use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.
the class NodeRequestProcessorTest method testOK.
@Test
public void testOK() {
Node node = Mockito.mock(Node.class, withSettings().extraInterfaces(RaftServerService.class));
Mockito.when(node.getGroupId()).thenReturn("test");
PeerId peerId = new PeerId("localhost", 8081);
Mockito.when(node.getNodeId()).thenReturn(new NodeId("test", peerId));
asyncContext.getNodeManager().add(node);
this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
assertNotNull(resp);
assertEquals(0, resp.errorCode());
}
use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.
the class ReplicatorGroupTest method setup.
@BeforeEach
public void setup() {
this.timerManager = new TimerManager(5);
this.replicatorGroup = new ReplicatorGroupImpl();
final ReplicatorGroupOptions rgOpts = new ReplicatorGroupOptions();
rgOpts.setHeartbeatTimeoutMs(heartbeatTimeout(this.options.getElectionTimeoutMs()));
rgOpts.setElectionTimeoutMs(this.options.getElectionTimeoutMs());
rgOpts.setLogManager(this.logManager);
rgOpts.setBallotBox(this.ballotBox);
rgOpts.setNode(this.node);
rgOpts.setRaftRpcClientService(this.rpcService);
rgOpts.setSnapshotStorage(this.snapshotStorage);
rgOpts.setRaftOptions(this.raftOptions);
rgOpts.setTimerManager(this.timerManager);
Mockito.when(this.logManager.getLastLogIndex()).thenReturn(10L);
Mockito.when(this.logManager.getTerm(10)).thenReturn(1L);
Mockito.when(this.node.getNodeMetrics()).thenReturn(new NodeMetrics(false));
Mockito.when(this.node.getNodeId()).thenReturn(new NodeId("test", new PeerId("localhost", 8081)));
mockSendEmptyEntries();
assertTrue(this.replicatorGroup.init(this.node.getNodeId(), rgOpts));
}
use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.
the class AbstractCliRequestProcessorTest method testHandleRequest.
@Test
public void testHandleRequest() {
this.mockNodes(3);
Mockito.when(this.node.getGroupId()).thenReturn(this.groupId);
PeerId peerId = new PeerId();
peerId.parse(this.peerIdStr);
Mockito.when(this.node.getOptions()).thenReturn(new NodeOptions());
Mockito.when(this.node.getNodeId()).thenReturn(new NodeId("test", peerId));
if (asyncContext != null)
asyncContext.getNodeManager().add(node);
BaseCliRequestProcessor<T> processor = newProcessor();
processor.handleRequest(this.asyncContext, createRequest(this.groupId, peerId));
ArgumentCaptor<Closure> doneArg = ArgumentCaptor.forClass(Closure.class);
verify(processor.interest(), this.node, doneArg);
}
use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.
the class BaseCliRequestProcessorTest method mockNode.
private Node mockNode(boolean disableCli) {
Node node = Mockito.mock(Node.class);
Mockito.when(node.getGroupId()).thenReturn("test");
Mockito.when(node.getNodeId()).thenReturn(new NodeId("test", this.peer.copy()));
NodeOptions opts = new NodeOptions();
opts.setDisableCli(disableCli);
Mockito.when(node.getOptions()).thenReturn(opts);
this.asyncContext.getNodeManager().add(node);
return node;
}
Aggregations