kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guozh...@apache.org
Subject kafka git commit: KAFKA-6118: Fix transient failure testTwoConsumersWithDifferentSaslCredentials
Date Sat, 02 Dec 2017 07:52:34 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk d1e0443ba -> 2d8918b1a


KAFKA-6118: Fix transient failure testTwoConsumersWithDifferentSaslCredentials

It's rare, but it can happen that the initial FindCoordinator request returns before the first
Metadata request. Both authorization errors are fine for this test case.

Author: Jason Gustafson <jason@confluent.io>

Reviewers: Guozhang Wang <wangguoz@gmail.com>

Closes #4287 from hachikuji/KAFKA-6118


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/2d8918b1
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/2d8918b1
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/2d8918b1

Branch: refs/heads/trunk
Commit: 2d8918b1aec2601a66e9321da4460a8826b88139
Parents: d1e0443
Author: Jason Gustafson <jason@confluent.io>
Authored: Fri Dec 1 23:52:25 2017 -0800
Committer: Guozhang Wang <wangguoz@gmail.com>
Committed: Fri Dec 1 23:52:25 2017 -0800

----------------------------------------------------------------------
 .../kafka/api/SaslEndToEndAuthorizationTest.scala     | 14 +++++++++-----
 .../test/scala/integration/kafka/api/SaslSetup.scala  |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/2d8918b1/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
b/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
index fb6bee8..f5409b1 100644
--- a/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
@@ -22,8 +22,9 @@ import kafka.utils.TestUtils
 import kafka.utils.Implicits._
 import org.apache.kafka.common.config.SaslConfigs
 import org.apache.kafka.common.security.auth.SecurityProtocol
-import org.apache.kafka.common.errors.TopicAuthorizationException
+import org.apache.kafka.common.errors.{GroupAuthorizationException, TopicAuthorizationException}
 import org.junit.{Before, Test}
+import org.junit.Assert.{assertEquals, assertTrue}
 
 import scala.collection.immutable.List
 import scala.collection.JavaConverters._
@@ -37,7 +38,7 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest
{
   protected def kafkaServerSaslMechanisms: List[String]
   
   @Before
-  override def setUp {
+  override def setUp() {
     // create static config including client login context with credentials for JaasTestUtils
'client2'
     startSasl(jaasSections(kafkaServerSaslMechanisms, Option(kafkaClientSaslMechanism), Both))
     // set dynamic properties with credentials for JaasTestUtils 'client1' so that dynamic
JAAS configuration is also
@@ -45,7 +46,7 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest
{
     val clientLoginContext = jaasClientLoginModule(kafkaClientSaslMechanism)
     producerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
     consumerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
-    super.setUp
+    super.setUp()
   }
 
   /**
@@ -77,9 +78,12 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest
{
 
     try {
       consumeRecords(consumer2)
-      fail("Expected exception as consumer2 has no access to topic")
+      fail("Expected exception as consumer2 has no access to topic or group")
     } catch {
-      case _: TopicAuthorizationException => //expected
+      // Either exception is possible depending on the order that the first Metadata
+      // and FindCoordinator requests are received
+      case e: TopicAuthorizationException => assertTrue(e.unauthorizedTopics.contains(topic))
+      case e: GroupAuthorizationException => assertEquals(group, e.groupId)
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/2d8918b1/core/src/test/scala/integration/kafka/api/SaslSetup.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/integration/kafka/api/SaslSetup.scala b/core/src/test/scala/integration/kafka/api/SaslSetup.scala
index 51deb85..f459252 100644
--- a/core/src/test/scala/integration/kafka/api/SaslSetup.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslSetup.scala
@@ -89,7 +89,7 @@ trait SaslSetup {
                              mode: SaslSetupMode = Both,
                              kafkaServerEntryName: String = JaasTestUtils.KafkaServerContextName):
Seq[JaasSection] = {
     val hasKerberos = mode != ZkSasl &&
-      (kafkaServerSaslMechanisms.contains("GSSAPI") || kafkaClientSaslMechanism.exists(_
== "GSSAPI"))
+      (kafkaServerSaslMechanisms.contains("GSSAPI") || kafkaClientSaslMechanism.contains("GSSAPI"))
     if (hasKerberos)
       maybeCreateEmptyKeytabFiles()
     mode match {


Mime
View raw message