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);
}
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);
}
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());
}
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));
}
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);
}
Aggregations