alievmirza commented on code in PR #4978:
URL: https://github.com/apache/ignite-3/pull/4978#discussion_r1899555246


##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java:
##########
@@ -3433,10 +3436,83 @@ public void testNewPeersConfigurationAppliedListener() 
throws Exception {
                 return false;
             }, 10_000));
 
-            verify(raftGrpEvtsLsnr, 
times(1)).onNewPeersConfigurationApplied(List.of(newPeer), List.of(newLearner));
+            verify(raftGrpEvtsLsnr, 
times(1)).onNewPeersConfigurationApplied(eq(List.of(newPeer)), 
eq(List.of(newLearner)), anyLong(), anyLong());
         }
     }
 
+    @Test
+    public void 
testIndexAndTermArePropagatedToOnNewPeersConfigurationApplied() throws 
Exception {
+        TestPeer peer0 = new TestPeer(testInfo, TestUtils.INIT_PORT);
+        var raftGrpEvtsLsnr = mock(JraftGroupEventsListener.class);
+
+        AtomicLong term = new AtomicLong(-1);
+        AtomicLong index = new AtomicLong(-1);
+
+        cluster = new TestCluster(
+                
"testIndexAndTermArePropagatedToOnNewPeersConfigurationApplied",
+                dataPath,
+                Collections.singletonList(peer0),
+                new LinkedHashSet<>(),
+                ELECTION_TIMEOUT_MILLIS,
+                (peerId, opts) -> {
+                    opts.setRaftGrpEvtsLsnr(raftGrpEvtsLsnr);
+                    opts.setFsm(new MockStateMachine(peerId) {
+                        @Override
+                        public void 
onRawConfigurationCommitted(ConfigurationEntry conf) {
+                            term.set(conf.getId().getTerm());
+                            index.set(conf.getId().getIndex());
+                            super.onRawConfigurationCommitted(conf);
+                        }
+                    });
+                },
+                testInfo
+        );
+
+        assertTrue(cluster.start(peer0));
+
+        cluster.ensureLeader(cluster.waitAndGetLeader());
+
+        Node leader = cluster.waitAndGetLeader();
+
+        assertNotEquals(-1, term.get());
+        assertNotEquals(-1, index.get());
+
+        term.set(-1);

Review Comment:
   refactored



##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java:
##########
@@ -3433,10 +3436,83 @@ public void testNewPeersConfigurationAppliedListener() 
throws Exception {
                 return false;
             }, 10_000));
 
-            verify(raftGrpEvtsLsnr, 
times(1)).onNewPeersConfigurationApplied(List.of(newPeer), List.of(newLearner));
+            verify(raftGrpEvtsLsnr, 
times(1)).onNewPeersConfigurationApplied(eq(List.of(newPeer)), 
eq(List.of(newLearner)), anyLong(), anyLong());
         }
     }
 
+    @Test
+    public void 
testIndexAndTermArePropagatedToOnNewPeersConfigurationApplied() throws 
Exception {
+        TestPeer peer0 = new TestPeer(testInfo, TestUtils.INIT_PORT);
+        var raftGrpEvtsLsnr = mock(JraftGroupEventsListener.class);
+
+        AtomicLong term = new AtomicLong(-1);
+        AtomicLong index = new AtomicLong(-1);
+
+        cluster = new TestCluster(
+                
"testIndexAndTermArePropagatedToOnNewPeersConfigurationApplied",
+                dataPath,
+                Collections.singletonList(peer0),
+                new LinkedHashSet<>(),
+                ELECTION_TIMEOUT_MILLIS,
+                (peerId, opts) -> {
+                    opts.setRaftGrpEvtsLsnr(raftGrpEvtsLsnr);
+                    opts.setFsm(new MockStateMachine(peerId) {
+                        @Override
+                        public void 
onRawConfigurationCommitted(ConfigurationEntry conf) {
+                            term.set(conf.getId().getTerm());
+                            index.set(conf.getId().getIndex());
+                            super.onRawConfigurationCommitted(conf);
+                        }
+                    });
+                },
+                testInfo
+        );
+
+        assertTrue(cluster.start(peer0));
+
+        cluster.ensureLeader(cluster.waitAndGetLeader());
+
+        Node leader = cluster.waitAndGetLeader();
+
+        assertNotEquals(-1, term.get());
+        assertNotEquals(-1, index.get());
+
+        term.set(-1);
+        index.set(-1);
+
+        sendTestTaskAndWait(leader);
+
+        TestPeer newPeer = new TestPeer(testInfo, TestUtils.INIT_PORT + 1);
+        assertTrue(cluster.start(newPeer, false, 300));
+
+        verify(raftGrpEvtsLsnr, never()).onNewPeersConfigurationApplied(any(), 
any(), anyLong(), anyLong());
+
+        // Wait until new node node sees every other node, otherwise
+        // changePeersAndLearnersAsync can fail.
+        waitForTopologyOnEveryNode(1, cluster);
+
+        leader = cluster.getLeader();

Review Comment:
   removed



-- 
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]

Reply via email to