Search in sources :

Example 76 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method testAddTunnelId.

/**
 * Tests the addTunnelId, getTunnelIds(), removeTunnelId() methods with the store.
 */
@Test
public void testAddTunnelId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    ConnectPoint cp1 = new ConnectPoint(DID1, P1);
    ConnectPoint cp2 = new ConnectPoint(DID2, P1);
    VirtualNetworkIntent virtualIntent = VirtualNetworkIntent.builder().networkId(virtualNetwork.id()).key(Key.of("Test", APP_ID)).appId(APP_ID).ingressPoint(cp1).egressPoint(cp2).build();
    TunnelId tunnelId = TunnelId.valueOf("virtual tunnel");
    // Add the intent to tunnelID mapping to the store.
    manager.store.addTunnelId(virtualIntent, tunnelId);
    assertEquals("The tunnels size should match.", 1, manager.store.getTunnelIds(virtualIntent).size());
    // Remove the intent to tunnelID mapping from the store.
    manager.store.removeTunnelId(virtualIntent, tunnelId);
    assertTrue("The tunnels should be empty.", manager.store.getTunnelIds(virtualIntent).isEmpty());
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualNetworkIntent(org.onosproject.incubator.net.virtual.VirtualNetworkIntent) ConnectPoint(org.onosproject.net.ConnectPoint) TunnelId(org.onosproject.incubator.net.tunnel.TunnelId) Test(org.junit.Test)

Example 77 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method testGetVirtualNetworkForRegisteredNetwork.

/**
 * Test method {@code getVirtualNetwork()} for registered virtual network.
 */
@Test
public void testGetVirtualNetworkForRegisteredNetwork() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
    assertNotNull("Registered virtual network is null", manager.getVirtualNetwork(virtualNetwork.id()));
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Test(org.junit.Test)

Example 78 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork 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 79 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkPathManagerTest method testGetPathsWithNullSrc.

/**
 * Tests getPaths() using a null source device on an empty virtual network.
 */
@Test(expected = NullPointerException.class)
public void testGetPathsWithNullSrc() {
    VirtualNetwork vnet = setupEmptyVnet();
    PathService pathService = manager.get(vnet.id(), PathService.class);
    pathService.getPaths(null, DID3);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) PathService(org.onosproject.net.topology.PathService) Test(org.junit.Test)

Example 80 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkPathManagerTest method testGetPathsWithNullDest.

/**
 * Tests getPaths() using a null destination device on a non-empty virtual network.
 */
@Test(expected = NullPointerException.class)
public void testGetPathsWithNullDest() {
    VirtualNetwork vnet = setupVnet();
    PathService pathService = manager.get(vnet.id(), PathService.class);
    pathService.getPaths(DID1, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) PathService(org.onosproject.net.topology.PathService) Test(org.junit.Test)

Aggregations

VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)98 Test (org.junit.Test)82 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)38 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)24 ConnectPoint (org.onosproject.net.ConnectPoint)24 TopologyService (org.onosproject.net.topology.TopologyService)24 Topology (org.onosproject.net.topology.Topology)23 DeviceService (org.onosproject.net.device.DeviceService)15 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 DisjointPath (org.onosproject.net.DisjointPath)11 LinkService (org.onosproject.net.link.LinkService)10 ArrayList (java.util.ArrayList)8 HostService (org.onosproject.net.host.HostService)8 TenantId (org.onosproject.net.TenantId)7 Path (org.onosproject.net.Path)6 PathService (org.onosproject.net.topology.PathService)5 TopologyCluster (org.onosproject.net.topology.TopologyCluster)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 Link (org.onosproject.net.Link)4