use of org.onosproject.net.flow.criteria.MplsCriterion in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerTest method singleHopTestFilteredForSp.
/**
* We test the proper compilation of sp2mp with
* trivial selector, trivial treatment and 1 hop.
*/
@Test
public void singleHopTestFilteredForSp() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of()).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls80Selector))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p0, vlan200Selector))).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(1));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(1));
FlowRule ruleS1 = rulesS1.stream().filter(rule -> {
PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
return inPort.port().equals(d1p0.port());
}).findFirst().get();
assertThat(ruleS1.selector(), Is.is(DefaultTrafficSelector.builder(vlan200Selector).matchInPort(d1p0.port()).build()));
assertThat(ruleS1.treatment(), Is.is(DefaultTrafficTreatment.builder().setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p10.port()).popVlan().pushMpls().setMpls(((MplsCriterion) mpls80Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p11.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.flow.criteria.MplsCriterion in project onos by opennetworkinglab.
the class LinkCollectionOptimizationTest method testUntaggedOrder.
/**
* We test the proper optimization of sp2mp with untagged
* ingress point and different egress points: 1) it is
* a vlan ingress point; 2) it is a mpls ingress point;
* 3) It is a simple ingress point. 1) and 2) share the same
* egress switch. The outcomes of the test are the re-ordering
* of the actions and the proper optimization of the chain.
*/
@Test
public void testUntaggedOrder() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).links(linksForSp2Mp).applyTreatmentOnEgress(true).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls200Selector), new FilteredConnectPoint(d1p12), new FilteredConnectPoint(d2p10))).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(3));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder().matchInPort(d3p10.port()).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p0.port()).build()));
Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS2, hasSize(1));
FlowRule ruleS2 = rulesS2.iterator().next();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p1.port()).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p0.port()).setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(1));
FlowRule ruleS1 = rulesS1.iterator().next();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p0.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d1p12.port()).pushVlan().setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p10.port()).popVlan().pushMpls().copyTtlOut().setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p11.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.flow.criteria.MplsCriterion in project onos by opennetworkinglab.
the class LinkCollectionOptimizationTest method testMplsOrder.
/**
* We test the proper optimization of sp2mp with MPLS
* ingress point and different egress points: 1) it is
* a vlan ingress point; 2) it is a mpls ingress point;
* 3) It is a simple ingress point. 1) and 2) share the same
* egress switch. The outcomes of the test are the re-ordering
* of the actions and the proper optimization of the chain.
*/
@Test
public void testMplsOrder() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).links(linksForSp2Mp).applyTreatmentOnEgress(true).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, mpls100Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, mpls200Selector), new FilteredConnectPoint(d2p10))).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(3));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder(mpls100Selector).matchInPort(d3p10.port()).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p0.port()).build()));
Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS2, hasSize(1));
FlowRule ruleS2 = rulesS2.iterator().next();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder(mpls100Selector).matchInPort(d2p1.port()).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p0.port()).copyTtlIn().popMpls(IPV4.ethType()).setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(1));
FlowRule ruleS1 = rulesS1.iterator().next();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder(mpls100Selector).matchInPort(d1p0.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p11.port()).copyTtlIn().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p10.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.flow.criteria.MplsCriterion in project onos by opennetworkinglab.
the class LinkCollectionOptimizationTest method testOptimizationVlanEncapDifferentSelectors.
/**
* We test the proper compilation of sp2mp with the VLAN
* encapsulation and filtered selectors of different type.
*/
@Test
public void testOptimizationVlanEncapDifferentSelectors() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).constraints(constraintsForVlan).links(linksForSp2Mp).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, vlan69Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, mpls100Selector), new FilteredConnectPoint(d1p11, vlan200Selector), new FilteredConnectPoint(d1p12), new FilteredConnectPoint(d2p10, mpls200Selector))).build();
sut.activate();
/*
* We use the FIRST_FIT to simplify tests.
*/
LinkCollectionCompiler.labelAllocator.setLabelSelection(LABEL_SELECTION);
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(3));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder(vlan69Selector).matchInPort(d3p10.port()).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(VlanId.vlanId(LABEL)).setOutput(d3p0.port()).build()));
Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS2, hasSize(1));
FlowRule ruleS2 = rulesS2.iterator().next();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p1.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(VlanId.vlanId(LABEL)).setOutput(d2p0.port()).popVlan().pushMpls().copyTtlOut().setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(1));
FlowRule ruleS1 = rulesS1.iterator().next();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p0.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p11.port()).popVlan().setOutput(d1p12.port()).pushMpls().copyTtlOut().setMpls(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p10.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.flow.criteria.MplsCriterion in project onos by opennetworkinglab.
the class LinkCollectionEncapIntentCompilerTest method testVlanEncapsulationFilteredForSp.
/**
* We test the proper compilation of sp2mp with the VLAN
* encapsulation and filtered selector.
*/
@Test
public void testVlanEncapsulationFilteredForSp() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).constraints(constraintsForVlan).links(linksForSp2Mp).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, mpls69Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, mpls100Selector), new FilteredConnectPoint(d1p11, mpls200Selector), new FilteredConnectPoint(d2p10, mpls80Selector))).build();
sut.activate();
LinkCollectionCompiler.labelAllocator.setLabelSelection(LABEL_SELECTION);
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
assertThat(rules, hasSize(3));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder(mpls69Selector).matchInPort(d3p10.port()).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().popMpls(IPV4.ethType()).pushVlan().setVlanId(VlanId.vlanId(LABEL)).setOutput(d3p0.port()).build()));
Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS2, hasSize(1));
FlowRule ruleS2 = rulesS2.iterator().next();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p1.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(VlanId.vlanId(LABEL)).setOutput(d2p0.port()).popVlan().pushMpls().setMpls(((MplsCriterion) mpls80Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(1));
FlowRule ruleS1 = rulesS1.iterator().next();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder().matchInPort(d1p0.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(((MplsCriterion) mpls100Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p10.port()).setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d1p11.port()).build()));
sut.deactivate();
}
Aggregations