+ }
+ }
+
+ @Test
+ public void testRestoreFromDatastoreSnapshot() throws Exception {
+ final IntegrationTestKit testKit = new IntegrationTestKit(getSystem(), datastoreContextBuilder);
+ final String name = "transactionIntegrationTest";
+
+ final ContainerNode carsNode = CarsModel.newCarsNode(
+ CarsModel.newCarsMapNode(CarsModel.newCarEntry("optima", BigInteger.valueOf(20000L)),
+ CarsModel.newCarEntry("sportage", BigInteger.valueOf(30000L))));
+
+ DataTree dataTree = new InMemoryDataTreeFactory().create(
+ DataTreeConfiguration.DEFAULT_OPERATIONAL, SchemaContextHelper.full());
+ AbstractShardTest.writeToStore(dataTree, CarsModel.BASE_PATH, carsNode);
+ NormalizedNode<?, ?> root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY);
+
+ final Snapshot carsSnapshot = Snapshot.create(
+ new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
+ Collections.emptyList(), 2, 1, 2, 1, 1, "member-1", null);
+
+ dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+ SchemaContextHelper.full());
+
+ final NormalizedNode<?, ?> peopleNode = PeopleModel.create();
+ AbstractShardTest.writeToStore(dataTree, PeopleModel.BASE_PATH, peopleNode);
+
+ root = AbstractShardTest.readStore(dataTree, YangInstanceIdentifier.EMPTY);
+
+ final Snapshot peopleSnapshot = Snapshot.create(
+ new ShardSnapshotState(new MetadataShardDataTreeSnapshot(root)),
+ Collections.emptyList(), 2, 1, 2, 1, 1, "member-1", null);
+
+ testKit.restoreFromSnapshot = new DatastoreSnapshot(name, null, Arrays.asList(
+ new DatastoreSnapshot.ShardSnapshot("cars", carsSnapshot),
+ new DatastoreSnapshot.ShardSnapshot("people", peopleSnapshot)));
+
+ try (AbstractDataStore dataStore = testKit.setupAbstractDataStore(
+ testParameter, name, "module-shards-member1.conf", true, "cars", "people")) {
+
+ final DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction();
+
+ // two reads
+ Optional<NormalizedNode<?, ?>> optional = readTx.read(CarsModel.BASE_PATH).get(5, TimeUnit.SECONDS);
+ assertTrue("isPresent", optional.isPresent());
+ assertEquals("Data node", carsNode, optional.get());