hachikuji commented on a change in pull request #11667:
URL: https://github.com/apache/kafka/pull/11667#discussion_r804266771



##########
File path: 
core/src/test/scala/unit/kafka/server/AbstractApiVersionsRequestTest.scala
##########
@@ -59,15 +68,40 @@ abstract class AbstractApiVersionsRequestTest(cluster: 
ClusterInstance) {
     } finally socket.close()
   }
 
-  def validateApiVersionsResponse(apiVersionsResponse: ApiVersionsResponse): 
Unit = {
-    val expectedApis = ApiKeys.zkBrokerApis()
+  def validateApiVersionsResponse(apiVersionsResponse: ApiVersionsResponse, 
listenerName: ListenerName = cluster.clientListener()): Unit = {
+    val expectedApis = if (!cluster.isKRaftTest) {
+      ApiKeys.zkBrokerApis()
+    } else if 
(cluster.controllerListenerName().asScala.contains(listenerName)) {
+      ApiKeys.controllerApis()
+    } else {
+      val apis = ApiVersionsResponse.intersectForwardableApis(
+        ApiMessageType.ListenerType.BROKER,
+        RecordVersion.current,
+        new 
NodeApiVersions(ApiKeys.controllerApis().asScala.map(ApiVersionsResponse.toApiVersion).asJava).allSupportedApiVersions()
+      )
+      apis.add(
+        new ApiVersionsResponseData.ApiVersion()

Review comment:
       This had me a bit confused. It looks like the kraft broker is exposing 
`Envelope` request because of the logic here: 
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/server/ApiVersionManager.scala#L104.
 This seems like a bug to me since the kraft broker itself should not receive 
`Envelope` requests. I feel like we should fix this so that we only add 
`Envelope` request to `ApiVersions` if forwarding is enabled _and_ it is not a 
kraft broker.




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to