use of org.openkilda.persistence.repositories.FlowPathRepository in project open-kilda by telstra.
the class FlowDeleteServiceTest method shouldCompleteDeleteOnErrorDuringCompletingFlowPathRemoval.
@Test
public void shouldCompleteDeleteOnErrorDuringCompletingFlowPathRemoval() throws DuplicateKeyException, UnknownKeyException {
Flow target = makeFlow();
FlowPath forwardPath = target.getForwardPath();
Assert.assertNotNull(forwardPath);
FlowPathRepository repository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).remove(eq(forwardPath.getPathId()));
FlowDeleteService service = makeService();
service.handleRequest(dummyRequestKey, commandContext, target.getFlowId());
verifyFlowStatus(target.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
produceSpeakerResponses(service);
// 4 flow rules + 4 mirror rules
verify(carrier, times(8)).sendSpeakerRequest(any());
verifyFlowIsMissing(target);
}
use of org.openkilda.persistence.repositories.FlowPathRepository in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldCompleteRerouteOnErrorDuringCompletingFlowPathRemoval.
@Test
public void shouldCompleteRerouteOnErrorDuringCompletingFlowPathRemoval() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowPathRepository repository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).remove(eq(origin.getForwardPathId()));
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) {
produceAsyncResponse(service, speakerRequest);
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
}
use of org.openkilda.persistence.repositories.FlowPathRepository in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteOnErrorDuringCompletingFlowPathInstallation.
@Test
public void shouldFailRerouteOnErrorDuringCompletingFlowPathInstallation() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowPathRepository repository = setupFlowPathRepositorySpy();
Set<PathId> originalPaths = origin.getPaths().stream().map(FlowPath::getPathId).collect(toSet());
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).updateStatus(ArgumentMatchers.argThat(argument -> !originalPaths.contains(argument)), eq(FlowPathStatus.ACTIVE));
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.handleAsyncResponse(currentRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
produceAsyncResponse(service, speakerRequest);
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.persistence.repositories.FlowPathRepository in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteOnSwapPathsError.
@Ignore("FIXME: need to replace mocking of updateStatus with another approach")
@Test
public void shouldFailRerouteOnSwapPathsError() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowPathRepository flowPathRepository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(flowPathRepository).updateStatus(eq(origin.getForwardPathId()), eq(FlowPathStatus.IN_PROGRESS));
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.handleAsyncResponse(currentRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
produceAsyncResponse(service, speakerRequest);
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.persistence.repositories.FlowPathRepository in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteFlowOnResourcesAllocationConstraint.
@Test
public void shouldFailRerouteFlowOnResourcesAllocationConstraint() throws RecoverableException, UnroutableFlowException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowPathRepository repository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).add(any(FlowPath.class));
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.UP, ErrorType.INTERNAL_ERROR);
}
Aggregations