use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.
the class VirtualNetworkManagerTest method testTopologyChanged.
/**
* Test the topologyChanged() method.
*/
@Test
public void testTopologyChanged() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
VirtualNetworkProviderService providerService = manager.createProviderService(topologyProvider);
// Initial setup is two clusters of devices/links.
assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
// Adding this link will join the two clusters together.
List<Event> reasons = new ArrayList<>();
VirtualLink link = manager.createVirtualLink(virtualNetwork.id(), cp6, cp7);
virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.ACTIVE);
VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp7, cp6);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
Topology topology = topologyService.currentTopology();
providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
// Validate that all links are still active.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
});
virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.INACTIVE);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.INACTIVE);
providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
// Validate that all links are active again.
manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
});
}
use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullSrcDeviceId.
/**
* Test getPaths() method using a null src device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullSrcDeviceId() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method using a null src device identifier.
Set<Path> paths = topologyService.getPaths(topology, null, dstVirtualDevice.id());
}
use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testIsInfrastructure.
/**
* Test isInfrastructure() method.
*/
@Test
public void testIsInfrastructure() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID4);
ConnectPoint cp1 = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
ConnectPoint cp2 = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
// test the isInfrastructure() method.
Boolean isInfrastructure = topologyService.isInfrastructure(topology, cp1);
assertTrue("The connect point should be infrastructure.", isInfrastructure);
isInfrastructure = topologyService.isInfrastructure(topology, cp2);
assertFalse("The connect point should not be infrastructure.", isInfrastructure);
}
use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPaths.
/**
* Test getPaths() and getPaths() by weight methods.
*/
@Test
public void testGetPaths() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method.
Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id());
assertNotNull("The paths should not be null.", paths);
assertEquals("The paths size did not match.", 1, paths.size());
// test the getPaths() by weight method.
LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<Path> paths1 = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
Path path = paths1.iterator().next();
assertEquals("wrong path length", 1, path.links().size());
assertEquals("wrong path cost", ScalarWeight.toWeight(1.0), path.weight());
}
use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testCurrentTopology.
/**
* Tests the currentTopology() method.
*/
@Test
public void testCurrentTopology() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
assertNotNull("The topology should not be null.", topology);
}
Aggregations