use of org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site in project lispflowmapping by opendaylight.
the class MultiSiteScenario method concatenateSites.
private Iterable<Site> concatenateSites(final Site dstSite, final Site... additionalSitesFromMapping) {
final List<Site> sites = new ArrayList<>();
sites.add(dstSite);
for (Site additionalSite : additionalSitesFromMapping) {
sites.add(additionalSite);
}
return sites;
}
use of org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site in project lispflowmapping by opendaylight.
the class MultiSiteScenario method prepareMappingRecord.
private MappingRecordBuilder prepareMappingRecord(final EidType eidType, final Site srcSite, final Site... dstSites) {
assertTrue(isEidEquals(dstSites));
final MappingRecordBuilder mrb = prepareMappingRecordGeneral(eidType, srcSite, dstSites[0]);
final List<LocatorRecord> locatorRecords = new ArrayList<>();
if (!dstSites[0].isForDeletion) {
for (Site dstSite : dstSites) {
if (dstSite.getRloc() != null) {
locatorRecords.add(provideLocatorRecord(LispAddressUtil.asIpv4Rloc(dstSite.getRloc()), dstSite.getRloc(), dstSite.getWeight(), dstSite.getPriority()));
}
}
}
mrb.setLocatorRecord(locatorRecords);
return mrb;
}
use of org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site in project lispflowmapping by opendaylight.
the class MultiSiteScenario method checkActionAndRloc.
boolean checkActionAndRloc(final Site dstSite, boolean expectedPingWorks, MapReply mapReplyFromSrcToDst, final Site... additionalSitesFromMapping) {
final MappingRecord mappingRecord = verifyMappingRecord(mapReplyFromSrcToDst);
final boolean isNotDroppendSrcDst = !MappingRecord.Action.Drop.equals(mappingRecord.getAction());
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isNotDroppendSrcDst, "Drop action has appeared " + "during ping")) {
return true;
}
final List<LocatorRecord> locatorRecords = verifyLocatorRecordExists(mappingRecord);
for (Site expectedTargetSite : concatenateSites(dstSite, additionalSitesFromMapping)) {
boolean expectedTargetFound = false;
for (LocatorRecord locatorRecord : locatorRecords) {
if (expectedTargetSite.getRloc().equals(rlocToString(locatorRecord))) {
final byte[] ipv4AddressSrcDst = verifyIpv4Address(locatorRecord).getValue();
final byte[] rloc = InetAddresses.forString((expectedTargetSite.getRloc())).getAddress();
final boolean isRlocSrcDstEqual = Arrays.equals(ipv4AddressSrcDst, rloc);
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isRlocSrcDstEqual, "Unexpected RLOC." + "Expected value " + rloc + ". Real value " + ipv4AddressSrcDst + ".")) {
return true;
}
final boolean isWeightEquals = expectedTargetSite.getWeight() == locatorRecord.getWeight();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isWeightEquals, "Weight isn't equal." + "Expected value " + expectedTargetSite.getWeight() + ". Value from mapping" + locatorRecord.getWeight() + ".")) {
return true;
}
final boolean isPriorityEquals = expectedTargetSite.getPriority() == locatorRecord.getPriority();
if (isPossibleAssertPingResultImmediately(expectedPingWorks, isPriorityEquals, "Priority isn't " + "equal. Expected value " + expectedTargetSite.getPriority() + ". Value from mapping" + locatorRecord.getPriority() + ".")) {
return true;
}
expectedTargetFound = true;
break;
}
}
if (isPossibleAssertPingResultImmediately(expectedPingWorks, expectedTargetFound, "Mapping for " + expectedTargetSite.getRloc() + " was expected but wasn't returned from mapping service." + expectedTargetFound)) {
return true;
}
}
return false;
}
Aggregations