Search in sources :

Example 16 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testTwoEgressCompilation.

/**
 * Tests a simple topology where two egress points share some path segments
 * and some path segments are not shared.
 */
@Test
public void testTwoEgressCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
    FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo);
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = { S2, S3 };
    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, is(true));
    if (resultIntent instanceof LinkCollectionIntent) {
        LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
        assertThat(linkIntent.links(), hasSize(4));
        assertThat(linkIntent.links(), linksHasPath(S1, S2));
        assertThat(linkIntent.links(), linksHasPath(S2, S3));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
        assertThat(linkIntent.links(), linksHasPath(S3, S5));
    }
    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 17 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testSameDeviceCompilation.

/**
 * Tests ingress and egress on the same device.
 */
@Test
public void testSameDeviceCompilation() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = Sets.newHashSet(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_3)));
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
    assertThat(intent, is(notNullValue()));
    final String[] hops = {};
    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(0));
    }
    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 18 with SinglePointToMultiPointIntent

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

the class SinglePointToMultiPointIntentCompilerTest method testPartialFailureConstraintSuccess.

/**
 * Tests if all expected links are present when a partial failure
 * constraint is used and one ingress is not present.
 */
@Test
public void testPartialFailureConstraintSuccess() {
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2)));
    final List<Constraint> constraints = Collections.singletonList(new PartialFailureConstraint());
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, constraints);
    String[] hops = { S3 };
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), null);
    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(2));
        assertThat(linkIntent.links(), linksHasPath(S1, S3));
        assertThat(linkIntent.links(), linksHasPath(S3, S4));
    }
    assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Also used : PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) 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) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 19 with SinglePointToMultiPointIntent

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

the class VplsIntentTest method buildBrcIntent.

/**
 * Builds a broadcast intent.
 *
 * @param key the key to identify the intent
 * @param src the ingress connect point
 * @param dsts the egress connect points
 * @return the generated single-point to multi-point intent
 */
private SinglePointToMultiPointIntent buildBrcIntent(Key key, FilteredConnectPoint src, Set<FilteredConnectPoint> dsts, EncapsulationType encap) {
    SinglePointToMultiPointIntent.Builder intentBuilder;
    TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
    intentBuilder = SinglePointToMultiPointIntent.builder().appId(APPID).key(key).selector(selector).filteredIngressPoint(src).filteredEgressPoints(dsts).constraints(VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET);
    VplsIntentUtility.setEncap(intentBuilder, VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT, encap);
    return intentBuilder.build();
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 20 with SinglePointToMultiPointIntent

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

the class VplsIntentTest method generateVplsBrc.

/**
 * Generates a list of the expected sp2mp intents for a VPLS.
 *
 * @param fcPoints the filtered connect point
 * @param name the name of the VPLS
 * @param encap the encapsulation type
 * @return the list of expected sp2mp intents for the given VPLS
 */
private List<SinglePointToMultiPointIntent> generateVplsBrc(Set<FilteredConnectPoint> fcPoints, String name, EncapsulationType encap) {
    List<SinglePointToMultiPointIntent> intents = Lists.newArrayList();
    fcPoints.forEach(point -> {
        Set<FilteredConnectPoint> otherPoints = fcPoints.stream().filter(fcp -> !fcp.equals(point)).collect(Collectors.toSet());
        Key brckey = buildKey(VplsIntentUtility.PREFIX_BROADCAST, point.connectPoint(), name, MacAddress.BROADCAST);
        intents.add(buildBrcIntent(brckey, point, otherPoints, encap));
    });
    return intents;
}
Also used : IntentServiceAdapter(org.onosproject.net.intent.IntentServiceAdapter) MockIdGenerator(org.onosproject.net.intent.MockIdGenerator) Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) NONE(org.onosproject.net.EncapsulationType.NONE) VplsData(org.onosproject.vpls.api.VplsData) InterfaceService(org.onosproject.net.intf.InterfaceService) IntentUtils(org.onosproject.net.intent.IntentUtils) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) After(org.junit.After) Map(java.util.Map) Intent(org.onosproject.net.intent.Intent) EasyMock.replay(org.easymock.EasyMock.replay) EasyMock.createMock(org.easymock.EasyMock.createMock) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) Before(org.junit.Before) EasyMock.anyObject(org.easymock.EasyMock.anyObject) ImmutableSet(com.google.common.collect.ImmutableSet) VLAN(org.onosproject.net.EncapsulationType.VLAN) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) VplsIntentUtility(org.onosproject.vpls.intent.VplsIntentUtility) EasyMock.expect(org.easymock.EasyMock.expect) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) EasyMock.expectLastCall(org.easymock.EasyMock.expectLastCall) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) MacAddress(org.onlab.packet.MacAddress) Assert.assertEquals(org.junit.Assert.assertEquals) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

SinglePointToMultiPointIntent (org.onosproject.net.intent.SinglePointToMultiPointIntent)22 ConnectPoint (org.onosproject.net.ConnectPoint)14 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)14 Intent (org.onosproject.net.intent.Intent)13 Test (org.junit.Test)10 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)10 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)9 TrafficSelector (org.onosproject.net.flow.TrafficSelector)8 Key (org.onosproject.net.intent.Key)7 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)6 MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Constraint (org.onosproject.net.intent.Constraint)3 IntentService (org.onosproject.net.intent.IntentService)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ImmutableSet (com.google.common.collect.ImmutableSet)2