Search in sources :

Example 41 with VirtualDevice

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);
}
Also used : VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Test(org.junit.Test)

Example 42 with VirtualDevice

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 43 with VirtualDevice

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 44 with VirtualDevice

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());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 45 with VirtualDevice

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);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Aggregations

VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)51 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)39 Test (org.junit.Test)29 ConnectPoint (org.onosproject.net.ConnectPoint)27 TopologyService (org.onosproject.net.topology.TopologyService)13 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 Topology (org.onosproject.net.topology.Topology)12 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)11 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)9 DisjointPath (org.onosproject.net.DisjointPath)9 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)7 DeviceService (org.onosproject.net.device.DeviceService)7 HashSet (java.util.HashSet)6 DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)6 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)6 DeviceId (org.onosproject.net.DeviceId)6 ArrayList (java.util.ArrayList)5 DefaultVirtualPort (org.onosproject.incubator.net.virtual.DefaultVirtualPort)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3