- void testWriteTransaction(DistributedDataStore dataStore, YangInstanceIdentifier nodePath,
- NormalizedNode<?, ?> nodeToWrite) throws Exception {
+ public static void verifyShardState(final ClientBackedDataStore datastore, final String shardName,
+ final Consumer<OnDemandShardState> verifier) throws Exception {
+ ActorUtils actorUtils = datastore.getActorUtils();
+
+ Future<ActorRef> future = actorUtils.findLocalShardAsync(shardName);
+ ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS));
+
+ AssertionError lastError = null;
+ Stopwatch sw = Stopwatch.createStarted();
+ while (sw.elapsed(TimeUnit.SECONDS) <= 5) {
+ OnDemandShardState shardState = (OnDemandShardState)actorUtils
+ .executeOperation(shardActor, GetOnDemandRaftState.INSTANCE);
+
+ try {
+ verifier.accept(shardState);
+ return;
+ } catch (AssertionError e) {
+ lastError = e;
+ Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ throw lastError;
+ }
+
+ void testWriteTransaction(final ClientBackedDataStore dataStore, final YangInstanceIdentifier nodePath,
+ final NormalizedNode nodeToWrite) throws Exception {