Search in sources :

Example 56 with VirtualNetwork

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

the class VirtualNetworkHostManagerTest method testGetHostsOnEmptyVnet.

/**
 * Tests the getHosts(), getHost(), getHostsByXX(), getConnectedHosts() methods
 * on an empty virtual network.
 */
@Test
public void testGetHostsOnEmptyVnet() {
    VirtualNetwork virtualNetwork = setupEmptyVnet();
    HostService hostService = manager.get(virtualNetwork.id(), HostService.class);
    // test the getHosts() and getHostCount() methods
    Iterator<Host> itHosts = hostService.getHosts().iterator();
    assertEquals("The host set size did not match.", 0, Iterators.size(itHosts));
    assertEquals("The host count did not match.", 0, hostService.getHostCount());
    // test the getHost() method
    Host testHost = hostService.getHost(HID2);
    assertNull("The host should be null.", testHost);
    // test the getHostsByVlan(...) method
    Collection<Host> collHost = hostService.getHostsByVlan(VLAN1);
    assertEquals("The host set size did not match.", 0, collHost.size());
    // test the getHostsByMac(...) method
    collHost = hostService.getHostsByMac(MAC2);
    assertEquals("The host set size did not match.", 0, collHost.size());
    // test the getHostsByIp(...) method
    collHost = hostService.getHostsByIp(IP1);
    assertEquals("The host set size did not match.", 0, collHost.size());
    // test the getConnectedHosts(ConnectPoint) method
    collHost = hostService.getConnectedHosts(LOC1);
    assertEquals("The host set size did not match.", 0, collHost.size());
    // test the getConnectedHosts(DeviceId) method
    collHost = hostService.getConnectedHosts(DID2);
    assertEquals("The host set size did not match.", 0, collHost.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) HostService(org.onosproject.net.host.HostService) VirtualHost(org.onosproject.incubator.net.virtual.VirtualHost) Host(org.onosproject.net.Host) Test(org.junit.Test)

Example 57 with VirtualNetwork

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

the class VirtualNetworkIntentManagerTest method testCreateAndRemoveIntent.

/**
 * Tests the submit(), withdraw(), and purge() methods.
 */
@Test
public void testCreateAndRemoveIntent() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    Key intentKey = Key.of("test", APP_ID);
    List<Constraint> constraints = new ArrayList<>();
    constraints.add(new EncapsulationConstraint(EncapsulationType.VLAN));
    VirtualNetworkIntent virtualIntent = VirtualNetworkIntent.builder().networkId(virtualNetwork.id()).key(intentKey).appId(APP_ID).ingressPoint(cp1).egressPoint(cp5).constraints(constraints).build();
    // Test the submit() method.
    vnetIntentService.submit(virtualIntent);
    // Wait for the both intents to go into an INSTALLED state.
    try {
        if (!created.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for intent to get installed.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception during intent installation." + e.getMessage());
    }
    // Test the getIntentState() method
    assertEquals("The intent state did not match as expected.", IntentState.INSTALLED, vnetIntentService.getIntentState(virtualIntent.key()));
    // Test the withdraw() method.
    vnetIntentService.withdraw(virtualIntent);
    // Wait for the both intents to go into a WITHDRAWN state.
    try {
        if (!withdrawn.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for intent to get withdrawn.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception during intent withdrawal." + e.getMessage());
    }
    // Test the getIntentState() method
    assertEquals("The intent state did not match as expected.", IntentState.WITHDRAWN, vnetIntentService.getIntentState(virtualIntent.key()));
    // Test the purge() method.
    vnetIntentService.purge(virtualIntent);
    // Wait for the both intents to be removed/purged.
    try {
        if (!purged.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for intent to get purged.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception during intent purging." + e.getMessage());
    }
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) VirtualNetworkIntent(org.onosproject.incubator.net.virtual.VirtualNetworkIntent) Key(org.onosproject.net.intent.Key) Test(org.junit.Test)

Example 58 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetDeviceLinksByNullId.

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

Example 59 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetLinksByNullId.

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

Example 60 with VirtualNetwork

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

the class VirtualNetworkLinkManagerTest method testGetDeviceEgressLinksByNullId.

/**
 * Tests querying for device egress links using a null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetDeviceEgressLinksByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getDeviceEgressLinks() method with a null device identifier.
    linkService.getDeviceEgressLinks(null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkService(org.onosproject.net.link.LinkService) 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