use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class IteratorImplTest method testRunTheRestClosureWithError.
@Test
public void testRunTheRestClosureWithError() throws Exception {
testSetErrorAndRollback();
for (final Closure closure : this.closures) {
final MockClosure mc = (MockClosure) closure;
assertNull(mc.s);
}
this.iter.runTheRestClosureWithError();
Thread.sleep(500);
int i = 0;
for (final Closure closure : this.closures) {
i++;
final MockClosure mc = (MockClosure) closure;
if (i < 7) {
assertNull(mc.s);
} else {
final Status s = mc.s;
assertEquals(RaftError.ESTATEMACHINE.getNumber(), s.getCode());
assertEquals("StateMachine meet critical error when applying one or more tasks since index=6, Status[UNKNOWN<-1>: test]", s.getErrorMsg());
}
}
}
use of org.apache.ignite.raft.jraft.Closure 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.Closure in project ignite-3 by apache.
the class RemovePeerRequestProcessorTest method verify.
@Override
public void verify(String interest, Node node, ArgumentCaptor<Closure> doneArg) {
assertEquals(RemovePeerRequest.class.getName(), interest);
Mockito.verify(node).removePeer(eq(new PeerId("localhost", 8082)), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[localhost:8081, localhost:8082, localhost:8083]", this.asyncContext.as(RemovePeerResponse.class).oldPeersList().toString());
assertEquals("[localhost:8081, localhost:8083]", this.asyncContext.as(RemovePeerResponse.class).newPeersList().toString());
}
Aggregations