use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPaths.
/**
* Test getDisjointPaths() methods.
*/
@Test
public void testGetDisjointPaths() {
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 getDisjointPaths() method.
Set<DisjointPath> paths = topologyService.getDisjointPaths(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 getDisjointPaths() method using a weight.
LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
}
use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPathsUsingNullDstDeviceId.
/**
* Test getDisjointPaths() methods using a null dst device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetDisjointPathsUsingNullDstDeviceId() {
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 getDisjointPaths() method using a null dst device identifier.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), null);
}
use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class AbstractPathServiceTest method checkDisjointPaths.
private void checkDisjointPaths(Set<DisjointPath> paths) {
assertThat(paths, notNullValue());
assertThat(paths, hasSize(1));
Path path = paths.iterator().next();
checkPathValues(path);
}
use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class AbstractPathService method edgeToEdgePathD.
// Produces a direct edge-to-edge path.
private DisjointPath edgeToEdgePathD(EdgeLink srcLink, EdgeLink dstLink, DisjointPath path, LinkWeigher weigher) {
Path primary = null;
Path backup = null;
if (path != null) {
primary = path.primary();
backup = path.backup();
}
if (backup == null) {
return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher));
}
return new DefaultDisjointPath(PID, (DefaultPath) edgeToEdgePath(srcLink, dstLink, primary, weigher), (DefaultPath) edgeToEdgePath(srcLink, dstLink, backup, weigher));
}
use of org.onosproject.net.DisjointPath in project onos by opennetworkinglab.
the class VirtualNetworkPathManagerTest method testGetPathsOnNonEmptyVnet.
/**
* Tests getPaths(), getDisjointPaths()
* on a non-empty virtual network.
*/
@Test
public void testGetPathsOnNonEmptyVnet() {
VirtualNetwork vnet = setupVnet();
PathService pathService = manager.get(vnet.id(), PathService.class);
// src and dest are in vnet and are connected by a virtual link
Set<Path> paths = pathService.getPaths(DID1, DID3);
validatePaths(paths, 1, 1, DID1, DID3, 1.0);
LinkWeigher linkWeight = new LinkWeigherAdapter(2.0);
paths = pathService.getPaths(DID1, DID3, linkWeight);
validatePaths(paths, 1, 1, DID1, DID3, 2.0);
Set<DisjointPath> disjointPaths = pathService.getDisjointPaths(DID1, DID3);
validatePaths(disjointPaths, 1, 1, DID1, DID3, 1.0);
disjointPaths = pathService.getDisjointPaths(DID1, DID3, linkWeight);
validatePaths(disjointPaths, 1, 1, DID1, DID3, 2.0);
// src and dest are in vnet but are not connected
paths = pathService.getPaths(DID4, DID3);
assertEquals("incorrect path count", 0, paths.size());
disjointPaths = pathService.getDisjointPaths(DID4, DID3);
assertEquals("incorrect path count", 0, disjointPaths.size());
// src is in vnet, but dest is not in vnet.
DeviceId nonExistentDeviceId = DeviceId.deviceId("nonExistentDevice");
paths = pathService.getPaths(DID2, nonExistentDeviceId);
assertEquals("incorrect path count", 0, paths.size());
disjointPaths = pathService.getDisjointPaths(DID2, nonExistentDeviceId);
assertEquals("incorrect path count", 0, disjointPaths.size());
}
Aggregations