use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkPacketManagerTest method requestAndCancelPacketsForVnetTest.
/**
* Tests the addition and removal of packet requests for all devices in a virtual
* network.
*
* @throws TestUtils.TestUtilsException
*/
@Test
public void requestAndCancelPacketsForVnetTest() throws TestUtils.TestUtilsException {
TestFlowObjectiveService testFlowObjectiveService = new TestFlowObjectiveService();
TestUtils.setField(packetManager1, "objectiveService", testFlowObjectiveService);
TrafficSelector ts = DefaultTrafficSelector.emptySelector();
Set<VirtualDevice> vnet1Devices = manager.getVirtualDevices(vnet1.id());
// add first request
packetManager1.requestPackets(ts, CONTROL, appId);
assertEquals("1 packet expected", 1, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, ADD);
// add same request as first
packetManager1.requestPackets(ts, CONTROL, appId);
assertEquals("1 packet expected", 1, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, ADD);
// add second request
packetManager1.requestPackets(ts, REACTIVE, appId);
assertEquals("2 packets expected", 2, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, ADD);
// cancel second request
packetManager1.cancelPackets(ts, REACTIVE, appId);
assertEquals("1 packet expected", 1, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, REMOVE);
// cancel second request again
packetManager1.cancelPackets(ts, REACTIVE, appId);
assertEquals("1 packet expected", 1, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, REMOVE);
// cancel first request
packetManager1.cancelPackets(ts, CONTROL, appId);
assertEquals("0 packet expected", 0, packetManager1.getRequests().size());
testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, REMOVE);
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullSrcDeviceId.
/**
* Test getPaths() method using a null src device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullSrcDeviceId() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method using a null src device identifier.
Set<Path> paths = topologyService.getPaths(topology, null, dstVirtualDevice.id());
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testIsInfrastructure.
/**
* Test isInfrastructure() method.
*/
@Test
public void testIsInfrastructure() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID4);
ConnectPoint cp1 = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
ConnectPoint cp2 = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
// test the isInfrastructure() method.
Boolean isInfrastructure = topologyService.isInfrastructure(topology, cp1);
assertTrue("The connect point should be infrastructure.", isInfrastructure);
isInfrastructure = topologyService.isInfrastructure(topology, cp2);
assertFalse("The connect point should not be infrastructure.", isInfrastructure);
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPaths.
/**
* Test getPaths() and getPaths() by weight methods.
*/
@Test
public void testGetPaths() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method.
Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id());
assertNotNull("The paths should not be null.", paths);
assertEquals("The paths size did not match.", 1, paths.size());
// test the getPaths() by weight method.
LinkWeigher weight = new LinkWeigherAdapter(1.0);
Set<Path> paths1 = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
assertNotNull("The paths should not be null.", paths1);
assertEquals("The paths size did not match.", 1, paths1.size());
Path path = paths1.iterator().next();
assertEquals("wrong path length", 1, path.links().size());
assertEquals("wrong path cost", ScalarWeight.toWeight(1.0), path.weight());
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullDstDeviceId.
/**
* Test getPaths() method using a null dst device identifier.
*/
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullDstDeviceId() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
// test the getPaths() method using a null dst device identifier.
Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), null);
}
Aggregations