+ @Test
+ public void testWaitTillReadyCountDown() {
+ try (DistributedDataStore distributedDataStore = new DistributedDataStore(actorContext, UNKNOWN_ID)) {
+ doReturn(datastoreContext).when(actorContext).getDatastoreContext();
+ doReturn(shardElectionTimeout).when(datastoreContext).getShardLeaderElectionTimeout();
+ doReturn(FiniteDuration.apply(5000, TimeUnit.MILLISECONDS)).when(shardElectionTimeout).duration();
+
+ Executors.newSingleThreadExecutor().submit(() -> {
+ Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+ distributedDataStore.getWaitTillReadyCountDownLatch().countDown();
+ });
+
+ long start = System.currentTimeMillis();
+
+ distributedDataStore.waitTillReady();
+
+ long end = System.currentTimeMillis();
+
+ assertTrue("Expected to be released in 500 millis", end - start < 5000);
+ }
+ }
+}