lucasbru commented on code in PR #23747:
URL: https://github.com/apache/kafka/pull/23747#discussion_r4218946914
##########
core/src/test/scala/unit/kafka/server/StreamsGroupTopologyDescriptionRequestTest.scala:
##########
@@ -592,6 +593,159 @@ class StreamsGroupTopologyDescriptionRequestTest(cluster:
ClusterInstance) exten
}
}
+ @ClusterTest(serverProperties = Array(
+ new ClusterConfigProperty(
+ key =
GroupCoordinatorConfig.STREAMS_GROUP_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS_CONFIG,
+ value = "kafka.server.FailingTopologyDescriptionPlugin"),
+ // Keeps the periodic cleanup cycle from also deleting the topology while
the test runs.
+ new ClusterConfigProperty(key =
GroupCoordinatorConfig.OFFSETS_RETENTION_CHECK_INTERVAL_MS_CONFIG, value =
"3600000")
+ ))
+ def testClassicJoinDeletesStoredTopologyAndConvertsEmptyStreamsGroup(): Unit
= {
+ val admin = cluster.admin()
+ val groupId = "test-group"
+ val topicName = "test-topic"
+
+ try {
+ FailingTopologyDescriptionPlugin.reset()
+ createEmptyStreamsGroupWithStoredTopology(admin, groupId, topicName)
+
+ assertEquals(Errors.NONE.code(), classicJoin(groupId).errorCode())
+ assertEquals(1,
FailingTopologyDescriptionPlugin.deleteTopologyAttempts(groupId))
+ assertEquals(Errors.GROUP_ID_NOT_FOUND.code(),
streamsGroupDescribe(List(groupId)).head.errorCode())
+ assertEquals("consumer",
describeGroups(List(groupId)).head.protocolType())
+ } finally {
+ FailingTopologyDescriptionPlugin.reset()
+ admin.close()
+ }
+ }
+
+ @ClusterTest(serverProperties = Array(
+ new ClusterConfigProperty(
+ key =
GroupCoordinatorConfig.STREAMS_GROUP_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS_CONFIG,
+ value = "kafka.server.FailingTopologyDescriptionPlugin")
+ ))
+ def testClassicJoinIsRejectedRetriablyWhenPluginDeleteFails(): Unit = {
+ val admin = cluster.admin()
+ val groupId = "test-group"
+ val topicName = "test-topic"
+
+ try {
+ FailingTopologyDescriptionPlugin.reset()
+ createEmptyStreamsGroupWithStoredTopology(admin, groupId, topicName)
+
+ FailingTopologyDescriptionPlugin.failDeleteTopologyWith(new
RuntimeException("plugin offline"))
+ assertEquals(Errors.REBALANCE_IN_PROGRESS.code(),
classicJoin(groupId).errorCode())
+ assertEquals(1,
FailingTopologyDescriptionPlugin.deleteTopologyAttempts(groupId))
+ assertStillStreamsGroup(groupId)
+ } finally {
+ FailingTopologyDescriptionPlugin.reset()
+ admin.close()
+ }
+ }
+
+ @Timeout(120)
+ @ClusterTest(serverProperties = Array(
+ new ClusterConfigProperty(
+ key =
GroupCoordinatorConfig.STREAMS_GROUP_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS_CONFIG,
+ value = "kafka.server.FailingTopologyDescriptionPlugin"),
+ // Drives the periodic topology cleanup cycle, which runs on the offsets
retention check interval.
+ new ClusterConfigProperty(key =
GroupCoordinatorConfig.OFFSETS_RETENTION_CHECK_INTERVAL_MS_CONFIG, value =
"500")
+ ))
+ def testPeriodicCleanupClearsTopologyAfterFailedClassicJoin(): Unit = {
+ val admin = cluster.admin()
+ val groupId = "test-group"
+ val topicName = "test-topic"
+
+ try {
+ FailingTopologyDescriptionPlugin.reset()
+ createEmptyStreamsGroupWithStoredTopology(admin, groupId, topicName)
+
+ // The plugin cannot delete: the classic join is rejected and the group
stays a streams group.
+ FailingTopologyDescriptionPlugin.failDeleteTopologyWith(new
RuntimeException("plugin offline"))
Review Comment:
Good catch, the failure is now configured before the group is created, so no
cycle can delete the topology once the group is empty.
--
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]