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