Search in sources :

Example 51 with Intent

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

the class MultiPointToSinglePointIntentCompilerTest method testSingleLongPathCompilation.

/**
 * Tests a single ingress point with 8 hops to its egress point.
 */
@Test
public void testSingleLongPathCompilation() {
    Set<FilteredConnectPoint> ingress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1)));
    FilteredConnectPoint egress = new FilteredConnectPoint(new ConnectPoint(DID_8, PORT_1));
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    String[] hops = { S2, S3, S4, S5, S6, S7 };
    MultiPointToSinglePointIntentCompiler 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 : 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 52 with Intent

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

the class MultiPointToSinglePointIntentCompilerTest method testPartialFailureConstraintFailure.

/**
 * Tests if compiling an intent without partial failure constraints set and
 * with a missing ingress connect point generates an exception and no other
 * results.
 */
@Test
public void testPartialFailureConstraintFailure() {
    Set<FilteredConnectPoint> ingress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1)), new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_1)));
    FilteredConnectPoint egress = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress);
    String[] hops = { S3 };
    MultiPointToSinglePointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), null);
    assertThat(compiler, is(notNullValue()));
    intentException.expect(IntentException.class);
    List<Intent> result = compiler.compile(intent, null);
    assertThat(result, null);
}
Also used : MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 53 with Intent

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

the class MultiPointToSinglePointIntentCompilerTest method testNonTrivialSelectorsIntent.

/**
 * Tests selector, filtered ingress and egress.
 */
@Test
public void testNonTrivialSelectorsIntent() {
    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));
    TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf("192.168.100.0/24")).build();
    MultiPointToSinglePointIntent intent = makeIntent(ingress, egress, ipPrefixSelector);
    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(linkIntent.selector(), is(ipPrefixSelector));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) 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 54 with Intent

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

the class PathIntentCompilerTest method testCompile.

/**
 * Tests the compilation behavior of the path intent compiler.
 */
@Test
public void testCompile() {
    sut.activate();
    List<Intent> compiled = sut.compile(intent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(d1p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule1, d1p0.deviceId());
    assertThat(rule1.selector(), is(DefaultTrafficSelector.builder(selector).matchInPort(d1p0.port()).build()));
    assertThat(rule1.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d1p1.port()).build()));
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(d2p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule2, d2p0.deviceId());
    assertThat(rule2.selector(), is(DefaultTrafficSelector.builder(selector).matchInPort(d2p0.port()).build()));
    assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d2p1.port()).build()));
    FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(d3p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule3, d3p1.deviceId());
    assertThat(rule3.selector(), is(DefaultTrafficSelector.builder(selector).matchInPort(d3p1.port()).build()));
    assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder(treatment).setOutput(d3p0.port()).build()));
    sut.deactivate();
}
Also used : Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) FlowRule(org.onosproject.net.flow.FlowRule) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 55 with Intent

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

the class PathIntentCompilerTest method testMplsEncapCompile.

/**
 * Tests the compilation behavior of the path intent compiler in case of
 * encasulation costraint {@link EncapsulationConstraint}.
 */
@Test
public void testMplsEncapCompile() {
    sut.activate();
    List<Intent> compiled = sut.compile(constraintMplsIntent, Collections.emptyList());
    assertThat(compiled, hasSize(1));
    Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
    assertThat(rules, hasSize(3));
    FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(d1p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule1, d1p0.deviceId());
    assertThat(rule1.selector(), is(DefaultTrafficSelector.builder(selector).matchInPort(d1p0.port()).build()));
    MplsLabel mplsLabelToEncap = verifyMplsEncapTreatment(rule1.treatment(), d1p1, true, false);
    FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(d2p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule2, d2p0.deviceId());
    verifyMplsEncapSelector(rule2.selector(), d2p0, mplsLabelToEncap);
    mplsLabelToEncap = verifyMplsEncapTreatment(rule2.treatment(), d2p1, false, false);
    FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(d3p0.deviceId())).findFirst().get();
    verifyIdAndPriority(rule3, d3p1.deviceId());
    verifyMplsEncapSelector(rule3.selector(), d3p1, mplsLabelToEncap);
    verifyMplsEncapTreatment(rule3.treatment(), d3p0, false, true);
    sut.deactivate();
}
Also used : MplsLabel(org.onlab.packet.MplsLabel) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) FlowRule(org.onosproject.net.flow.FlowRule) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

Intent (org.onosproject.net.intent.Intent)282 Test (org.junit.Test)176 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)133 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)110 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)108 FlowRule (org.onosproject.net.flow.FlowRule)90 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)87 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)84 ConnectPoint (org.onosproject.net.ConnectPoint)78 DeviceId (org.onosproject.net.DeviceId)77 List (java.util.List)75 Collectors (java.util.stream.Collectors)71 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)70 PathIntent (org.onosproject.net.intent.PathIntent)70 Collection (java.util.Collection)60 VlanId (org.onlab.packet.VlanId)60 TrafficSelector (org.onosproject.net.flow.TrafficSelector)60 CoreService (org.onosproject.core.CoreService)59 Collections (java.util.Collections)57 ImmutableSet (com.google.common.collect.ImmutableSet)54