Search in sources :

Example 26 with LinkCollectionIntent

use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.

the class LinkCollectionIntentFlowObjectiveCompilerTest method testCompile.

/**
 * We test the proper compilation of a simple link collection intent
 * with connect points, empty trivial treatment and empty trivial selector.
 */
@Test
public void testCompile() {
    LinkCollectionIntent intent = LinkCollectionIntent.builder().appId(appId).selector(selector).treatment(treatment).links(links).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p1))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p1))).build();
    List<Intent> result = compiler.compile(intent, Collections.emptyList());
    assertThat(result, hasSize(1));
    assertThat(result.get(0), instanceOf(FlowObjectiveIntent.class));
    FlowObjectiveIntent foIntent = (FlowObjectiveIntent) result.get(0);
    List<Objective> objectives = foIntent.objectives();
    assertThat(objectives, hasSize(6));
    /*
         * First set of objective
         */
    forwardingObjective = (ForwardingObjective) objectives.get(0);
    nextObjective = (NextObjective) objectives.get(1);
    // expect selector and treatment
    TrafficSelector expectSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(1)).build();
    TrafficTreatment expectTreatment = DefaultTrafficTreatment.builder().setOutput(PortNumber.portNumber(1)).build();
    // test case for first next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for first forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * Second set of objective
         */
    forwardingObjective = (ForwardingObjective) objectives.get(2);
    nextObjective = (NextObjective) objectives.get(3);
    expectSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(0)).build();
    // test case for second next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for second forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * 3rd set of objective
         */
    forwardingObjective = (ForwardingObjective) objectives.get(4);
    nextObjective = (NextObjective) objectives.get(5);
    expectSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(1)).build();
    // test case for 3rd next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for 3rd forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 27 with LinkCollectionIntent

use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.

the class LinkCollectionIntentFlowObjectiveCompilerTest method testFilteredConnectPointForMpWithEncap.

/**
 * Multi point to single point intent with filtered connect point.
 * Scenario is the follow:
 *
 * -1 of1 2-1 of2 2-1 of4 2-
 *             3
 * -1 of3 2---/
 * We test the proper compilation constraint of mp2sp
 * with encapsulation, trivial selector, empty treatment and points.
 */
