Search in sources :

Example 41 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldSkipRerouteOnOutdatedRequest.

@Test
public void shouldSkipRerouteOnOutdatedRequest() {
    Flow origin = makeFlow();
    FlowRerouteService service = makeService();
    IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(origin, result);
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 42 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldIgnoreEffectivelyDownStateIfSamePaths.

@Test
public void shouldIgnoreEffectivelyDownStateIfSamePaths() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make2SwitchesPathPair());
    FlowRerouteService service = makeService();
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.emptySet(), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        produceAsyncResponse(service, speakerRequest);
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(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 43 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldFailRerouteOnTimeoutDuringValidation.

@Test
public void shouldFailRerouteOnTimeoutDuringValidation() 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.isVerifyRequest()) {
            service.handleTimeout(currentRequestKey);
        } 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 validate 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 44 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class FlowRerouteServiceTest method shouldFailRerouteFlowIfNoPathAvailable.

@Test
public void shouldFailRerouteFlowIfNoPathAvailable() throws RecoverableException, UnroutableFlowException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), new UnroutableFlowException(injectedErrorMessage));
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
    testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.DOWN, ErrorType.NOT_FOUND);
    verify(pathComputer, times(11)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
Also used : UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 45 with FlowRerouteRequest

use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.

the class RerouteBolt method handleCommandMessage.

private void handleCommandMessage(CommandMessage commandMessage) {
    CommandData commandData = commandMessage.getData();
    String correlationId = getCommandContext().getCorrelationId();
    if (commandData instanceof RerouteAffectedFlows) {
        rerouteService.rerouteAffectedFlows(this, correlationId, (RerouteAffectedFlows) commandData);
    } else if (commandData instanceof RerouteAffectedInactiveFlows) {
        rerouteService.rerouteInactiveAffectedFlows(this, correlationId, ((RerouteAffectedInactiveFlows) commandData).getSwitchId());
    } else if (commandData instanceof RerouteInactiveFlows) {
        rerouteService.rerouteInactiveFlows(this, correlationId, (RerouteInactiveFlows) commandData);
    } else if (commandData instanceof FlowRerouteRequest) {
        rerouteService.processRerouteRequest(this, correlationId, (FlowRerouteRequest) commandData);
    } else if (commandData instanceof YFlowRerouteRequest) {
        rerouteService.processRerouteRequest(this, correlationId, (YFlowRerouteRequest) commandData);
    } else {
        unhandledInput(getCurrentTuple());
    }
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) CommandData(org.openkilda.messaging.command.CommandData) RerouteInactiveFlows(org.openkilda.messaging.command.reroute.RerouteInactiveFlows) RerouteAffectedInactiveFlows(org.openkilda.messaging.command.reroute.RerouteAffectedInactiveFlows)

Aggregations

FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)49 Test (org.junit.Test)27 Flow (org.openkilda.model.Flow)23 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)14 Values (org.apache.storm.tuple.Values)10 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)9 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 IslEndpoint (org.openkilda.model.IslEndpoint)8 CommandContext (org.openkilda.wfm.CommandContext)7 FlowPath (org.openkilda.model.FlowPath)6 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)5 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)4 GetPathsResult (org.openkilda.pce.GetPathsResult)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 HashSet (java.util.HashSet)3 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Ignore (org.junit.Ignore)2 FlowErrorResponse (org.openkilda.floodlight.flow.response.FlowErrorResponse)2