KAFKA-3508: Fix transient SimpleACLAuthorizerTest failures Allows the the maximum retires when writing to zookeeper to be overridden in tests and sets the value to Int.MaxValue to avoid transient failure.
Author: Grant Henke <[email protected]> Reviewers: Ismael Juma <[email protected]>, Ewen Cheslack-Postava <[email protected]> Closes #1156 from granthenke/transient-acl-test Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/35fadbf6 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/35fadbf6 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/35fadbf6 Branch: refs/heads/0.10.0 Commit: 35fadbf639650a14f061a97904755d12499fd7fa Parents: e733d8c Author: Grant Henke <[email protected]> Authored: Tue Apr 5 15:17:46 2016 -0700 Committer: Gwen Shapira <[email protected]> Committed: Tue Apr 5 17:08:53 2016 -0700 ---------------------------------------------------------------------- .../main/scala/kafka/security/auth/SimpleAclAuthorizer.scala | 2 +- .../unit/kafka/security/auth/SimpleAclAuthorizerTest.scala | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/35fadbf6/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala b/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala index 1a06af2..18fff45 100644 --- a/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala +++ b/core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala @@ -79,7 +79,7 @@ class SimpleAclAuthorizer extends Authorizer with Logging { // The maximum number of times we should try to update the resource acls in zookeeper before failing; // This should never occur, but is a safeguard just in case. - private val maxUpdateRetries = 10 + protected[auth] var maxUpdateRetries = 10 private val retryBackoffMs = 100 private val retryBackoffJitterMs = 50 http://git-wip-us.apache.org/repos/asf/kafka/blob/35fadbf6/core/src/test/scala/unit/kafka/security/auth/SimpleAclAuthorizerTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/security/auth/SimpleAclAuthorizerTest.scala b/core/src/test/scala/unit/kafka/security/auth/SimpleAclAuthorizerTest.scala index bdadb15..7fcc33d 100644 --- a/core/src/test/scala/unit/kafka/security/auth/SimpleAclAuthorizerTest.scala +++ b/core/src/test/scala/unit/kafka/security/auth/SimpleAclAuthorizerTest.scala @@ -44,6 +44,10 @@ class SimpleAclAuthorizerTest extends ZooKeeperTestHarness { override def setUp() { super.setUp() + // Increase maxUpdateRetries to avoid transient failures + simpleAclAuthorizer.maxUpdateRetries = Int.MaxValue + simpleAclAuthorizer2.maxUpdateRetries = Int.MaxValue + val props = TestUtils.createBrokerConfig(0, zkConnect) props.put(SimpleAclAuthorizer.SuperUsersProp, superUsers) @@ -307,7 +311,7 @@ class SimpleAclAuthorizerTest extends ZooKeeperTestHarness { def testHighConcurrencyModificationOfResourceAcls() { val commonResource = new Resource(Topic, "test") - val acls = (0 to 100).map { i => + val acls = (0 to 50).map { i => val useri = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, i.toString) new Acl(useri, Allow, WildCardHost, Read) }
