kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: KAFKA-2910: Close Zookeeper clients in unit tests
Date Fri, 01 Apr 2016 17:52:45 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 623ab1e7c -> 77142f6ba


KAFKA-2910: Close Zookeeper clients in unit tests

Zookeeper clients that are not closed after the server is shutdown keep trying to reconnect,
reloading JAAS configuration. This impacts subsequent tests which rely on JAAS config to be
reset.

Author: Rajini Sivaram <rajinisivaram@googlemail.com>

Reviewers: Flavio Junqueira <fpj@apache.org>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes #1171 from rajinisivaram/KAFKA-2910


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

Branch: refs/heads/trunk
Commit: 77142f6baeb35e6de9608a7372113f72ea330936
Parents: 623ab1e
Author: Rajini Sivaram <rajinisivaram@googlemail.com>
Authored: Fri Apr 1 10:52:26 2016 -0700
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Fri Apr 1 10:52:26 2016 -0700

----------------------------------------------------------------------
 core/src/test/scala/unit/kafka/utils/TestUtils.scala    | 1 +
 core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala | 4 +++-
 core/src/test/scala/unit/kafka/zk/ZKPathTest.scala      | 8 ++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/77142f6b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/utils/TestUtils.scala b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
index a1e7912..be7741d 100755
--- a/core/src/test/scala/unit/kafka/utils/TestUtils.scala
+++ b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
@@ -585,6 +585,7 @@ object TestUtils extends Logging {
   def updateConsumerOffset(config : ConsumerConfig, path : String, offset : Long) = {
     val zkUtils = ZkUtils(config.zkConnect, config.zkSessionTimeoutMs, config.zkConnectionTimeoutMs,
false)
     zkUtils.updatePersistentPath(path, offset.toString)
+    zkUtils.close()
 
   }
 

http://git-wip-us.apache.org/repos/asf/kafka/blob/77142f6b/core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala b/core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala
index fb53d77..32c7a5d 100644
--- a/core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala
+++ b/core/src/test/scala/unit/kafka/zk/ZKEphemeralTest.scala
@@ -91,6 +91,7 @@ class ZKEphemeralTest(val secure: Boolean) extends ZooKeeperTestHarness
{
     zkUtils = ZkUtils(zkConnect, zkSessionTimeoutMs, config.zkConnectionTimeoutMs, JaasUtils.isZkSecurityEnabled())
     val nodeExists = zkUtils.pathExists("/tmp/zktest")
     Assert.assertFalse(nodeExists)
+    zkUtils.close()
   }
 
   /*****
@@ -137,7 +138,7 @@ class ZKEphemeralTest(val secure: Boolean) extends ZooKeeperTestHarness
{
     val zk1 = zkUtils.zkConnection.getZookeeper
 
     //Creates a second session
-    val (_, zkConnection2) = ZkUtils.createZkClientAndConnection(zkConnect, zkSessionTimeoutMs,
zkConnectionTimeout)
+    val (zkClient2, zkConnection2) = ZkUtils.createZkClientAndConnection(zkConnect, zkSessionTimeoutMs,
zkConnectionTimeout)
     val zk2 = zkConnection2.getZookeeper
     var zwe = new ZKCheckedEphemeral(path, "", zk2, JaasUtils.isZkSecurityEnabled())
 
@@ -153,6 +154,7 @@ class ZKEphemeralTest(val secure: Boolean) extends ZooKeeperTestHarness
{
         gotException = true
     }
     Assert.assertTrue(gotException)
+    zkClient2.close()
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/kafka/blob/77142f6b/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala b/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
index 65dd589..92fae02 100644
--- a/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
+++ b/core/src/test/scala/unit/kafka/zk/ZKPathTest.scala
@@ -43,6 +43,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       case configException: ConfigException =>
       case exception: Throwable => fail("Should have thrown ConfigException")
     }
+    zkUtils.close()
   }
 
   @Test
@@ -57,6 +58,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
     }
 
     assertTrue("Failed to create persistent path", zkUtils.pathExists(path))
+    zkUtils.close()
   }
 
   @Test
@@ -73,6 +75,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       case configException: ConfigException =>
       case exception: Throwable => fail("Should have thrown ConfigException")
     }
+    zkUtils.close()
   }
 
   @Test
@@ -87,6 +90,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
     }
 
     assertTrue("Failed to create persistent path", zkUtils.pathExists(path))
+    zkUtils.close()
   }
 
   @Test
@@ -103,6 +107,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       case configException: ConfigException =>
       case exception: Throwable => fail("Should have thrown ConfigException")
     }
+    zkUtils.close()
   }
 
   @Test
@@ -117,6 +122,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
     }
 
     assertTrue("Failed to create ephemeral path", zkUtils.pathExists(path))
+    zkUtils.close()
   }
 
   @Test
@@ -133,6 +139,7 @@ class ZKPathTest extends ZooKeeperTestHarness {
       case configException: ConfigException =>
       case exception: Throwable => fail("Should have thrown ConfigException")
     }
+    zkUtils.close()
   }
 
   @Test
@@ -149,5 +156,6 @@ class ZKPathTest extends ZooKeeperTestHarness {
     }
 
     assertTrue("Failed to create persistent path", zkUtils.pathExists(actualPath))
+    zkUtils.close()
   }
 }


Mime
View raw message