Search in sources :

Example 51 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetLink.

@Test
public final void testGetLink() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    LinkKey linkId1 = LinkKey.linkKey(src, dst);
    putLink(linkId1, DIRECT);
    Link link = linkStore.getLink(src, dst);
    assertLink(linkId1, DIRECT, link);
    assertNull("There shouldn't be reverese link", linkStore.getLink(dst, src));
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 52 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetDeviceIngressLinks.

@Test
public final void testGetDeviceIngressLinks() {
    LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
    LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
    LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
    putLink(linkId1, DIRECT);
    putLink(linkId2, DIRECT);
    putLink(linkId3, DIRECT);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    Set<Link> links1 = linkStore.getDeviceIngressLinks(DID2);
    assertEquals(2, links1.size());
    // check
    Set<Link> links2 = linkStore.getDeviceIngressLinks(DID1);
    assertEquals(1, links2.size());
    assertLink(linkId2, DIRECT, links2.iterator().next());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Example 53 with LinkKey

use of org.onosproject.net.LinkKey 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 54 with LinkKey

use of org.onosproject.net.LinkKey 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 55 with LinkKey

use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetIngressLinks.

@Test
public final void testGetIngressLinks() {
    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);
    LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
    putLink(linkId1, DIRECT);
    putLink(linkId2, DIRECT);
    putLink(linkId3, DIRECT);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    Set<Link> links1 = linkStore.getIngressLinks(d2P2);
    assertEquals(1, links1.size());
    assertLink(linkId1, DIRECT, links1.iterator().next());
    Set<Link> links2 = linkStore.getIngressLinks(d1P1);
    assertEquals(1, links2.size());
    assertLink(linkId2, DIRECT, links2.iterator().next());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Aggregations

LinkKey (org.onosproject.net.LinkKey)61 Test (org.junit.Test)34 ConnectPoint (org.onosproject.net.ConnectPoint)31 Link (org.onosproject.net.Link)23 Identifier (org.onlab.util.Identifier)14 DeviceId (org.onosproject.net.DeviceId)9 Set (java.util.Set)7 MplsLabel (org.onlab.packet.MplsLabel)7 VlanId (org.onlab.packet.VlanId)7 LinkDescription (org.onosproject.net.link.LinkDescription)7 LinkEvent (org.onosproject.net.link.LinkEvent)7 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)6 ProviderId (org.onosproject.net.provider.ProviderId)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 FirstFitSelection (org.onosproject.net.resource.impl.LabelAllocator.FirstFitSelection)5 RandomSelection (org.onosproject.net.resource.impl.LabelAllocator.RandomSelection)5 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)4 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)4 BasicLinkConfig (org.onosproject.net.config.basics.BasicLinkConfig)4