X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FDistributedDataStoreIntegrationTest.java;h=482021aa8b78cfc01a2d503ec5c592730d9217a8;hp=2e5c69bf663524a7aa768c9ee2e99de6ec2e484c;hb=e254db554221f96c911f93a6a3e9a1c1e0238c3d;hpb=f41c5e6e6f6e10b36b1e4b1992877e38e718c8fb diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index 2e5c69bf66..482021aa8b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -59,7 +59,6 @@ import org.opendaylight.controller.cluster.datastore.messages.LocalShardFound; import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.MetadataShardDataTreeSnapshot; import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState; -import org.opendaylight.controller.cluster.datastore.utils.MockDataChangeListener; import org.opendaylight.controller.cluster.datastore.utils.MockDataTreeChangeListener; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; @@ -68,12 +67,10 @@ import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.PeopleModel; import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.common.api.ReadFailedException; import org.opendaylight.mdsal.common.api.TransactionChainClosedException; import org.opendaylight.mdsal.common.api.TransactionChainListener; -import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; import org.opendaylight.mdsal.dom.api.DOMTransactionChain; @@ -933,12 +930,12 @@ public class DistributedDataStoreIntegrationTest { final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class); DOMTransactionChain txChain = broker.createTransactionChain(listener); - final List> futures = new ArrayList<>(); + final List> futures = new ArrayList<>(); final DOMDataTreeWriteTransaction writeTx = txChain.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, CarsModel.emptyContainer()); writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode()); - futures.add(writeTx.submit()); + futures.add(writeTx.commit()); int numCars = 100; for (int i = 0; i < numCars; i++) { @@ -947,11 +944,11 @@ public class DistributedDataStoreIntegrationTest { rwTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.newCarPath("car" + i), CarsModel.newCarEntry("car" + i, BigInteger.valueOf(20000))); - futures.add(rwTx.submit()); + futures.add(rwTx.commit()); } - for (final CheckedFuture f : futures) { - f.checkedGet(); + for (final ListenableFuture f : futures) { + f.get(5, TimeUnit.SECONDS); } final Optional> optional = txChain.newReadOnlyTransaction() @@ -1104,9 +1101,9 @@ public class DistributedDataStoreIntegrationTest { writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData); try { - writeTx.submit().checkedGet(5, TimeUnit.SECONDS); + writeTx.commit().get(5, TimeUnit.SECONDS); fail("Expected TransactionCommitFailedException"); - } catch (final TransactionCommitFailedException e) { + } catch (final ExecutionException e) { // Expected } @@ -1150,9 +1147,9 @@ public class DistributedDataStoreIntegrationTest { // succeeds b/c deep validation is not // done for put for performance reasons. try { - writeTx.submit().checkedGet(5, TimeUnit.SECONDS); + writeTx.commit().get(5, TimeUnit.SECONDS); fail("Expected TransactionCommitFailedException"); - } catch (final TransactionCommitFailedException e) { + } catch (final ExecutionException e) { // Expected } @@ -1166,59 +1163,6 @@ public class DistributedDataStoreIntegrationTest { }; } - @Test - public void testChangeListenerRegistration() throws Exception { - new IntegrationTestKit(getSystem(), datastoreContextBuilder) { - { - try (AbstractDataStore dataStore = setupAbstractDataStore( - testParameter, "testChangeListenerRegistration", "test-1")) { - - testWriteTransaction(dataStore, TestModel.TEST_PATH, - ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - final MockDataChangeListener listener = new MockDataChangeListener(1); - - final ListenerRegistration listenerReg = dataStore - .registerChangeListener(TestModel.TEST_PATH, listener, DataChangeScope.SUBTREE); - - assertNotNull("registerChangeListener returned null", listenerReg); - - IntegrationTestKit.verifyShardState(dataStore, "test-1", - state -> assertEquals("getDataChangeListenerActors", 1, - state.getDataChangeListenerActors().size())); - - // Wait for the initial notification - listener.waitForChangeEvents(TestModel.TEST_PATH); - listener.reset(2); - - // Write 2 updates. - testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH, - ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()); - - YangInstanceIdentifier listPath = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH) - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1).build(); - testWriteTransaction(dataStore, listPath, - ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)); - - // Wait for the 2 updates. - listener.waitForChangeEvents(TestModel.OUTER_LIST_PATH, listPath); - listenerReg.close(); - - IntegrationTestKit.verifyShardState(dataStore, "test-1", - state -> assertEquals("getDataChangeListenerActors", 0, - state.getDataChangeListenerActors().size())); - - testWriteTransaction(dataStore, - YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH) - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2).build(), - ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)); - - listener.expectNoMoreChanges("Received unexpected change after close"); - } - } - }; - } - @Test public void testDataTreeChangeListenerRegistration() throws Exception { new IntegrationTestKit(getSystem(), datastoreContextBuilder) {