Search in sources :

Example 36 with FlowRequest

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

the class FlowCreateHubBolt method onRequest.

@Override
protected void onRequest(Tuple input) throws PipelineException {
    currentKey = pullKey(input);
    FlowRequest payload = pullValue(input, FIELD_ID_PAYLOAD, FlowRequest.class);
    try {
        service.handleRequest(currentKey, getCommandContext(), payload);
    } catch (DuplicateKeyException e) {
        log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
    }
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) DuplicateKeyException(org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException)

Example 37 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateFlowIfNoPathAvailable.

@Test
public void shouldFailUpdateFlowIfNoPathAvailable() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    Flow origin = makeFlow();
    when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), anyCollection())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).bandwidth(origin.getBandwidth() + 1).build();
    Flow result = testExpectedFailure(request, origin, ErrorType.NOT_FOUND);
    Assert.assertEquals(origin.getBandwidth(), result.getBandwidth());
    verify(pathComputer, times(11)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 38 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulValidation.

@Test
public void shouldFailUpdateOnUnsuccessfulValidation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    FlowUpdateService service = makeService();
    service.handleUpdateRequest(dummyRequestKey, commandContext, request);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        if (speakerRequest.isVerifyRequest()) {
            service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
        } else {
            service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
        }
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(origin, result);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 39 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateFlowIfRecoverableException.

@Test
public void shouldFailUpdateFlowIfRecoverableException() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    Flow origin = makeFlow();
    when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), anyCollection())).thenThrow(new RecoverableException(injectedErrorMessage));
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).bandwidth(origin.getBandwidth() + 1).build();
    testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
    verify(pathComputer, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) RecoverableException(org.openkilda.pce.exception.RecoverableException) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 40 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulInstallation.

@Test
public void shouldFailUpdateOnUnsuccessfulInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    FlowUpdateService service = makeService();
    service.handleUpdateRequest(dummyRequestKey, commandContext, request);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    verifyNorthboundSuccessResponse(carrier);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        if (speakerRequest.isInstallRequest()) {
            service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().messageContext(speakerRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description("Switch is unavailable").commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
        } else {
            service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
        }
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyNoPathReplace(origin, result);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)45 Test (org.junit.Test)28 Flow (org.openkilda.model.Flow)25 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)12 FlowEndpoint (org.openkilda.model.FlowEndpoint)6 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 MessageException (org.openkilda.messaging.error.MessageException)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 SwapFlowResponse (org.openkilda.messaging.info.flow.SwapFlowResponse)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 CommandContext (org.openkilda.wfm.CommandContext)4 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)4 DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)3 Sets (com.google.common.collect.Sets)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 UUID (java.util.UUID)2 Collectors (java.util.stream.Collectors)2 Ignore (org.junit.Ignore)2