Search in sources :

Example 6 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateOnTimeoutDuringInstallation.

@Test
public void shouldFailUpdateOnTimeoutDuringInstallation() 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);
    service.handleTimeout(dummyRequestKey);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        if (speakerRequest.isRemoveRequest()) {
            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 7 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateFlowIfMultipleOverprovisionBandwidth.

@Test
public void shouldFailUpdateFlowIfMultipleOverprovisionBandwidth() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    IslRepository repository = setupIslRepositorySpy();
    doReturn(-1L).when(repository).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
    verify(repository, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
}
Also used : IslRepository(org.openkilda.persistence.repositories.IslRepository) FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 8 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateFlowOnResourcesAllocationConstraint.

@Test
public void shouldFailUpdateFlowOnResourcesAllocationConstraint() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowPathRepository repository = setupFlowPathRepositorySpy();
    doThrow(new RuntimeException(injectedErrorMessage)).when(repository).add(any(FlowPath.class));
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
}
Also used : FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 9 with FlowRequest

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

the class FlowUpdateServiceTest method shouldFailUpdateFlowIfNoResourcesAvailable.

@Test
public void shouldFailUpdateFlowIfNoResourcesAvailable() throws RecoverableException, UnroutableFlowException, ResourceAllocationException, DuplicateKeyException {
    Flow origin = makeFlow();
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    doThrow(new ResourceAllocationException(injectedErrorMessage)).when(flowResourcesManager).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
    verify(flowResourcesManager, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) ResourceAllocationException(org.openkilda.wfm.share.flow.resources.ResourceAllocationException) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 10 with FlowRequest

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

the class FlowUpdateServiceTest method shouldSuccessfullyUpdateFlow.

@Test
public void shouldSuccessfullyUpdateFlow() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
    Flow origin = makeFlow();
    // TODO(surabujin): why for we forcing initial DOWN state here?
    origin.setStatus(FlowStatus.DOWN);
    transactionManager.doInTransaction(() -> repositoryFactory.createFlowRepository().updateStatus(origin.getFlowId(), FlowStatus.DOWN));
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
    testExpectedSuccess(request, origin);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) 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