Search in sources :

Example 1 with Site

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;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) ArrayList(java.util.ArrayList)

Example 2 with Site

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;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Example 3 with Site

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;
}
Also used : Site(org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site) MappingRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Aggregations

Site (org.opendaylight.lispflowmapping.integrationtest.MultiSiteScenarioUtil.Site)3 ArrayList (java.util.ArrayList)2 LocatorRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)2 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)1 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)1