use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnSwapPathsError.
@Ignore("FIXME: need to replace mocking of updateStatus with another approach")
@Test
public void shouldFailUpdateOnSwapPathsError() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowPathRepository flowPathRepository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(flowPathRepository).updateStatus(eq(origin.getForwardPathId()), eq(FlowPathStatus.IN_PROGRESS));
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, buildResponseOnVerifyRequest(speakerRequest));
} 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);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateYSubFlow.
@Test
public void shouldFailUpdateYSubFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
Flow origin = makeFlow();
createTestYFlowForSubFlow(origin);
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
testExpectedFailure(request, origin, ErrorType.REQUEST_INVALID);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnErrorDuringCompletingFlowPathInstallation.
@Test
public void shouldFailUpdateOnErrorDuringCompletingFlowPathInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowPathRepository repository = setupFlowPathRepositorySpy();
Set<PathId> originalPaths = origin.getPaths().stream().map(FlowPath::getPathId).collect(Collectors.toSet());
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).updateStatus(ArgumentMatchers.argThat(argument -> !originalPaths.contains(argument)), eq(FlowPathStatus.ACTIVE));
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, buildResponseOnVerifyRequest(speakerRequest));
} 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);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnTimeoutDuringValidation.
@Test
public void shouldFailUpdateOnTimeoutDuringValidation() 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.handleTimeout(dummyRequestKey);
} 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);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowCreateServiceTest method shouldCreateFlowWithTransitSwitches.
@Test
public void shouldCreateFlowWithTransitSwitches() throws Exception {
FlowRequest request = makeRequest().flowId("test_successful_flow_id").build();
preparePathComputation(request.getFlowId(), make3SwitchesPathPair());
testHappyPath(request, "successful_flow_create");
}
Aggregations