ijuma commented on a change in pull request #9986:
URL: https://github.com/apache/kafka/pull/9986#discussion_r569243982
##########
File path:
core/src/test/scala/unit/kafka/server/SaslApiVersionsRequestTest.scala
##########
@@ -16,83 +16,94 @@
*/
package kafka.server
+import integration.kafka.server.IntegrationTestHelper
+
import java.net.Socket
import java.util.Collections
import kafka.api.{KafkaSasl, SaslSetup}
import kafka.utils.JaasTestUtils
import org.apache.kafka.common.message.SaslHandshakeRequestData
import org.apache.kafka.common.protocol.{ApiKeys, Errors}
import org.apache.kafka.common.requests.{ApiVersionsRequest,
ApiVersionsResponse, SaslHandshakeRequest, SaslHandshakeResponse}
-import org.apache.kafka.common.security.auth.SecurityProtocol
+import kafka.test.annotation.{ClusterTest, Type}
+import kafka.test.junit.ClusterTestExtensions
+import kafka.test.{ClusterConfig, ClusterInstance}
import org.junit.jupiter.api.Assertions._
-import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
+import org.junit.jupiter.api.{AfterEach, BeforeEach}
+import org.junit.jupiter.api.extension.ExtendWith
-class SaslApiVersionsRequestTest extends AbstractApiVersionsRequestTest with
SaslSetup {
- override protected def securityProtocol = SecurityProtocol.SASL_PLAINTEXT
- private val kafkaClientSaslMechanism = "PLAIN"
- private val kafkaServerSaslMechanisms = List("PLAIN")
- protected override val serverSaslProperties =
Some(kafkaServerSaslProperties(kafkaServerSaslMechanisms,
kafkaClientSaslMechanism))
- protected override val clientSaslProperties =
Some(kafkaClientSaslProperties(kafkaClientSaslMechanism))
- override def brokerCount = 1
+import scala.jdk.CollectionConverters._
- @BeforeEach
- override def setUp(): Unit = {
- startSasl(jaasSections(kafkaServerSaslMechanisms,
Some(kafkaClientSaslMechanism), KafkaSasl,
JaasTestUtils.KafkaServerContextName))
- super.setUp()
- }
- @AfterEach
- override def tearDown(): Unit = {
- super.tearDown()
- closeSasl()
+@ExtendWith(value = Array(classOf[ClusterTestExtensions]))
+class SaslApiVersionsRequestTest(helper: IntegrationTestHelper,
+ cluster: ClusterInstance) extends
AbstractApiVersionsRequestTest(helper, cluster) {
+
+ val kafkaClientSaslMechanism = "PLAIN"
+ val kafkaServerSaslMechanisms = List("PLAIN")
+
+ private var sasl: SaslSetup = _
+
+ @BeforeEach
+ def setupSasl(config: ClusterConfig): Unit = {
+ sasl = new SaslSetup() {}
+ sasl.startSasl(sasl.jaasSections(kafkaServerSaslMechanisms,
Some(kafkaClientSaslMechanism), KafkaSasl,
JaasTestUtils.KafkaServerContextName))
+
config.saslServerProperties().putAll(sasl.kafkaServerSaslProperties(kafkaServerSaslMechanisms,
kafkaClientSaslMechanism))
+
config.saslClientProperties().putAll(sasl.kafkaClientSaslProperties(kafkaClientSaslMechanism))
+ super.brokerPropertyOverrides(config.serverProperties())
}
- @Test
+ @ClusterTest(securityProtocol = "SASL_PLAINTEXT", clusterType = Type.Zk)
def testApiVersionsRequestBeforeSaslHandshakeRequest(): Unit = {
- val socket = connect()
+ val socket = helper.connect(cluster.brokers().asScala.head,
cluster.listener())
try {
- val apiVersionsResponse = sendAndReceive[ApiVersionsResponse](
+ val apiVersionsResponse = helper.sendAndReceive[ApiVersionsResponse](
new ApiVersionsRequest.Builder().build(0), socket)
- validateApiVersionsResponse(apiVersionsResponse)
+ validateApiVersionsResponse(apiVersionsResponse, cluster.listener())
sendSaslHandshakeRequestValidateResponse(socket)
} finally {
socket.close()
}
}
- @Test
+ @ClusterTest(securityProtocol = "SASL_PLAINTEXT", clusterType = Type.Zk)
Review comment:
It's a bit weird to repeat the security protocol in every test method
given the class name. Can we not do it in the setup method?
----------------------------------------------------------------
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:
[email protected]