From 6393b089b7887eba6528b3f6685b8ed48f4414aa Mon Sep 17 00:00:00 2001 From: Zhang Yifei Date: Wed, 23 Oct 2024 12:58:55 +0800 Subject: [PATCH] test --- .../election/NetworkPartitionChannelTest.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/junit-functional/org/jgroups/tests/election/NetworkPartitionChannelTest.java b/tests/junit-functional/org/jgroups/tests/election/NetworkPartitionChannelTest.java index 0b0b1fc..4d0c7fa 100644 --- a/tests/junit-functional/org/jgroups/tests/election/NetworkPartitionChannelTest.java +++ b/tests/junit-functional/org/jgroups/tests/election/NetworkPartitionChannelTest.java @@ -1,6 +1,7 @@ package org.jgroups.tests.election; import org.jgroups.*; +import org.jgroups.conf.ClassConfigurator; import org.jgroups.protocols.SHARED_LOOPBACK; import org.jgroups.protocols.pbcast.GMS; import org.jgroups.protocols.raft.ELECTION2; @@ -76,14 +77,18 @@ public void electionAfterMerge(Class ignore) throws Exception { System.out.println("partition1: " + view(leader)); System.out.println("partition2: " + view(coord)); + raft(leader).set("cmd".getBytes(), 0, 3); + for (int i : indexes) { + System.out.println(address(i) + " lastAppended: " + raft(i).lastAppended()); + } + // block the new coordinator to advance the term in voting thread newTerm = new Semaphore(0); merge(leader, coord); - - int finalLeader = leader; - assertThat(eventually(() -> coordIndex(finalLeader) == coord && coordIndex(coord) == coord, 10, TimeUnit.SECONDS)) - .isTrue(); + Util.waitUntilAllChannelsHaveSameView(30_000, 1000, channels()); + assertEquals(coordIndex(leader), coord); + assertEquals(coordIndex(coord), coord); System.out.println("after merge: " + view(coord)); // since the term is not advanced yet, new coordinator has accepted the existing leader, and stopping the @@ -112,6 +117,10 @@ public void electionAfterMerge(Class ignore) throws Exception { @Override protected RAFT newRaftInstance() { return new RAFT() { + { + id = ClassConfigurator.getProtocolId(RAFT.class); + } + @Override public long createNewTerm() { Semaphore s = newTerm;