sashapolo commented on code in PR #1397:
URL: https://github.com/apache/ignite-3/pull/1397#discussion_r1043200960
##########
modules/raft/src/integrationTest/java/org/apache/ignite/internal/raft/ItLearnersTest.java:
##########
@@ -273,20 +292,120 @@ public void testLostLearners() throws Exception {
assertThat(services.get(0).thenCompose(RaftGroupService::refreshLeader),
willCompleteSuccessfully());
}
+ /**
+ * Tests a situation when a peer and a learner are started on the same
node.
+ */
+ @Test
+ void testLearnersOnTheSameNodeAsPeers() throws InterruptedException {
+ RaftNode node = nodes.get(0);
+
+ PeersAndLearners configuration = createConfiguration(List.of(node),
List.of(node));
+
+ var peerListener = new TestRaftGroupListener();
+ var learnerListener = new TestRaftGroupListener();
+
+ Peer peer = configuration.peer(node.consistentId());
+ Peer learner = configuration.learner(node.consistentId());
+
+ CompletableFuture<RaftGroupService> peerService = startRaftGroup(node,
peer, configuration, peerListener);
+ CompletableFuture<RaftGroupService> learnerService =
startRaftGroup(node, learner, configuration, learnerListener);
+
+ assertThat(peerService.thenApply(RaftGroupService::leader),
willBe(peer));
+ assertThat(peerService.thenApply(RaftGroupService::leader),
willBe(not(learner)));
+ assertThat(learnerService.thenApply(RaftGroupService::leader),
willBe(peer));
+ assertThat(learnerService.thenApply(RaftGroupService::leader),
willBe(not(learner)));
+
+ // Test writing data.
+ CompletableFuture<?> writeFuture = peerService
+ .thenCompose(s -> s.run(createWriteCommand("foo")).thenApply(v
-> s))
+ .thenCompose(s -> s.run(createWriteCommand("bar")));
+
+ assertThat(writeFuture, willCompleteSuccessfully());
+
+ for (TestRaftGroupListener listener : Arrays.asList(peerListener,
learnerListener)) {
+ assertThat(listener.storage.poll(1, TimeUnit.SECONDS), is("foo"));
+ assertThat(listener.storage.poll(1, TimeUnit.SECONDS), is("bar"));
+ }
+ }
+
+ /**
+ * Tests adding a new learner to a node that already runs a Raft node.
+ */
+ @Test
+ void testAddLearnerToSameNodeAsPeer() throws InterruptedException {
Review Comment:
> 'add learner to same node as peer' might be understood as 'we have a
learner on node A, and we add a peer to the same node A'
I don't understand how it can be understood like this. It clearly states
that we add a learner a node that hosts a peer.
I've updated the javadoc and the test name
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]