|
28 | 28 | import org.junit.jupiter.api.extension.RegisterExtension; |
29 | 29 |
|
30 | 30 | import java.time.Duration; |
31 | | -import java.util.Arrays; |
| 31 | +import java.util.List; |
32 | 32 | import java.util.Objects; |
| 33 | +import java.util.stream.Collectors; |
33 | 34 | import java.util.stream.Stream; |
34 | 35 |
|
35 | 36 | import static com.alibaba.fluss.record.TestData.DATA1; |
@@ -78,32 +79,44 @@ void testDeleteOutOfSyncReplicaLogAfterCommit() throws Exception { |
78 | 79 | i * 10L); |
79 | 80 | } |
80 | 81 |
|
81 | | - // stop a replica to mock follower is out of sync |
82 | | - int stopFollower = Stream.of(0, 1, 2).filter(i -> i != leader).findFirst().get(); |
83 | | - FLUSS_CLUSTER_EXTENSION.stopReplica(stopFollower, tb, 1); |
| 82 | + // stop replicas to mock followers are out of sync |
| 83 | + List<Integer> stopFollowers = |
| 84 | + Stream.of(0, 1, 2).filter(i -> i != leader).collect(Collectors.toList()); |
| 85 | + for (int stopFollower : stopFollowers) { |
| 86 | + FLUSS_CLUSTER_EXTENSION.stopReplica(stopFollower, tb, 1); |
| 87 | + } |
84 | 88 | leaderGateWay |
85 | 89 | .produceLog( |
86 | 90 | newProduceLogRequest(tableId, 0, -1, genMemoryLogRecordsByObject(DATA1))) |
87 | 91 | .get(); |
88 | | - FLUSS_CLUSTER_EXTENSION.waitUtilReplicaShrinkFromIsr(tb, stopFollower); |
89 | | - |
90 | | - LogTablet stopfollowerLogTablet = |
91 | | - FLUSS_CLUSTER_EXTENSION.waitAndGetFollowerReplica(tb, stopFollower).getLogTablet(); |
92 | | - assertThat(stopfollowerLogTablet.logSegments()).hasSize(3); |
| 92 | + for (int stopFollower : stopFollowers) { |
| 93 | + FLUSS_CLUSTER_EXTENSION.waitUtilReplicaShrinkFromIsr(tb, stopFollower); |
| 94 | + LogTablet stopfollowerLogTablet = |
| 95 | + FLUSS_CLUSTER_EXTENSION |
| 96 | + .waitAndGetFollowerReplica(tb, stopFollower) |
| 97 | + .getLogTablet(); |
| 98 | + assertThat(stopfollowerLogTablet.logSegments()).hasSize(3); |
| 99 | + } |
93 | 100 |
|
94 | | - // send notify leader to make remote log tier happen immediately |
95 | | - FLUSS_CLUSTER_EXTENSION.notifyLeaderAndIsr( |
| 101 | + // restart the leader server with a small log tiering interval |
| 102 | + FLUSS_CLUSTER_EXTENSION.restartTabletServer( |
96 | 103 | leader, |
97 | | - DATA1_TABLE_PATH, |
98 | | - tb, |
99 | | - FLUSS_CLUSTER_EXTENSION.getZooKeeperClient().getLeaderAndIsr(tb).get(), |
100 | | - Arrays.asList(0, 1, 2)); |
| 104 | + new Configuration() |
| 105 | + .set( |
| 106 | + ConfigOptions.REMOTE_LOG_TASK_INTERVAL_DURATION, |
| 107 | + Duration.ofMillis(1))); |
101 | 108 | FLUSS_CLUSTER_EXTENSION.waitUtilSomeLogSegmentsCopyToRemote(tb); |
102 | 109 |
|
103 | | - // check has two remote log segments for the stopped replica |
104 | | - retry( |
105 | | - Duration.ofMinutes(1), |
106 | | - () -> assertThat(stopfollowerLogTablet.logSegments()).hasSize(2)); |
| 110 | + // check only has two remote log segments for the stopped replicas |
| 111 | + for (int stopFollower : stopFollowers) { |
| 112 | + LogTablet stopfollowerLogTablet = |
| 113 | + FLUSS_CLUSTER_EXTENSION |
| 114 | + .waitAndGetFollowerReplica(tb, stopFollower) |
| 115 | + .getLogTablet(); |
| 116 | + retry( |
| 117 | + Duration.ofMinutes(1), |
| 118 | + () -> assertThat(stopfollowerLogTablet.logSegments()).hasSize(2)); |
| 119 | + } |
107 | 120 | } |
108 | 121 |
|
109 | 122 | private static Configuration initConfig() { |
|
0 commit comments