use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testIsLatest.
/**
* Test isLatest() method.
*/
@Test
public void testIsLatest() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
// test the isLatest() method.
assertTrue("This should be latest topology", topologyService.isLatest(topology));
VirtualDevice srcVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
VirtualDevice dstVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID2);
// test the isLatest() method where a new device has been added to the current topology.
assertFalse("This should not be latest topology", topologyService.isLatest(topology));
topology = topologyService.currentTopology();
ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
manager.createVirtualPort(virtualNetwork.id(), src.deviceId(), src.port(), new ConnectPoint(srcVirtualDevice.id(), src.port()));
ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
manager.createVirtualPort(virtualNetwork.id(), dst.deviceId(), dst.port(), new ConnectPoint(dstVirtualDevice.id(), dst.port()));
VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst);
// test the isLatest() method where a new link has been added to the current topology.
assertFalse("This should not be latest topology", topologyService.isLatest(topology));
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method setupVirtualNetworkTopology.
/**
* Method to create the virtual network for further testing.
*
* @return virtual network
*/
private VirtualNetwork setupVirtualNetworkTopology() {
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);
VirtualDevice virtualDevice3 = manager.createVirtualDevice(virtualNetwork.id(), DID3);
VirtualDevice virtualDevice4 = manager.createVirtualDevice(virtualNetwork.id(), DID4);
ConnectPoint cp1 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
manager.createVirtualPort(virtualNetwork.id(), cp1.deviceId(), cp1.port(), cp1);
ConnectPoint cp2 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(2));
manager.createVirtualPort(virtualNetwork.id(), cp2.deviceId(), cp2.port(), cp2);
ConnectPoint cp3 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(3));
manager.createVirtualPort(virtualNetwork.id(), cp3.deviceId(), cp3.port(), cp3);
ConnectPoint cp4 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(4));
manager.createVirtualPort(virtualNetwork.id(), cp4.deviceId(), cp4.port(), cp4);
ConnectPoint cp5 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(5));
manager.createVirtualPort(virtualNetwork.id(), cp5.deviceId(), cp5.port(), cp5);
ConnectPoint cp6 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(6));
manager.createVirtualPort(virtualNetwork.id(), cp6.deviceId(), cp6.port(), cp6);
VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
VirtualLink link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
VirtualLink link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
VirtualLink link5 = manager.createVirtualLink(virtualNetwork.id(), cp2, cp6);
virtualNetworkManagerStore.updateLink(link5, link5.tunnelId(), Link.State.ACTIVE);
VirtualLink link6 = manager.createVirtualLink(virtualNetwork.id(), cp6, cp2);
virtualNetworkManagerStore.updateLink(link6, link6.tunnelId(), Link.State.ACTIVE);
return virtualNetwork;
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPathsUsingNullRiskProfile.
/**
* Test getDisjointPaths() methods using a null risk profile.
*/
@Test(expected = NullPointerException.class)
public void testGetDisjointPathsUsingNullRiskProfile() {
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 getDisjointPaths() method using a null risk profile.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), (Map<Link, Object>) null);
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testIsBroadcastPoint.
/**
* Test isBroadcastPoint() method.
*/
@Test
public void testIsBroadcastPoint() {
VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
Topology topology = topologyService.currentTopology();
VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
ConnectPoint cp = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
// test the isBroadcastPoint() method.
Boolean isBroadcastPoint = topologyService.isBroadcastPoint(topology, cp);
assertTrue("The connect point should be a broadcast point.", isBroadcastPoint);
}
use of org.onosproject.incubator.net.virtual.VirtualDevice in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManagerTest method testGetDisjointPathsUsingNullWeight.
/**
* Test getDisjointPaths() methods using a null weight.
*/
@Test(expected = NullPointerException.class)
public void testGetDisjointPathsUsingNullWeight() {
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 getDisjointPaths() method using a null weight.
Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), (LinkWeigher) null);
}
Aggregations