Search in sources :

Example 21 with Topology

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));
    });
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualNetworkProviderService(org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService) ArrayList(java.util.ArrayList) Event(org.onosproject.event.Event) VirtualNetworkEvent(org.onosproject.incubator.net.virtual.VirtualNetworkEvent) Topology(org.onosproject.net.topology.Topology) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 22 with Topology

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

Example 23 with Topology

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

Example 24 with Topology

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());
}
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 25 with Topology

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

Aggregations

Topology (org.onosproject.net.topology.Topology)46 TopologyService (org.onosproject.net.topology.TopologyService)30 Test (org.junit.Test)29 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)23 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)12 TopologyCluster (org.onosproject.net.topology.TopologyCluster)11 DisjointPath (org.onosproject.net.DisjointPath)9 Path (org.onosproject.net.Path)9 ConnectPoint (org.onosproject.net.ConnectPoint)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 Link (org.onosproject.net.Link)7 Path (javax.ws.rs.Path)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)5 DeviceId (org.onosproject.net.DeviceId)5 LinkWeigher (org.onosproject.net.topology.LinkWeigher)5 Event (org.onosproject.event.Event)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ClusterEvent (org.onosproject.cluster.ClusterEvent)2