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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations