Search in sources :

Example 1 with FlowEntityMatcher

use of org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method testProgramVpnToScfWithIfacesNotBound.

@Test
public void testProgramVpnToScfWithIfacesNotBound() throws Exception {
    // ///////////////////
    // Basic stubbing //
    // ///////////////////
    String ifaceName = "eth0";
    stubGetRouteDistinguisher(VPN_NAME, RD);
    stubGetVpnInstance(RD, "1.2.3.4", ifaceName);
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder("11.12.13.14", 2000L, DC_GW_IP, RouteOrigin.STATIC, null).build();
    stubGetVrfEntries(RD, Collections.singletonList(vrfEntry));
    stubReadVpnToDpnList(RD, DPN_ID, Collections.singletonList(ifaceName));
    stubScfIsNotBoundOnIface(SCF_TAG, ifaceName);
    // ///////
    // SUT //
    // ///////
    short tableId = 10;
    vpnsch.programVpnToScfPipeline(VPN_NAME, tableId, SCF_TAG, LPORT_TAG, NwConstants.ADD_FLOW);
    // //////////
    // Verify //
    // //////////
    ArgumentCaptor<FlowEntity> argumentCaptor = ArgumentCaptor.forClass(FlowEntity.class);
    verify(ifaceMgr).bindService(eq(ifaceName), eq(ServiceModeIngress.class), anyObject());
    verify(mdsalMgr, times(2)).installFlow(argumentCaptor.capture());
    List<FlowEntity> installedFlowsCaptured = argumentCaptor.getAllValues();
    assert installedFlowsCaptured.size() == 2;
    RoutePaths routePath = vrfEntry.getRoutePaths().get(0);
    FlowEntity expectedLFibFlowEntity = VpnServiceChainUtils.buildLFibVpnPseudoPortFlow(DPN_ID, routePath.getLabel(), routePath.getNexthopAddress(), LPORT_TAG);
    assert new FlowEntityMatcher(expectedLFibFlowEntity).matches(installedFlowsCaptured.get(0));
    FlowEntity expectedLPortDispatcher = VpnServiceChainUtils.buildLportFlowDispForVpnToScf(DPN_ID, LPORT_TAG, SCF_TAG, tableId);
    assert new FlowEntityMatcher(expectedLPortDispatcher).matches(installedFlowsCaptured.get(1));
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) FlowEntityMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) ServiceModeIngress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress) Test(org.junit.Test)

Example 2 with FlowEntityMatcher

use of org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher in project netvirt by opendaylight.

the class VPNServiceChainHandlerTest method testProgramVpnToScfWithVpnIfacesAlreadyBound.

@Test
public void testProgramVpnToScfWithVpnIfacesAlreadyBound() throws Exception {
    // ///////////////////
    // Basic stubbing //
    // ///////////////////
    String ifaceName = "eth0";
    stubGetRouteDistinguisher(VPN_NAME, RD);
    stubGetVpnInstance(RD, "1.2.3.4", ifaceName);
    VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder("11.12.13.14", 2000L, DC_GW_IP, RouteOrigin.STATIC, null).build();
    stubGetVrfEntries(RD, Collections.singletonList(vrfEntry));
    stubReadVpnToDpnList(RD, DPN_ID, Collections.singletonList(ifaceName));
    stubScfIsBoundOnIface(SCF_TAG, ifaceName);
    // ///////
    // SUT //
    // ///////
    short tableId = 10;
    vpnsch.programVpnToScfPipeline(VPN_NAME, tableId, SCF_TAG, LPORT_TAG, NwConstants.ADD_FLOW);
    // //////////
    // Verify //
    // //////////
    ArgumentCaptor<FlowEntity> argumentCaptor = ArgumentCaptor.forClass(FlowEntity.class);
    verify(mdsalMgr, times(2)).installFlow(argumentCaptor.capture());
    List<FlowEntity> installedFlowsCaptured = argumentCaptor.getAllValues();
    assert installedFlowsCaptured.size() == 2;
    RoutePaths routePath = vrfEntry.getRoutePaths().get(0);
    FlowEntity expectedLFibFlowEntity = VpnServiceChainUtils.buildLFibVpnPseudoPortFlow(DPN_ID, routePath.getLabel(), routePath.getNexthopAddress(), LPORT_TAG);
    assert new FlowEntityMatcher(expectedLFibFlowEntity).matches(installedFlowsCaptured.get(0));
    FlowEntity expectedLPortDispatcher = VpnServiceChainUtils.buildLportFlowDispForVpnToScf(DPN_ID, LPORT_TAG, SCF_TAG, tableId);
    assert new FlowEntityMatcher(expectedLPortDispatcher).matches(installedFlowsCaptured.get(1));
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) FlowEntityMatcher(org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)2 FlowEntityMatcher (org.opendaylight.netvirt.cloudservicechain.matchers.FlowEntityMatcher)2 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)2 RoutePaths (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)2 ServiceModeIngress (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress)1