Search in sources :

Example 1 with VirtualNetworkProviderService

use of org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method testTopologyChanged.

/**
 * Test the topologyChanged() method.
 */
@Test
public void testTopologyChanged() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
    VirtualNetworkProviderService providerService = manager.createProviderService(topologyProvider);
    // Initial setup is two clusters of devices/links.
    assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
    // Adding this link will join the two clusters together.
    List<Event> reasons = new ArrayList<>();
    VirtualLink link = manager.createVirtualLink(virtualNetwork.id(), cp6, cp7);
    virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp7, cp6);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    Topology topology = topologyService.currentTopology();
    providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
    // Validate that all links are still active.
    manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
        assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
    });
    virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.INACTIVE);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.INACTIVE);
    providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
    // Validate that all links are active again.
    manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
        assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
    });
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualNetworkProviderService(org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService) ArrayList(java.util.ArrayList) Event(org.onosproject.event.Event) VirtualNetworkEvent(org.onosproject.incubator.net.virtual.VirtualNetworkEvent) Topology(org.onosproject.net.topology.Topology) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Event (org.onosproject.event.Event)1 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)1 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)1 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)1 VirtualNetworkEvent (org.onosproject.incubator.net.virtual.VirtualNetworkEvent)1 VirtualNetworkProviderService (org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService)1 Topology (org.onosproject.net.topology.Topology)1