use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowServiceImpl method rerouteFlowV2.
@Override
public CompletableFuture<FlowRerouteResponseV2> rerouteFlowV2(String flowId) {
logger.info("Processing flow reroute: {}", flowId);
FlowRerouteRequest payload = createManualFlowRerouteRequest(flowId, false, false, "initiated via Northbound");
CommandMessage command = new CommandMessage(payload, System.currentTimeMillis(), RequestCorrelationId.getId(), Destination.WFM);
return messagingChannel.sendAndGet(rerouteTopic, command).thenApply(FlowRerouteResponse.class::cast).thenApply(response -> flowMapper.toRerouteResponseV2(flowId, response.getPayload(), response.isRerouted()));
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteYSubFlow.
@Test
public void shouldFailRerouteYSubFlow() throws UnroutableFlowException, RecoverableException {
Flow origin = makeFlow();
createTestYFlowForSubFlow(origin);
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRerouteService service = makeService();
IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
service.handleRequest(currentRequestKey, request, commandContext);
verifyNoSpeakerInteraction(carrier);
verifyNorthboundErrorResponse(carrier, ErrorType.REQUEST_INVALID);
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound.
@Test
public void shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound() throws Exception {
Flow origin = makeFlow();
origin.setTargetPathComputationStrategy(MAX_LATENCY);
setupFlowRepositorySpy().findById(origin.getFlowId()).ifPresent(foundPath -> foundPath.setTargetPathComputationStrategy(MAX_LATENCY));
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), any(Collection.class))).thenReturn(make3SwitchesPathPair(true));
FlowRerouteService service = makeService();
IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
service.handleRequest(currentRequestKey, request, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
produceAsyncResponse(service, speakerRequest);
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.DEGRADED);
verifyPathReplace(origin, result);
assertEquals(MAX_LATENCY, result.getPathComputationStrategy());
assertNull(result.getTargetPathComputationStrategy());
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteFlowIfNoResourcesAvailable.
@Test
public void shouldFailRerouteFlowIfNoResourcesAvailable() throws RecoverableException, UnroutableFlowException, ResourceAllocationException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
doThrow(new ResourceAllocationException(injectedErrorMessage)).when(flowResourcesManager).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.UP, ErrorType.INTERNAL_ERROR);
verify(flowResourcesManager, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).allocateFlowResources(makeFlowArgumentMatch(origin.getFlowId()), any(), any());
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldSkipRerouteIfNoNewPathFound.
@Test
public void shouldSkipRerouteIfNoNewPathFound() throws RecoverableException, UnroutableFlowException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make2SwitchesPathPair());
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
makeService().handleRequest(dummyRequestKey, request, commandContext);
verifyNoSpeakerInteraction(carrier);
verifyNorthboundSuccessResponse(carrier);
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
}
Aggregations