use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldRerouteFlowWithTransitSwitchesWithSecondaryFlowAffectedIsl.
@Test
public void shouldRerouteFlowWithTransitSwitchesWithSecondaryFlowAffectedIsl() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
// given
YFlowRequest createYFlowRequest = createYFlow();
YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
request.setAffectedIsl(Collections.singleton(new IslEndpoint(SWITCH_TRANSIT, 27)));
preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPairWithNewTransit());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_SHARED);
// when
processRerouteRequestAndSpeakerCommands(request, FlowStatus.IN_PROGRESS, FlowStatus.UP, FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(yFlowRerouteHubCarrier, YFlowRerouteResponse.class);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
verifyAffinity(request.getYFlowId());
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(null), anyString());
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldRerouteFlowWithTransitSwitches.
@Test
public void shouldRerouteFlowWithTransitSwitches() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
// given
YFlowRequest createYFlowRequest = createYFlow();
YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
preparePathComputationForReroute("test_flow_1", buildFirstSubFlowPathPairWithNewTransit());
preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPairWithNewTransit());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_NEW_TRANSIT);
// when
processRerouteRequestAndSpeakerCommands(request);
verifyNorthboundSuccessResponse(yFlowRerouteHubCarrier, YFlowRerouteResponse.class);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
verifyAffinity(request.getYFlowId());
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(null), anyString());
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldUpdateFlowWithProtectedPath.
@Test
public void shouldUpdateFlowWithProtectedPath() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
// given
YFlowRequest createYFlowRequest = createYFlowWithProtectedPath();
YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
preparePathComputationForReroute("test_flow_1", buildFirstSubFlowPathPair(), buildFirstSubFlowPathPairWithNewTransit());
preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPair(), buildSecondSubFlowPathPairWithNewTransit());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT, SWITCH_TRANSIT);
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_NEW_TRANSIT, SWITCH_NEW_TRANSIT);
// when
processRerouteRequestAndSpeakerCommands(request);
verifyNorthboundSuccessResponse(yFlowRerouteHubCarrier, YFlowRerouteResponse.class);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
verifyAffinity(request.getYFlowId());
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(null), anyString());
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldFailIfNoPathAvailableForFirstSubFlow.
@Test
public void shouldFailIfNoPathAvailableForFirstSubFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
// given
YFlowRequest createYFlowRequest = createYFlow();
YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_1"), any())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPairWithNewTransit());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_NEW_TRANSIT);
// when
processRerouteRequestAndSpeakerCommands(request);
verifyNorthboundErrorResponse(yFlowRerouteHubCarrier, ErrorType.NOT_FOUND);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.DEGRADED, FlowStatus.DOWN, FlowStatus.UP);
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(new RerouteError("Failed to reroute sub-flows [test_flow_1] of y-flow test_successful_yflow")), anyString());
}
use of org.openkilda.messaging.command.yflow.YFlowRerouteRequest in project open-kilda by telstra.
the class YFlowServiceImpl method rerouteYFlow.
@Override
public CompletableFuture<YFlowRerouteResult> rerouteYFlow(String yFlowId) {
log.debug("Processing y-flow reroute: {}", yFlowId);
YFlowRerouteRequest flowRerouteRequest = new YFlowRerouteRequest(yFlowId, "initiated via Northbound");
CommandMessage command = new CommandMessage(flowRerouteRequest, System.currentTimeMillis(), RequestCorrelationId.getId());
return messagingChannel.sendAndGet(rerouteTopic, command).thenApply(YFlowRerouteResponse.class::cast).thenApply(flowMapper::toRerouteResult);
}
Aggregations