2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.junit.Assert.fail;
15 import static org.mockito.Matchers.any;
16 import static org.mockito.Matchers.eq;
17 import static org.mockito.Mockito.timeout;
18 import static org.mockito.Mockito.verify;
19 import akka.actor.ActorSystem;
20 import akka.actor.Address;
21 import akka.actor.AddressFromURIString;
22 import akka.cluster.Cluster;
23 import akka.testkit.JavaTestKit;
24 import com.google.common.base.Optional;
25 import com.google.common.collect.ImmutableMap;
26 import com.google.common.util.concurrent.CheckedFuture;
27 import com.google.common.util.concurrent.ListenableFuture;
28 import com.google.common.util.concurrent.MoreExecutors;
29 import com.google.common.util.concurrent.Uninterruptibles;
30 import com.typesafe.config.ConfigFactory;
31 import java.io.IOException;
32 import java.math.BigInteger;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.Collection;
36 import java.util.Collections;
37 import java.util.List;
38 import java.util.concurrent.CountDownLatch;
39 import java.util.concurrent.ExecutionException;
40 import java.util.concurrent.TimeUnit;
41 import java.util.concurrent.atomic.AtomicReference;
42 import org.junit.AfterClass;
43 import org.junit.BeforeClass;
44 import org.junit.Test;
45 import org.mockito.Mockito;
46 import org.opendaylight.controller.cluster.databroker.ConcurrentDOMDataBroker;
47 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
48 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
49 import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
50 import org.opendaylight.controller.cluster.datastore.messages.FindLocalShard;
51 import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound;
52 import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener;
53 import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
54 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
55 import org.opendaylight.controller.cluster.raft.Snapshot;
56 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
57 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
58 import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel;
59 import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper;
60 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
61 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
62 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
63 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
64 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
65 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
66 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
67 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
68 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
69 import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
70 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
71 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
72 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
73 import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
74 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
75 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
76 import org.opendaylight.yangtools.concepts.ListenerRegistration;
77 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
78 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
79 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
80 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
81 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
82 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
83 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
84 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
86 public class DistributedDataStoreIntegrationTest {
88 private static ActorSystem system;
90 private final DatastoreContext.Builder datastoreContextBuilder =
91 DatastoreContext.newBuilder().shardHeartbeatIntervalInMillis(100);
94 public static void setUpClass() throws IOException {
95 system = ActorSystem.create("cluster-test", ConfigFactory.load().getConfig("Member1"));
96 Address member1Address = AddressFromURIString.parse("akka.tcp://cluster-test@127.0.0.1:2558");
97 Cluster.get(system).join(member1Address);
101 public static void tearDownClass() throws IOException {
102 JavaTestKit.shutdownActorSystem(system);
106 protected ActorSystem getSystem() {
111 public void testWriteTransactionWithSingleShard() throws Exception{
112 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
113 try (DistributedDataStore dataStore =
114 setupDistributedDataStore("transactionIntegrationTest", "test-1")) {
116 testWriteTransaction(dataStore, TestModel.TEST_PATH,
117 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
119 testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
120 ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
126 public void testWriteTransactionWithMultipleShards() throws Exception{
127 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
128 try (DistributedDataStore dataStore =
129 setupDistributedDataStore("testWriteTransactionWithMultipleShards", "cars-1", "people-1")) {
131 DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
132 assertNotNull("newWriteOnlyTransaction returned null", writeTx);
134 writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
135 writeTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
137 doCommit(writeTx.ready());
139 writeTx = dataStore.newWriteOnlyTransaction();
141 writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
142 writeTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());
144 doCommit(writeTx.ready());
146 writeTx = dataStore.newWriteOnlyTransaction();
148 MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
149 YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
150 writeTx.write(carPath, car);
152 MapEntryNode person = PeopleModel.newPersonEntry("jack");
153 YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
154 writeTx.write(personPath, person);
156 doCommit(writeTx.ready());
158 // Verify the data in the store
160 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
162 Optional<NormalizedNode<?, ?>> optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
163 assertEquals("isPresent", true, optional.isPresent());
164 assertEquals("Data node", car, optional.get());
166 optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
167 assertEquals("isPresent", true, optional.isPresent());
168 assertEquals("Data node", person, optional.get());
174 public void testReadWriteTransactionWithSingleShard() throws Exception{
175 System.setProperty("shard.persistent", "true");
176 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
177 try (DistributedDataStore dataStore =
178 setupDistributedDataStore("testReadWriteTransactionWithSingleShard", "test-1")) {
180 // 1. Create a read-write Tx
182 DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
183 assertNotNull("newReadWriteTransaction returned null", readWriteTx);
185 // 2. Write some data
187 YangInstanceIdentifier nodePath = TestModel.TEST_PATH;
188 NormalizedNode<?, ?> nodeToWrite = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
189 readWriteTx.write(nodePath, nodeToWrite );
191 // 3. Read the data from Tx
193 Boolean exists = readWriteTx.exists(nodePath).checkedGet(5, TimeUnit.SECONDS);
194 assertEquals("exists", true, exists);
196 Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(nodePath).get(5, TimeUnit.SECONDS);
197 assertEquals("isPresent", true, optional.isPresent());
198 assertEquals("Data node", nodeToWrite, optional.get());
200 // 4. Ready the Tx for commit
202 DOMStoreThreePhaseCommitCohort cohort = readWriteTx.ready();
208 // 6. Verify the data in the store
210 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
212 optional = readTx.read(nodePath).get(5, TimeUnit.SECONDS);
213 assertEquals("isPresent", true, optional.isPresent());
214 assertEquals("Data node", nodeToWrite, optional.get());
220 public void testReadWriteTransactionWithMultipleShards() throws Exception{
221 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
222 try (DistributedDataStore dataStore =
223 setupDistributedDataStore("testReadWriteTransactionWithMultipleShards", "cars-1", "people-1")) {
225 DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
226 assertNotNull("newReadWriteTransaction returned null", readWriteTx);
228 readWriteTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
229 readWriteTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
231 doCommit(readWriteTx.ready());
233 readWriteTx = dataStore.newReadWriteTransaction();
235 readWriteTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
236 readWriteTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());
238 doCommit(readWriteTx.ready());
240 readWriteTx = dataStore.newReadWriteTransaction();
242 MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
243 YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
244 readWriteTx.write(carPath, car);
246 MapEntryNode person = PeopleModel.newPersonEntry("jack");
247 YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
248 readWriteTx.write(personPath, person);
250 Boolean exists = readWriteTx.exists(carPath).checkedGet(5, TimeUnit.SECONDS);
251 assertEquals("exists", true, exists);
253 Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(carPath).get(5, TimeUnit.SECONDS);
254 assertEquals("isPresent", true, optional.isPresent());
255 assertEquals("Data node", car, optional.get());
257 doCommit(readWriteTx.ready());
259 // Verify the data in the store
261 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
263 optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
264 assertEquals("isPresent", true, optional.isPresent());
265 assertEquals("Data node", car, optional.get());
267 optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
268 assertEquals("isPresent", true, optional.isPresent());
269 assertEquals("Data node", person, optional.get());
276 public void testSingleTransactionsWritesInQuickSuccession() throws Exception{
277 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
278 try (DistributedDataStore dataStore = setupDistributedDataStore(
279 "testSingleTransactionsWritesInQuickSuccession", "cars-1")) {
281 DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
283 DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
284 writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
285 writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
286 doCommit(writeTx.ready());
288 writeTx = txChain.newWriteOnlyTransaction();
291 for(int i = 0; i < nCars; i++) {
292 writeTx.write(CarsModel.newCarPath("car" + i),
293 CarsModel.newCarEntry("car" + i, BigInteger.valueOf(20000)));
296 doCommit(writeTx.ready());
298 Optional<NormalizedNode<?, ?>> optional = txChain.newReadOnlyTransaction().read(
299 CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS);
300 assertEquals("isPresent", true, optional.isPresent());
301 assertEquals("# cars", nCars, ((Collection<?>)optional.get().getValue()).size());
306 private void testTransactionWritesWithShardNotInitiallyReady(final String testName,
307 final boolean writeOnly) throws Exception {
308 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
309 String shardName = "test-1";
311 // Setup the InMemoryJournal to block shard recovery to ensure the shard isn't
312 // initialized until we create and submit the write the Tx.
313 String persistentID = String.format("member-1-shard-%s-%s", shardName, testName);
314 CountDownLatch blockRecoveryLatch = new CountDownLatch(1);
315 InMemoryJournal.addBlockReadMessagesLatch(persistentID, blockRecoveryLatch);
317 try (DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName)) {
319 // Create the write Tx
321 final DOMStoreWriteTransaction writeTx = writeOnly ? dataStore.newWriteOnlyTransaction() :
322 dataStore.newReadWriteTransaction();
323 assertNotNull("newReadWriteTransaction returned null", writeTx);
325 // Do some modification operations and ready the Tx on a separate thread.
327 final YangInstanceIdentifier listEntryPath = YangInstanceIdentifier.builder(
328 TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME,
329 TestModel.ID_QNAME, 1).build();
331 final AtomicReference<DOMStoreThreePhaseCommitCohort> txCohort = new AtomicReference<>();
332 final AtomicReference<Exception> caughtEx = new AtomicReference<>();
333 final CountDownLatch txReady = new CountDownLatch(1);
334 Thread txThread = new Thread() {
338 writeTx.write(TestModel.TEST_PATH,
339 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
341 writeTx.merge(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(
342 TestModel.OUTER_LIST_QNAME).build());
344 writeTx.write(listEntryPath, ImmutableNodes.mapEntry(
345 TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
347 writeTx.delete(listEntryPath);
349 txCohort.set(writeTx.ready());
350 } catch(Exception e) {
361 // Wait for the Tx operations to complete.
363 boolean done = Uninterruptibles.awaitUninterruptibly(txReady, 5, TimeUnit.SECONDS);
364 if(caughtEx.get() != null) {
365 throw caughtEx.get();
368 assertEquals("Tx ready", true, done);
370 // At this point the Tx operations should be waiting for the shard to initialize so
371 // trigger the latch to let the shard recovery to continue.
373 blockRecoveryLatch.countDown();
375 // Wait for the Tx commit to complete.
377 doCommit(txCohort.get());
379 // Verify the data in the store
381 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
383 Optional<NormalizedNode<?, ?>> optional = readTx.read(TestModel.TEST_PATH).
384 get(5, TimeUnit.SECONDS);
385 assertEquals("isPresent", true, optional.isPresent());
387 optional = readTx.read(TestModel.OUTER_LIST_PATH).get(5, TimeUnit.SECONDS);
388 assertEquals("isPresent", true, optional.isPresent());
390 optional = readTx.read(listEntryPath).get(5, TimeUnit.SECONDS);
391 assertEquals("isPresent", false, optional.isPresent());
397 public void testWriteOnlyTransactionWithShardNotInitiallyReady() throws Exception {
398 datastoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true);
399 testTransactionWritesWithShardNotInitiallyReady("testWriteOnlyTransactionWithShardNotInitiallyReady", true);
403 public void testReadWriteTransactionWithShardNotInitiallyReady() throws Exception {
404 testTransactionWritesWithShardNotInitiallyReady("testReadWriteTransactionWithShardNotInitiallyReady", false);
408 public void testTransactionReadsWithShardNotInitiallyReady() throws Exception {
409 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
410 String testName = "testTransactionReadsWithShardNotInitiallyReady";
411 String shardName = "test-1";
413 // Setup the InMemoryJournal to block shard recovery to ensure the shard isn't
414 // initialized until we create the Tx.
415 String persistentID = String.format("member-1-shard-%s-%s", shardName, testName);
416 CountDownLatch blockRecoveryLatch = new CountDownLatch(1);
417 InMemoryJournal.addBlockReadMessagesLatch(persistentID, blockRecoveryLatch);
419 try (DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName)) {
421 // Create the read-write Tx
423 final DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
424 assertNotNull("newReadWriteTransaction returned null", readWriteTx);
426 // Do some reads on the Tx on a separate thread.
428 final AtomicReference<CheckedFuture<Boolean, ReadFailedException>> txExistsFuture =
429 new AtomicReference<>();
430 final AtomicReference<CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException>>
431 txReadFuture = new AtomicReference<>();
432 final AtomicReference<Exception> caughtEx = new AtomicReference<>();
433 final CountDownLatch txReadsDone = new CountDownLatch(1);
434 Thread txThread = new Thread() {
438 readWriteTx.write(TestModel.TEST_PATH,
439 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
441 txExistsFuture.set(readWriteTx.exists(TestModel.TEST_PATH));
443 txReadFuture.set(readWriteTx.read(TestModel.TEST_PATH));
444 } catch(Exception e) {
448 txReadsDone.countDown();
455 // Wait for the Tx operations to complete.
457 boolean done = Uninterruptibles.awaitUninterruptibly(txReadsDone, 5, TimeUnit.SECONDS);
458 if(caughtEx.get() != null) {
459 throw caughtEx.get();
462 assertEquals("Tx reads done", true, done);
464 // At this point the Tx operations should be waiting for the shard to initialize so
465 // trigger the latch to let the shard recovery to continue.
467 blockRecoveryLatch.countDown();
469 // Wait for the reads to complete and verify.
471 assertEquals("exists", true, txExistsFuture.get().checkedGet(5, TimeUnit.SECONDS));
472 assertEquals("read", true, txReadFuture.get().checkedGet(5, TimeUnit.SECONDS).isPresent());
479 @Test(expected=NotInitializedException.class)
480 public void testTransactionCommitFailureWithShardNotInitialized() throws Throwable{
481 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
482 String testName = "testTransactionCommitFailureWithShardNotInitialized";
483 String shardName = "test-1";
485 // Set the shard initialization timeout low for the test.
487 datastoreContextBuilder.shardInitializationTimeout(300, TimeUnit.MILLISECONDS);
489 // Setup the InMemoryJournal to block shard recovery indefinitely.
491 String persistentID = String.format("member-1-shard-%s-%s", shardName, testName);
492 CountDownLatch blockRecoveryLatch = new CountDownLatch(1);
493 InMemoryJournal.addBlockReadMessagesLatch(persistentID, blockRecoveryLatch);
495 InMemoryJournal.addEntry(persistentID, 1, "Dummy data so akka will read from persistence");
497 try (DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName)) {
499 // Create the write Tx
501 final DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
502 assertNotNull("newReadWriteTransaction returned null", writeTx);
504 // Do some modifications and ready the Tx on a separate thread.
506 final AtomicReference<DOMStoreThreePhaseCommitCohort> txCohort = new AtomicReference<>();
507 final AtomicReference<Exception> caughtEx = new AtomicReference<>();
508 final CountDownLatch txReady = new CountDownLatch(1);
509 Thread txThread = new Thread() {
513 writeTx.write(TestModel.TEST_PATH,
514 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
516 txCohort.set(writeTx.ready());
517 } catch(Exception e) {
528 // Wait for the Tx operations to complete.
530 boolean done = Uninterruptibles.awaitUninterruptibly(txReady, 5, TimeUnit.SECONDS);
531 if(caughtEx.get() != null) {
532 throw caughtEx.get();
535 assertEquals("Tx ready", true, done);
537 // Wait for the commit to complete. Since the shard never initialized, the Tx should
538 // have timed out and throw an appropriate exception cause.
541 txCohort.get().canCommit().get(5, TimeUnit.SECONDS);
542 } catch(ExecutionException e) {
545 blockRecoveryLatch.countDown();
551 @Test(expected=NotInitializedException.class)
552 public void testTransactionReadFailureWithShardNotInitialized() throws Throwable{
553 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
554 String testName = "testTransactionReadFailureWithShardNotInitialized";
555 String shardName = "test-1";
557 // Set the shard initialization timeout low for the test.
559 datastoreContextBuilder.shardInitializationTimeout(300, TimeUnit.MILLISECONDS);
561 // Setup the InMemoryJournal to block shard recovery indefinitely.
563 String persistentID = String.format("member-1-shard-%s-%s", shardName, testName);
564 CountDownLatch blockRecoveryLatch = new CountDownLatch(1);
565 InMemoryJournal.addBlockReadMessagesLatch(persistentID, blockRecoveryLatch);
567 InMemoryJournal.addEntry(persistentID, 1, "Dummy data so akka will read from persistence");
569 try (DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName)) {
571 // Create the read-write Tx
573 final DOMStoreReadWriteTransaction readWriteTx = dataStore.newReadWriteTransaction();
574 assertNotNull("newReadWriteTransaction returned null", readWriteTx);
576 // Do a read on the Tx on a separate thread.
578 final AtomicReference<CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException>>
579 txReadFuture = new AtomicReference<>();
580 final AtomicReference<Exception> caughtEx = new AtomicReference<>();
581 final CountDownLatch txReadDone = new CountDownLatch(1);
582 Thread txThread = new Thread() {
586 readWriteTx.write(TestModel.TEST_PATH,
587 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
589 txReadFuture.set(readWriteTx.read(TestModel.TEST_PATH));
592 } catch(Exception e) {
596 txReadDone.countDown();
603 // Wait for the Tx operations to complete.
605 boolean done = Uninterruptibles.awaitUninterruptibly(txReadDone, 5, TimeUnit.SECONDS);
606 if(caughtEx.get() != null) {
607 throw caughtEx.get();
610 assertEquals("Tx read done", true, done);
612 // Wait for the read to complete. Since the shard never initialized, the Tx should
613 // have timed out and throw an appropriate exception cause.
616 txReadFuture.get().checkedGet(5, TimeUnit.SECONDS);
617 } catch(ReadFailedException e) {
620 blockRecoveryLatch.countDown();
626 private void testTransactionCommitFailureWithNoShardLeader(final boolean writeOnly, final String testName) throws Throwable {
627 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
628 String shardName = "default";
630 // We don't want the shard to become the leader so prevent shard elections.
631 datastoreContextBuilder.customRaftPolicyImplementation(
632 "org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy");
634 // The ShardManager uses the election timeout for FindPrimary so reset it low so it will timeout quickly.
635 datastoreContextBuilder.shardHeartbeatIntervalInMillis(100).shardElectionTimeoutFactor(1).
636 shardInitializationTimeout(200, TimeUnit.MILLISECONDS);
638 try (DistributedDataStore dataStore = setupDistributedDataStore(testName, false, shardName)) {
640 Object result = dataStore.getActorContext().executeOperation(
641 dataStore.getActorContext().getShardManager(), new FindLocalShard(shardName, true));
642 assertTrue("Expected LocalShardFound. Actual: " + result, result instanceof LocalShardFound);
644 // Create the write Tx.
646 try (final DOMStoreWriteTransaction writeTx = writeOnly ? dataStore.newWriteOnlyTransaction() :
647 dataStore.newReadWriteTransaction()) {
648 assertNotNull("newReadWriteTransaction returned null", writeTx);
650 // Do some modifications and ready the Tx on a separate thread.
652 final AtomicReference<DOMStoreThreePhaseCommitCohort> txCohort = new AtomicReference<>();
653 final AtomicReference<Exception> caughtEx = new AtomicReference<>();
654 final CountDownLatch txReady = new CountDownLatch(1);
655 Thread txThread = new Thread() {
659 writeTx.write(TestModel.JUNK_PATH,
660 ImmutableNodes.containerNode(TestModel.JUNK_QNAME));
662 txCohort.set(writeTx.ready());
663 } catch(Exception e) {
674 // Wait for the Tx operations to complete.
676 boolean done = Uninterruptibles.awaitUninterruptibly(txReady, 5, TimeUnit.SECONDS);
677 if(caughtEx.get() != null) {
678 throw caughtEx.get();
681 assertEquals("Tx ready", true, done);
683 // Wait for the commit to complete. Since no shard leader was elected in time, the Tx
684 // should have timed out and throw an appropriate exception cause.
687 txCohort.get().canCommit().get(5, TimeUnit.SECONDS);
688 } catch(ExecutionException e) {
696 @Test(expected=NoShardLeaderException.class)
697 public void testWriteOnlyTransactionCommitFailureWithNoShardLeader() throws Throwable {
698 datastoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true);
699 testTransactionCommitFailureWithNoShardLeader(true, "testWriteOnlyTransactionCommitFailureWithNoShardLeader");
702 @Test(expected=NoShardLeaderException.class)
703 public void testReadWriteTransactionCommitFailureWithNoShardLeader() throws Throwable {
704 testTransactionCommitFailureWithNoShardLeader(false, "testReadWriteTransactionCommitFailureWithNoShardLeader");
708 public void testTransactionAbort() throws Exception{
709 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
710 try (DistributedDataStore dataStore =
711 setupDistributedDataStore("transactionAbortIntegrationTest", "test-1")) {
713 DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
714 assertNotNull("newWriteOnlyTransaction returned null", writeTx);
716 writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
718 DOMStoreThreePhaseCommitCohort cohort = writeTx.ready();
720 cohort.canCommit().get(5, TimeUnit.SECONDS);
722 cohort.abort().get(5, TimeUnit.SECONDS);
724 testWriteTransaction(dataStore, TestModel.TEST_PATH,
725 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
731 public void testTransactionChainWithSingleShard() throws Exception{
732 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
733 try (DistributedDataStore dataStore =
734 setupDistributedDataStore("testTransactionChainWithSingleShard", "test-1")) {
736 // 1. Create a Tx chain and write-only Tx
738 DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
740 DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
741 assertNotNull("newWriteOnlyTransaction returned null", writeTx);
743 // 2. Write some data
745 NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
746 writeTx.write(TestModel.TEST_PATH, testNode);
748 // 3. Ready the Tx for commit
750 final DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
752 // 4. Commit the Tx on another thread that first waits for the second read Tx.
754 final CountDownLatch continueCommit1 = new CountDownLatch(1);
755 final CountDownLatch commit1Done = new CountDownLatch(1);
756 final AtomicReference<Exception> commit1Error = new AtomicReference<>();
761 continueCommit1.await();
763 } catch (Exception e) {
766 commit1Done.countDown();
771 // 5. Create a new read Tx from the chain to read and verify the data from the first
772 // Tx is visible after being readied.
774 DOMStoreReadTransaction readTx = txChain.newReadOnlyTransaction();
775 Optional<NormalizedNode<?, ?>> optional = readTx.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
776 assertEquals("isPresent", true, optional.isPresent());
777 assertEquals("Data node", testNode, optional.get());
779 // 6. Create a new RW Tx from the chain, write more data, and ready it
781 DOMStoreReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
782 MapNode outerNode = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build();
783 rwTx.write(TestModel.OUTER_LIST_PATH, outerNode);
785 DOMStoreThreePhaseCommitCohort cohort2 = rwTx.ready();
787 // 7. Create a new read Tx from the chain to read the data from the last RW Tx to
788 // verify it is visible.
790 readTx = txChain.newReadWriteTransaction();
791 optional = readTx.read(TestModel.OUTER_LIST_PATH).get(5, TimeUnit.SECONDS);
792 assertEquals("isPresent", true, optional.isPresent());
793 assertEquals("Data node", outerNode, optional.get());
795 // 8. Wait for the 2 commits to complete and close the chain.
797 continueCommit1.countDown();
798 Uninterruptibles.awaitUninterruptibly(commit1Done, 5, TimeUnit.SECONDS);
800 if(commit1Error.get() != null) {
801 throw commit1Error.get();
808 // 9. Create a new read Tx from the data store and verify committed data.
810 readTx = dataStore.newReadOnlyTransaction();
811 optional = readTx.read(TestModel.OUTER_LIST_PATH).get(5, TimeUnit.SECONDS);
812 assertEquals("isPresent", true, optional.isPresent());
813 assertEquals("Data node", outerNode, optional.get());
819 public void testTransactionChainWithMultipleShards() throws Exception{
820 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
821 try (DistributedDataStore dataStore = setupDistributedDataStore("testTransactionChainWithMultipleShards",
822 "cars-1", "people-1")) {
824 DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
826 DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
827 assertNotNull("newWriteOnlyTransaction returned null", writeTx);
829 writeTx.write(CarsModel.BASE_PATH, CarsModel.emptyContainer());
830 writeTx.write(PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
832 writeTx.write(CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
833 writeTx.write(PeopleModel.PERSON_LIST_PATH, PeopleModel.newPersonMapNode());
835 DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
837 DOMStoreReadWriteTransaction readWriteTx = txChain.newReadWriteTransaction();
839 MapEntryNode car = CarsModel.newCarEntry("optima", BigInteger.valueOf(20000));
840 YangInstanceIdentifier carPath = CarsModel.newCarPath("optima");
841 readWriteTx.write(carPath, car);
843 MapEntryNode person = PeopleModel.newPersonEntry("jack");
844 YangInstanceIdentifier personPath = PeopleModel.newPersonPath("jack");
845 readWriteTx.merge(personPath, person);
847 Optional<NormalizedNode<?, ?>> optional = readWriteTx.read(carPath).get(5, TimeUnit.SECONDS);
848 assertEquals("isPresent", true, optional.isPresent());
849 assertEquals("Data node", car, optional.get());
851 optional = readWriteTx.read(personPath).get(5, TimeUnit.SECONDS);
852 assertEquals("isPresent", true, optional.isPresent());
853 assertEquals("Data node", person, optional.get());
855 DOMStoreThreePhaseCommitCohort cohort2 = readWriteTx.ready();
857 writeTx = txChain.newWriteOnlyTransaction();
859 writeTx.delete(carPath);
861 DOMStoreThreePhaseCommitCohort cohort3 = writeTx.ready();
863 ListenableFuture<Boolean> canCommit1 = cohort1.canCommit();
864 ListenableFuture<Boolean> canCommit2 = cohort2.canCommit();
866 doCommit(canCommit1, cohort1);
867 doCommit(canCommit2, cohort2);
872 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
874 optional = readTx.read(carPath).get(5, TimeUnit.SECONDS);
875 assertEquals("isPresent", false, optional.isPresent());
877 optional = readTx.read(personPath).get(5, TimeUnit.SECONDS);
878 assertEquals("isPresent", true, optional.isPresent());
879 assertEquals("Data node", person, optional.get());
885 public void testCreateChainedTransactionsInQuickSuccession() throws Exception{
886 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
887 try (DistributedDataStore dataStore = setupDistributedDataStore(
888 "testCreateChainedTransactionsInQuickSuccession", "cars-1")) {
890 ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
891 ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
892 LogicalDatastoreType.CONFIGURATION, dataStore).build(), MoreExecutors.directExecutor());
894 TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
895 DOMTransactionChain txChain = broker.createTransactionChain(listener);
897 List<CheckedFuture<Void, TransactionCommitFailedException>> futures = new ArrayList<>();
899 DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
900 writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, CarsModel.emptyContainer());
901 writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
902 futures.add(writeTx.submit());
905 for(int i = 0; i < nCars; i++) {
906 DOMDataReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
908 rwTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.newCarPath("car" + i),
909 CarsModel.newCarEntry("car" + i, BigInteger.valueOf(20000)));
911 futures.add(rwTx.submit());
914 for(CheckedFuture<Void, TransactionCommitFailedException> f: futures) {
918 Optional<NormalizedNode<?, ?>> optional = txChain.newReadOnlyTransaction().read(
919 LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS);
920 assertEquals("isPresent", true, optional.isPresent());
921 assertEquals("# cars", nCars, ((Collection<?>)optional.get().getValue()).size());
931 public void testCreateChainedTransactionAfterEmptyTxReadied() throws Exception{
932 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
933 try (DistributedDataStore dataStore = setupDistributedDataStore(
934 "testCreateChainedTransactionAfterEmptyTxReadied", "test-1")) {
936 DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
938 DOMStoreReadWriteTransaction rwTx1 = txChain.newReadWriteTransaction();
942 DOMStoreReadWriteTransaction rwTx2 = txChain.newReadWriteTransaction();
944 Optional<NormalizedNode<?, ?>> optional = rwTx2.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
945 assertEquals("isPresent", false, optional.isPresent());
953 public void testCreateChainedTransactionWhenPreviousNotReady() throws Throwable {
954 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
955 try (DistributedDataStore dataStore = setupDistributedDataStore(
956 "testCreateChainedTransactionWhenPreviousNotReady", "test-1")) {
958 final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
960 DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
961 assertNotNull("newWriteOnlyTransaction returned null", writeTx);
963 writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
965 // Try to create another Tx of each type - each should fail b/c the previous Tx wasn't
968 assertExceptionOnTxChainCreates(txChain, IllegalStateException.class);
974 public void testCreateChainedTransactionAfterClose() throws Throwable {
975 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
976 try (DistributedDataStore dataStore = setupDistributedDataStore(
977 "testCreateChainedTransactionAfterClose", "test-1")) {
979 DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
983 // Try to create another Tx of each type - should fail b/c the previous Tx was closed.
985 assertExceptionOnTxChainCreates(txChain, TransactionChainClosedException.class);
991 public void testChainWithReadOnlyTxAfterPreviousReady() throws Throwable {
992 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
993 try (DistributedDataStore dataStore = setupDistributedDataStore(
994 "testChainWithReadOnlyTxAfterPreviousReady", "test-1")) {
996 final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
998 // Create a write tx and submit.
1000 DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
1001 writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
1002 DOMStoreThreePhaseCommitCohort cohort1 = writeTx.ready();
1004 // Create read-only tx's and issue a read.
1006 CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture1 =
1007 txChain.newReadOnlyTransaction().read(TestModel.TEST_PATH);
1009 CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture2 =
1010 txChain.newReadOnlyTransaction().read(TestModel.TEST_PATH);
1012 // Create another write tx and issue the write.
1014 DOMStoreWriteTransaction writeTx2 = txChain.newWriteOnlyTransaction();
1015 writeTx2.write(TestModel.OUTER_LIST_PATH,
1016 ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
1018 // Ensure the reads succeed.
1020 assertEquals("isPresent", true, readFuture1.checkedGet(5, TimeUnit.SECONDS).isPresent());
1021 assertEquals("isPresent", true, readFuture2.checkedGet(5, TimeUnit.SECONDS).isPresent());
1023 // Ensure the writes succeed.
1025 DOMStoreThreePhaseCommitCohort cohort2 = writeTx2.ready();
1030 assertEquals("isPresent", true, txChain.newReadOnlyTransaction().read(TestModel.OUTER_LIST_PATH).
1031 checkedGet(5, TimeUnit.SECONDS).isPresent());
1037 public void testChainedTransactionFailureWithSingleShard() throws Exception{
1038 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
1039 try (DistributedDataStore dataStore = setupDistributedDataStore(
1040 "testChainedTransactionFailureWithSingleShard", "cars-1")) {
1042 ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
1043 ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
1044 LogicalDatastoreType.CONFIGURATION, dataStore).build(), MoreExecutors.directExecutor());
1046 TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
1047 DOMTransactionChain txChain = broker.createTransactionChain(listener);
1049 DOMDataReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
1051 ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
1052 new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)).
1053 withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();
1055 rwTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);
1058 rwTx.submit().checkedGet(5, TimeUnit.SECONDS);
1059 fail("Expected TransactionCommitFailedException");
1060 } catch (TransactionCommitFailedException e) {
1064 verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(rwTx), any(Throwable.class));
1073 public void testChainedTransactionFailureWithMultipleShards() throws Exception{
1074 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
1075 try (DistributedDataStore dataStore = setupDistributedDataStore(
1076 "testChainedTransactionFailureWithMultipleShards", "cars-1", "people-1")) {
1078 ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
1079 ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
1080 LogicalDatastoreType.CONFIGURATION, dataStore).build(), MoreExecutors.directExecutor());
1082 TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
1083 DOMTransactionChain txChain = broker.createTransactionChain(listener);
1085 DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
1087 writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
1089 ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
1090 new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)).
1091 withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();
1093 // Note that merge will validate the data and fail but put succeeds b/c deep validation is not
1094 // done for put for performance reasons.
1095 writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);
1098 writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
1099 fail("Expected TransactionCommitFailedException");
1100 } catch (TransactionCommitFailedException e) {
1104 verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));
1113 public void testChangeListenerRegistration() throws Exception{
1114 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
1115 try (DistributedDataStore dataStore =
1116 setupDistributedDataStore("testChangeListenerRegistration", "test-1")) {
1118 testWriteTransaction(dataStore, TestModel.TEST_PATH,
1119 ImmutableNodes.containerNode(TestModel.TEST_QNAME));
1121 MockDataChangeListener listener = new MockDataChangeListener(1);
1123 ListenerRegistration<MockDataChangeListener>
1124 listenerReg = dataStore.registerChangeListener(TestModel.TEST_PATH, listener,
1125 DataChangeScope.SUBTREE);
1127 assertNotNull("registerChangeListener returned null", listenerReg);
1129 // Wait for the initial notification
1131 listener.waitForChangeEvents(TestModel.TEST_PATH);
1137 testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH,
1138 ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
1140 YangInstanceIdentifier listPath = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH).
1141 nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1).build();
1142 testWriteTransaction(dataStore, listPath,
1143 ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1));
1145 // Wait for the 2 updates.
1147 listener.waitForChangeEvents(TestModel.OUTER_LIST_PATH, listPath);
1149 listenerReg.close();
1151 testWriteTransaction(dataStore, YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH).
1152 nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2).build(),
1153 ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2));
1155 listener.expectNoMoreChanges("Received unexpected change after close");
1161 public void testRestoreFromDatastoreSnapshot() throws Exception{
1162 new IntegrationTestKit(getSystem(), datastoreContextBuilder) {{
1163 String name = "transactionIntegrationTest";
1165 ContainerNode carsNode = CarsModel.newCarsNode(CarsModel.newCarsMapNode(
1166 CarsModel.newCarEntry("optima", BigInteger.valueOf(20000L)),
1167 CarsModel.newCarEntry("sportage", BigInteger.valueOf(30000L))));
1169 ShardDataTree dataTree = new ShardDataTree(SchemaContextHelper.full(), TreeType.OPERATIONAL);
1170 AbstractShardTest.writeToStore(dataTree, CarsModel.BASE_PATH, carsNode);
1171 NormalizedNode<?, ?> root = AbstractShardTest.readStore(dataTree.getDataTree(),
1172 YangInstanceIdentifier.builder().build());
1174 Snapshot carsSnapshot = Snapshot.create(SerializationUtils.serializeNormalizedNode(root),
1175 Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1");
1177 NormalizedNode<?, ?> peopleNode = PeopleModel.create();
1178 dataTree = new ShardDataTree(SchemaContextHelper.full(), TreeType.OPERATIONAL);
1179 AbstractShardTest.writeToStore(dataTree, PeopleModel.BASE_PATH, peopleNode);
1180 root = AbstractShardTest.readStore(dataTree.getDataTree(), YangInstanceIdentifier.builder().build());
1182 Snapshot peopleSnapshot = Snapshot.create(SerializationUtils.serializeNormalizedNode(root),
1183 Collections.<ReplicatedLogEntry>emptyList(), 2, 1, 2, 1, 1, "member-1");
1185 restoreFromSnapshot = new DatastoreSnapshot(name, null, Arrays.asList(
1186 new DatastoreSnapshot.ShardSnapshot("cars",
1187 org.apache.commons.lang3.SerializationUtils.serialize(carsSnapshot)),
1188 new DatastoreSnapshot.ShardSnapshot("people",
1189 org.apache.commons.lang3.SerializationUtils.serialize(peopleSnapshot))));
1191 try (DistributedDataStore dataStore = setupDistributedDataStore(name, "module-shards-member1.conf",
1192 true, "cars", "people")) {
1194 DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
1196 Optional<NormalizedNode<?, ?>> optional = readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
1197 assertEquals("isPresent", true, optional.isPresent());
1198 assertEquals("Data node", carsNode, optional.get());
1200 optional = readTx.read(PeopleModel.BASE_PATH).get(5, TimeUnit.SECONDS);
1201 assertEquals("isPresent", true, optional.isPresent());
1202 assertEquals("Data node", peopleNode, optional.get());