use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class OpticalOduIntentCompilerTest method test10GbeMultiplexOverOdu2.
/**
* Tests compile of OpticalOduIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_10GBE), over OTU ports (with OTU2):
* - All TributarySlots are used
*/
@Test
public void test10GbeMultiplexOverOdu2() {
intent = OpticalOduIntent.builder().appId(APP_ID).key(KEY1).src(d1p3).dst(d3p3).signalType(D1P3.signalType()).bidirectional(false).build();
sut.activate();
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();
// 1st Device
FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
selectorBuilder1.matchInPort(d1p3.port());
selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
assertThat(rule1.selector(), is(selectorBuilder1.build()));
// validate SRC treatment (without OduSignalId - all TributarySlots are used)
TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
treatmentBuilder1.setOutput(d1p2.port());
assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
// 2nd Device
FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
selectorBuilder2.matchInPort(d2p1.port());
selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate SRC treatment (without OduSignalId - all TributarySlots are used)
TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
treatmentBuilder2.setOutput(d2p2.port());
assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
// 3rd Device
FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(device3.id())).findFirst().get();
// validate DST selector (without OduSignalId - all TributarySlots are used)
TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
selectorBuilder3.matchInPort(d3p1.port());
selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
assertThat(rule3.selector(), is(selectorBuilder3.build()));
// validate DST treatment
assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p3.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopIndirectEgressVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-indirect-link scenario. No ingress VLAN. Egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopIndirectEgressVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopIndirectIntentEgressVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p2.port()).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(egressVlan).setOutput(d2p3.port()).build()));
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanMod = rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).collect(Collectors.toSet());
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).collect(Collectors.toSet()), hasSize(1));
assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction).collect(Collectors.toSet()), hasSize(0));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopIndirectVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-indirect-link scenario. Ingress VLAN. Egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopIndirectVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopIndirectIntentVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p2.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p2.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p2.port()).matchVlanId(ingressVlan).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(egressVlan).setOutput(d2p3.port()).build()));
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanMod = rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).collect(Collectors.toSet());
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).collect(Collectors.toSet()), hasSize(1));
assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction).collect(Collectors.toSet()), hasSize(0));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopDirectVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-direct-link scenario. Ingress VLAN. Egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopDirectVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopDirectIntentVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p4.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p4.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p4.port()).matchVlanId(ingressVlan).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(egressVlan).setOutput(d2p5.port()).build()));
Set<L2ModificationInstruction.ModVlanIdInstruction> vlanMod = rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).map(x -> (L2ModificationInstruction.ModVlanIdInstruction) x).collect(Collectors.toSet());
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanIdInstruction).collect(Collectors.toSet()), hasSize(1));
assertThat(vlanMod.iterator().next().vlanId(), is(egressVlan));
assertThat(rule.treatment().allInstructions().stream().filter(treat -> treat instanceof L2ModificationInstruction.ModVlanHeaderInstruction).collect(Collectors.toSet()), hasSize(0));
sut.deactivate();
}
use of org.onosproject.net.intent.FlowRuleIntent in project onos by opennetworkinglab.
the class PathIntentCompilerTest method testVlanEncapCompileSingleHopDirectNoVlan.
/**
* Tests the compilation behavior of the path intent compiler in case of
* VLAN {@link EncapsulationType} encapsulation constraint {@link EncapsulationConstraint}
* and single-hop-direct-link scenario. No ingress VLAN. No egress VLAN.
*/
@Test
public void testVlanEncapCompileSingleHopDirectNoVlan() {
sut.activate();
List<Intent> compiled = sut.compile(singleHopDirectIntentNoVlan, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
FlowRule rule = rules.stream().filter(x -> x.deviceId().equals(d2p4.deviceId())).findFirst().get();
verifyIdAndPriority(rule, d2p4.deviceId());
assertThat(rule.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p4.port()).build()));
assertThat(rule.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p5.port()).build()));
sut.deactivate();
}
Aggregations