use of com.alipay.sofa.jraft.entity.PeerId in project sofa-jraft by sofastack.
the class TransferLeadershipRequestProcessorTest method verify.
@Override
public void verify(String interest, Node node, ArgumentCaptor<Closure> doneArg) {
assertEquals(TransferLeaderRequest.class.getName(), interest);
Mockito.verify(node).transferLeadershipTo(new PeerId("localhost", 8082));
assertNotNull(asyncContext.getResponseObject());
}
use of com.alipay.sofa.jraft.entity.PeerId in project sofa-jraft by sofastack.
the class LocalRaftMetaStorageTest method testSaveFail.
@Test
public void testSaveFail() throws IOException {
FileUtils.deleteDirectory(new File(this.path));
assertFalse(this.raftMetaStorage.setVotedFor(new PeerId("localhost", 8081)));
Mockito.verify(this.node, Mockito.times(1)).onError((RaftException) Mockito.any());
}
use of com.alipay.sofa.jraft.entity.PeerId in project sofa-jraft by sofastack.
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));
NodeManager.getInstance().addAddress(peerId.getEndpoint());
NodeManager.getInstance().add(this.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 com.alipay.sofa.jraft.entity.PeerId in project sofa-jraft by sofastack.
the class AddPeerRequestProcessorTest method verify.
@Override
public void verify(String interest, Node node, ArgumentCaptor<Closure> doneArg) {
assertEquals(interest, AddPeerRequest.class.getName());
Mockito.verify(node).addPeer(eq(new PeerId("test", 8181)), 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(AddPeerResponse.class).getOldPeersList().toString());
assertEquals("[localhost:8081, localhost:8082, localhost:8083, test:8181]", this.asyncContext.as(AddPeerResponse.class).getNewPeersList().toString());
}
use of com.alipay.sofa.jraft.entity.PeerId in project sofa-jraft by sofastack.
the class RemoveLearnersRequestProcessorTest method verify.
@Override
public void verify(final String interest, final Node node, final ArgumentCaptor<Closure> doneArg) {
assertEquals(interest, RemoveLearnersRequest.class.getName());
Mockito.verify(node).removeLearners(eq(Arrays.asList(new PeerId("learner", 8082), new PeerId("test", 8183))), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[learner:8081, learner:8082, learner:8083]", this.asyncContext.as(LearnersOpResponse.class).getOldLearnersList().toString());
assertEquals("[learner:8081, learner:8083]", this.asyncContext.as(LearnersOpResponse.class).getNewLearnersList().toString());
}
Aggregations