Search in sources :

Example 31 with Reference

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.set.community.set.community.method.Reference in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method checkSmr.

/**
 * Read packets from the given socket until a Map-Request is found. Assert that the request is an SMR, and the
 * Source EID field contains the given IPv4 EID. Note that the source EID does not have a mask length. If a
 * reference to the LISP Mapping Service is passed, send an SMR-invoked Map-Request, to simulate what would happen
 * in the real world. If a reference to the Mapping Service is passed, the internal state of the map caches and
 * subscribers is logged.
 *
 * @param socket the receive socket
 * @param lms reference to the LISP Mapping Service, if present, an SMR-invoked Map-Request is sent in reply to the
 *            SMR
 * @param ms reference to the Mapping System, if present, the internal state of map-caches and subscribers is logged
 * @param vni the VNI for the expected EID
 * @param eids the expected EIDs, as an IPv4 string, without mask length
 */
static void checkSmr(DatagramSocket socket, IFlowMapping lms, IMappingService ms, long vni, String... eids) {
    LOG.debug("checkSmr: expecting {} SMRs: {}", eids.length, eids);
    List<MapRequest> mapRequests = receiveExpectedSmrs(socket, eids.length);
    assertNoMoreSMRs(socket, ms);
    HashMap<Eid, Integer> eidSet = prepareExpectedEids(vni, eids);
    for (MapRequest mapRequest : mapRequests) {
        LOG.trace("Solicit Map-Request: {}", mapRequest);
        Eid originalSourceEid = mapRequest.getEidItem().get(0).getEid();
        assertEquals(DEFAULT_IPV4_EID_PREFIX, originalSourceEid);
        Eid smrEid = mapRequest.getSourceEid().getEid();
        int counterDecremented = eidSet.get(smrEid) - 1;
        if (counterDecremented < 0) {
            fail("checkSmr: SMR contains EID " + LispAddressStringifier.getString(smrEid) + ", which is not in the list of expected EIDs: " + eidSet);
        } else {
            LOG.debug("checkSmr: successfully received expected SMR for {}", LispAddressStringifier.getString(smrEid));
        }
        if (lms != null) {
            sendSMRInvokedMapRequestMessage(mapRequest, lms);
        // TODO Capture the reply to the SMR-invoked Map-Request and assert on the expected result
        }
    }
    if (ms != null) {
        printMapCacheState(ms);
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) MapRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapRequest)

Aggregations

ArrayList (java.util.ArrayList)8 Test (org.junit.Test)6 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)6 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)6 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 BigInteger (java.math.BigInteger)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Nullable (javax.annotation.Nullable)3 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)3 CommunitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.CommunitiesBuilder)3 StringUtils (org.apache.commons.lang3.StringUtils)2 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)2 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)2 RouteEntryBaseAttributes (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes)2 BgpActionPolicy (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionPolicy)2 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)2 BGPRouteEntryImportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters)2