Search in sources :

Example 46 with Dst

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.

the class MappingSystemTest method getMappingTest_NbSbIntersection_withServicePathDestinationAddress.

/**
 * Tests {@link MappingSystem#getMapping} method, northbound and southbound intersection with ServicePath type dst
 * address and single Ipv4 type locator record. Returns the original mapping.
 */
@Test
public void getMappingTest_NbSbIntersection_withServicePathDestinationAddress() throws NoSuchFieldException, IllegalAccessException {
    setLookupPolicy(IMappingService.LookupPolicy.NB_AND_SB);
    final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(// Ipv4 type Rloc
    getDefaultLocatorRecordBuilder().build())).build();
    final MappingData mappingData = getDefaultMappingData(mappingRecord);
    Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH)).thenReturn(mappingData);
    assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH));
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 47 with Dst

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.

the class MappingSystemTest method getMappingTest_NbFirst.

/**
 * Tests {@link MappingSystem#getMapping} method with Ipv4 type dst address.
 */
@Test
public void getMappingTest_NbFirst() {
    final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().build())).build();
    final MappingData mappingData = getDefaultMappingData(mappingRecord);
    Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_IPV4_DST)).thenReturn(mappingData);
    assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST));
}
Also used : MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 48 with Dst

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.

the class MapResolverTest method handleMapRequest__withSubscribersToRemove.

/**
 * Tests {@link MapResolver#handleMapRequest} method.
 */
@Test
@Ignore
public void handleMapRequest__withSubscribersToRemove() {
    // input mapping
    final LocatorRecordBuilder locatorRecordBuilder = getDefaultLocatorBuilder();
    final MappingRecordBuilder mappingRecordBuilder = getDefaultMappingRecordBuilder();
    mappingRecordBuilder.getLocatorRecord().add(locatorRecordBuilder.build());
    MappingData mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_1)).thenReturn(mappingData);
    Mockito.when(mapServiceMock.getData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS)).thenReturn(subscriberSetMock);
    Subscriber subscriberMock = new Subscriber(mapRequestBuilder.getItrRloc().get(0).getRloc(), mapRequestBuilder.getSourceEid().getEid(), Subscriber.DEFAULT_SUBSCRIBER_TIMEOUT);
    subscriberMock.setSubscriberTtlByRecordTtl(mappingRecordBuilder.getRecordTtl());
    Mockito.when(subscriberSetMock.contains(subscriberMock)).thenReturn(true);
    // result
    final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
    mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder.build()).build());
    // check if a subscriber is re-instantiating when there already is one in the subscriber set
    mapResolver.handleMapRequest(mapRequestBuilder.build());
    Mockito.verify(subscriberSetMock).remove(subscriberMock);
    Mockito.verify(subscriberSetMock).add(subscriberMock);
    Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
    Mockito.verify(mapServiceMock).addData(MappingOrigin.Southbound, IPV4_PREFIX_EID_1, SubKeys.SUBSCRIBERS, subscriberSetMock);
    // verify that itrRloc is subscribed to dst address
    mappingRecordBuilder.setEid(SOURCE_DEST_KEY_EID);
    mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(IPV4_PREFIX_EID_2).build());
    mappingData = getDefaultMappingData(mappingRecordBuilder.build());
    Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), IPV4_PREFIX_EID_2)).thenReturn(mappingData);
    mapResolver.handleMapRequest(mapRequestBuilder.build());
    Mockito.verify(mapServiceMock).getData(MappingOrigin.Southbound, SourceDestKeyHelper.getDstBinary(SOURCE_DEST_KEY_EID), SubKeys.SUBSCRIBERS);
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) MappingRecordItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) MapReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder) EidItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.list.EidItemBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 49 with Dst

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.

the class MappingSystem method getMappingNbSbIntersection.

private MappingData getMappingNbSbIntersection(Eid src, Eid dst) {
    // lookupPolicy == NB_AND_SB, we return intersection
    // of NB and SB mappings, or NB mapping if intersection is empty.
    MappingData nbMappingData = (MappingData) pmc.getMapping(src, dst);
    if (nbMappingData == null) {
        return nbMappingData;
    }
    // no intersection for Service Path mappings
    if (dst.getAddress() instanceof ServicePath) {
        return updateServicePathMappingRecord(nbMappingData, dst);
    }
    MappingData sbMappingData = getSbMappingWithExpiration(src, dst, null);
    if (sbMappingData == null) {
        return nbMappingData;
    }
    // both NB and SB mappings exist. Compute intersection of the mappings
    return MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
}
Also used : MappingData(org.opendaylight.lispflowmapping.lisp.type.MappingData) ServicePath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath)

Example 50 with Dst

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.nx.reg.move.Dst in project lispflowmapping by opendaylight.

the class MapResolver method updateSubscribers.

private void updateSubscribers(Rloc itrRloc, Eid reqEid, Eid mapEid, Eid srcEid, Integer recordTtl) {
    Subscriber subscriber = new Subscriber(itrRloc, srcEid, Subscriber.recordTtlToSubscriberTime(recordTtl));
    Eid subscribedEid = mapEid;
    // mapping will be pushed to dst as well (see sendSMRs in MapServer)
    if (mapEid.getAddressType().equals(SourceDestKeyLcaf.class) && !reqEid.getAddressType().equals(SourceDestKeyLcaf.class)) {
        subscribedEid = SourceDestKeyHelper.getDstBinary(mapEid);
    }
    mapService.subscribe(subscriber, subscribedEid);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKeyLcaf(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SourceDestKeyLcaf)

Aggregations

Test (org.junit.Test)50 BigInteger (java.math.BigInteger)30 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)23 ArrayList (java.util.ArrayList)22 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)20 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)19 Ipv4Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match)18 UdpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch)18 TcpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch)17 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)16 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)15 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)15 Ipv6Match (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match)14 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 SctpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch)13 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)12 ArpMatch (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch)12 FlowWildcardsV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10)12 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)12 IpMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder)9