use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.
the class OpticalConnectivityTest method testLinkEstablishedByCircuitIntent.
/**
* Checks that isAllRealizingLink(Not)Established works for OpticalCircuitIntent.
*/
@Test
public void testLinkEstablishedByCircuitIntent() {
// Mock 7-nodes linear topology
ConnectPoint cp12 = createConnectPoint(1, 2);
ConnectPoint cp21 = createConnectPoint(2, 1);
ConnectPoint cp22 = createConnectPoint(2, 2);
ConnectPoint cp31 = createConnectPoint(3, 1);
ConnectPoint cp32 = createConnectPoint(3, 2);
ConnectPoint cp41 = createConnectPoint(4, 1);
ConnectPoint cp42 = createConnectPoint(4, 2);
ConnectPoint cp51 = createConnectPoint(5, 1);
ConnectPoint cp52 = createConnectPoint(5, 2);
ConnectPoint cp61 = createConnectPoint(6, 1);
ConnectPoint cp62 = createConnectPoint(6, 2);
ConnectPoint cp71 = createConnectPoint(7, 1);
Link link1 = createLink(cp12, cp21);
Link link2 = createLink(cp22, cp31);
Link link3 = createLink(cp32, cp41);
Link link4 = createLink(cp42, cp51);
Link link5 = createLink(cp52, cp61);
Link link6 = createLink(cp62, cp71);
List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList());
// Mocks 2 intents to create Och connectivity
OpticalCircuitIntent circuitIntent1 = createCircuitIntent(cp21, cp32);
PacketLinkRealizedByOptical ochLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, circuitIntent1);
OpticalCircuitIntent circuitIntent2 = createCircuitIntent(cp51, cp62);
PacketLinkRealizedByOptical ochLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, circuitIntent2);
Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(ochLink1, ochLink2);
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, plinks, Collections.emptySet());
assertTrue(oc1.isAllRealizingLinkNotEstablished());
assertFalse(oc1.isAllRealizingLinkEstablished());
// Sets link realized by circuitIntent1 to be established
OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true);
assertFalse(oc2.isAllRealizingLinkNotEstablished());
assertFalse(oc2.isAllRealizingLinkEstablished());
// Sets link realized by circuitIntent2 to be established
OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true);
assertFalse(oc3.isAllRealizingLinkNotEstablished());
assertTrue(oc3.isAllRealizingLinkEstablished());
}
use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.
the class PacketLinkRealizedByOpticalTest method testCreateWithCircuitIntent.
/**
* Checks the construction of OpticalConnectivityId object with OpticalCircuitIntent.
*/
@Test
public void testCreateWithCircuitIntent() {
ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
OpticalCircuitIntent circuitIntent = OpticalCircuitIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(CltSignalType.CLT_1GBE).build();
PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, circuitIntent);
assertNotNull(plink);
assertEquals(plink.src(), cp1);
assertEquals(plink.dst(), cp2);
assertEquals((long) plink.bandwidth().bps(), CltSignalType.CLT_1GBE.bitRate());
}
use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.
the class PacketLinkRealizedByOpticalTest method testIsBetween.
/**
* Checks that isBetween() method works.
*/
@Test
public void testIsBetween() {
ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
ConnectPoint cp3 = new ConnectPoint(DeviceId.deviceId("of:0000000000000003"), PortNumber.portNumber(3L));
OpticalCircuitIntent ochIntent = OpticalCircuitIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(CltSignalType.CLT_1GBE).build();
PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, ochIntent);
assertTrue(plink.isBetween(cp1, cp2));
assertFalse(plink.isBetween(cp1, cp3));
}
use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompilerTest method test10GbeNoMuxOverOdu2.
/**
* Tests compile of OpticalCircuitIntent without allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_10GBE), over OCH ports (with ODU2):
* - No TributarySlots are used
*/
@Test
public void test10GbeNoMuxOverOdu2() {
// Use driver without support for TributarySlotQuery Behaviour
sut.driverService = new MockDriverServiceNoTs();
ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P3.number());
ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P3.number());
ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P3.signalType()).bidirectional(false).build();
sut.activate(null);
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
selectorBuilder1.matchInPort(oduCltSrcCP.port());
assertThat(rule1.selector(), is(selectorBuilder1.build()));
// validate SRC treatment (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
treatmentBuilder1.setOutput(ochSrcCP.port());
assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
// validate DST selector (without OduSignalType and OduSignalId: i.e. No TributarySlots are used)
TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
selectorBuilder2.matchInPort(ochDstCP.port());
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate DST treatment
assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
use of org.onosproject.net.intent.OpticalCircuitIntent in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompilerTest method test1GbeMultiplexOverOdu2.
/**
* Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_1GBE), over OCH ports (with ODU2):
* - only one TributarySlot is used
*/
@Test
public void test1GbeMultiplexOverOdu2() {
// Use driver with TributarySlotQuery Behaviour
sut.driverService = new MockDriverServiceWithTs();
ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P1.number());
ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P1.number());
ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P1.signalType()).bidirectional(false).build();
sut.activate(null);
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
selectorBuilder1.matchInPort(oduCltSrcCP.port());
selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
assertThat(rule1.selector(), is(selectorBuilder1.build()));
// validate SRC treatment (with OduSignalId, where 1 TributarySlot is used)
TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
Set<TributarySlot> slots = new HashSet<>();
slots.add(TributarySlot.of(1));
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots);
treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
treatmentBuilder1.setOutput(ochSrcCP.port());
assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
// validate DST selector (with OduSignalId, where the same TributarySlot is used)
TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
selectorBuilder2.matchInPort(ochDstCP.port());
selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate DST treatment
assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
Aggregations