Search in sources :

Example 6 with Topology

use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetClusters.

/**
 * Test getClusters() method.
 */
@Test
public void testGetClusters() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    // test the getClusters() method.
    assertNotNull("The clusters should not be null.", topologyService.getClusters(topology));
    assertEquals("The clusters size did not match.", 2, topologyService.getClusters(topology).size());
}
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)

Example 7 with Topology

use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testGetClusterUsingNullClusterId.

/**
 * Test getCluster() method using a null cluster identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetClusterUsingNullClusterId() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    Set<TopologyCluster> clusters = topologyService.getClusters(topology);
    TopologyCluster cluster = clusters.stream().findFirst().get();
    // test the getCluster() method with a null cluster identifier
    TopologyCluster cluster1 = topologyService.getCluster(topology, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 8 with Topology

use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.

the class TopologyManagerTest method clusters.

@Test
public void clusters() {
    submitTopologyGraph();
    Topology topology = service.currentTopology();
    assertNotNull("topo expected", topology);
    assertEquals("wrong cluster count", 2, topology.clusterCount());
    assertEquals("wrong device count", 6, topology.deviceCount());
    assertEquals("wrong link count", 10, topology.linkCount());
    assertEquals("wrong cluster count", 2, service.getClusters(topology).size());
    TopologyCluster cluster = service.getCluster(topology, clusterId(0));
    assertEquals("wrong device count", 4, cluster.deviceCount());
    assertEquals("wrong device count", 4, service.getClusterDevices(topology, cluster).size());
    assertEquals("wrong link count", 8, cluster.linkCount());
    assertEquals("wrong link count", 8, service.getClusterLinks(topology, cluster).size());
}
Also used : Topology(org.onosproject.net.topology.Topology) TopologyCluster(org.onosproject.net.topology.TopologyCluster) Test(org.junit.Test)

Example 9 with Topology

use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.

the class TopologyManagerTest method precomputedPath.

@Test
public void precomputedPath() {
    submitTopologyGraph();
    Topology topology = service.currentTopology();
    Set<Path> paths = service.getPaths(topology, did("a"), did("c"));
    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(2), path.weight());
}
Also used : Path(org.onosproject.net.Path) Topology(org.onosproject.net.topology.Topology) Test(org.junit.Test)

Example 10 with Topology

use of org.onosproject.net.topology.Topology in project onos by opennetworkinglab.

the class TopologyManagerTest method basics.

@Test
public void basics() {
    Topology topology = service.currentTopology();
    assertNull("no topo expected", topology);
    submitTopologyGraph();
    validateEvents(TOPOLOGY_CHANGED);
    topology = service.currentTopology();
    assertTrue("should be latest", service.isLatest(topology));
    submitTopologyGraph();
    validateEvents(TOPOLOGY_CHANGED);
    assertFalse("should be latest", service.isLatest(topology));
}
Also used : Topology(org.onosproject.net.topology.Topology) Test(org.junit.Test)

Aggregations

Topology (org.onosproject.net.topology.Topology)45 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