use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainEndP2P.
/**
* We test the proper compilation of a domain ending with a domain device.
*/
@Test
public void testCompilationDomainEndP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d1p0, d2p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).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(d2p10));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainStartP2P.
/**
* We test the proper compilation of a domain starting with a domain device.
*/
@Test
public void testCompilationDomainStartP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d1p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10))).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(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d2p0));
assertThat(domainIntent.links(), hasSize(0));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(1)).flowRules();
assertThat(rules, hasSize(1));
sut.deactivate();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerDomainP2PTest method testCompilationDomainFullP2P.
/**
* We test the proper compilation of a path fully inside of a domain.
*/
@Test
public void testCompilationDomainFullP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).applyTreatmentOnEgress(true).links(ImmutableSet.of(link(d2p0, d4p0))).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d2p10))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d4p10))).constraints(domainConstraint).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
DomainPointToPointIntent domainIntent = ((DomainPointToPointIntent) compiled.get(0));
ConnectPoint ingress = domainIntent.filteredIngressPoints().iterator().next().connectPoint();
assertThat(ingress, equalTo(d2p10));
ConnectPoint egress = domainIntent.filteredEgressPoints().iterator().next().connectPoint();
assertThat(egress, equalTo(d4p10));
assertThat(domainIntent.links(), hasSize(1));
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();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class LinkCollectionIntentCompilerP2PTest method testMplsEncapsulationForP2P.
/**
* We test the proper compilation of p2p with the MPLS
* encapsulation and trivial filtered points.
*/
@Test
public void testMplsEncapsulationForP2P() {
intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).constraints(constraintsForMPLS).links(linksForMp2Sp).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, 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> 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()).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()).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().setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label()).setOutput(d3p10.port()).build()));
sut.deactivate();
}
Aggregations