Search in sources :

Example 1 with LinkWeigherAdapter

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 2 with LinkWeigherAdapter

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) PathService(org.onosproject.net.topology.PathService) LinkWeigher(org.onosproject.net.topology.LinkWeigher) DeviceId(org.onosproject.net.DeviceId) DisjointPath(org.onosproject.net.DisjointPath) Test(org.junit.Test)

Example 3 with LinkWeigherAdapter

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 4 with LinkWeigherAdapter

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());
}
Also used : LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) Path(org.onosproject.net.Path) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Topology(org.onosproject.net.topology.Topology) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 LinkWeigher (org.onosproject.net.topology.LinkWeigher)4 LinkWeigherAdapter (org.onosproject.net.topology.LinkWeigherAdapter)4 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)3 DisjointPath (org.onosproject.net.DisjointPath)3 Path (org.onosproject.net.Path)3 Topology (org.onosproject.net.topology.Topology)3 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)2 TopologyService (org.onosproject.net.topology.TopologyService)2 DeviceId (org.onosproject.net.DeviceId)1 PathService (org.onosproject.net.topology.PathService)1