showuon commented on code in PR #17147:
URL: https://github.com/apache/kafka/pull/17147#discussion_r1753049138
##########
metadata/src/test/java/org/apache/kafka/metadata/migration/KRaftMigrationDriverTest.java:
##########
@@ -232,6 +232,32 @@ CompletableFuture<Void>
enqueueMetadataChangeEventWithFuture(
return future;
}
+ @Test
+ public void testOnControllerChangeWhenUninitialized() throws
InterruptedException {
+ CountingMetadataPropagator metadataPropagator = new
CountingMetadataPropagator();
+ CapturingMigrationClient.newBuilder().build();
+ CapturingMigrationClient migrationClient =
CapturingMigrationClient.newBuilder().build();
+ MockFaultHandler faultHandler = new
MockFaultHandler("testBecomeLeaderUninitialized");
+ KRaftMigrationDriver.Builder builder = defaultTestBuilder()
+ .setZkMigrationClient(migrationClient)
+ .setPropagator(metadataPropagator)
+ .setFaultHandler(faultHandler);
+ try (KRaftMigrationDriver driver = builder.build()) {
+ // Fake a complete migration with ZK client
+ migrationClient.setMigrationRecoveryState(
+
ZkMigrationLeadershipState.EMPTY.withKRaftMetadataOffsetAndEpoch(100, 1));
+
+ // enqueue a poll event. once run, this will enqueue a recovery
event
+ driver.start();
Review Comment:
nit: I think we can invoke `driver.start` after `driver.onControllerChange`,
so that we can reliably make sure the test goes with what we expected, that is:
UNINITIALIZED state -> `onControllerChange` ->
`RecoverMigrationStateFromZKEvent`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]