Search in sources :

Example 16 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class KubevirtRouterManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : KubevirtRouterEvent(org.onosproject.kubevirtnetworking.api.KubevirtRouterEvent) Event(org.onosproject.event.Event)

Example 17 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class KubevirtSecurityGroupManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : Event(org.onosproject.event.Event) KubevirtSecurityGroupEvent(org.onosproject.kubevirtnetworking.api.KubevirtSecurityGroupEvent)

Example 18 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method validateEvents.

/**
 * Method to validate that the actual versus expected virtual network events were
 * received correctly.
 *
 * @param types expected virtual network events.
 */
private void validateEvents(Enum... types) {
    TestTools.assertAfter(100, () -> {
        int i = 0;
        assertEquals("wrong events received", types.length, listener.events.size());
        for (Event event : listener.events) {
            assertEquals("incorrect event type", types[i], event.type());
            i++;
        }
        listener.events.clear();
    });
}
Also used : Event(org.onosproject.event.Event) VirtualNetworkEvent(org.onosproject.incubator.net.virtual.VirtualNetworkEvent) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 19 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class VirtualNetworkTopologyProviderTest method testTopologyChanged.

/**
 * Test the topologyChanged() method.
 */
@Test
public void testTopologyChanged() {
    // 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);
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_ADDED, link));
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_ADDED, link2));
    TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topologyService.currentTopology(), reasons);
    topologyProvider.topologyListener.event(event);
    // Wait for the topology changed event, and that the topologyChanged method was called.
    try {
        if (!changed.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for topology changed event.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception." + e.getMessage());
    }
    // Validate that the topology changed method received a single cluster of connect points.
    // This means that the two previous clusters have now joined into a single cluster.
    assertEquals("The cluster count did not match.", 1, this.clusters.size());
    assertEquals("The cluster count did not match.", 1, topologyService.currentTopology().clusterCount());
    // Now remove the virtual link to split it back into two clusters.
    manager.removeVirtualLink(virtualNetwork.id(), link.src(), link.dst());
    manager.removeVirtualLink(virtualNetwork.id(), link2.src(), link2.dst());
    assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
    reasons = new ArrayList<>();
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_REMOVED, link));
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2));
    event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topologyService.currentTopology(), reasons);
    topologyProvider.topologyListener.event(event);
    // Wait for the topology changed event, and that the topologyChanged method was called.
    try {
        if (!changed.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for topology changed event.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception." + e.getMessage());
    }
    // Validate that the topology changed method received two clusters of connect points.
    // This means that the single previous clusters has now split into two clusters.
    assertEquals("The cluster count did not match.", 2, this.clusters.size());
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ArrayList(java.util.ArrayList) LinkEvent(org.onosproject.net.link.LinkEvent) Event(org.onosproject.event.Event) TopologyEvent(org.onosproject.net.topology.TopologyEvent) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 20 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class AbstractVirtualListenerManagerTest method validate.

private void validate(TestListener listener, String... strings) {
    int i = 0;
    assertEquals("incorrect event count", strings.length, listener.events.size());
    for (String string : strings) {
        Event event = (Event) listener.events.get(i++);
        assertEquals("incorrect event", string, event.subject());
    }
}
Also used : AbstractEvent(org.onosproject.event.AbstractEvent) VirtualEvent(org.onosproject.incubator.net.virtual.event.VirtualEvent) Event(org.onosproject.event.Event)

Aggregations

Event (org.onosproject.event.Event)47 TopologyEvent (org.onosproject.net.topology.TopologyEvent)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)7 LinkEvent (org.onosproject.net.link.LinkEvent)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 HostEvent (org.onosproject.net.host.HostEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Map (java.util.Map)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Collectors (java.util.stream.Collectors)2 ClusterEvent (org.onosproject.cluster.ClusterEvent)2 MastershipEvent (org.onosproject.mastership.MastershipEvent)2 Link (org.onosproject.net.Link)2 IntentEvent (org.onosproject.net.intent.IntentEvent)2