use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MapResolverTest method handleMapRequest_withMultipleEids.
/**
* Tests {@link MapResolver#handleMapRequest} method.
*/
@Test
public void handleMapRequest_withMultipleEids() {
mapRequestBuilder.getEidItem().add(new EidItemBuilder().setEid(IPV6_PREFIX_EID).build());
final LocatorRecordBuilder locatorRecordBuilder_1 = getDefaultLocatorBuilder();
final LocatorRecordBuilder locatorRecordBuilder_2 = getDefaultLocatorBuilder();
locatorRecordBuilder_2.setRloc(LispAddressUtil.asIpv6Rloc(IPV6_STRING));
// input mapping
final MappingRecordBuilder mappingRecordBuilder_1 = getDefaultMappingRecordBuilder();
mappingRecordBuilder_1.getLocatorRecord().add(locatorRecordBuilder_1.build());
final MappingData mappingData_1 = getDefaultMappingData(mappingRecordBuilder_1.build());
final MappingRecordBuilder mappingRecordBuilder_2 = getDefaultMappingRecordBuilder();
mappingRecordBuilder_2.getLocatorRecord().add(locatorRecordBuilder_2.build());
mappingRecordBuilder_2.setEid(IPV6_PREFIX_EID);
final MappingData mappingData_2 = getDefaultMappingData(mappingRecordBuilder_2.build());
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), mapRequestBuilder.getEidItem().get(0).getEid())).thenReturn(mappingData_1);
Mockito.when(mapServiceMock.getMapping(mapRequestBuilder.getSourceEid().getEid(), mapRequestBuilder.getEidItem().get(1).getEid())).thenReturn(mappingData_2);
// result
final MapReplyBuilder mapReplyBuilder = getDefaultMapReplyBuilder();
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder_1.build()).build());
mapReplyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(mappingRecordBuilder_2.build()).build());
mapResolver.handleMapRequest(mapRequestBuilder.build());
Mockito.verify(lispMappingServiceMock).handleMapReply(mapReplyBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MultiSiteScenario method emitMapRegisterMessage.
private void emitMapRegisterMessage(final Site dstSite, final boolean merge) {
final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder();
mapRegisterBuilder.setXtrSiteIdPresent(true);
mapRegisterBuilder.setXtrId(dstSite.getXtrId());
mapRegisterBuilder.setSiteId(new SiteId(DEFAULT_SITE_ID));
mapRegisterBuilder.setMergeEnabled(merge);
final MappingRecordItemBuilder mappingRecordItemBuilder = new MappingRecordItemBuilder();
mappingRecordItemBuilder.setMappingRecordItemId(MAP_RECORD_A);
final MappingRecordBuilder mrb = prepareMappingRecord(EidType.EID_WITH_PREFIX, null, dstSite);
mappingRecordItemBuilder.setMappingRecord(mrb.build());
mapRegisterBuilder.setMappingRecordItem(Collections.singletonList(mappingRecordItemBuilder.build()));
lms.handleMapRegister(mapRegisterBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method runPrefixTest.
private void runPrefixTest(Eid registerEID, Eid matchedAddress, Eid unMatchedAddress) throws SocketTimeoutException {
mapService.addAuthenticationKey(registerEID, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRegisterBuilder mapRegister = new MapRegisterBuilder();
mapRegister.setWantMapNotify(true);
mapRegister.setNonce((long) 8);
mapRegister.setWantMapNotify(true);
mapRegister.setKeyId((short) 0);
mapRegister.setAuthenticationData(new byte[0]);
mapRegister.setNonce((long) 8);
mapRegister.setProxyMapReply(false);
MappingRecordBuilder etlr = new MappingRecordBuilder();
etlr.setRecordTtl(254);
etlr.setAction(Action.NoAction);
etlr.setAuthoritative(false);
etlr.setMapVersion((short) 0);
etlr.setEid(registerEID);
etlr.setRecordTtl(254);
LocatorRecordBuilder record = new LocatorRecordBuilder();
record.setRloc(LispAddressUtil.asIpv4Rloc("4.3.2.1"));
record.setLocalLocator(false);
record.setRlocProbed(false);
record.setRouted(true);
record.setMulticastPriority((short) 0);
record.setMulticastWeight((short) 0);
record.setPriority((short) 0);
record.setWeight((short) 0);
etlr.setLocatorRecord(new ArrayList<LocatorRecord>());
etlr.getLocatorRecord().add(record.build());
mapRegister.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapRegister.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(etlr.build()).build());
sendMapRegister(mapRegister.build());
MapNotify mapNotify = receiveMapNotify();
assertEquals(8, mapNotify.getNonce().longValue());
sleepForSeconds(1);
MapRequestBuilder mapRequest = new MapRequestBuilder();
mapRequest.setNonce((long) 4);
mapRequest.setSourceEid(new SourceEidBuilder().setEid(LispAddressUtil.asIpv4Eid(ourAddress)).build());
mapRequest.setEidItem(new ArrayList<EidItem>());
mapRequest.setAuthoritative(false);
mapRequest.setMapDataPresent(false);
mapRequest.setPitr(false);
mapRequest.setProbe(false);
mapRequest.setSmr(false);
mapRequest.setSmrInvoked(false);
mapRequest.getEidItem().add(new EidItemBuilder().setEid(matchedAddress).build());
mapRequest.setItrRloc(new ArrayList<ItrRloc>());
mapRequest.getItrRloc().add(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(ourAddress)).build());
sendMapRequest(mapRequest.build());
MapReply mapReply = receiveMapReply();
assertEquals(4, mapReply.getNonce().longValue());
assertEquals(record.getRloc(), mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
mapRequest.setEidItem(new ArrayList<EidItem>());
mapRequest.getEidItem().add(new EidItemBuilder().setEid(unMatchedAddress).build());
sendMapRequest(mapRequest.build());
mapReply = receiveMapReply();
assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder in project lispflowmapping by opendaylight.
the class MapNotifySerializationTest method serialize__NoPrefixInEidToLocator.
@Test
public void serialize__NoPrefixInEidToLocator() throws Exception {
MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().build()).build());
mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(null).build()).build());
mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(new MappingRecordBuilder().setEid(LispAddressUtil.getNoAddressEid()).build()).build());
ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
// jump to first record prefix AFI
bb.position(bb.position() + 16);
assertEquals(0, bb.getShort());
// jump to second record prefix AFI
bb.position(bb.position() + 10);
assertEquals(0, bb.getShort());
// jump to third record prefix AFI
bb.position(bb.position() + 10);
assertEquals(0, bb.getShort());
}
Aggregations