use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class BasicLinkConfigTest method testConstruction.
/**
* Tests construction, setters and getters of a BasicLinkConfig object.
*/
@Test
public void testConstruction() {
BasicLinkConfig config = new BasicLinkConfig();
ConfigApplyDelegate delegate = configApply -> {
};
ObjectMapper mapper = new ObjectMapper();
LinkKey linkKey = LinkKey.linkKey(NetTestTools.connectPoint("device1", 1), NetTestTools.connectPoint("device2", 2));
config.init(linkKey, "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
config.bandwidth(BANDWIDTH).jitter(JITTER).delay(DELAY).loss(LOSS).availability(AVAILABILITY).flapping(FLAPPING).isDurable(FALSE).metric(METRIC).type(Link.Type.DIRECT).latency(LATENCY).isBidirectional(FALSE).isMetered(TRUE).tier(TIER).meteredUsage(METERED_USAGE);
assertThat(config.bandwidth(), is(BANDWIDTH));
assertThat(config.jitter(), is(JITTER));
assertThat(config.delay(), is(DELAY));
assertThat(config.loss(), is(LOSS));
assertThat(config.availability(), is(AVAILABILITY));
assertThat(config.flapping(), is(FLAPPING));
assertThat(config.isDurable(), is(FALSE));
assertThat(config.metric(), is(METRIC));
assertThat(config.type(), is(Link.Type.DIRECT));
assertThat(config.latency(), is(LATENCY));
assertThat(config.isBidirectional(), is(FALSE));
assertThat(config.isValid(), is(true));
assertThat(config.isMetered(), is(TRUE));
assertThat(config.tier(), is(TIER));
assertThat(config.meteredUsage(), is(METERED_USAGE));
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class SubjectFactoriesTest method testLinkFactory.
@Test
public void testLinkFactory() {
SubjectFactory<LinkKey> linkFactory = SubjectFactories.LINK_SUBJECT_FACTORY;
assertThat(linkFactory, notNullValue());
String deviceName1 = "d1";
String deviceName2 = "d2";
String ofDeviceName1 = "of:" + deviceName1;
String ofDeviceName2 = "of:" + deviceName2;
int devicePort1 = 2;
int devicePort2 = 3;
String cpString1 = ofDeviceName1 + "/" + Integer.toString(devicePort1);
String cpString2 = ofDeviceName2 + "/" + Integer.toString(devicePort2);
ConnectPoint cp1 = NetTestTools.connectPoint(deviceName1, devicePort1);
ConnectPoint cp2 = NetTestTools.connectPoint(deviceName2, devicePort2);
String linkString1 = cpString1 + '-' + cpString2;
LinkKey key1 = LinkKey.linkKey(cp1, cp2);
LinkKey createdLink1 = linkFactory.createSubject(linkString1);
assertThat(createdLink1.asId(), is(linkString1));
assertThat(linkFactory.subjectKey(key1), is(linkString1));
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class ECLinkStoreTest method testGetLinks.
@Test
public final void testGetLinks() {
assertEquals("initialy empty", 0, Iterables.size(linkStore.getLinks()));
LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
putLink(linkId1, DIRECT);
putLink(linkId2, DIRECT);
putLink(linkId1, DIRECT);
assertEquals("expecting 2 unique link", 2, Iterables.size(linkStore.getLinks()));
Map<LinkKey, Link> links = new HashMap<>();
for (Link link : linkStore.getLinks()) {
links.put(LinkKey.linkKey(link), link);
}
assertLink(linkId1, DIRECT, links.get(linkId1));
assertLink(linkId2, DIRECT, links.get(linkId2));
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class ECLinkStoreTest 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());
}
use of org.onosproject.net.LinkKey in project onos by opennetworkinglab.
the class ECLinkStoreTest 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());
}
Aggregations