Search in sources :

Example 16 with LinkEvent

use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testCreateOrUpdateLinkAncillary.

@Test
public final void testCreateOrUpdateLinkAncillary() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    // add Ancillary link
    LinkEvent event = linkStore.createOrUpdateLink(PIDA, new DefaultLinkDescription(src, dst, INDIRECT, A1));
    assertNotNull("Ancillary only link is ignored", event);
    // add Primary link
    LinkEvent event2 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, INDIRECT, A2));
    assertLink(DID1, P1, DID2, P2, INDIRECT, event2.subject());
    assertAnnotationsEquals(event2.subject().annotations(), A2, A1);
    assertEquals(LINK_UPDATED, event2.type());
    // update link type
    LinkEvent event3 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT, A2));
    assertLink(DID1, P1, DID2, P2, DIRECT, event3.subject());
    assertAnnotationsEquals(event3.subject().annotations(), A2, A1);
    assertEquals(LINK_UPDATED, event3.type());
    // no change
    LinkEvent event4 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
    assertNull("No change event expected", event4);
    // update link annotation (Primary)
    LinkEvent event5 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT, A2_2));
    assertLink(DID1, P1, DID2, P2, DIRECT, event5.subject());
    assertAnnotationsEquals(event5.subject().annotations(), A2, A2_2, A1);
    assertEquals(LINK_UPDATED, event5.type());
    // update link annotation (Ancillary)
    LinkEvent event6 = linkStore.createOrUpdateLink(PIDA, new DefaultLinkDescription(src, dst, DIRECT, A1_2));
    assertLink(DID1, P1, DID2, P2, DIRECT, event6.subject());
    assertAnnotationsEquals(event6.subject().annotations(), A2, A2_2, A1, A1_2);
    assertEquals(LINK_UPDATED, event6.type());
    // update link type (Ancillary) : ignored
    LinkEvent event7 = linkStore.createOrUpdateLink(PIDA, new DefaultLinkDescription(src, dst, EDGE));
    assertNull("Ancillary change other than annotation is ignored", event7);
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 17 with LinkEvent

use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.

the class ECLinkStoreTest method testCreateOrUpdateLink.

@Test
public final void testCreateOrUpdateLink() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    final DefaultLinkDescription linkDescription = new DefaultLinkDescription(src, dst, INDIRECT);
    LinkEvent event = linkStore.createOrUpdateLink(PID, linkDescription);
    assertLink(DID1, P1, DID2, P2, INDIRECT, event.subject());
    assertEquals(LINK_ADDED, event.type());
    LinkEvent event2 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
    assertLink(DID1, P1, DID2, P2, DIRECT, event2.subject());
    assertEquals(LINK_UPDATED, event2.type());
    // no change
    LinkEvent event3 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
    assertNull("No change event expected", event3);
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 18 with LinkEvent

use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.

the class ECLinkStore method purgeLinkCache.

private LinkEvent purgeLinkCache(LinkKey linkKey) {
    Link removedLink = links.remove(linkKey);
    if (removedLink != null) {
        getAllProviders(linkKey).forEach(p -> linkDescriptions.remove(new Provided<>(linkKey, p)));
        linkProviders.remove(linkKey);
        return new LinkEvent(LINK_REMOVED, removedLink);
    }
    return null;
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Example 19 with LinkEvent

use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.

the class ObjectiveTrackerTest method testEventLinkAdded.

/**
 * Tests an event for a link being added.
 *
 * @throws InterruptedException if the latch wait fails.
 */
@Test
public void testEventLinkAdded() throws InterruptedException {
    final Link link = link("src", 1, "dst", 2);
    final LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_ADDED, link);
    reasons.add(linkEvent);
    final TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons);
    listener.event(event);
    assertThat(delegate.latch.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS), is(true));
    assertThat(delegate.intentIdsFromEvent, hasSize(0));
    assertThat(delegate.compileAllFailedFromEvent, is(true));
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) TopologyEvent(org.onosproject.net.topology.TopologyEvent) Link(org.onosproject.net.Link) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 20 with LinkEvent

use of org.onosproject.net.link.LinkEvent in project onos by opennetworkinglab.

the class DefaultTopologyProviderTest method eventDriven.

@Test
public void eventDriven() throws InterruptedException, TimeoutException {
    assertEquals(1, topologyChangedCounts.awaitAdvanceInterruptibly(0, 1, TimeUnit.SECONDS));
    validateSubmission();
    deviceService.postEvent(new DeviceEvent(DEVICE_ADDED, device("z"), null));
    linkService.postEvent(new LinkEvent(LINK_ADDED, link("z", 1, "a", 4)));
    assertThat(topologyChangedCounts.awaitAdvanceInterruptibly(1, 1, TimeUnit.SECONDS), is(greaterThanOrEqualTo(2)));
    // Note: posting event, to trigger topologyChanged call,
    // but dummy topology will not change.
    validateSubmission();
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) LinkEvent(org.onosproject.net.link.LinkEvent) Test(org.junit.Test)

Aggregations

LinkEvent (org.onosproject.net.link.LinkEvent)25 Test (org.junit.Test)16 Link (org.onosproject.net.Link)13 ConnectPoint (org.onosproject.net.ConnectPoint)10 DefaultLink (org.onosproject.net.DefaultLink)6 TopologyEvent (org.onosproject.net.topology.TopologyEvent)6 DeviceEvent (org.onosproject.net.device.DeviceEvent)5 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)5 LinkKey (org.onosproject.net.LinkKey)4 AbstractEventTest (org.onosproject.event.AbstractEventTest)3 Event (org.onosproject.event.Event)3 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)3 ClusterEvent (org.onosproject.cluster.ClusterEvent)2 MastershipEvent (org.onosproject.mastership.MastershipEvent)2 HostEvent (org.onosproject.net.host.HostEvent)2 IntentEvent (org.onosproject.net.intent.IntentEvent)2 Topology (org.onosproject.net.topology.Topology)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1