Search in sources :

Example 11 with LinkCollectionIntent

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)));
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) Link(org.onosproject.net.Link) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 12 with LinkCollectionIntent

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()));
}
Also used : PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 13 with LinkCollectionIntent

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()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 14 with LinkCollectionIntent

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()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 15 with LinkCollectionIntent

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()));
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)39 Intent (org.onosproject.net.intent.Intent)37 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)35 ConnectPoint (org.onosproject.net.ConnectPoint)29 Test (org.junit.Test)27 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)20 Link (org.onosproject.net.Link)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)12 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)11 FlowObjectiveIntent (org.onosproject.net.intent.FlowObjectiveIntent)10 ImmutableList (com.google.common.collect.ImmutableList)9 DeviceId (org.onosproject.net.DeviceId)9 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)9 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)9 NextObjective (org.onosproject.net.flowobjective.NextObjective)9 Objective (org.onosproject.net.flowobjective.Objective)9 Set (java.util.Set)8 SinglePointToMultiPointIntent (org.onosproject.net.intent.SinglePointToMultiPointIntent)8