X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-topology-singleton%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Ftopology%2Fsingleton%2Fimpl%2FMountPointEndToEndTest.java;h=c23046e86f72b2aad8cdb0453888c2ad609604d3;hb=04ea29719433bc67129dfda1990bf517866e7d89;hp=b19a2cca2079ba04b035217c198ff925a06d1253;hpb=6ab1941217e38336ae5970a29505f9bb21d4ef21;p=netconf.git diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java index b19a2cca20..c23046e86f 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java @@ -44,6 +44,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.Map.Entry; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -63,7 +64,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -85,8 +85,10 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; import org.opendaylight.controller.md.sal.dom.broker.impl.mount.DOMMountPointServiceImpl; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener; +import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; +import org.opendaylight.mdsal.dom.api.DOMMountPointListener; import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -123,7 +125,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; @@ -167,7 +168,7 @@ public class MountPointEndToEndTest { @Mock private ScheduledThreadPool mockKeepaliveExecutor; @Mock private ActorSystemProvider mockMasterActorSystemProvider; - @Mock private MountProvisionListener masterMountPointListener; + @Mock private DOMMountPointListener masterMountPointListener; private final DOMMountPointService masterMountPointService = new DOMMountPointServiceImpl(); private final DOMRpcRouter deviceRpcService = new DOMRpcRouter(); private DOMClusterSingletonServiceProviderImpl masterClusterSingletonServiceProvider; @@ -180,7 +181,7 @@ public class MountPointEndToEndTest { @Mock private ActorSystemProvider mockSlaveActorSystemProvider; @Mock private ClusterSingletonServiceProvider mockSlaveClusterSingletonServiceProvider; @Mock private ClusterSingletonServiceRegistration mockSlaveClusterSingletonServiceReg; - @Mock private MountProvisionListener slaveMountPointListener; + @Mock private DOMMountPointListener slaveMountPointListener; private final DOMMountPointService slaveMountPointService = new DOMMountPointServiceImpl(); private DataBroker slaveDataBroker; private ActorSystem slaveSystem; @@ -194,7 +195,7 @@ public class MountPointEndToEndTest { private YangModuleInfo topModuleInfo; private SchemaPath putTopRpcSchemaPath; private SchemaPath getTopRpcSchemaPath; - private BindingToNormalizedNodeCodec bindingToNormalized; + private BindingNormalizedNodeSerializer bindingToNormalized; private YangInstanceIdentifier yangNodeInstanceId; private final TopDOMRpcImplementation topRpcImplementation = new TopDOMRpcImplementation(); @@ -231,15 +232,15 @@ public class MountPointEndToEndTest { LOG.info("****** Setup complete"); } - private void deleteCacheDir() { + private static void deleteCacheDir() { FileUtils.deleteQuietly(new File(NetconfTopologyUtils.CACHE_DIRECTORY)); } @After public void tearDown() throws Exception { deleteCacheDir(); - TestKit.shutdownActorSystem(slaveSystem, Boolean.TRUE); - TestKit.shutdownActorSystem(masterSystem, Boolean.TRUE); + TestKit.shutdownActorSystem(slaveSystem, true); + TestKit.shutdownActorSystem(masterSystem, true); } private void setupMaster() throws Exception { @@ -269,8 +270,8 @@ public class MountPointEndToEndTest { mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config, masterMountPointService, mockEncryptionService) { @Override - protected NetconfTopologyContext newNetconfTopologyContext(NetconfTopologySetup setup, - ServiceGroupIdentifier serviceGroupIdent, Timeout actorResponseWaitTime) { + protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, + final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) { NetconfTopologyContext context = super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime); NetconfTopologyContext spiedContext = spy(context); @@ -304,10 +305,10 @@ public class MountPointEndToEndTest { slaveNetconfTopologyManager = new NetconfTopologyManager(slaveDataBroker, mockRpcProviderRegistry, mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool, mockSlaveActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config, - slaveMountPointService, mockEncryptionService) { + slaveMountPointService, mockEncryptionService) { @Override - protected NetconfTopologyContext newNetconfTopologyContext(NetconfTopologySetup setup, - ServiceGroupIdentifier serviceGroupIdent, Timeout actorResponseWaitTime) { + protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, + final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime) { NetconfTopologyContext spiedContext = spy(super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime)); slaveNetconfTopologyContextFuture.set(spiedContext); @@ -321,12 +322,12 @@ public class MountPointEndToEndTest { slaveTxChain = slaveDataBroker.createTransactionChain(new TransactionChainListener() { @Override - public void onTransactionChainSuccessful(TransactionChain chain) { + public void onTransactionChainSuccessful(final TransactionChain chain) { } @Override - public void onTransactionChainFailed(TransactionChain chain, AsyncTransaction transaction, - Throwable cause) { + public void onTransactionChainFailed(final TransactionChain chain, + final AsyncTransaction transaction, final Throwable cause) { LOG.error("Slave transaction chain failed", cause); } }); @@ -451,7 +452,7 @@ public class MountPointEndToEndTest { Optional node = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_INSTANCE_ID).get(5, TimeUnit.SECONDS); assertTrue(node.isPresent()); - final NetconfNode netconfNode = node.get().getAugmentation(NetconfNode.class); + final NetconfNode netconfNode = node.get().augmentation(NetconfNode.class); return netconfNode.getConnectionStatus() != NetconfNodeConnectionStatus.ConnectionStatus.Connected; } }); @@ -466,7 +467,7 @@ public class MountPointEndToEndTest { verify(mockSlaveClusterSingletonServiceReg).close(); } - private void testDOMRpcService(DOMRpcService domRpcService) + private void testDOMRpcService(final DOMRpcService domRpcService) throws InterruptedException, ExecutionException, TimeoutException { testPutTopRpc(domRpcService, new DefaultDOMRpcResult((NormalizedNode)null)); testPutTopRpc(domRpcService, null); @@ -481,7 +482,7 @@ public class MountPointEndToEndTest { testFailedRpc(domRpcService, getTopRpcSchemaPath, null); } - private void testPutTopRpc(DOMRpcService domRpcService, DOMRpcResult result) + private void testPutTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException { ContainerNode putTopInput = bindingToNormalized.toNormalizedNodeRpcData( new PutTopInputBuilder().setTopLevelList(Arrays.asList(new TopLevelListBuilder().setName("one") @@ -489,13 +490,14 @@ public class MountPointEndToEndTest { testRpc(domRpcService, putTopRpcSchemaPath, putTopInput, result); } - private void testGetTopRpc(DOMRpcService domRpcService, DOMRpcResult result) + private void testGetTopRpc(final DOMRpcService domRpcService, final DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException { testRpc(domRpcService, getTopRpcSchemaPath, null, result); } - private void testRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode input, - DOMRpcResult result) throws InterruptedException, ExecutionException, TimeoutException { + private void testRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + final NormalizedNode input, final DOMRpcResult result) throws InterruptedException, + ExecutionException, TimeoutException { final DOMRpcResult actual = invokeRpc(domRpcService, schemaPath, input, Futures.immediateCheckedFuture(result)); if (result == null) { assertNull(actual); @@ -520,8 +522,8 @@ public class MountPointEndToEndTest { } } - private void testFailedRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode input) - throws InterruptedException, TimeoutException { + private void testFailedRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + final NormalizedNode input) throws InterruptedException, TimeoutException { try { invokeRpc(domRpcService, schemaPath, input, Futures.immediateFailedCheckedFuture( new ClusteringRpcException("mock"))); @@ -532,8 +534,8 @@ public class MountPointEndToEndTest { } } - private DOMRpcResult invokeRpc(DOMRpcService domRpcService, SchemaPath schemaPath, NormalizedNode input, - CheckedFuture returnFuture) + private DOMRpcResult invokeRpc(final DOMRpcService domRpcService, final SchemaPath schemaPath, + final NormalizedNode input, final CheckedFuture returnFuture) throws InterruptedException, ExecutionException, TimeoutException { topRpcImplementation.init(returnFuture); final ListenableFuture resultFuture = domRpcService.invokeRpc(schemaPath, input); @@ -543,7 +545,7 @@ public class MountPointEndToEndTest { return resultFuture.get(5, TimeUnit.SECONDS); } - private static void testDOMDataBrokerOperations(DOMDataBroker dataBroker) + private static void testDOMDataBrokerOperations(final DOMDataBroker dataBroker) throws InterruptedException, ExecutionException, TimeoutException { DOMDataWriteTransaction writeTx = dataBroker.newWriteOnlyTransaction(); @@ -573,7 +575,7 @@ public class MountPointEndToEndTest { assertTrue(readTx.cancel()); } - private static void writeNetconfNode(String cacheDir, DataBroker databroker) + private static void writeNetconfNode(final String cacheDir, final DataBroker databroker) throws InterruptedException, ExecutionException, TimeoutException { final NetconfNode netconfNode = new NetconfNodeBuilder() .setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))) @@ -596,8 +598,8 @@ public class MountPointEndToEndTest { writeTx.commit().get(5, TimeUnit.SECONDS); } - private static void verifyDataInStore(DOMDataReadTransaction readTx, YangInstanceIdentifier path, - NormalizedNode expNode) throws InterruptedException, ExecutionException, TimeoutException { + private static void verifyDataInStore(final DOMDataReadTransaction readTx, final YangInstanceIdentifier path, + final NormalizedNode expNode) throws InterruptedException, ExecutionException, TimeoutException { final Optional> read = readTx.read(LogicalDatastoreType.CONFIGURATION, path) .get(5, TimeUnit.SECONDS); assertTrue(read.isPresent()); @@ -607,7 +609,7 @@ public class MountPointEndToEndTest { assertTrue(exists); } - private static void verifyTopologyNodesCreated(DataBroker dataBroker) { + private static void verifyTopologyNodesCreated(final DataBroker dataBroker) { await().atMost(5, TimeUnit.SECONDS).until(() -> { try (ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction()) { Optional configTopology = readTx.read(LogicalDatastoreType.CONFIGURATION, @@ -622,7 +624,7 @@ public class MountPointEndToEndTest { private AbstractConcurrentDataBrokerTest newDataBrokerTest() throws Exception { AbstractConcurrentDataBrokerTest dataBrokerTest = new AbstractConcurrentDataBrokerTest(true) { @Override - protected Iterable getModuleInfos() throws Exception { + protected Set getModuleInfos() throws Exception { return ImmutableSet.of(BindingReflections.getModuleInfo(NetconfNode.class), BindingReflections.getModuleInfo(NetworkTopology.class), BindingReflections.getModuleInfo(Topology.class), @@ -635,26 +637,27 @@ public class MountPointEndToEndTest { return dataBrokerTest; } - private void awaitMountPointNotPresent(DOMMountPointService mountPointService) { + private void awaitMountPointNotPresent(final DOMMountPointService mountPointService) { await().atMost(5, TimeUnit.SECONDS).until( () -> !mountPointService.getMountPoint(yangNodeInstanceId).isPresent()); } - private static DOMDataBroker getDOMDataBroker(DOMMountPoint mountPoint) { + private static DOMDataBroker getDOMDataBroker(final DOMMountPoint mountPoint) { return getMountPointService(mountPoint, DOMDataBroker.class); } - private static DOMRpcService getDOMRpcService(DOMMountPoint mountPoint) { + private static DOMRpcService getDOMRpcService(final DOMMountPoint mountPoint) { return getMountPointService(mountPoint, DOMRpcService.class); } - private static T getMountPointService(DOMMountPoint mountPoint, Class serviceClass) { + private static T getMountPointService(final DOMMountPoint mountPoint, + final Class serviceClass) { final Optional maybeService = mountPoint.getService(serviceClass); assertTrue(maybeService.isPresent()); return maybeService.get(); } - private DOMMountPoint awaitMountPoint(DOMMountPointService mountPointService) { + private DOMMountPoint awaitMountPoint(final DOMMountPointService mountPointService) { await().atMost(5, TimeUnit.SECONDS).until(() -> { return mountPointService.getMountPoint(yangNodeInstanceId).isPresent(); }); @@ -662,7 +665,7 @@ public class MountPointEndToEndTest { return mountPointService.getMountPoint(yangNodeInstanceId).get(); } - private RpcDefinition findRpcDefinition(String rpc) { + private RpcDefinition findRpcDefinition(final String rpc) { Module topModule = deviceSchemaContext.findModule(TOP_MODULE_NAME, topModuleInfo.getName().getRevision()).get(); RpcDefinition rpcDefinition = null; for (RpcDefinition def: topModule.getRpcs()) { @@ -681,18 +684,18 @@ public class MountPointEndToEndTest { private volatile CheckedFuture returnFuture; @Override - public CheckedFuture invokeRpc(DOMRpcIdentifier rpc, - NormalizedNode input) { + public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, + final NormalizedNode input) { rpcInvokedFuture.set(new SimpleEntry<>(rpc, input)); return returnFuture; } - void init(CheckedFuture retFuture) { + void init(final CheckedFuture retFuture) { this.returnFuture = retFuture; rpcInvokedFuture = SettableFuture.create(); } - void verify(DOMRpcIdentifier expRpc, NormalizedNode expInput) + void verify(final DOMRpcIdentifier expRpc, final NormalizedNode expInput) throws InterruptedException, ExecutionException, TimeoutException { final Entry> actual = rpcInvokedFuture.get(5, TimeUnit.SECONDS); assertEquals(expRpc, actual.getKey());