use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class LispSouthboundHandlerTest method mapRegister__VerifyBasicFields.
@Test
public void mapRegister__VerifyBasicFields() throws Exception {
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
MappingRecord eidToLocator = captor.getValue().getMapRegister().getMappingRecordItem().get(0).getMappingRecord();
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), eidToLocator.getEid());
assertEquals(1, eidToLocator.getLocatorRecord().size());
assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), eidToLocator.getLocatorRecord().get(0).getRloc());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testRepeatedSmr.
private void testRepeatedSmr() throws SocketTimeoutException, UnknownHostException {
cleanUP();
long timeout = ConfigIni.getInstance().getSmrTimeout();
ConfigIni.getInstance().setSmrRetryCount(5);
final InstanceIdType iid = new InstanceIdType(1L);
final Eid eid1 = LispAddressUtil.asIpv4Eid("1.1.1.1", 1L);
final Eid subscriberEid = LispAddressUtil.asIpv4Eid("2.2.2.2", 1L);
final int expectedSmrs1 = 2;
final int expectedSmrs2 = 3;
/* set auth */
final Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("0.0.0.0/0", iid);
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
/* add subscribers */
final String subscriberSrcRloc1 = "127.0.0.3";
final String subscriberSrcRloc2 = "127.0.0.4";
final Set<Subscriber> subscriberSet1 = Sets.newHashSet(newSubscriber(subscriberEid, subscriberSrcRloc1), newSubscriber(subscriberEid, subscriberSrcRloc2));
mapService.addData(MappingOrigin.Southbound, eid1, SubKeys.SUBSCRIBERS, subscriberSet1);
final SocketReader reader1 = startSocketReader(subscriberSrcRloc1, 15000);
final SocketReader reader2 = startSocketReader(subscriberSrcRloc2, 15000);
sleepForSeconds(1);
/* add mapping */
final MappingRecord mapping1 = new MappingRecordBuilder().setEid(eid1).setTimestamp(System.currentTimeMillis()).setRecordTtl(1440).build();
mapService.addMapping(MappingOrigin.Northbound, eid1, null, new MappingData(mapping1));
sleepForMilliseconds((timeout * expectedSmrs1) - (timeout / 2));
final List<MapRequest> requests1 = processSmrPackets(reader1, subscriberSrcRloc1, expectedSmrs1);
final MapReply mapReply1 = lms.handleMapRequest(new MapRequestBuilder(requests1.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc1)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
// sleep to get 1 extra smr request
sleepForMilliseconds(timeout * 1);
final List<MapRequest> requests2 = processSmrPackets(reader2, subscriberSrcRloc2, expectedSmrs2);
final MapReply mapReply2 = lms.handleMapRequest(new MapRequestBuilder(requests2.get(0)).setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()).setItrRloc(Lists.newArrayList(new ItrRlocBuilder().setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc2)).build())).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())).setSmrInvoked(true).setSmr(false).build());
sleepForSeconds(3);
assertEquals(expectedSmrs1, requests1.size());
assertEquals(expectedSmrs2, requests2.size());
assertEquals((long) mapReply1.getNonce(), (long) requests1.get(0).getNonce());
assertEquals((long) mapReply2.getNonce(), (long) requests2.get(0).getNonce());
assertNextBufferEmpty(reader1);
assertNextBufferEmpty(reader2);
reader1.stopReading();
reader2.stopReading();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method insertNBMappings.
private void insertNBMappings(long iid, String... prefixes) {
LOG.debug("Adding Northbound mappings in VNI {} for prefixes: {}", iid, prefixes);
final InstanceIdType iiType = new InstanceIdType(iid);
for (String prefix : prefixes) {
MappingRecord record = newMappingRecord(prefix, iiType);
mapService.addMapping(MappingOrigin.Northbound, record.getEid(), null, new MappingData(record));
}
sleepForMilliseconds(100);
MappingServiceIntegrationTestUtil.printMapCacheState(mapService);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method test22SBnegativeToSBexactMatch.
/*
* Mapping change: updating a negative southbound mapping with a positive one
* Support status: SUPPORTED
* Description: Simple case of updating an exact match SB prefix.
*/
private void test22SBnegativeToSBexactMatch() {
cleanUP();
allowNullAuthenticationForAllIPv4(1L);
// First we add two negative mappings to NB with a hole between them
insertNBMappings(1L, "192.167.0.0/16", "192.169.0.0/16");
// We query for the hole, adding a negative SB mapping for 192.168.0.0/16 with a subscriber in the process
MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
Eid expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
assertEquals(expectedNegativePrefix, mr.getEid());
assertTrue(MappingRecordUtil.isNegativeMapping(mr));
// Updated SB mapping with different locator set for the same exact prefix
registerSBMapping(1L, "192.168.0.0/16", "10.10.10.10");
// Notification is sent for the prefix
MappingServiceIntegrationTestUtil.checkSmr(socket, lms, mapService, 1L, "192.168.0.0");
mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
Eid expectedPositivePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
assertEquals(expectedPositivePrefix, mr.getEid());
assertTrue(MappingRecordUtil.isPositiveMapping(mr));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testNegativePrefix.
private void testNegativePrefix() {
// First, we test with one mapping in NB and one mapping in SB
cleanUP();
allowNullAuthenticationForAllIPv4(1L);
insertNBMappings(1L, "192.0.2.0/24");
insertSBMappings(false, 1L, "10.0.0.0/32");
restartSocket();
sleepForSeconds(2);
MapReply mapReply = lms.handleMapRequest(newMapRequest(1L, "11.1.1.1/32"));
Eid expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "11.0.0.0/8");
assertEquals(expectedNegativePrefix, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid());
assertTrue(MappingRecordUtil.isNegativeMapping(mapReply.getMappingRecordItem().get(0).getMappingRecord()));
// Second, we test with two mappings in NB only
cleanUP();
insertNBMappings(1L, "192.167.0.0/16", "192.169.0.0/16");
restartSocket();
sleepForSeconds(2);
mapReply = lms.handleMapRequest(newMapRequest(1L, "192.168.0.1/32"));
expectedNegativePrefix = LispAddressUtil.asIpv4PrefixBinaryEid(1L, "192.168.0.0/16");
MappingRecord mr = mapReply.getMappingRecordItem().get(0).getMappingRecord();
assertEquals(expectedNegativePrefix, mr.getEid());
assertTrue(MappingRecordUtil.isNegativeMapping(mr));
}
Aggregations