diff --git a/kyuubi-server/src/main/scala/yaooqinn/kyuubi/ha/FailoverService.scala b/kyuubi-server/src/main/scala/yaooqinn/kyuubi/ha/FailoverService.scala index b044309ac..b0daf03c6 100644 --- a/kyuubi-server/src/main/scala/yaooqinn/kyuubi/ha/FailoverService.scala +++ b/kyuubi-server/src/main/scala/yaooqinn/kyuubi/ha/FailoverService.scala @@ -93,6 +93,7 @@ private[kyuubi] class FailoverService(name: String, server: KyuubiServer) override private[ha] def reset(): Unit = { info("Reset Zookeeper leader latch") closeLeaderLatch() + zkServiceStarted = false startLeaderLatch() } } diff --git a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/ha/FailoverServiceSuite.scala b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/ha/FailoverServiceSuite.scala index 35922ab07..b8b1b24f9 100644 --- a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/ha/FailoverServiceSuite.scala +++ b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/ha/FailoverServiceSuite.scala @@ -108,19 +108,26 @@ class FailoverServiceSuite extends SparkFunSuite server.init(conf) haService.init(conf) haService.start() - Thread.sleep(10000) + Thread.sleep(5000) val list = zooKeeperClient.getChildren.forPath("/").asScala.toList assert(list.size === 3) - assert(list.contains("kyuubiserver")) - assert(list.contains("kyuubiserver-latch")) - val l2 = zooKeeperClient.getChildren.forPath("/kyuubiserver").asScala.toList + val ns = "kyuubiserver" + assert(list.contains(ns)) + assert(list.contains(ns + "-latch")) + val l2 = zooKeeperClient.getChildren.forPath("/" + ns).asScala.toList assert(l2.size === 1) - val l3 = zooKeeperClient.getChildren.forPath("/kyuubiserver-latch").asScala.toList + val l3 = zooKeeperClient.getChildren.forPath("/" + ns + "-latch").asScala.toList assert(l3.size === 1) haService.reset() Thread.sleep(5000) - val l4 = zooKeeperClient.getChildren.forPath("/kyuubiserver-latch").asScala.toList + val l4 = zooKeeperClient.getChildren.forPath("/" + ns + "-latch").asScala.toList assert(l4.size === 1) assert(l3.head !== l4.head) + + zooKeeperClient.delete().forPath("/" + ns + "/" + l2.head) + Thread.sleep(5000) + val l5 = zooKeeperClient.getChildren.forPath("/" + ns + "-latch").asScala.toList + assert(l5.size === 1) + assert(l5.head !== l4.head) } } diff --git a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/spark/SparkSessionCacheManagerSuite.scala b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/spark/SparkSessionCacheManagerSuite.scala index 869109ced..21404c62d 100644 --- a/kyuubi-server/src/test/scala/yaooqinn/kyuubi/spark/SparkSessionCacheManagerSuite.scala +++ b/kyuubi-server/src/test/scala/yaooqinn/kyuubi/spark/SparkSessionCacheManagerSuite.scala @@ -106,7 +106,7 @@ class SparkSessionCacheManagerSuite c.decReuseTimeAndGet c.decReuseTimeAndGet } - Thread.sleep(1000) + Thread.sleep(5000) assert(cacheManager.getAndIncrease("alice").isEmpty) assert(cacheManager.getAndIncrease("bob").isEmpty) assert(cacheManager.getAndIncrease("tom").isEmpty)