Skip to content

Commit

Permalink
LIVY-231 Session recovery for batch sessions with multiple Livy servers
Browse files Browse the repository at this point in the history
Mocking batchSessionsCache in ZooKeeperStateStore.
Without mocking, Livy test fails to start a ZooKeeperStateStore.

Task-url: https://issues.cloudera.org/browse/LIVY-231
  • Loading branch information
meisam committed Nov 2, 2016
1 parent 279b23d commit 62e1cde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ZooKeeperStateStore(
batchSessionsCache.start(StartMode.BUILD_INITIAL_CACHE)
} catch {
case _ : NullPointerException =>
throw new IllegalArgumentException("Invalid Zookeeper settings.")
throw new IllegalArgumentException("Invalid Zookeeper settings.")
}

// TODO Make sure ZK path has proper secure permissions so that other users cannot read its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import scala.collection.JavaConverters._
import org.apache.curator.framework.CuratorFramework
import org.apache.curator.framework.api._
import org.apache.curator.framework.listen.Listenable
import org.apache.curator.framework.state.ConnectionStateListener
import org.apache.curator.utils.EnsurePath
import org.apache.zookeeper.data.Stat
import org.mockito.Matchers.anyString
import org.mockito.Mockito._
import org.scalatest.FunSpec
import org.scalatest.Matchers._
Expand All @@ -43,6 +46,16 @@ class ZooKeeperStateStoreSpec extends FunSpec with LivyBaseUnitTestSuite {
val curatorClient = mock[CuratorFramework]
when(curatorClient.getUnhandledErrorListenable())
.thenReturn(mock[Listenable[UnhandledErrorListener]])
when(curatorClient.getConnectionStateListenable())
.thenReturn(mock[Listenable[ConnectionStateListener]])
when(curatorClient.newNamespaceAwareEnsurePath(anyString()))
.thenReturn(mock[EnsurePath])

val builder: GetChildrenBuilder = mock[GetChildrenBuilder]
when(curatorClient.getChildren())
.thenReturn(builder)
when(builder.forPath(anyString()))
.thenReturn(new java.util.LinkedList[String]())
val stateStore = new ZooKeeperStateStore(conf, Some(curatorClient))
testBody(TestFixture(stateStore, curatorClient))
}
Expand Down

0 comments on commit 62e1cde

Please sign in to comment.