use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdatedWithPortDown.
@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorUpdatedWithPortDown() {
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey("node1");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey("tp1");
final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")));
Topology topology = new TopologyBuilder().setLink(linkList).build();
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
setupStubbedSubmit(mockTx);
CountDownLatch deleteLatch = new CountDownLatch(1);
ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
setupStubbedDeletes(mockTx, deletedLinkIDs, deleteLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(provideFlowCapableNodeConnector(false, true));
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForDeletes(1, deleteLatch);
InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1")));
verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), any(TerminationPoint.class), eq(true));
assertDeletedIDs(new InstanceIdentifier[] { topologyIID.child(Link.class, linkList.get(0).getKey()) }, deletedLinkIDs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdated.
@Test
public void testOnNodeConnectorUpdated() {
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey("node1");
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey("tp1");
InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
CountDownLatch submitLatch = setupStubbedSubmit(mockTx);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch);
ArgumentCaptor<TerminationPoint> mergedNode = ArgumentCaptor.forClass(TerminationPoint.class);
NodeId expNodeId = new NodeId("node1");
TpId expTpId = new TpId("tp1");
InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(expNodeId)).child(TerminationPoint.class, new TerminationPointKey(expTpId));
verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), mergedNode.capture(), eq(true));
assertEquals("getTpId", expTpId, mergedNode.getValue().getTpId());
InventoryNodeConnector augmentation = mergedNode.getValue().getAugmentation(InventoryNodeConnector.class);
assertNotNull("Missing augmentation", augmentation);
assertEquals("getInventoryNodeConnectorRef", new NodeConnectorRef(invNodeConnID), augmentation.getInventoryNodeConnectorRef());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project controller by opendaylight.
the class DataServiceIT method test.
/**
* Ignored this, because classes here are constructed from
* very different class loader as MD-SAL is run into,
* this is code is run from different classloader.
*
* @throws Exception
*/
@Test
public void test() throws Exception {
BindingAwareConsumer consumer = session -> dataBroker = session.getSALService(DataBroker.class);
broker.registerConsumer(consumer);
assertNotNull(dataBroker);
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction);
InstanceIdentifier<UnorderedList> node1 = createNodeRef("0");
Optional<UnorderedList> node = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(node.isPresent());
UnorderedList nodeData1 = createNode("0");
transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
transaction.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertTrue(readedData.isPresent());
assertEquals(nodeData1.getKey(), readedData.get().getKey());
final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
assertNotNull(transaction2);
transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
transaction2.submit().checkedGet(5, TimeUnit.SECONDS);
Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).checkedGet(5, TimeUnit.SECONDS);
assertFalse(readedData2.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project controller by opendaylight.
the class EventSourceTopology method insert.
private void insert(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) {
final NodeKey nodeKey = sourcePath.getKey();
final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class);
final Node1 nodeAgument = new Node1Builder().setEventSourceNode(new NodeId(nodeKey.getNodeId().getValue())).build();
putData(OPERATIONAL, augmentPath, nodeAgument);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1 in project bgpcep by opendaylight.
the class Ipv4ReachabilityTopologyBuilderTest method testIpv4ReachabilityTopologyBuilder.
@Test
public void testIpv4ReachabilityTopologyBuilder() throws TransactionCommitFailedException, ReadFailedException {
// create route
updateIpv4Route(createIpv4Route(NEXT_HOP));
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
final TopologyTypes1 topologyTypes = topology.getTopologyTypes().getAugmentation(TopologyTypes1.class);
assertNotNull(topologyTypes);
assertNotNull(topologyTypes.getBgpIpv4ReachabilityTopology());
assertEquals(1, topology.getNode().size());
final Node node = topology.getNode().get(0);
assertEquals(NEXT_HOP, node.getNodeId().getValue());
assertEquals(ROUTE_IP4PREFIX, node.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
return topology;
});
// update route
updateIpv4Route(createIpv4Route(NEW_NEXT_HOP));
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final Node nodeUpdated = topology.getNode().get(0);
assertEquals(NEW_NEXT_HOP, nodeUpdated.getNodeId().getValue());
assertEquals(ROUTE_IP4PREFIX, nodeUpdated.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
return topology;
});
// delete route
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.ipv4RouteIID);
wTx.submit();
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(0, topology.getNode().size());
return topology;
});
this.ipv4TopoBuilder.close();
checkNotPresentOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier());
}
Aggregations