Search in sources :

Example 36 with YFlowRequest

use of org.openkilda.messaging.command.yflow.YFlowRequest 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 37 with YFlowRequest

use of org.openkilda.messaging.command.yflow.YFlowRequest 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 38 with YFlowRequest

use of org.openkilda.messaging.command.yflow.YFlowRequest in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailOnUnsuccessfulMeterInstallation.

@Test
public void shouldFailOnUnsuccessfulMeterInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
    preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    YFlowCreateService service = makeYFlowCreateService(0);
    // when
    service.handleRequest(request.getYFlowId(), new CommandContext(), request);
    verifyYFlowAndSubFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
    // and
    handleSpeakerCommandsAndFailInstall(service, request.getYFlowId(), request.getYFlowId());
    // then
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 39 with YFlowRequest

use of org.openkilda.messaging.command.yflow.YFlowRequest in project open-kilda by telstra.

the class YFlowCreateServiceTest method shouldFailOnTimeoutDuringMeterValidation.

@Ignore("TODO: implement meter validation")
@Test
public void shouldFailOnTimeoutDuringMeterValidation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
    // given
    YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
    preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
    preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    YFlowCreateService service = makeYFlowCreateService(0);
    // when
    service.handleRequest(request.getYFlowId(), new CommandContext(), request);
    verifyYFlowAndSubFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
    // and
    handleSpeakerCommandsAndTimeoutVerify(service, request.getYFlowId(), request.getYFlowId());
    // then
    verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
    verifyYFlowIsAbsent(request.getYFlowId());
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 40 with YFlowRequest

use of org.openkilda.messaging.command.yflow.YFlowRequest in project open-kilda by telstra.

the class YFlowUpdateServiceTest method createYFlow.

private YFlowRequest createYFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
    YFlowRequest request = buildYFlowRequest("test_successful_yflow", "test_flow_1", "test_flow_2").build();
    preparePathComputationForCreate("test_flow_1", buildFirstSubFlowPathPair());
    preparePathComputationForCreate("test_flow_2", buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
    processCreateRequestAndSpeakerCommands(request);
    verifyNorthboundSuccessResponse(yFlowCreateHubCarrier, YFlowResponse.class);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    verifyAffinity(request.getYFlowId());
    return request;
}
Also used : YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest)

Aggregations

YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)50 Test (org.junit.Test)35 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)27 YFlow (org.openkilda.model.YFlow)12 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)11 CommandContext (org.openkilda.wfm.CommandContext)10 SwitchId (org.openkilda.model.SwitchId)9 SubFlowSharedEndpointEncapsulation (org.openkilda.messaging.command.yflow.SubFlowSharedEndpointEncapsulation)8 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)7 RerouteError (org.openkilda.messaging.info.reroute.error.RerouteError)5 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)5 ResourceAllocationException (org.openkilda.wfm.share.flow.resources.ResourceAllocationException)4 Ignore (org.junit.Ignore)3 CommandMessage (org.openkilda.messaging.command.CommandMessage)3 YFlowResponse (org.openkilda.messaging.command.yflow.YFlowResponse)3 FlowEndpoint (org.openkilda.model.FlowEndpoint)3 FlowStatus (org.openkilda.model.FlowStatus)3 IslEndpoint (org.openkilda.model.IslEndpoint)3 DuplicateKeyException (org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException)3 YFlowPartialUpdateRequest (org.openkilda.messaging.command.yflow.YFlowPartialUpdateRequest)2