use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException 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.wfm.topology.flowhs.exception.UnknownKeyException 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.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class YFlowDeleteServiceTest method handleSpeakerCommandsAndTimeoutRemove.
private void handleSpeakerCommandsAndTimeoutRemove(YFlowDeleteService yFlowDeleteService, String yFlowFsmKey) {
handleSpeakerRequests(request -> {
SpeakerResponse commandResponse;
if (request instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
if (speakerCommandsRequest instanceof DeleteSpeakerCommandsRequest) {
try {
yFlowDeleteService.handleTimeout(yFlowFsmKey);
} catch (UnknownKeyException ex) {
// skip
}
} else {
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
}
}
});
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class FlowCreateServiceTest method testHappyPath.
private Flow testHappyPath(FlowRequest flowRequest, String key) throws DuplicateKeyException {
FlowCreateService service = makeService();
service.handleRequest(key, new CommandContext(), flowRequest);
Flow inProgress = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.IN_PROGRESS);
verifyFlowPathStatus(inProgress.getForwardPath(), FlowPathStatus.IN_PROGRESS, "forward");
verifyFlowPathStatus(inProgress.getReversePath(), FlowPathStatus.IN_PROGRESS, "reverse");
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest request;
while ((request = requests.poll()) != null) {
try {
if (request.isVerifyRequest()) {
service.handleAsyncResponse(key, buildResponseOnVerifyRequest(request));
} else {
handleResponse(service, key, request);
}
} catch (UnknownKeyException ex) {
// skip
}
}
Flow result = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.UP);
verifyFlowPathStatus(result.getForwardPath(), FlowPathStatus.ACTIVE, "forward");
verifyFlowPathStatus(result.getReversePath(), FlowPathStatus.ACTIVE, "reverse");
return result;
}
use of org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException in project open-kilda by telstra.
the class FlowDeleteService method handleTimeout.
/**
* Handles timeout case.
*
* @param key command identifier.
*/
public void handleTimeout(@NonNull String key) throws UnknownKeyException {
log.debug("Handling timeout for {}", key);
FlowDeleteFsm fsm = fsmRegister.getFsmByKey(key).orElseThrow(() -> new UnknownKeyException(key));
fsmExecutor.fire(fsm, Event.TIMEOUT);
removeIfFinished(fsm, key);
}
Aggregations