Search in sources :

Example 21 with LinkEvent

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

the class SimpleLinkStoreTest method testCreateOrUpdateLink.

@Test
public final void testCreateOrUpdateLink() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    // add link
    LinkEvent event = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, INDIRECT));
    assertLink(DID1, P1, DID2, P2, INDIRECT, event.subject());
    assertEquals(LINK_ADDED, event.type());
    // update link 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 22 with LinkEvent

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

the class SimpleLinkStoreTest method testRemoveLink.

@Test
public final void testRemoveLink() {
    final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
    final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
    LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
    LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
    putLink(linkId1, DIRECT, A1);
    putLink(linkId2, DIRECT, A2);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    LinkEvent event = linkStore.removeLink(d1P1, d2P2);
    assertEquals(LINK_REMOVED, event.type());
    assertAnnotationsEquals(event.subject().annotations(), A1);
    LinkEvent event2 = linkStore.removeLink(d1P1, d2P2);
    assertNull(event2);
    assertLink(linkId2, DIRECT, linkStore.getLink(d2P2, d1P1));
    assertAnnotationsEquals(linkStore.getLink(d2P2, d1P1).annotations(), A2);
    // annotations, etc. should not survive remove
    putLink(linkId1, DIRECT);
    assertLink(linkId1, DIRECT, linkStore.getLink(d1P1, d2P2));
    assertAnnotationsEquals(linkStore.getLink(d1P1, d2P2).annotations());
}
Also used : LinkKey(org.onosproject.net.LinkKey) LinkEvent(org.onosproject.net.link.LinkEvent) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 23 with LinkEvent

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

the class SimpleLinkStoreTest method removeOrDownLink.

private void removeOrDownLink(boolean isDurable) {
    final ConnectPoint d1P1 = new ConnectPoint(DID1, P1);
    final ConnectPoint d2P2 = new ConnectPoint(DID2, P2);
    LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
    LinkKey linkId2 = LinkKey.linkKey(d2P2, d1P1);
    putLink(linkId1, DIRECT, isDurable ? DA1 : A1);
    putLink(linkId2, DIRECT, isDurable ? DA2 : A2);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    LinkEvent event = linkStore.removeOrDownLink(d1P1, d2P2);
    assertEquals(isDurable ? LINK_UPDATED : LINK_REMOVED, event.type());
    assertAnnotationsEquals(event.subject().annotations(), isDurable ? DA1 : A1);
    LinkEvent event2 = linkStore.removeOrDownLink(d1P1, d2P2);
    assertNull(event2);
    assertLink(linkId2, DIRECT, linkStore.getLink(d2P2, d1P1));
    assertAnnotationsEquals(linkStore.getLink(d2P2, d1P1).annotations(), isDurable ? DA2 : A2);
    // annotations, etc. should not survive remove
    if (!isDurable) {
        putLink(linkId1, DIRECT);
        assertLink(linkId1, DIRECT, linkStore.getLink(d1P1, d2P2));
        assertAnnotationsEquals(linkStore.getLink(d1P1, d2P2).annotations());
    }
}
Also used : LinkKey(org.onosproject.net.LinkKey) LinkEvent(org.onosproject.net.link.LinkEvent) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 24 with LinkEvent

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

the class MQEventHandlerTest method testAddLink.

@Test
public void testAddLink() throws Exception {
    Link link = createLink();
    LinkEvent event = new LinkEvent(LINK_ADDED, link, 123L);
    validateEvent(event, LINK_ADDED, link, 123L);
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 25 with LinkEvent

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

the class MQEventHandlerTest method testRemoveLink.

@Test
public void testRemoveLink() throws Exception {
    Link link = createLink();
    LinkEvent event = new LinkEvent(LINK_ADDED, link, 123L);
    validateEvent(event, LINK_ADDED, link, 123L);
    LinkEvent event1 = new LinkEvent(LINK_REMOVED, link, 123L);
    validateEvent(event1, LINK_REMOVED, link, 123L);
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) AbstractEventTest(org.onosproject.event.AbstractEventTest) 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