[ONOS-4595] Harmonize the sb of the Intent Framework
Changes:
- Moves PointToPointIntent to LinkCollectionIntent;
- Moves PointToPointIntent to the new FilteredConnectPoint API;
- Updates unit tests;
Change-Id: Iade5090b9289c5b2d9f4ee41aa0d2d01b5e3699c
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/AbstractLinkCollectionTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/AbstractLinkCollectionTest.java
index f7389e7..38aad30 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/AbstractLinkCollectionTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/AbstractLinkCollectionTest.java
@@ -98,6 +98,11 @@
link(d2p0, d1p0)
);
+ final Set<Link> p2pLinks = ImmutableSet.of(
+ link(d1p0, d2p0),
+ link(d2p1, d3p1)
+ );
+
final TrafficTreatment treatment = emptyTreatment();
final TrafficTreatment ethDstTreatment = macDstTreatment("C0:FF:EE:C0:FF:EE");
final TrafficTreatment decTllTreatment = decTtlTreatment();
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
index 295a998..eb58cce 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionEncapIntentCompilerTest.java
@@ -1166,7 +1166,7 @@
/**
* We test the proper compilation of p2p with the VLAN
- * encapsulation and filtered points.
+ * encapsulation and trivial filtered points.
*/
@Test
public void testVlanEncapsulationForP2P() {
@@ -1260,7 +1260,7 @@
/**
* We test the proper compilation of p2p with the MPLS
- * encapsulation and filtered points.
+ * encapsulation and trivial filtered points.
*/
@Test
public void testMplsEncapsulationForP2P() {
@@ -1354,4 +1354,206 @@
}
+ /**
+ * We test the proper compilation of p2p with the VLAN
+ * encapsulation, filtered points, selector and treatment.
+ */
+ @Test
+ public void testVlanEncapsulationNonTrivialForP2P() {
+
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(ipPrefixSelector)
+ .treatment(ethDstTreatment)
+ .constraints(constraintsForVlan)
+ .links(linksForMp2Sp)
+ .filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector)))
+ .filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, mpls69Selector)))
+ .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(ipPrefixSelector)
+ .matchInPort(d1p10.port())
+ .matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+ .build()
+ ));
+ assertThat(ruleS1.treatment(), is(
+ DefaultTrafficTreatment
+ .builder()
+ .setVlanId(VlanId.vlanId(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())
+ .matchVlanId(VlanId.vlanId(LABEL))
+ .build()
+ ));
+ assertThat(ruleS2.treatment(), is(
+ DefaultTrafficTreatment
+ .builder()
+ .setVlanId(VlanId.vlanId(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())
+ .matchVlanId(VlanId.vlanId(LABEL))
+ .build()
+ ));
+ assertThat(ruleS3.treatment(), is(
+ DefaultTrafficTreatment
+ .builder()
+ .setEthDst(((ModEtherInstruction) ethDstTreatment
+ .allInstructions()
+ .stream()
+ .filter(instruction -> instruction instanceof ModEtherInstruction)
+ .findFirst().get()).mac())
+ .popVlan()
+ .pushMpls()
+ .setMpls(((MplsCriterion) mpls69Selector.getCriterion(MPLS_LABEL)).label())
+ .setOutput(d3p10.port())
+ .build()
+ ));
+
+ sut.deactivate();
+
+ }
+
+ /**
+ * We test the proper compilation of p2p with the MPLS
+ * encapsulation, filtered points, selector and treatment.
+ */
+ @Test
+ public void testMplsEncapsulationNonTrivialForP2P() {
+
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(ipPrefixSelector)
+ .treatment(ethDstTreatment)
+ .constraints(constraintsForMPLS)
+ .links(linksForMp2Sp)
+ .filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p10, vlan100Selector)))
+ .filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p10, mpls69Selector)))
+ .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(ipPrefixSelector)
+ .matchInPort(d1p10.port())
+ .matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+ .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()
+ .setEthDst(((ModEtherInstruction) ethDstTreatment
+ .allInstructions()
+ .stream()
+ .filter(instruction -> instruction instanceof ModEtherInstruction)
+ .findFirst().get()).mac())
+ .setMpls(((MplsCriterion) mpls69Selector.getCriterion(MPLS_LABEL)).label())
+ .setOutput(d3p10.port())
+ .build()
+ ));
+
+ sut.deactivate();
+
+ }
+
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
index cfbddea..4c45bb4 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompilerTest.java
@@ -1079,4 +1079,282 @@
}
+ /**
+ * We test the proper compilation of p2p with
+ * trivial selector and trivial treatment.
+ */
+ @Test
+ public void p2p() {
+
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .applyTreatmentOnEgress(true)
+ .links(p2pLinks)
+ .filteredIngressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d1p10)
+ ))
+ .filteredEgressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d3p0)
+ ))
+ .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> 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.is(
+ DefaultTrafficSelector
+ .builder()
+ .matchInPort(d1p10.port())
+ .build()
+ ));
+ assertThat(ruleS1.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .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.is(
+ DefaultTrafficSelector
+ .builder()
+ .matchInPort(d2p0.port())
+ .build()
+ ));
+ assertThat(ruleS2.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .setOutput(d2p1.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.is(
+ DefaultTrafficSelector
+ .builder()
+ .matchInPort(d3p1.port())
+ .build()
+ ));
+ assertThat(ruleS3.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .setOutput(d3p0.port())
+ .build()
+ ));
+
+ sut.deactivate();
+
+ }
+
+ /**
+ * We test the proper compilation of p2p with
+ * trivial selector, trivial treatment and filtered points.
+ */
+ @Test
+ public void p2pFilteredPoint() {
+
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(selector)
+ .treatment(treatment)
+ .applyTreatmentOnEgress(true)
+ .links(p2pLinks)
+ .filteredIngressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d1p10, vlan100Selector)
+ ))
+ .filteredEgressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d3p0, mpls200Selector)
+ ))
+ .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> 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.is(
+ DefaultTrafficSelector
+ .builder(vlan100Selector)
+ .matchInPort(d1p10.port())
+ .build()
+ ));
+ assertThat(ruleS1.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .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.is(
+ DefaultTrafficSelector
+ .builder(vlan100Selector)
+ .matchInPort(d2p0.port())
+ .build()
+ ));
+ assertThat(ruleS2.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .setOutput(d2p1.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.is(
+ DefaultTrafficSelector
+ .builder(vlan100Selector)
+ .matchInPort(d3p1.port())
+ .build()
+ ));
+ assertThat(ruleS3.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .popVlan()
+ .pushMpls()
+ .setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label())
+ .setOutput(d3p0.port())
+ .build()
+ ));
+
+ sut.deactivate();
+
+ }
+
+ /**
+ * We test the proper compilation of p2p with
+ * selector, treatment and filtered points.
+ */
+ @Test
+ public void p2pNonTrivial() {
+
+ intent = LinkCollectionIntent.builder()
+ .appId(APP_ID)
+ .selector(ipPrefixSelector)
+ .treatment(ethDstTreatment)
+ .applyTreatmentOnEgress(true)
+ .links(p2pLinks)
+ .filteredIngressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d1p10, vlan100Selector)
+ ))
+ .filteredEgressPoints(ImmutableSet.of(
+ new FilteredConnectPoint(d3p0, mpls200Selector)
+ ))
+ .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> 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.is(
+ DefaultTrafficSelector
+ .builder(ipPrefixSelector)
+ .matchInPort(d1p10.port())
+ .matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+ .build()
+ ));
+ assertThat(ruleS1.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .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.is(
+ DefaultTrafficSelector
+ .builder(ipPrefixSelector)
+ .matchInPort(d2p0.port())
+ .matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+ .build()
+ ));
+ assertThat(ruleS2.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .setOutput(d2p1.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.is(
+ DefaultTrafficSelector
+ .builder(ipPrefixSelector)
+ .matchInPort(d3p1.port())
+ .matchVlanId(((VlanIdCriterion) vlan100Selector.getCriterion(VLAN_VID)).vlanId())
+ .build()
+ ));
+ assertThat(ruleS3.treatment(), Is.is(
+ DefaultTrafficTreatment
+ .builder()
+ .setEthDst(((ModEtherInstruction) ethDstTreatment
+ .allInstructions()
+ .stream()
+ .filter(instruction -> instruction instanceof ModEtherInstruction)
+ .findFirst().get()).mac())
+ .popVlan()
+ .pushMpls()
+ .setMpls(((MplsCriterion) mpls200Selector.getCriterion(MPLS_LABEL)).label())
+ .setOutput(d3p0.port())
+ .build()
+ ));
+
+ sut.deactivate();
+
+ }
+
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
index e620f0e..d61e01d 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
@@ -15,21 +15,22 @@
*/
package org.onosproject.net.intent.impl.compiler;
+import com.google.common.collect.ImmutableSet;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.onlab.util.Bandwidth;
import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.FilteredConnectPoint;
import org.onosproject.net.Link;
-import org.onosproject.net.Path;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.AbstractIntentTest;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.Intent;
import org.onosproject.net.intent.IntentTestsMocks;
-import org.onosproject.net.intent.PathIntent;
+import org.onosproject.net.intent.LinkCollectionIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.intent.constraint.BandwidthConstraint;
import org.onosproject.net.intent.impl.PathNotFoundException;
@@ -37,6 +38,7 @@
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -44,7 +46,6 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.fail;
-import static org.onosproject.net.DefaultEdgeLink.createEdgeLink;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.NetTestTools.APP_ID;
import static org.onosproject.net.NetTestTools.connectPoint;
@@ -74,8 +75,8 @@
.appId(APPID)
.selector(selector)
.treatment(treatment)
- .ingressPoint(connectPoint(ingressIdString, 1))
- .egressPoint(connectPoint(egressIdString, 1))
+ .filteredIngressPoint(new FilteredConnectPoint(connectPoint(ingressIdString, 1)))
+ .filteredEgressPoint(new FilteredConnectPoint(connectPoint(egressIdString, 1)))
.build();
}
@@ -93,8 +94,8 @@
.appId(APPID)
.selector(selector)
.treatment(treatment)
- .ingressPoint(connectPoint(ingressIdString, 1))
- .egressPoint(connectPoint(egressIdString, 1))
+ .filteredIngressPoint(new FilteredConnectPoint(connectPoint(ingressIdString, 1)))
+ .filteredEgressPoint(new FilteredConnectPoint(connectPoint(egressIdString, 1)))
.constraints(constraints)
.build();
}
@@ -140,19 +141,23 @@
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
- assertThat(forwardResultIntent instanceof PathIntent, is(true));
+ assertThat(forwardResultIntent instanceof LinkCollectionIntent, is(true));
- if (forwardResultIntent instanceof PathIntent) {
- PathIntent forwardPathIntent = (PathIntent) forwardResultIntent;
+ if (forwardResultIntent instanceof LinkCollectionIntent) {
+ LinkCollectionIntent forwardIntent = (LinkCollectionIntent) forwardResultIntent;
+ FilteredConnectPoint ingressPoint = new FilteredConnectPoint(connectPoint("d1", 1));
+ FilteredConnectPoint egressPoint = new FilteredConnectPoint(connectPoint("d8", 1));
// 7 links for the hops, plus one default lnk on ingress and egress
- assertThat(forwardPathIntent.path().links(), hasSize(hops.length + 1));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d1", "d2"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d2", "d3"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d3", "d4"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d4", "d5"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d5", "d6"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d6", "d7"));
- assertThat(forwardPathIntent.path().links(), linksHasPath("d7", "d8"));
+ assertThat(forwardIntent.links(), hasSize(hops.length - 1));
+ assertThat(forwardIntent.links(), linksHasPath("d1", "d2"));
+ assertThat(forwardIntent.links(), linksHasPath("d2", "d3"));
+ assertThat(forwardIntent.links(), linksHasPath("d3", "d4"));
+ assertThat(forwardIntent.links(), linksHasPath("d4", "d5"));
+ assertThat(forwardIntent.links(), linksHasPath("d5", "d6"));
+ assertThat(forwardIntent.links(), linksHasPath("d6", "d7"));
+ assertThat(forwardIntent.links(), linksHasPath("d7", "d8"));
+ assertThat(forwardIntent.filteredIngressPoints(), is(ImmutableSet.of(ingressPoint)));
+ assertThat(forwardIntent.filteredEgressPoints(), is(ImmutableSet.of(egressPoint)));
}
}
@@ -171,18 +176,22 @@
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent reverseResultIntent = result.get(0);
- assertThat(reverseResultIntent instanceof PathIntent, is(true));
+ assertThat(reverseResultIntent instanceof LinkCollectionIntent, is(true));
- if (reverseResultIntent instanceof PathIntent) {
- PathIntent reversePathIntent = (PathIntent) reverseResultIntent;
- assertThat(reversePathIntent.path().links(), hasSize(hops.length + 1));
- assertThat(reversePathIntent.path().links(), linksHasPath("d2", "d1"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d3", "d2"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d4", "d3"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d5", "d4"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d6", "d5"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d7", "d6"));
- assertThat(reversePathIntent.path().links(), linksHasPath("d8", "d7"));
+ if (reverseResultIntent instanceof LinkCollectionIntent) {
+ LinkCollectionIntent reverseLinkCollectionIntent = (LinkCollectionIntent) reverseResultIntent;
+ FilteredConnectPoint egressPoint = new FilteredConnectPoint(connectPoint("d1", 1));
+ FilteredConnectPoint ingressPoint = new FilteredConnectPoint(connectPoint("d8", 1));
+ assertThat(reverseLinkCollectionIntent.links(), hasSize(hops.length - 1));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d2", "d1"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d3", "d2"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d4", "d3"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d5", "d4"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d6", "d5"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d7", "d6"));
+ assertThat(reverseLinkCollectionIntent.links(), linksHasPath("d8", "d7"));
+ assertThat(reverseLinkCollectionIntent.filteredIngressPoints(), is(ImmutableSet.of(ingressPoint)));
+ assertThat(reverseLinkCollectionIntent.filteredEgressPoints(), is(ImmutableSet.of(egressPoint)));
}
}
@@ -191,14 +200,14 @@
*/
@Test
public void testSameSwitchDifferentPortsIntentCompilation() {
- ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1));
- ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2));
+ FilteredConnectPoint src = new FilteredConnectPoint(new ConnectPoint(deviceId("1"), portNumber(1)));
+ FilteredConnectPoint dst = new FilteredConnectPoint(new ConnectPoint(deviceId("1"), portNumber(2)));
PointToPointIntent intent = PointToPointIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
- .ingressPoint(src)
- .egressPoint(dst)
+ .filteredIngressPoint(src)
+ .filteredEgressPoint(dst)
.build();
String[] hops = {"1"};
@@ -207,14 +216,13 @@
List<Intent> compiled = sut.compile(intent, null);
assertThat(compiled, hasSize(1));
- assertThat(compiled.get(0), is(instanceOf(PathIntent.class)));
- Path path = ((PathIntent) compiled.get(0)).path();
+ assertThat(compiled.get(0), is(instanceOf(LinkCollectionIntent.class)));
+ LinkCollectionIntent linkCollectionIntent = (LinkCollectionIntent) compiled.get(0);
+ Set<Link> links = linkCollectionIntent.links();
- assertThat(path.links(), hasSize(2));
- Link firstLink = path.links().get(0);
- assertThat(firstLink, is(createEdgeLink(src, true)));
- Link secondLink = path.links().get(1);
- assertThat(secondLink, is(createEdgeLink(dst, false)));
+ assertThat(links, hasSize(0));
+ assertThat(linkCollectionIntent.filteredIngressPoints(), is(ImmutableSet.of(src)));
+ assertThat(linkCollectionIntent.filteredEgressPoints(), is(ImmutableSet.of(dst)));
}
/**