Search in sources :

Example 11 with UnroutableFlowException

use of org.openkilda.pce.exception.UnroutableFlowException 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());
}
Also used : UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteError(org.openkilda.messaging.info.reroute.error.RerouteError) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 12 with UnroutableFlowException

use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailIfNoPathAvailableForSecondSubFlow.

@Test
public void shouldFailIfNoPathAvailableForSecondSubFlow() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
    when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_2"))).thenThrow(new UnroutableFlowException(injectedErrorMessage));
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    // when
    processRequestAndSpeakerCommands(request);
    // then
    verifyNorthboundErrorResponse(yFlowCreateHubCarrier, ErrorType.NOT_FOUND);
    verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 13 with UnroutableFlowException

use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailOnErrorDuringDraftYFlowCreation.

@Test
public void shouldFailOnErrorDuringDraftYFlowCreation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    YFlowRepository repository = setupYFlowRepositorySpy();
    doThrow(new RuntimeException(injectedErrorMessage)).when(repository).add(ArgumentMatchers.argThat(argument -> argument.getYFlowId().equals(request.getYFlowId())));
    preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
    preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    // when
    processRequest(request);
    // then
    verifyNorthboundErrorResponse(yFlowCreateHubCarrier, ErrorType.INTERNAL_ERROR);
    verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArgumentMatchers(org.mockito.ArgumentMatchers) FlowPath(org.openkilda.model.FlowPath) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) RunWith(org.junit.runner.RunWith) FlowStatus(org.openkilda.model.FlowStatus) ResourceAllocationException(org.openkilda.wfm.share.flow.resources.ResourceAllocationException) RecoverableException(org.openkilda.pce.exception.RecoverableException) Mockito.doThrow(org.mockito.Mockito.doThrow) SpeakerRequest(org.openkilda.floodlight.api.request.SpeakerRequest) ArgumentMatcher(org.mockito.ArgumentMatcher) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) InstallSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest) Mockito.doAnswer(org.mockito.Mockito.doAnswer) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) UnknownKeyException(org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException) FlowDeleteService(org.openkilda.wfm.topology.flowhs.service.FlowDeleteService) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Before(org.junit.Before) FlowGenericCarrier(org.openkilda.wfm.topology.flowhs.service.FlowGenericCarrier) DuplicateKeyException(org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException) ErrorType(org.openkilda.messaging.error.ErrorType) Mockito.times(org.mockito.Mockito.times) CommandContext(org.openkilda.wfm.CommandContext) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) FlowCreateService(org.openkilda.wfm.topology.flowhs.service.FlowCreateService) Mockito.verify(org.mockito.Mockito.verify) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) SwitchId(org.openkilda.model.SwitchId) Ignore(org.junit.Ignore) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) GetPathsResult(org.openkilda.pce.GetPathsResult) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 14 with UnroutableFlowException

use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailIfNoPathAvailableForFirstSubFlow.

@Test
public void shouldFailIfNoPathAvailableForFirstSubFlow() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_1"))).thenThrow(new UnroutableFlowException(injectedErrorMessage));
    preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    // when
    processRequest(request);
    // then
    verifyNorthboundErrorResponse(yFlowCreateHubCarrier, ErrorType.NOT_FOUND);
    verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 15 with UnroutableFlowException

use of org.openkilda.pce.exception.UnroutableFlowException in project open-kilda by telstra.

the class YFlowUpdateServiceTest method shouldFailIfNoPathAvailableForSecondSubFlow.

@Test
public void shouldFailIfNoPathAvailableForSecondSubFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
    // given
    YFlowRequest request = createYFlow();
    request.setMaximumBandwidth(2000L);
    request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
    request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
    preparePathComputationForUpdate("test_flow_1", buildNewFirstSubFlowPathPair(), buildFirstSubFlowPathPair());
    when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_2"), any())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
    prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
    // when
    processUpdateRequestAndSpeakerCommands(request, FlowStatus.IN_PROGRESS, FlowStatus.UP, FlowStatus.IN_PROGRESS);
    verifyNorthboundErrorResponse(yFlowUpdateHubCarrier, ErrorType.NOT_FOUND);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    YFlow flow = getYFlow(request.getYFlowId());
    assertEquals(1000L, flow.getMaximumBandwidth());
    Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_FIRST_EP, SWITCH_SECOND_EP).collect(Collectors.toSet());
    Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
    assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
Also used : YFlow(org.openkilda.model.YFlow) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) SwitchId(org.openkilda.model.SwitchId) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Aggregations

UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)22 Test (org.junit.Test)12 Flow (org.openkilda.model.Flow)10 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 List (java.util.List)8 FlowPath (org.openkilda.model.FlowPath)8 GetPathsResult (org.openkilda.pce.GetPathsResult)8 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)7 ResourceAllocationException (org.openkilda.wfm.share.flow.resources.ResourceAllocationException)7 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)7 ErrorType (org.openkilda.messaging.error.ErrorType)6 PathId (org.openkilda.model.PathId)6 SwitchId (org.openkilda.model.SwitchId)6 ArrayList (java.util.ArrayList)5 Slf4j (lombok.extern.slf4j.Slf4j)5 Objects (java.util.Objects)4 Set (java.util.Set)4 Collection (java.util.Collection)3 Collectors (java.util.stream.Collectors)3 Assert.assertEquals (org.junit.Assert.assertEquals)3