Skip to content

Commit

Permalink
[KUUBI-198][FOLLOWUP]Fix SparkSessionCache unit test occasionally fai…
Browse files Browse the repository at this point in the history
…ls (#200)

* fix travis occasionally fails

* ad ut
  • Loading branch information
yaooqinn committed Jun 20, 2019
1 parent b6591d3 commit f4c08c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4c08c6

Please sign in to comment.