Search in sources :

Example 1 with LinkKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey in project openflowplugin by opendaylight.

the class FlowCapableTopologyExporterTest method testOnLinkRemovedLinkDoesNotExist.

@Test
public void testOnLinkRemovedLinkDoesNotExist() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
    InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
    InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    doReturn(Futures.immediateCheckedFuture(Optional.<Link>absent())).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
    exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
    waitForSubmit(submitLatch);
    verify(mockTx, never()).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) LinkKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey) LinkRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito.doReturn(org.mockito.Mockito.doReturn) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) LinkId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId) Test(org.junit.Test)

Example 2 with LinkKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey in project openflowplugin by opendaylight.

the class FlowCapableTopologyExporterTest method testOnLinkRemoved.

@Test
public void testOnLinkRemoved() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
    InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
    InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
    Link link = newLink(sourceNodeConnKey.getId().getValue(), newSourceTp(sourceNodeConnKey.getId().getValue()), newDestTp(destNodeConnKey.getId().getValue()));
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    final CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    doReturn(Futures.immediateCheckedFuture(Optional.of(link))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
    exporter.onLinkRemoved(new LinkRemovedBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
    waitForSubmit(submitLatch);
    verify(mockTx).delete(LogicalDatastoreType.OPERATIONAL, topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId()))));
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) LinkKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey) LinkRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito.doReturn(org.mockito.Mockito.doReturn) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) LinkId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId) Test(org.junit.Test)

Example 3 with LinkKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey in project bgpcep by opendaylight.

the class TunnelProgrammingTest method createLink.

private void createLink() throws TransactionCommitFailedException {
    final LinkBuilder linkBuilder = new LinkBuilder();
    linkBuilder.setSource(new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.SourceBuilder().setSourceNode(NODE1_ID).setSourceTp(TP1_ID).build());
    linkBuilder.setDestination(new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.link.attributes.DestinationBuilder().setDestNode(NODE2_ID).setDestTp(TP2_ID).build());
    linkBuilder.setLinkId(LINK1_ID);
    linkBuilder.setKey(new LinkKey(LINK1_ID));
    linkBuilder.addAugmentation(Link1.class, new Link1Builder().setSymbolicPathName(LINK1_ID.getValue()).build());
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.OPERATIONAL, TOPO_IID.builder().child(Link.class, new LinkKey(LINK1_ID)).build(), linkBuilder.build(), true);
    wTx.submit().checkedGet();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) LinkKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder) LinkBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder) Link1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.Link1Builder) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.DestinationBuilder)

Example 4 with LinkKey

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey in project openflowplugin by opendaylight.

the class FlowCapableTopologyExporterTest method testOnLinkDiscovered.

@Test
public void testOnLinkDiscovered() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey sourceNodeKey = newInvNodeKey("sourceNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey sourceNodeConnKey = newInvNodeConnKey("sourceTP");
    InstanceIdentifier<?> sourceConnID = newNodeConnID(sourceNodeKey, sourceNodeConnKey);
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey destNodeKey = newInvNodeKey("destNode");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey destNodeConnKey = newInvNodeConnKey("destTP");
    InstanceIdentifier<?> destConnID = newNodeConnID(destNodeKey, destNodeConnKey);
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    exporter.onLinkDiscovered(new LinkDiscoveredBuilder().setSource(new NodeConnectorRef(sourceConnID)).setDestination(new NodeConnectorRef(destConnID)).build());
    waitForSubmit(submitLatch);
    ArgumentCaptor<Link> mergedNode = ArgumentCaptor.forClass(Link.class);
    verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))), mergedNode.capture(), eq(true));
    assertEquals("Source node ID", "sourceNode", mergedNode.getValue().getSource().getSourceNode().getValue());
    assertEquals("Dest TP ID", "sourceTP", mergedNode.getValue().getSource().getSourceTp().getValue());
    assertEquals("Dest node ID", "destNode", mergedNode.getValue().getDestination().getDestNode().getValue());
    assertEquals("Dest TP ID", "destTP", mergedNode.getValue().getDestination().getDestTp().getValue());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) LinkKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey) CountDownLatch(java.util.concurrent.CountDownLatch) LinkDiscoveredBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder) Mockito.doReturn(org.mockito.Mockito.doReturn) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) LinkId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId) Test(org.junit.Test)

Aggregations

LinkKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 Mockito.doReturn (org.mockito.Mockito.doReturn)3 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)3 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)3 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)3 LinkId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.LinkId)3 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)3 LinkRemovedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 LinkDiscoveredBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder)1 Link1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.Link1Builder)1 DestinationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.DestinationBuilder)1 SourceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder)1 LinkBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder)1