@Test
public void testFilteredConnectPointForMpWithEncap() throws Exception {
    LinkCollectionCompiler.labelAllocator.setLabelSelection(LABEL_SELECTION);
    Set<Link> testLinks = ImmutableSet.of(DefaultLink.builder().providerId(PID).src(of1p2).dst(of2p1).type(DIRECT).build(), DefaultLink.builder().providerId(PID).src(of3p2).dst(of2p3).type(DIRECT).build(), DefaultLink.builder().providerId(PID).src(of2p2).dst(of4p1).type(DIRECT).build());
    Set<FilteredConnectPoint> ingress = ImmutableSet.of(new FilteredConnectPoint(of3p1, vlan100Selector), new FilteredConnectPoint(of1p1, vlan100Selector));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(of4p2, vlan100Selector));
    EncapsulationConstraint constraint = new EncapsulationConstraint(EncapsulationType.VLAN);
    LinkCollectionIntent intent = LinkCollectionIntent.builder().appId(appId).selector(ethDstSelector).treatment(treatment).links(testLinks).filteredIngressPoints(ingress).filteredEgressPoints(egress).constraints(ImmutableList.of(constraint)).build();
    List<Intent> result = compiler.compile(intent, Collections.emptyList());
    assertThat(result, hasSize(1));
    assertThat(result.get(0), instanceOf(FlowObjectiveIntent.class));
    FlowObjectiveIntent foIntent = (FlowObjectiveIntent) result.get(0);
    List<Objective> objectives = foIntent.objectives();
    assertThat(objectives, hasSize(15));
    TrafficSelector expectSelector = DefaultTrafficSelector.builder(ethDstSelector).matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_100).build();
    TrafficSelector filteringSelector = vlan100Selector;
    TrafficTreatment expectTreatment = DefaultTrafficTreatment.builder().setVlanId(VLAN_1).setOutput(PortNumber.portNumber(2)).build();
    /*
         * First set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(0);
    forwardingObjective = (ForwardingObjective) objectives.get(1);
    nextObjective = (NextObjective) objectives.get(2);
    PortCriterion inPortCriterion = (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);
    // test case for first filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, filteringSelector.criteria());
    // test case for first next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for first forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * Second set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(3);
    forwardingObjective = (ForwardingObjective) objectives.get(4);
    nextObjective = (NextObjective) objectives.get(5);
    expectSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_1).build();
    filteringSelector = vlan1Selector;
    expectTreatment = DefaultTrafficTreatment.builder().setVlanId(VLAN_100).setOutput(PortNumber.portNumber(2)).build();
    // test case for second filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, filteringSelector.criteria());
    // test case for second next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for second forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * 3rd set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(6);
    forwardingObjective = (ForwardingObjective) objectives.get(7);
    nextObjective = (NextObjective) objectives.get(8);
    filteringSelector = vlan100Selector;
    expectTreatment = DefaultTrafficTreatment.builder().setVlanId(VLAN_1).setOutput(PortNumber.portNumber(2)).build();
    expectSelector = DefaultTrafficSelector.builder(ethDstSelector).matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_100).build();
    // test case for 3rd filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, filteringSelector.criteria());
    // test case for 3rd next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for 3rd forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * 4th set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(9);
    forwardingObjective = (ForwardingObjective) objectives.get(10);
    nextObjective = (NextObjective) objectives.get(11);
    filteringSelector = vlan1Selector;
    expectSelector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(1)).matchVlanId(VLAN_1).build();
    // test case for 4th filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, filteringSelector.criteria());
    // test case for 4th next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for 4th forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
    /*
         * 5th set of objective
         */
    filteringObjective = (FilteringObjective) objectives.get(12);
    forwardingObjective = (ForwardingObjective) objectives.get(13);
    nextObjective = (NextObjective) objectives.get(14);
    expectSelector = DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("1")).matchInPort(PortNumber.portNumber(3)).build();
    inPortCriterion = (PortCriterion) expectSelector.getCriterion(Criterion.Type.IN_PORT);
    // test case for 5th filtering objective
    checkFiltering(filteringObjective, inPortCriterion, intent.priority(), null, appId, true, filteringSelector.criteria());
    // test case for 5th next objective
    checkNext(nextObjective, SIMPLE, expectTreatment, expectSelector, ADD);
    // test case for 5th forwarding objective
    checkForward(forwardingObjective, ADD, expectSelector, nextObjective.id(), SPECIFIC);
}
Also used : EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) NextObjective(org.onosproject.net.flowobjective.NextObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) Objective(org.onosproject.net.flowobjective.Objective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test)

Example 28 with LinkCollectionIntent

use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.

the class MultiPointToSinglePointIntentCompilerTest method testSameDeviceCompilation.

/**
 * Tests ingress and egress on the same device.
 */
@Test
public void testSameDeviceCompilation() {
    Set<FilteredConnectPoint> ingress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1)), new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)));
    FilteredConnectPoint egress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_3));
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = {};
    MultiPointToSinglePointIntentCompiler 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(0));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 29 with LinkCollectionIntent

use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.

the class MultiPointToSinglePointIntentCompilerTest method testMultiIngressCompilation.

/**
 * Tests a large number of ingress points that share a common path to the
 * egress point.
 */
@Test
public void testMultiIngressCompilation() {
    Set<FilteredConnectPoint> ingress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1)), new FilteredConnectPoint(new ConnectPoint(DID_2, PORT_1)), new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_1)));
    FilteredConnectPoint egress = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_1));
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = { S4 };
    MultiPointToSinglePointIntentCompiler 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, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(4));
        assertThat(linkIntent.links(), linksHasPath(S1, S4));
        assertThat(linkIntent.links(), linksHasPath(S2, S4));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
        assertThat(linkIntent.links(), linksHasPath(S4, S5));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 30 with LinkCollectionIntent

use of org.onosproject.net.intent.LinkCollectionIntent in project onos by opennetworkinglab.

the class MultiPointToSinglePointIntentCompilerTest method testFilteredConnectPointIntent.

/**
 * Tests filtered ingress and egress.
 */
@Test
public void testFilteredConnectPointIntent() {
    Set<FilteredConnectPoint> ingress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("100")).build()), new FilteredConnectPoint(new ConnectPoint(DID_2, PORT_1), DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId("200")).build()));
    FilteredConnectPoint egress = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress, selector);
    String[] hops = { S3 };
    MultiPointToSinglePointIntentCompiler 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, S3));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) 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