hachikuji commented on a change in pull request #10900: URL: https://github.com/apache/kafka/pull/10900#discussion_r655556345
########## File path: core/src/test/java/kafka/test/annotation/Type.java ########## @@ -28,7 +28,7 @@ * The type of cluster config being requested. Used by {@link kafka.test.ClusterConfig} and the test annotations. */ public enum Type { - RAFT { + KRAFT { Review comment: Not needed for correctness of course, but KRaft seems to be the preferred term these days for the Kafka+Raft clusters. ########## File path: core/src/test/scala/unit/kafka/server/KafkaApisTest.scala ########## @@ -462,16 +461,55 @@ class KafkaApisTest { @Test def testAlterConfigsWithForwarding(): Unit = { val requestBuilder = new AlterConfigsRequest.Builder(Collections.emptyMap(), false) - testForwardableAPI(ApiKeys.ALTER_CONFIGS, requestBuilder) + testForwardableApi(ApiKeys.ALTER_CONFIGS, requestBuilder) + } + + @Test + def testDescribeQuorumNotAllowedForZkClusters(): Unit = { + val requestData = DescribeQuorumRequest.singletonRequest(KafkaRaftServer.MetadataPartition) + val requestBuilder = new DescribeQuorumRequest.Builder(requestData) + val request = buildRequest(requestBuilder.build()) + + val capturedResponse = expectNoThrottling(request) + EasyMock.replay(replicaManager, clientRequestQuotaManager, requestChannel, adminManager, controller) + createKafkaApis(enableForwarding = true).handle(request, RequestLocal.withThreadConfinedCaching) + + val response = capturedResponse.getValue.asInstanceOf[DescribeQuorumResponse] + assertEquals(Errors.UNKNOWN_SERVER_ERROR, Errors.forCode(response.data.errorCode)) + } + + @Test + def testDescribeQuorumForwardedForKRaftClusters(): Unit = { + val requestData = DescribeQuorumRequest.singletonRequest(KafkaRaftServer.MetadataPartition) + val requestBuilder = new DescribeQuorumRequest.Builder(requestData) + metadataCache = MetadataCache.raftMetadataCache(brokerId) + + testForwardableApi( + createKafkaApis(raftSupport = true), + ApiKeys.DESCRIBE_QUORUM, + requestBuilder + ) + } + + private def testForwardableApi(apiKey: ApiKeys, requestBuilder: AbstractRequest.Builder[_ <: AbstractRequest]): Unit = { + testForwardableApi( + createKafkaApis(enableForwarding = true), + apiKey, + requestBuilder + ) } - private def testForwardableAPI(apiKey: ApiKeys, requestBuilder: AbstractRequest.Builder[_ <: AbstractRequest]): Unit = { + private def testForwardableApi( + kafkaApis: KafkaApis, + apiKey: ApiKeys, + requestBuilder: AbstractRequest.Builder[_ <: AbstractRequest], + ): Unit = { val topicHeader = new RequestHeader(apiKey, apiKey.latestVersion, clientId, 0) val request = buildRequest(requestBuilder.build(topicHeader.apiVersion)) - EasyMock.expect(controller.isActive).andReturn(false) + EasyMock.expect(controller.isActive).andStubReturn(false) Review comment: I was being a little lazy. For `DescribeQuorum` in KRaft clusters, we forward it to the controller blindly because the broker cannot be a controller. Let me see if I can make this conditional. ########## File path: core/src/test/java/kafka/test/annotation/Type.java ########## @@ -28,7 +28,7 @@ * The type of cluster config being requested. Used by {@link kafka.test.ClusterConfig} and the test annotations. */ public enum Type { - RAFT { + KRAFT { Review comment: Not needed for correctness of course, but KRaft seems to be the preferred term these days for the Kafka+Raft clusters. I thought I would go ahead and change here since there are only a few uses so far. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org