Search in sources :

Example 6 with SpeakerResponse

use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.

the class FlowPathSwapServiceTest method shouldFailSwapOnUnsuccessfulYFlowRulesInstallation.

@Test
public void shouldFailSwapOnUnsuccessfulYFlowRulesInstallation() {
    // given
    Flow origin = dummyFactory.makeFlowWithProtectedPath(flowSource, flowDestination, singletonList(islSourceDest), singletonList(islSourceDestAlt));
    createTestYFlowForSubFlow(origin);
    // when
    FlowPathSwapService service = makeService();
    FlowPathSwapRequest request = new FlowPathSwapRequest(origin.getFlowId(), false);
    service.handleRequest(dummyRequestKey, commandContext, request);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    int failCounter = 1;
    SpeakerRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        SpeakerResponse commandResponse;
        if (speakerRequest instanceof FlowSegmentRequest) {
            commandResponse = buildSpeakerResponse((FlowSegmentRequest) speakerRequest);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
            if (failCounter > 0) {
                commandResponse = buildErrorYFlowSpeakerResponse(speakerCommandsRequest);
                failCounter--;
            } else {
                commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
            }
        }
        service.handleAsyncResponse(dummyRequestKey, commandResponse);
    }
    // then
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyPathNotSwapped(origin, result);
    verifyNorthboundSuccessResponse(carrier);
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowPathSwapRequest(org.openkilda.messaging.command.flow.FlowPathSwapRequest) SpeakerRequest(org.openkilda.floodlight.api.request.SpeakerRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 7 with SpeakerResponse

use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.

the class YFlowDeleteServiceTest method handleSpeakerCommandsAndTimeoutRemove.

private void handleSpeakerCommandsAndTimeoutRemove(YFlowDeleteService yFlowDeleteService, String yFlowFsmKey) {
    handleSpeakerRequests(request -> {
        SpeakerResponse commandResponse;
        if (request instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
            commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
            handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
            if (speakerCommandsRequest instanceof DeleteSpeakerCommandsRequest) {
                try {
                    yFlowDeleteService.handleTimeout(yFlowFsmKey);
                } catch (UnknownKeyException ex) {
                // skip
                }
            } else {
                commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
                handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
            }
        }
    });
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) DeleteSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)

Example 8 with SpeakerResponse

use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.

the class YFlowUpdateServiceTest method processCreateRequestAndSpeakerCommands.

private void processCreateRequestAndSpeakerCommands(YFlowRequest yFlowRequest) throws DuplicateKeyException {
    YFlowCreateService service = makeYFlowCreateService(0);
    service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
    verifyYFlowStatus(yFlowRequest.getYFlowId(), FlowStatus.IN_PROGRESS);
    handleSpeakerRequests(speakerRequest -> {
        SpeakerResponse commandResponse;
        if (speakerRequest instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
            commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
            commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
        }
        handleAsyncResponse(service, yFlowRequest.getYFlowId(), commandResponse);
    });
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)

Example 9 with SpeakerResponse

use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.

the class YFlowUpdateServiceTest method handleSpeakerCommandsAndFailInstall.

private void handleSpeakerCommandsAndFailInstall(YFlowUpdateService yFlowUpdateService, String yFlowFsmKey, String commandFlowIdToFail) {
    handleSpeakerRequests(request -> {
        SpeakerResponse commandResponse;
        if (request instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
            commandResponse = flowSegmentRequest.isInstallRequest() && flowSegmentRequest.getMetadata().getFlowId().equals(commandFlowIdToFail) ? buildErrorSpeakerResponse(flowSegmentRequest) : buildSuccessfulSpeakerResponse(flowSegmentRequest);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
            commandResponse = request instanceof InstallSpeakerCommandsRequest ? buildErrorYFlowSpeakerResponse(speakerCommandsRequest) : buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
        }
        handleAsyncResponse(yFlowUpdateService, yFlowFsmKey, commandResponse);
    });
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) InstallSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)

Example 10 with SpeakerResponse

use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.

the class YFlowUpdateServiceTest method handleSpeakerCommandsAndTimeoutInstall.

private void handleSpeakerCommandsAndTimeoutInstall(YFlowUpdateService yFlowUpdateService, String yFlowFsmKey) {
    handleSpeakerRequests(request -> {
        SpeakerResponse commandResponse;
        if (request instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
            commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
            yFlowUpdateService.handleAsyncResponse(yFlowFsmKey, commandResponse);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
            if (speakerCommandsRequest instanceof InstallSpeakerCommandsRequest) {
                handleTimeout(yFlowUpdateService, yFlowFsmKey);
            } else {
                commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
                yFlowUpdateService.handleAsyncResponse(yFlowFsmKey, commandResponse);
            }
        }
    });
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) InstallSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)

Aggregations

SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)33 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)21 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)21 CommandContext (org.openkilda.wfm.CommandContext)9 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)6 UUID (java.util.UUID)4 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)4 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)3 String.format (java.lang.String.format)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)2 SpeakerFlowSegmentResponse (org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse)2 SpeakerCommandResponse (org.openkilda.floodlight.api.response.rulemanager.SpeakerCommandResponse)2 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)2 SwitchId (org.openkilda.model.SwitchId)2 FlowPathSwapContext (org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapContext)2 FlowPathSwapFsm (org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapFsm)2 Event (org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapFsm.Event)2