alievmirza commented on code in PR #5083: URL: https://github.com/apache/ignite-3/pull/5083#discussion_r1938959476
########## modules/raft/src/integrationTest/java/org/apache/ignite/raft/jraft/core/ItNodeTest.java: ########## @@ -3506,6 +3507,102 @@ public void onRawConfigurationCommitted(ConfigurationEntry conf) { ); } + @Test + public void testIndexAndTermOfCfgArePropagatedToSnapshotMeta() throws Exception { + TestPeer peer0 = new TestPeer(testInfo, TestUtils.INIT_PORT); + + AtomicLong term = new AtomicLong(-1); + AtomicLong index = new AtomicLong(-1); + + AtomicLong metaTerm = new AtomicLong(-1); + AtomicLong metaIndex = new AtomicLong(-1); + + cluster = new TestCluster( + "testIndexAndTermOfCfgArePropagatedToSnapshotMeta", + dataPath, + Collections.singletonList(peer0), + new LinkedHashSet<>(), + ELECTION_TIMEOUT_MILLIS, + (peerId, opts) -> { + opts.setFsm(new MockStateMachine(peerId) { + @Override + public boolean onSnapshotLoad(SnapshotReader reader) { + SnapshotMeta meta = reader.load(); + + metaTerm.set(meta.cfgTerm()); + metaIndex.set(meta.cfgIndex()); + + return super.onSnapshotLoad(reader); + } + + @Override + public void onRawConfigurationCommitted(ConfigurationEntry conf) { + term.set(conf.getId().getTerm()); + index.set(conf.getId().getIndex()); + System.out.println("Index + term = " + index + " " + term); + super.onRawConfigurationCommitted(conf); + } + }); + }, + testInfo + ); + + assertTrue(cluster.start(peer0)); + + Node leader = cluster.waitAndGetLeader(); + + assertEquals(1, term.get()); + assertEquals(1, index.get()); + + TestPeer newPeer = new TestPeer(testInfo, TestUtils.INIT_PORT + 1); + TestPeer otherPeer = new TestPeer(testInfo, TestUtils.INIT_PORT + 2); + + assertTrue(cluster.start(newPeer, false, 300)); + assertTrue(cluster.start(otherPeer, false, 300)); + + // Wait until new node node sees every other node, otherwise + // changePeersAndLearnersAsync can fail. + waitForTopologyOnEveryNode(1, cluster); + + SynchronizedClosure done = new SynchronizedClosure(); + leader.changePeersAndLearnersAsync( + new Configuration(List.of(peer0.getPeerId(), newPeer.getPeerId(), otherPeer.getPeerId()), List.of()), leader.getCurrentTerm(), + done + ); + + assertEquals(done.await(), Status.OK()); + + assertTrue(waitForCondition(() -> cluster.getLeader().listAlivePeers().contains(newPeer.getPeerId()), 10_000)); + + assertTrue(cluster.stop(newPeer.getPeerId())); + + // apply something more + sendTestTaskAndWait(leader); + triggerLeaderSnapshot(cluster, leader); + + sendTestTaskAndWait(leader, 10); + + triggerLeaderSnapshot(cluster, leader, 2); + + //restart follower. + cluster.clean(newPeer.getPeerId()); + assertTrue(cluster.start(newPeer, false, 300)); + + cluster.ensureSame(); + + assertEquals(3, cluster.getFsms().size()); + for (MockStateMachine fsm : cluster.getFsms()) + assertEquals(20, fsm.getLogs().size(), fsm.getPeerId().toString()); Review Comment: We check that snapshot successfully installed on restarted node. This is the common way to do that across the ItNodeTest -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org