use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionEncapIntentCompilerTest method testMplsEncapsulationFilteredForMp.
/**
* We test the proper compilation of mp2sp with the MPLS
* encapsulation and filtered selector.
*/
@Test
public void testMplsEncapsulationFilteredForMp() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).constraints(constraintsForMPLS).links(linksForMp2Sp).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, vlan69Selector))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector), new FilteredConnectPoint(d1p11, vlan200Selector), new FilteredConnectPoint(d2p10, vlan300Selector))).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(5));
Collection<FlowRule> rulesS1 = rules.stream().filter(rule -> rule.deviceId().equals(d1p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS1, hasSize(2));
FlowRule ruleS1 = rulesS1.stream().filter(rule -> {
PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
return inPort.port().equals(d1p10.port());
}).findFirst().get();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder(vlan100Selector).matchInPort(d1p10.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d1p0.port()).build()));
ruleS1 = rulesS1.stream().filter(rule -> {
PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
return inPort.port().equals(d1p11.port());
}).findFirst().get();
assertThat(ruleS1.selector(), is(DefaultTrafficSelector.builder(vlan200Selector).matchInPort(d1p11.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d1p0.port()).build()));
Collection<FlowRule> rulesS2 = rules.stream().filter(rule -> rule.deviceId().equals(d2p0.deviceId())).collect(Collectors.toSet());
assertThat(rulesS2, hasSize(2));
FlowRule ruleS2 = rulesS2.stream().filter(rule -> {
PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
return inPort.port().equals(d2p10.port());
}).findFirst().get();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder(vlan300Selector).matchInPort(d2p10.port()).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d2p1.port()).build()));
ruleS2 = rulesS2.stream().filter(rule -> {
PortCriterion inPort = (PortCriterion) rule.selector().getCriterion(IN_PORT);
return inPort.port().equals(d2p0.port());
}).findFirst().get();
assertThat(ruleS2.selector(), is(DefaultTrafficSelector.builder().matchInPort(d2p0.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d2p1.port()).build()));
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(d3p0.port()).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).matchEthType(Ethernet.MPLS_UNICAST).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan69Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d3p10.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class HostToHostIntentCompilerTest method testSingleLongPathCompilation.
/**
* Tests a pair of hosts with 8 hops between them.
*/
@Test
public void testSingleLongPathCompilation() {
HostToHostIntent intent = makeIntent(HOST_ONE, HOST_TWO);
assertThat(intent, is(notNullValue()));
String[] hops = { HOST_ONE, S1, S2, S3, S4, S5, S6, S7, S8, HOST_TWO };
HostToHostIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(2));
Intent forwardIntent = result.get(0);
assertThat(forwardIntent instanceof LinkCollectionIntent, is(true));
Intent reverseIntent = result.get(1);
assertThat(reverseIntent instanceof LinkCollectionIntent, is(true));
LinkCollectionIntent forwardLCIntent = (LinkCollectionIntent) forwardIntent;
Set<Link> links = forwardLCIntent.links();
assertThat(links, hasSize(7));
Set<FilteredConnectPoint> ingressPoints = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_S1, PORT_1)));
assertThat(forwardLCIntent.filteredIngressPoints(), is(ingressPoints));
assertThat(links, linksHasPath(S1, S2));
assertThat(links, linksHasPath(S2, S3));
assertThat(links, linksHasPath(S3, S4));
assertThat(links, linksHasPath(S4, S5));
assertThat(links, linksHasPath(S5, S6));
assertThat(links, linksHasPath(S6, S7));
assertThat(links, linksHasPath(S7, S8));
Set<FilteredConnectPoint> egressPoints = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_S8, PORT_2)));
assertThat(forwardLCIntent.filteredEgressPoints(), is(egressPoints));
LinkCollectionIntent reverseLCIntent = (LinkCollectionIntent) reverseIntent;
links = reverseLCIntent.links();
assertThat(reverseLCIntent.links(), hasSize(7));
ingressPoints = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_S8, PORT_2)));
assertThat(reverseLCIntent.filteredIngressPoints(), is(ingressPoints));
assertThat(links, linksHasPath(S2, S1));
assertThat(links, linksHasPath(S3, S2));
assertThat(links, linksHasPath(S4, S3));
assertThat(links, linksHasPath(S5, S4));
assertThat(links, linksHasPath(S6, S5));
assertThat(links, linksHasPath(S7, S6));
assertThat(links, linksHasPath(S8, S7));
egressPoints = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_S1, PORT_1)));
assertThat(reverseLCIntent.filteredEgressPoints(), is(egressPoints));
assertThat("key is inherited", result.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionEncapIntentCompilerTest method testCoLocatedPointsTrivialForSp.
/**
* We test the proper compilation of sp2mp with trivial selector,
* trivial treatment, vlan encapsulation and co-located
* ingress/egress points.
*/
@Test
public void testCoLocatedPointsTrivialForSp() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(linksForSp2MpCoLoc).constraints(constraintsForVlan).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p11), new FilteredConnectPoint(d2p10), new FilteredConnectPoint(d3p10))).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> 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(selector).matchInPort(d1p10.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().pushVlan().setVlanId(VlanId.vlanId(LABEL)).setOutput(d1p0.port()).popVlan().setOutput(d1p11.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(d2p0.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setVlanId(VlanId.vlanId(LABEL)).setOutput(d2p1.port()).popVlan().setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p1.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder().matchInPort(d3p0.port()).matchVlanId(VlanId.vlanId(LABEL)).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().popVlan().setOutput(d3p10.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionEncapIntentCompilerTest method testCoLocatedFilteredPointsTrivialForSp.
/**
* We test the proper compilation of sp2mp with trivial selector,
* trivial treatment, mpls encapsulation and co-located
* filtered ingress/egress points.
*/
@Test
public void testCoLocatedFilteredPointsTrivialForSp() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(linksForSp2MpCoLoc).constraints(constraintsForMPLS).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p11, vlan200Selector), new FilteredConnectPoint(d2p10, vlan300Selector), new FilteredConnectPoint(d3p10, vlan69Selector))).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> 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(vlan100Selector).matchInPort(d1p10.port()).build()));
assertThat(ruleS1.treatment(), is(DefaultTrafficTreatment.builder().popVlan().pushMpls().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d1p0.port()).popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan200Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d1p11.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(d2p0.port()).matchEthType(Ethernet.MPLS_UNICAST).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).build()));
assertThat(ruleS2.treatment(), is(DefaultTrafficTreatment.builder().setMpls(MplsLabel.mplsLabel(LABEL)).setOutput(d2p1.port()).popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan300Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d2p10.port()).build()));
Collection<FlowRule> rulesS3 = rules.stream().filter(rule -> rule.deviceId().equals(d3p1.deviceId())).collect(Collectors.toSet());
assertThat(rulesS3, hasSize(1));
FlowRule ruleS3 = rulesS3.iterator().next();
assertThat(ruleS3.selector(), is(DefaultTrafficSelector.builder().matchInPort(d3p0.port()).matchEthType(Ethernet.MPLS_UNICAST).matchMplsLabel(MplsLabel.mplsLabel(LABEL)).build()));
assertThat(ruleS3.treatment(), is(DefaultTrafficTreatment.builder().popMpls(IPV4.ethType()).pushVlan().setVlanId(((VlanIdCriterion) vlan69Selector.getCriterion(VLAN_VID)).vlanId()).setOutput(d3p10.port()).build()));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationMultiHopDomainP2P.
/**
* We test the proper compilation of a domain with two devices.
*/
@Test
public void testCompilationMultiHopDomainP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(domainP2Plinks).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(2));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p0));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d4p0));
assertThat(domainIntent.links(), hasSize(1));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(2));
sut.deactivate();
}
Aggregations