use of org.openkilda.model.FlowPath 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.model.FlowPath in project open-kilda by telstra.
the class FlowRerouteServiceTest method extractIslEndpoint.
private IslEndpoint extractIslEndpoint(Flow flow) {
FlowPath forwardPath = flow.getForwardPath();
assertNotNull(forwardPath);
List<PathSegment> forwardSegments = forwardPath.getSegments();
assertFalse(forwardSegments.isEmpty());
PathSegment firstSegment = forwardSegments.get(0);
return new IslEndpoint(firstSegment.getSrcSwitchId(), firstSegment.getSrcPort());
}
use of org.openkilda.model.FlowPath 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.model.FlowPath in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldSuccessfullyHandleOverlappingRequests.
@Test
public void shouldSuccessfullyHandleOverlappingRequests() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
origin.setStatus(FlowStatus.DOWN);
transactionManager.doInTransaction(() -> repositoryFactory.createFlowRepository().updateStatus(origin.getFlowId(), FlowStatus.DOWN));
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), any())).thenReturn(make2SwitchAltPathPair()).thenReturn(make3SwitchesPathPair());
FlowRerouteService service = makeService();
FlowRerouteRequest rerouteRequest = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
service.handleRequest(currentRequestKey, rerouteRequest, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
String overlappingKey = dummyRequestKey + "2";
service.handleRequest(overlappingKey, rerouteRequest, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
FlowSegmentRequest request;
while ((request = requests.poll()) != null) {
produceAsyncResponse(service, request);
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
FlowPath forwardPath = result.getForwardPath();
Assert.assertNotNull(forwardPath);
// second request is dropped
Assert.assertEquals(1, forwardPath.getSegments().size());
verify(carrier).sendRerouteResultStatus(eq(origin.getFlowId()), argThat(hasProperty("message", equalTo("Reroute is in progress"))), any(String.class));
}
use of org.openkilda.model.FlowPath 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);
}
Aggregations