Search in sources :

Example 61 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetDeviceIngressLinksByNullId.

/**
 * Tests querying for device ingress links using a null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetDeviceIngressLinksByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getDeviceIngressLinks() method with a null device identifier.
    linkService.getDeviceIngressLinks(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkService(org.onosproject.net.link.LinkService) Test(org.junit.Test)

Example 62 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetEgressLinksByNullId.

/**
 * Tests querying for egress links using a null connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetEgressLinksByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getEgressLinks() method with a null connect point.
    linkService.getEgressLinks(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkService(org.onosproject.net.link.LinkService) Test(org.junit.Test)

Example 63 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetLinks.

/**
 * Tests the getLinks(), getActiveLinks(), getLinkCount(), getLink(),
 * getLinks(ConnectPoint), getDeviceLinks(), getDeviceEgressLinks(), getDeviceIngressLinks(),
 * getEgressLinks(), getIngressLinks() methods.
 */
@Test
public void testGetLinks() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), src.deviceId(), src.port(), new ConnectPoint(srcVirtualDevice.id(), src.port()));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), dst.deviceId(), dst.port(), new ConnectPoint(dstVirtualDevice.id(), dst.port()));
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), dst, src);
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getLinks() method
    Iterator<Link> it = linkService.getLinks().iterator();
    assertEquals("The link set size did not match.", 2, Iterators.size(it));
    // test the getActiveLinks() method where all links are INACTIVE
    Iterator<Link> it2 = linkService.getActiveLinks().iterator();
    assertEquals("The link set size did not match.", 0, Iterators.size(it2));
    // test the getActiveLinks() method where one link is ACTIVE
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    Iterator<Link> it3 = linkService.getActiveLinks().iterator();
    assertEquals("The link set size did not match.", 1, Iterators.size(it3));
    // test the getLinkCount() method
    assertEquals("The link set size did not match.", 2, linkService.getLinkCount());
    // test the getLink() method
    assertEquals("The expect link did not match.", link1, linkService.getLink(src, dst));
    assertEquals("The expect link did not match.", link2, linkService.getLink(dst, src));
    assertNotEquals("The expect link should not have matched.", link1, linkService.getLink(dst, src));
    // test the getLinks(ConnectPoint) method
    assertEquals("The link set size did not match.", 2, linkService.getLinks(src).size());
    assertEquals("The link set size did not match.", 2, linkService.getLinks(dst).size());
    ConnectPoint connectPoint = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(3));
    assertEquals("The link set size did not match.", 0, linkService.getLinks(connectPoint).size());
    // test the getDeviceLinks() method
    assertEquals("The link set size did not match.", 2, linkService.getDeviceLinks(DID1).size());
    assertEquals("The link set size did not match.", 2, linkService.getDeviceLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceLinks(DID3).size());
    // test the getDeviceEgressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getDeviceEgressLinks(DID1).size());
    assertEquals("The link set size did not match.", 1, linkService.getDeviceEgressLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceEgressLinks(DID3).size());
    // test the getDeviceIngressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getDeviceIngressLinks(DID1).size());
    assertEquals("The link set size did not match.", 1, linkService.getDeviceIngressLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceIngressLinks(DID3).size());
    // test the getEgressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getEgressLinks(src).size());
    assertEquals("The link set size did not match.", 1, linkService.getEgressLinks(dst).size());
    assertEquals("The link set size did not match.", 0, linkService.getEgressLinks(connectPoint).size());
    // test the getIngressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getIngressLinks(src).size());
    assertEquals("The link set size did not match.", 1, linkService.getIngressLinks(dst).size());
    assertEquals("The link set size did not match.", 0, linkService.getIngressLinks(connectPoint).size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) LinkService(org.onosproject.net.link.LinkService) Link(org.onosproject.net.Link) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 64 with VirtualNetwork

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

the class VirtualNetworkManagerTest method testGetTenantIdForRegisteredVirtualNetwork.

/**
 * Test method {@code getTenantId()} for registered virtual network.
 */
@Test
public void testGetTenantIdForRegisteredVirtualNetwork() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
    TenantId tenantId = manager.getTenantId(virtualNetwork.id());
    assertThat(tenantId.toString(), is(tenantIdValue1));
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) Test(org.junit.Test)

Example 65 with VirtualNetwork

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

the class VirtualNetworkManagerTest method testCreateVirtualHostWithNoNetwork.

/**
 * Tests adding a virtual host where no virtual network exists.
 */
@Test(expected = IllegalStateException.class)
public void testCreateVirtualHostWithNoNetwork() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
    manager.createVirtualHost(virtualNetwork.id(), HID1, null, null, null, null);
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) 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