mirror of https://github.com/apache/kafka.git
KAFKA-18981: Deflake testMinIsrUpdateWithElr by heartbeating survivor broker
This commit is contained in:
parent
f5a87b3703
commit
e9b246100f
|
@ -649,6 +649,27 @@ public class QuorumControllerTest {
|
|||
|
||||
// Unfence all brokers and create a topic foo (min ISR 2)
|
||||
sendBrokerHeartbeatToUnfenceBrokers(active, allBrokers, brokerEpochs);
|
||||
|
||||
// Heartbeat pumper
|
||||
final java.util.concurrent.ScheduledExecutorService hbExec =
|
||||
java.util.concurrent.Executors.newSingleThreadScheduledExecutor();
|
||||
final java.util.concurrent.atomic.AtomicBoolean keepOnly =
|
||||
new java.util.concurrent.atomic.AtomicBoolean(false);
|
||||
final long periodMs = Math.max(50L, sessionTimeoutMillis / 3);
|
||||
|
||||
hbExec.scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
if (keepOnly.get()) {
|
||||
sendBrokerHeartbeatToUnfenceBrokers(active, brokersToKeepUnfenced, brokerEpochs);
|
||||
} else {
|
||||
sendBrokerHeartbeatToUnfenceBrokers(active, allBrokers, brokerEpochs);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}, 0L, periodMs, java.util.concurrent.TimeUnit.MILLISECONDS);
|
||||
|
||||
try {
|
||||
CreateTopicsRequestData createTopicsRequestData = new CreateTopicsRequestData().setTopics(
|
||||
new CreatableTopicCollection(List.of(
|
||||
new CreatableTopic().setName("foo").setNumPartitions(1).
|
||||
|
@ -670,6 +691,9 @@ public class QuorumControllerTest {
|
|||
.setValue("2");
|
||||
RecordTestUtils.replayAll(active.configurationControl(), List.of(new ApiMessageAndVersion(configRecord, (short) 0)));
|
||||
|
||||
// Before fencing wait, switch pumper to only keep brokersToKeepUnfenced alive
|
||||
keepOnly.set(true);
|
||||
|
||||
// Fence brokers
|
||||
TestUtils.waitForCondition(() -> {
|
||||
sendBrokerHeartbeatToUnfenceBrokers(active, brokersToKeepUnfenced, brokerEpochs);
|
||||
|
@ -731,6 +755,9 @@ public class QuorumControllerTest {
|
|||
partition = active.replicationControl().getPartition(topicIdBar, 0);
|
||||
assertEquals(0, partition.elr.length, partition.toString());
|
||||
assertArrayEquals(new int[]{1}, partition.isr, partition.toString());
|
||||
} finally {
|
||||
hbExec.shutdownNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue