CalvinConfluent commented on code in PR #18277:
URL: https://github.com/apache/kafka/pull/18277#discussion_r1938075074
##########
metadata/src/test/java/org/apache/kafka/controller/ClusterControlManagerTest.java:
##########
@@ -855,13 +866,65 @@ public void testReRegistrationAndBrokerEpoch(boolean
newIncarnationId) {
}
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ public void testReRegistrationWithUncleanShutdownDetection(boolean
isCleanShutdown) {
+ ClusterControlManager clusterControl = new
ClusterControlManager.Builder().
+ setClusterId("pjvUwj3ZTEeSVQmUiH3IJw").
+ setFeatureControlManager(new
FeatureControlManager.Builder().build()).
+ setBrokerShutdownHandler((brokerId, cleanShutdown, records) -> {
+ if (!cleanShutdown) {
+ records.add(new ApiMessageAndVersion(new
PartitionChangeRecord(), PartitionChangeRecord.HIGHEST_SUPPORTED_VERSION));
+ }
+ }).
+ build();
+ clusterControl.activate();
+ List<ApiMessageAndVersion> records = clusterControl.registerBroker(
+ new BrokerRegistrationRequestData().
+ setBrokerId(1).
+ setClusterId(clusterControl.clusterId()).
+ setIncarnationId(Uuid.fromString("mISEfEFwQIuaD1gKCc5tzQ")).
+
setLogDirs(Arrays.asList(Uuid.fromString("Vv1gzkM2QpuE-PPrIc6XEw"))),
+ 100,
+ new FinalizedControllerFeatures(Collections.emptyMap(), 100L),
+ true).
+ records();
+ records.add(new ApiMessageAndVersion(new
BrokerRegistrationChangeRecord().
+ setBrokerId(1).setBrokerEpoch(100).
+
setInControlledShutdown(BrokerRegistrationInControlledShutdownChange.IN_CONTROLLED_SHUTDOWN.value()),
+ (short) 1));
+ RecordTestUtils.replayAll(clusterControl, records);
+
+ records = clusterControl.registerBroker(
+ new BrokerRegistrationRequestData().
+ setBrokerId(1).
+ setClusterId(clusterControl.clusterId()).
+ setIncarnationId(Uuid.fromString("07OOcU7MQFeSmGAFPP2Zww")).
+ setPreviousBrokerEpoch(isCleanShutdown ? 100 : 10).
+
setLogDirs(Arrays.asList(Uuid.fromString("Vv1gzkM2QpuE-PPrIc6XEw"))),
+ 111,
+ new FinalizedControllerFeatures(Collections.emptyMap(), 100L),
+ true).records();
+ RecordTestUtils.replayAll(clusterControl, records);
+ assertEquals(Uuid.fromString("07OOcU7MQFeSmGAFPP2Zww"),
+ clusterControl.brokerRegistrations().get(1).incarnationId());
+
assertFalse(clusterControl.brokerRegistrations().get(1).inControlledShutdown());
+ if (isCleanShutdown) {
+ assertEquals(100,
clusterControl.brokerRegistrations().get(1).epoch());
Review Comment:
Good catch. The test is not correct.
--
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]