Committed by
Gerrit Code Review
Fix [ONOS-5467]
We were missing the selector during the building of the sp2mp and mp2sp. Change-Id: Ica456e7c92ef346721ce3f4ceccaf55033d25029
Showing
4 changed files
with
106 additions
and
4 deletions
... | @@ -120,6 +120,7 @@ public class MultiPointToSinglePointIntentCompiler | ... | @@ -120,6 +120,7 @@ public class MultiPointToSinglePointIntentCompiler |
120 | Intent result = LinkCollectionIntent.builder() | 120 | Intent result = LinkCollectionIntent.builder() |
121 | .appId(intent.appId()) | 121 | .appId(intent.appId()) |
122 | .treatment(intent.treatment()) | 122 | .treatment(intent.treatment()) |
123 | + .selector(intent.selector()) | ||
123 | .links(Sets.newHashSet(links.values())) | 124 | .links(Sets.newHashSet(links.values())) |
124 | .filteredIngressPoints(intent.filteredIngressPoints()) | 125 | .filteredIngressPoints(intent.filteredIngressPoints()) |
125 | .filteredEgressPoints(ImmutableSet.of(intent.filteredEgressPoint())) | 126 | .filteredEgressPoints(ImmutableSet.of(intent.filteredEgressPoint())) | ... | ... |
... | @@ -69,6 +69,7 @@ public class SinglePointToMultiPointIntentCompiler | ... | @@ -69,6 +69,7 @@ public class SinglePointToMultiPointIntentCompiler |
69 | Intent result = LinkCollectionIntent.builder() | 69 | Intent result = LinkCollectionIntent.builder() |
70 | .appId(intent.appId()) | 70 | .appId(intent.appId()) |
71 | .key(intent.key()) | 71 | .key(intent.key()) |
72 | + .selector(intent.selector()) | ||
72 | .treatment(intent.treatment()) | 73 | .treatment(intent.treatment()) |
73 | .links(links) | 74 | .links(links) |
74 | .filteredIngressPoints(ImmutableSet.of(intent.filteredIngressPoint())) | 75 | .filteredIngressPoints(ImmutableSet.of(intent.filteredIngressPoint())) | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent.impl.compiler; | ... | @@ -18,6 +18,7 @@ package org.onosproject.net.intent.impl.compiler; |
18 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
19 | import org.hamcrest.Matchers; | 19 | import org.hamcrest.Matchers; |
20 | import org.junit.Test; | 20 | import org.junit.Test; |
21 | +import org.onlab.packet.IpPrefix; | ||
21 | import org.onlab.packet.VlanId; | 22 | import org.onlab.packet.VlanId; |
22 | import org.onosproject.TestApplicationId; | 23 | import org.onosproject.TestApplicationId; |
23 | import org.onosproject.core.ApplicationId; | 24 | import org.onosproject.core.ApplicationId; |
... | @@ -87,10 +88,12 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes | ... | @@ -87,10 +88,12 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes |
87 | * @return | 88 | * @return |
88 | */ | 89 | */ |
89 | private MultiPointToSinglePointIntent makeFilteredConnectPointIntent(Set<FilteredConnectPoint> ingress, | 90 | private MultiPointToSinglePointIntent makeFilteredConnectPointIntent(Set<FilteredConnectPoint> ingress, |
90 | - FilteredConnectPoint egress) { | 91 | + FilteredConnectPoint egress, |
92 | + TrafficSelector trafficSelector) { | ||
91 | return MultiPointToSinglePointIntent.builder() | 93 | return MultiPointToSinglePointIntent.builder() |
92 | .appId(APPID) | 94 | .appId(APPID) |
93 | .treatment(treatment) | 95 | .treatment(treatment) |
96 | + .selector(trafficSelector) | ||
94 | .filteredIngressPoints(ingress) | 97 | .filteredIngressPoints(ingress) |
95 | .filteredEgressPoint(egress) | 98 | .filteredEgressPoint(egress) |
96 | .build(); | 99 | .build(); |
... | @@ -257,7 +260,7 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes | ... | @@ -257,7 +260,7 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes |
257 | 260 | ||
258 | FilteredConnectPoint egress = new FilteredConnectPoint(connectPoint("of4", 1)); | 261 | FilteredConnectPoint egress = new FilteredConnectPoint(connectPoint("of4", 1)); |
259 | 262 | ||
260 | - MultiPointToSinglePointIntent intent = makeFilteredConnectPointIntent(ingress, egress); | 263 | + MultiPointToSinglePointIntent intent = makeFilteredConnectPointIntent(ingress, egress, selector); |
261 | String[] hops = {"of3"}; | 264 | String[] hops = {"of3"}; |
262 | 265 | ||
263 | MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops); | 266 | MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops); |
... | @@ -280,5 +283,48 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes | ... | @@ -280,5 +283,48 @@ public class MultiPointToSinglePointIntentCompilerTest extends AbstractIntentTes |
280 | 283 | ||
281 | } | 284 | } |
282 | 285 | ||
286 | + /** | ||
287 | + * Tests selector, filtered ingress and egress. | ||
288 | + */ | ||
289 | + @Test | ||
290 | + public void testNonTrivialSelectorsIntent() { | ||
291 | + | ||
292 | + Set<FilteredConnectPoint> ingress = ImmutableSet.of( | ||
293 | + new FilteredConnectPoint(connectPoint("of1", 1), | ||
294 | + DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), | ||
295 | + new FilteredConnectPoint(connectPoint("of2", 1), | ||
296 | + DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()) | ||
297 | + ); | ||
298 | + | ||
299 | + TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder() | ||
300 | + .matchIPDst(IpPrefix.valueOf("192.168.100.0/24")) | ||
301 | + .build(); | ||
302 | + | ||
303 | + FilteredConnectPoint egress = new FilteredConnectPoint(connectPoint("of4", 1)); | ||
304 | + | ||
305 | + MultiPointToSinglePointIntent intent = makeFilteredConnectPointIntent(ingress, egress, ipPrefixSelector); | ||
306 | + String[] hops = {"of3"}; | ||
307 | + | ||
308 | + MultiPointToSinglePointIntentCompiler compiler = makeCompiler(hops); | ||
309 | + assertThat(compiler, is(notNullValue())); | ||
310 | + | ||
311 | + List<Intent> result = compiler.compile(intent, null); | ||
312 | + assertThat(result, is(notNullValue())); | ||
313 | + assertThat(result, hasSize(1)); | ||
314 | + | ||
315 | + Intent resultIntent = result.get(0); | ||
316 | + assertThat(resultIntent, instanceOf(LinkCollectionIntent.class)); | ||
317 | + | ||
318 | + if (resultIntent instanceof LinkCollectionIntent) { | ||
319 | + LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent; | ||
320 | + assertThat(linkIntent.links(), hasSize(3)); | ||
321 | + assertThat(linkIntent.links(), linksHasPath("of1", "of3")); | ||
322 | + assertThat(linkIntent.links(), linksHasPath("of2", "of3")); | ||
323 | + assertThat(linkIntent.links(), linksHasPath("of3", "of4")); | ||
324 | + assertThat(linkIntent.selector(), is(ipPrefixSelector)); | ||
325 | + } | ||
326 | + | ||
327 | + } | ||
328 | + | ||
283 | 329 | ||
284 | } | 330 | } | ... | ... |
... | @@ -19,6 +19,7 @@ package org.onosproject.net.intent.impl.compiler; | ... | @@ -19,6 +19,7 @@ package org.onosproject.net.intent.impl.compiler; |
19 | import com.google.common.collect.ImmutableSet; | 19 | import com.google.common.collect.ImmutableSet; |
20 | import org.hamcrest.Matchers; | 20 | import org.hamcrest.Matchers; |
21 | import org.junit.Test; | 21 | import org.junit.Test; |
22 | +import org.onlab.packet.IpPrefix; | ||
22 | import org.onlab.packet.VlanId; | 23 | import org.onlab.packet.VlanId; |
23 | import org.onosproject.TestApplicationId; | 24 | import org.onosproject.TestApplicationId; |
24 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
... | @@ -91,10 +92,12 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes | ... | @@ -91,10 +92,12 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes |
91 | * @return | 92 | * @return |
92 | */ | 93 | */ |
93 | private SinglePointToMultiPointIntent makeFilteredConnectPointIntent(FilteredConnectPoint ingress, | 94 | private SinglePointToMultiPointIntent makeFilteredConnectPointIntent(FilteredConnectPoint ingress, |
94 | - Set<FilteredConnectPoint> egress) { | 95 | + Set<FilteredConnectPoint> egress, |
96 | + TrafficSelector trafficSelector) { | ||
95 | return SinglePointToMultiPointIntent.builder() | 97 | return SinglePointToMultiPointIntent.builder() |
96 | .appId(APPID) | 98 | .appId(APPID) |
97 | .treatment(treatment) | 99 | .treatment(treatment) |
100 | + .selector(trafficSelector) | ||
98 | .filteredIngressPoint(ingress) | 101 | .filteredIngressPoint(ingress) |
99 | .filteredEgressPoints(egress) | 102 | .filteredEgressPoints(egress) |
100 | .build(); | 103 | .build(); |
... | @@ -260,7 +263,7 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes | ... | @@ -260,7 +263,7 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes |
260 | ); | 263 | ); |
261 | 264 | ||
262 | 265 | ||
263 | - SinglePointToMultiPointIntent intent = makeFilteredConnectPointIntent(ingress, egress); | 266 | + SinglePointToMultiPointIntent intent = makeFilteredConnectPointIntent(ingress, egress, selector); |
264 | String[] hops = {"of2"}; | 267 | String[] hops = {"of2"}; |
265 | 268 | ||
266 | SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops); | 269 | SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops); |
... | @@ -290,4 +293,55 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes | ... | @@ -290,4 +293,55 @@ public class SinglePointToMultiPointIntentCompilerTest extends AbstractIntentTes |
290 | } | 293 | } |
291 | 294 | ||
292 | } | 295 | } |
296 | + | ||
297 | + /** | ||
298 | + * Tests selector, filtered ingress and egress. | ||
299 | + */ | ||
300 | + @Test | ||
301 | + public void testNonTrivialSelectorsIntent() { | ||
302 | + | ||
303 | + FilteredConnectPoint ingress = new FilteredConnectPoint(connectPoint("of1", 1)); | ||
304 | + | ||
305 | + Set<FilteredConnectPoint> egress = ImmutableSet.of( | ||
306 | + new FilteredConnectPoint(connectPoint("of3", 1), | ||
307 | + DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), | ||
308 | + new FilteredConnectPoint(connectPoint("of4", 1), | ||
309 | + DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()) | ||
310 | + ); | ||
311 | + | ||
312 | + TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder() | ||
313 | + .matchIPDst(IpPrefix.valueOf("192.168.100.0/24")) | ||
314 | + .build(); | ||
315 | + | ||
316 | + SinglePointToMultiPointIntent intent = makeFilteredConnectPointIntent(ingress, egress, ipPrefixSelector); | ||
317 | + String[] hops = {"of2"}; | ||
318 | + | ||
319 | + SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops); | ||
320 | + assertThat(compiler, is(notNullValue())); | ||
321 | + | ||
322 | + List<Intent> result = compiler.compile(intent, null); | ||
323 | + assertThat(result, is(notNullValue())); | ||
324 | + assertThat(result, hasSize(1)); | ||
325 | + | ||
326 | + Intent resultIntent = result.get(0); | ||
327 | + assertThat(resultIntent, instanceOf(LinkCollectionIntent.class)); | ||
328 | + | ||
329 | + if (resultIntent instanceof LinkCollectionIntent) { | ||
330 | + LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent; | ||
331 | + assertThat(linkIntent.links(), hasSize(3)); | ||
332 | + | ||
333 | + assertThat(linkIntent.links(), linksHasPath("of1", "of2")); | ||
334 | + assertThat(linkIntent.links(), linksHasPath("of2", "of3")); | ||
335 | + assertThat(linkIntent.links(), linksHasPath("of2", "of4")); | ||
336 | + | ||
337 | + Set<FilteredConnectPoint> ingressPoints = linkIntent.filteredIngressPoints(); | ||
338 | + assertThat("Link collection ingress points do not match base intent", | ||
339 | + ingressPoints.size() == 1 && ingressPoints.contains(intent.filteredIngressPoint())); | ||
340 | + | ||
341 | + assertThat("Link collection egress points do not match base intent", | ||
342 | + linkIntent.filteredEgressPoints().equals(intent.filteredEgressPoints())); | ||
343 | + assertThat(linkIntent.selector(), is(ipPrefixSelector)); | ||
344 | + } | ||
345 | + | ||
346 | + } | ||
293 | } | 347 | } | ... | ... |
-
Please register or login to post a comment