[ONOS-4387] Support for multiple selectors in mp2sp intents
Changes:
- Adds extension to mp2sp intents;
- Adds extension to linkcollection intents;
- Adds extension to mp2sp compiler;
- Adds extension to linkcollection compiler;
- Adds unit tests for both mp2sp and linkcollection intents;
Change-Id: I673c2b660d2364c510b1b3050ed3626ad2f37bda
diff --git a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
index 0f5b3d0..6e9d68c 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/ConnectivityIntentTest.java
@@ -15,8 +15,12 @@
*/
package org.onosproject.net.intent;
+import java.util.Collections;
+import java.util.Map;
import java.util.Set;
+import com.google.common.collect.Maps;
+import org.onlab.packet.VlanId;
import org.onosproject.core.ApplicationId;
import org.onosproject.TestApplicationId;
import org.onosproject.net.ConnectPoint;
@@ -38,6 +42,7 @@
public static final IntentId IID = new IntentId(123);
public static final TrafficSelector MATCH = DefaultTrafficSelector.emptySelector();
public static final TrafficTreatment NOP = DefaultTrafficTreatment.emptyTreatment();
+ public static final Map<ConnectPoint, TrafficSelector> MATCHES = Collections.emptyMap();
public static final ConnectPoint P1 = new ConnectPoint(DeviceId.deviceId("111"), PortNumber.portNumber(0x1));
public static final ConnectPoint P2 = new ConnectPoint(DeviceId.deviceId("222"), PortNumber.portNumber(0x2));
@@ -45,4 +50,18 @@
public static final Set<ConnectPoint> PS1 = itemSet(new ConnectPoint[]{P1, P3});
public static final Set<ConnectPoint> PS2 = itemSet(new ConnectPoint[]{P2, P3});
+
+ public static final TrafficSelector VLANMATCH1 = DefaultTrafficSelector.builder()
+ .matchVlanId(VlanId.vlanId("2"))
+ .build();
+ public static final TrafficSelector VLANMATCH2 = DefaultTrafficSelector.builder()
+ .matchVlanId(VlanId.vlanId("3"))
+ .build();
+
+ public static final Map<ConnectPoint, TrafficSelector> VLANMATCHES = Maps.newHashMap();
+ static {
+ VLANMATCHES.put(P1, VLANMATCH1);
+ VLANMATCHES.put(P2, VLANMATCH2);
+ }
+
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
index 9061418..115af4a 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/MultiPointToSinglePointIntentTest.java
@@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.onosproject.net.intent;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
@@ -42,6 +45,39 @@
assertEquals("incorrect egress", P2, intent.egressPoint());
}
+ @Rule
+ public ExpectedException wrongMultiple = ExpectedException.none();
+
+ @Test
+ public void multipleSelectors() {
+
+ MultiPointToSinglePointIntent intent = createFirstMultiple();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", PS1, intent.ingressPoints());
+ assertEquals("incorrect egress", P2, intent.egressPoint());
+ assertEquals("incorrect selectors", MATCHES, intent.ingressSelectors());
+
+ intent = createSecondMultiple();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", VLANMATCH1, intent.selector());
+ assertEquals("incorrect ingress", PS1, intent.ingressPoints());
+ assertEquals("incorrect egress", P2, intent.egressPoint());
+ assertEquals("incorrect selectors", MATCHES, intent.ingressSelectors());
+
+ intent = createThirdMultiple();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect match", MATCH, intent.selector());
+ assertEquals("incorrect ingress", PS1, intent.ingressPoints());
+ assertEquals("incorrect egress", P2, intent.egressPoint());
+ assertEquals("incorrect selectors", VLANMATCHES, intent.ingressSelectors());
+
+ wrongMultiple.expect(IllegalArgumentException.class);
+ wrongMultiple.expectMessage("Selector and Multiple Selectors are both set");
+ intent = createWrongMultiple();
+ }
+
+
@Override
protected MultiPointToSinglePointIntent createOne() {
return MultiPointToSinglePointIntent.builder()
@@ -63,4 +99,49 @@
.egressPoint(P1)
.build();
}
+
+ protected MultiPointToSinglePointIntent createFirstMultiple() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .selectors(MATCHES)
+ .build();
+ }
+
+ protected MultiPointToSinglePointIntent createSecondMultiple() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(VLANMATCH1)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .selectors(MATCHES)
+ .build();
+ }
+
+ protected MultiPointToSinglePointIntent createThirdMultiple() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(MATCH)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .selectors(VLANMATCHES)
+ .build();
+ }
+
+ protected MultiPointToSinglePointIntent createWrongMultiple() {
+ return MultiPointToSinglePointIntent.builder()
+ .appId(APPID)
+ .selector(VLANMATCH1)
+ .treatment(NOP)
+ .ingressPoints(PS1)
+ .egressPoint(P2)
+ .selectors(VLANMATCHES)
+ .build();
+ }
+
}