This is an automated email from the ASF dual-hosted git repository.
sanpwc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new b329a4f27c5 IGNITE-25611 Fix ItConnectionErrorTest.testStopFollower
(#6734)
b329a4f27c5 is described below
commit b329a4f27c5035e34b16e53bad0e47980639ec90
Author: Alexander Lapin <[email protected]>
AuthorDate: Thu Oct 9 18:58:07 2025 +0300
IGNITE-25611 Fix ItConnectionErrorTest.testStopFollower (#6734)
---
.../ignite/raft/server/ItConnectionErrorTest.java | 25 +++++++++++++++++++---
.../ignite/raft/server/JraftAbstractTest.java | 6 +++++-
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/ItConnectionErrorTest.java
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/ItConnectionErrorTest.java
index c86da4c7aa4..c4d75e29003 100644
---
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/ItConnectionErrorTest.java
+++
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/ItConnectionErrorTest.java
@@ -80,13 +80,32 @@ public class ItConnectionErrorTest extends
JraftAbstractTest {
stopLogInspectors(logInspectors);
}
+ // Otherwise, the leader elected after the start of two nodes may log an
exception about the impossibility of reaching the third
+ // starting node, which is expected in essence, but is not taken into
account in the test verification invariants.
+ // The flow is following:
+ // 1. NodeA (5003) starts.
+ // 2. NodeB (5004) starts.
+ // 3. Leader is elected, let's say that NodeA is a leader.
+ // 4. Because NodeC(5005) startup hangs a bit, leader ping message to
NodeC may fail and in a rare unfortunate event will be accumulated
+ // by log inspector.
+ // 5. NodeC starts.
+ // 6. NodeB stops.
+ // 7. Leader failed to send message to B which is expected.
+ // As a result there are two connectivity related records in log from step
4 and step 7. However within test we expect only one from
+ // step 7.
+ // In case of two nodes in the group, situation explained in step 4
becomes impossible, thus we use 2 nodes only.
+ @Override
+ protected int nodesCount() {
+ return 2;
+ }
+
/**
* Starts a cluster for the test.
*
* @throws Exception If failed.
*/
private void startCluster() throws Exception {
- for (int i = 0; i < NODES; i++) {
+ for (int i = 0; i < nodesCount(); i++) {
int finalI = i;
startServer(i, raftServer -> {
@@ -123,7 +142,7 @@ public class ItConnectionErrorTest extends
JraftAbstractTest {
int nodeToStop = whetherStopLeader
? leaderIndex
- : range(0, NODES).filter(i -> i !=
leaderIndex).findFirst().orElseThrow();
+ : range(0, nodesCount()).filter(i -> i !=
leaderIndex).findFirst().orElseThrow();
stopServer(nodeToStop);
@@ -136,7 +155,7 @@ public class ItConnectionErrorTest extends
JraftAbstractTest {
.findAny()
.isEmpty();
- assertTrue(correct, cls.getName() + " has been written to the log
more than 1 time.");
+ assertTrue(correct, cls.getName() + " has been written to the log
more than 1 time.");
});
}
diff --git
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/JraftAbstractTest.java
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/JraftAbstractTest.java
index fd92816458b..b8d9b501589 100644
---
a/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/JraftAbstractTest.java
+++
b/modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/JraftAbstractTest.java
@@ -121,7 +121,7 @@ public abstract class JraftAbstractTest extends
RaftServerAbstractTest {
void before() {
executor = new ScheduledThreadPoolExecutor(20,
IgniteThreadFactory.create("common", Loza.CLIENT_POOL_NAME, logger()));
- initialMembersConf = IntStream.range(0, NODES)
+ initialMembersConf = IntStream.range(0, nodesCount())
.mapToObj(i -> testNodeName(testInfo, PORT + i))
.collect(collectingAndThen(toSet(),
PeersAndLearners::fromConsistentIds));
}
@@ -291,4 +291,8 @@ public abstract class JraftAbstractTest extends
RaftServerAbstractTest {
return client;
}
+
+ protected int nodesCount() {
+ return NODES;
+ }
}