kevin-wu24 commented on code in PR #22191:
URL: https://github.com/apache/kafka/pull/22191#discussion_r3290356469
##########
core/src/test/scala/unit/kafka/server/ControllerRegistrationManagerTest.scala:
##########
@@ -318,4 +336,86 @@ class ControllerRegistrationManagerTest {
manager.close()
}
}
+
+ @Test
+ def testReRegistrationAfterUnregister(): Unit = {
+ val context = new RegistrationTestContext(configProperties)
+ val manager = newControllerRegistrationManager(context)
+ try {
+ context.controllerNodeProvider.node.set(controller1)
+ manager.start(context.mockChannelManager)
+
+ // initial state with controller registered in log
+ val image = doMetadataUpdate(MetadataImage.EMPTY,
+ manager,
+ MetadataVersion.IBP_3_7_IV0,
+ r => Some(r),
+ _ => None
+ )
+ assertTrue(registeredInLog(manager))
+
+ // Now unregister the controller via an UnregisterControllerRecord.
+ doMetadataUpdate(image,
+ manager,
+ MetadataVersion.IBP_3_7_IV0,
+ _ => None,
+ r => if (r.controllerId() == 1) Some(r) else None
+ )
+ assertFalse(registeredInLog(manager))
+
+ // The local manager should send a new registration RPC.
+ assertEquals((true, 0, 0), rpcStats(manager))
+ } finally {
+ manager.close()
+ }
+ }
+
+ @Test
+ def testReRegistrationAfterDifferentIncarnationId(): Unit = {
Review Comment:
This is existing behavior. From `ControllerRegistrationManager`:
```
} else if (!curRegistration.incarnationId().equals(incarnationId)) {
logger.info("Found registration for {} instead
of our incarnation.", curRegistration.incarnationId());
registeredInLog = false;
```
setting the `registeredInLog = false` tells the manage to send
`ControllerRegistrationRequest`.
--
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]