use of org.onosproject.net.topology.LinkWeigherAdapter 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.topology.LinkWeigherAdapter 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());
}
use of org.onosproject.net.topology.LinkWeigherAdapter 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.LinkWeigherAdapter in project onos by opennetworkinglab.
the class TopologyManagerTest method onDemandPath.
@Test
public void onDemandPath() {
submitTopologyGraph();
Topology topology = service.currentTopology();
LinkWeigher weight = new LinkWeigherAdapter(3.3);
Set<Path> paths = service.getPaths(topology, did("a"), did("c"), weight);
assertEquals("wrong path count", 2, paths.size());
Path path = paths.iterator().next();
assertEquals("wrong path length", 2, path.links().size());
assertEquals("wrong path cost", ScalarWeight.toWeight(6.6), path.weight());
}
Aggregations