Search in sources :

Example 6 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.

the class FlowDeleteServiceTest method shouldFailDeleteOnTimeoutDuringRuleRemoval.

@Test
public void shouldFailDeleteOnTimeoutDuringRuleRemoval() throws UnknownKeyException, DuplicateKeyException {
    String flowId = makeFlow().getFlowId();
    FlowDeleteService service = makeService();
    service.handleRequest(dummyRequestKey, commandContext, flowId);
    verifyFlowStatus(flowId, FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    // 4 flow rules + 4 mirror rules
    verify(carrier, times(8)).sendSpeakerRequest(any());
    service.handleTimeout(dummyRequestKey);
    // FIXME(surabujin): flow stays in IN_PROGRESS status, any further request can't be handled.
    // em... there is no actual handling for timeout event, so FSM will stack in memory forever
    Flow flow = verifyFlowStatus(flowId, FlowStatus.IN_PROGRESS);
    // Flow delete will be completed only on timeout event(s) produced by {@link SpeakerWorkerBolt} for all produced
    // speaker requests.
    FlowSegmentRequest flowRequest;
    while ((flowRequest = requests.poll()) != null) {
        service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().commandId(flowRequest.getCommandId()).switchId(flowRequest.getSwitchId()).metadata(flowRequest.getMetadata()).errorCode(ErrorCode.OPERATION_TIMED_OUT).messageContext(flowRequest.getMessageContext()).build());
    }
    verifyFlowIsMissing(flow);
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 7 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.

the class FlowDeleteServiceTest method testSpeakerErrorResponse.

private void testSpeakerErrorResponse(String flowId, ErrorCode errorCode) throws UnknownKeyException, DuplicateKeyException {
    FlowDeleteService service = makeService();
    service.handleRequest(dummyRequestKey, commandContext, flowId);
    Flow flow = verifyFlowStatus(flowId, FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    FlowSegmentRequest flowRequest;
    while ((flowRequest = requests.poll()) != null) {
        service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().errorCode(errorCode).description("Switch is unavailable").commandId(flowRequest.getCommandId()).metadata(flowRequest.getMetadata()).switchId(flowRequest.getSwitchId()).messageContext(flowRequest.getMessageContext()).build());
    }
    // 4 times sending 8 (4 flow rules + 4 mirror rules) rules = 32 requests.
    verify(carrier, times(32)).sendSpeakerRequest(any());
    verifyFlowIsMissing(flow);
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) Flow(org.openkilda.model.Flow)

Example 8 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldFailRerouteOnUnsuccessfulInstallation.

@Test
public void shouldFailRerouteOnUnsuccessfulInstallation() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    GetPathsResult newPathPair = make3SwitchesPathPair();
    preparePathComputation(origin.getFlowId(), newPathPair);
    FlowRerouteService service = makeService();
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        if (speakerRequest.isInstallRequest()) {
            service.handleAsyncResponse(currentRequestKey, FlowErrorResponse.errorBuilder().messageContext(speakerRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
        } else {
            produceAsyncResponse(service, speakerRequest);
        }
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(origin, result);
    verify(carrier).sendRerouteResultStatus(eq(origin.getFlowId()), argThat(hasProperty("message", equalTo("Failed to install rules"))), any(String.class));
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 9 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldCompleteRerouteOnErrorDuringResourceDeallocation.

@Test
public void shouldCompleteRerouteOnErrorDuringResourceDeallocation() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRerouteService service = makeService();
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    doThrow(new RuntimeException(injectedErrorMessage)).when(flowResourcesManager).deallocatePathResources(argThat(hasProperty("forward", hasProperty("pathId", equalTo(origin.getForwardPathId())))));
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        if (speakerRequest.isVerifyRequest()) {
            service.handleAsyncResponse(currentRequestKey, buildResponseOnVerifyRequest(speakerRequest));
        } else {
            produceAsyncResponse(service, speakerRequest);
        }
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyPathReplace(origin, result);
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 10 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldCompleteRerouteOnErrorDuringCompletingFlowPathRemoval.

@Test
public void shouldCompleteRerouteOnErrorDuringCompletingFlowPathRemoval() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowPathRepository repository = setupFlowPathRepositorySpy();
    doThrow(new RuntimeException(injectedErrorMessage)).when(repository).remove(eq(origin.getForwardPathId()));
    FlowRerouteService service = makeService();
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        produceAsyncResponse(service, speakerRequest);
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyPathReplace(origin, result);
}
Also used : FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)65 Flow (org.openkilda.model.Flow)38 Test (org.junit.Test)31 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)23 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)21 CommandContext (org.openkilda.wfm.CommandContext)15 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)14 FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)12 UUID (java.util.UUID)10 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)9 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)9 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 FlowPath (org.openkilda.model.FlowPath)6 GetPathsResult (org.openkilda.pce.GetPathsResult)6 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)6 ArrayList (java.util.ArrayList)5 Ignore (org.junit.Ignore)4 SpeakerRequest (org.openkilda.floodlight.api.request.SpeakerRequest)4 FlowEndpoint (org.openkilda.model.FlowEndpoint)4 FlowPathSwapRequest (org.openkilda.messaging.command.flow.FlowPathSwapRequest)3