Search in sources :

Example 16 with FlowSegmentRequest

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

the class FlowRerouteServiceTest method shouldSuccessfullyRerouteFlow.

@Test
public void shouldSuccessfullyRerouteFlow() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    origin.setStatus(FlowStatus.DOWN);
    transactionManager.doInTransaction(() -> repositoryFactory.createFlowRepository().updateStatus(origin.getFlowId(), FlowStatus.DOWN));
    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);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        produceAsyncResponse(service, speakerRequest);
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyPathReplace(origin, result);
    RerouteResultInfoData expected = RerouteResultInfoData.builder().flowId(origin.getFlowId()).success(true).build();
    verify(carrier).sendRerouteResultStatus(eq(origin.getFlowId()), isNull(), any(String.class));
}
Also used : FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 17 with FlowSegmentRequest

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

the class FlowRerouteServiceTest method shouldFailRerouteOnTimeoutDuringInstallation.

@Test
public void shouldFailRerouteOnTimeoutDuringInstallation() 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);
    service.handleTimeout(currentRequestKey);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        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 18 with FlowSegmentRequest

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

the class FlowRerouteServiceTest method shouldFailRerouteOnSwapPathsError.

@Ignore("FIXME: need to replace mocking of updateStatus with another approach")
@Test
public void shouldFailRerouteOnSwapPathsError() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowPathRepository flowPathRepository = setupFlowPathRepositorySpy();
    doThrow(new RuntimeException(injectedErrorMessage)).when(flowPathRepository).updateStatus(eq(origin.getForwardPathId()), eq(FlowPathStatus.IN_PROGRESS));
    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.isVerifyRequest()) {
            service.handleAsyncResponse(currentRequestKey, buildResponseOnVerifyRequest(speakerRequest));
        } else {
            produceAsyncResponse(service, speakerRequest);
        }
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with FlowSegmentRequest

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

the class FlowPathSwapServiceTest method produceAsyncResponse.

private void produceAsyncResponse(FlowPathSwapService service, String fsmKey, SpeakerRequest speakerRequest) {
    SpeakerResponse commandResponse;
    if (speakerRequest instanceof FlowSegmentRequest) {
        commandResponse = buildSpeakerResponse((FlowSegmentRequest) speakerRequest);
    } else {
        BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
        commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
    }
    service.handleAsyncResponse(fsmKey, 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)

Example 20 with FlowSegmentRequest

use of org.openkilda.floodlight.api.request.FlowSegmentRequest 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)

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