use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkHostManagerTest method testGetHostsByNullVlan.
/**
* Tests querying for hosts with null vlan.
*/
@Test(expected = NullPointerException.class)
public void testGetHostsByNullVlan() {
VirtualNetwork vnet = setupEmptyVnet();
HostService hostService = manager.get(vnet.id(), HostService.class);
hostService.getHostsByVlan(null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkHostManagerTest method setupVnet.
/**
* Sets up a virtual network with hosts.
*
* @return virtual network
*/
private VirtualNetwork setupVnet() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);
ConnectPoint hostCp1 = new ConnectPoint(DID1, P1);
ConnectPoint hostCp2 = new ConnectPoint(DID2, P2);
manager.createVirtualPort(virtualNetwork.id(), hostCp1.deviceId(), hostCp1.port(), new ConnectPoint(virtualDevice1.id(), hostCp1.port()));
manager.createVirtualPort(virtualNetwork.id(), hostCp2.deviceId(), hostCp2.port(), new ConnectPoint(virtualDevice2.id(), hostCp2.port()));
manager.createVirtualHost(virtualNetwork.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
manager.createVirtualHost(virtualNetwork.id(), HID2, MAC2, VLAN2, LOC2, IPSET2);
return virtualNetwork;
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkHostManagerTest method testGetHostByNullId.
/**
* Tests querying for a host using a null host identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetHostByNullId() {
VirtualNetwork vnet = setupEmptyVnet();
HostService hostService = manager.get(vnet.id(), HostService.class);
hostService.getHost(null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkHostManagerTest method testGetConnectedHostsByNullDeviceId.
/**
* Tests querying for connected hosts with null device id.
*/
@Test(expected = NullPointerException.class)
public void testGetConnectedHostsByNullDeviceId() {
VirtualNetwork vnet = setupVnet();
HostService hostService = manager.get(vnet.id(), HostService.class);
hostService.getConnectedHosts((DeviceId) null);
}
use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkIntentManagerTest method testGetIntents.
/**
* Tests the getIntents, getIntent(), getIntentData(), getIntentCount(),
* isLocal() methods.
*/
@Test
public void testGetIntents() {
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 getIntents() method
assertEquals("The intents size did not match as expected.", 1, Iterators.size(vnetIntentService.getIntents().iterator()));
// Test the getIntent() method
assertNotNull("The intent should have been found.", vnetIntentService.getIntent(virtualIntent.key()));
// Test the getIntentData() method
assertEquals("The intent data size did not match as expected.", 1, Iterators.size(vnetIntentService.getIntentData().iterator()));
// Test the getIntentCount() method
assertEquals("The intent count did not match as expected.", 1, vnetIntentService.getIntentCount());
// Test the isLocal() method
assertTrue("The intent should be local.", vnetIntentService.isLocal(virtualIntent.key()));
}
Aggregations