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:54:10 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.11.0 cc15da1d7 -> d2a95ec07


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

(cherry picked from commit 2d8918b1aec2601a66e9321da4460a8826b88139)
Signed-off-by: Guozhang Wang <wangguoz@gmail.com>


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

Branch: refs/heads/0.11.0
Commit: d2a95ec07ed258c819e74a259ac43f5a85826180
Parents: cc15da1
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:54:02 2017 -0800

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


http://git-wip-us.apache.org/repos/asf/kafka/blob/d2a95ec0/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 7e549c8..f9b3bda 100644
--- a/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslEndToEndAuthorizationTest.scala
@@ -21,8 +21,14 @@ import java.util.Properties
 import kafka.utils.TestUtils
 import org.apache.kafka.common.protocol.SecurityProtocol
 import org.apache.kafka.common.config.SaslConfigs
+<<<<<<< HEAD
 import org.apache.kafka.common.errors.GroupAuthorizationException
+=======
+import org.apache.kafka.common.security.auth.SecurityProtocol
+import org.apache.kafka.common.errors.{GroupAuthorizationException, TopicAuthorizationException}
+>>>>>>> 2d8918b... KAFKA-6118: Fix transient failure testTwoConsumersWithDifferentSaslCredentials
 import org.junit.{Before, Test}
+import org.junit.Assert.{assertEquals, assertTrue}
 
 import scala.collection.immutable.List
 import scala.collection.JavaConverters._
@@ -36,7 +42,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
@@ -44,7 +50,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()
   }
 
   /**
@@ -76,9 +82,12 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest
{
 
     try {
       consumeRecords(consumer2)
-      fail("Expected exception as consumer2 has no access to group")
+      fail("Expected exception as consumer2 has no access to topic or group")
     } catch {
-      case _: GroupAuthorizationException => //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/d2a95ec0/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 1128ad0..4096968 100644
--- a/core/src/test/scala/integration/kafka/api/SaslSetup.scala
+++ b/core/src/test/scala/integration/kafka/api/SaslSetup.scala
@@ -86,7 +86,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