use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testSameSwitchDifferentPortsIntentCompilation.
/**
* Tests the compilation of an intent which designates two different ports
* on the same switch.
*/
@Test
public void testSameSwitchDifferentPortsIntentCompilation() {
FilteredConnectPoint src = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint dst = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2));
PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_1, PORT_2));
String[] hops = { S1 };
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> compiled = compiler.compile(intent, null);
assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(LinkCollectionIntent.class)));
LinkCollectionIntent linkCollectionIntent = (LinkCollectionIntent) compiled.get(0);
Set<Link> links = linkCollectionIntent.links();
assertThat(links, hasSize(0));
assertThat(linkCollectionIntent.filteredIngressPoints(), is(ImmutableSet.of(src)));
assertThat(linkCollectionIntent.filteredEgressPoints(), is(ImmutableSet.of(dst)));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testForwardPathCompilation.
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testForwardPathCompilation() {
PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_8, PORT_1));
String[] hops = { S1, S2, S3, S4, S5, S6, S7, S8 };
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
assertThat(forwardResultIntent instanceof LinkCollectionIntent, is(true));
if (forwardResultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent forwardIntent = (LinkCollectionIntent) forwardResultIntent;
FilteredConnectPoint ingressPoint = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressPoint = new FilteredConnectPoint(new ConnectPoint(DID_8, PORT_1));
// 7 links for the hops, plus one default lnk on ingress and egress
assertThat(forwardIntent.links(), hasSize(hops.length - 1));
assertThat(forwardIntent.links(), linksHasPath(S1, S2));
assertThat(forwardIntent.links(), linksHasPath(S2, S3));
assertThat(forwardIntent.links(), linksHasPath(S3, S4));
assertThat(forwardIntent.links(), linksHasPath(S4, S5));
assertThat(forwardIntent.links(), linksHasPath(S5, S6));
assertThat(forwardIntent.links(), linksHasPath(S6, S7));
assertThat(forwardIntent.links(), linksHasPath(S7, S8));
assertThat(forwardIntent.filteredIngressPoints(), is(ImmutableSet.of(ingressPoint)));
assertThat(forwardIntent.filteredEgressPoints(), is(ImmutableSet.of(egressPoint)));
}
assertThat("key is inherited", forwardResultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testSingleLongPathCompilation.
/**
* Tests a single ingress point with 8 hops to its egress point.
*/
@Test
public void testSingleLongPathCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
Set<FilteredConnectPoint> egress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_8, PORT_2)));
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
String[] hops = { S2, S3, S4, S5, S6, S7 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(7));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S3, S4));
assertThat(linkIntent.links(), linksHasPath(S4, S5));
assertThat(linkIntent.links(), linksHasPath(S5, S6));
assertThat(linkIntent.links(), linksHasPath(S6, S7));
assertThat(linkIntent.links(), linksHasPath(S7, S8));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testFilteredConnectPointIntent.
/**
* Tests filtered ingress and egress connect points.
*/
@Test
public void testFilteredConnectPointIntent() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()));
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, selector);
String[] hops = { S2 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(3));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S2, S4));
Set<FilteredConnectPoint> ingressPoints = linkIntent.filteredIngressPoints();
assertThat("Link collection ingress points do not match base intent", ingressPoints.size() == 1 && ingressPoints.contains(intent.filteredIngressPoint()));
assertThat("Link collection egress points do not match base intent", linkIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testNonTrivialSelectorsIntent.
/**
* Tests filtered ingress and egress points with an intent selector set.
*/
@Test
public void testNonTrivialSelectorsIntent() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()));
TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf("192.168.100.0/24")).build();
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, ipPrefixSelector);
String[] hops = { S2 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent, instanceOf(LinkCollectionIntent.class));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(3));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S2, S4));
Set<FilteredConnectPoint> ingressPoints = linkIntent.filteredIngressPoints();
assertThat("Link collection ingress points do not match base intent", ingressPoints.size() == 1 && ingressPoints.contains(intent.filteredIngressPoint()));
assertThat("Link collection egress points do not match base intent", linkIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()));
assertThat(linkIntent.selector(), is(ipPrefixSelector));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Aggregations