Search in sources :

Example 86 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class YFlowCreateServiceTest method processRequest.

private void processRequest(YFlowRequest yFlowRequest) throws DuplicateKeyException {
    YFlowCreateService service = makeYFlowCreateService(0);
    service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
}
Also used : CommandContext(org.openkilda.wfm.CommandContext)

Example 87 with CommandContext

use of org.openkilda.wfm.CommandContext 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 88 with CommandContext

use of org.openkilda.wfm.CommandContext 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 89 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class YFlowUpdateServiceTest method processUpdateRequestAndSpeakerCommands.

private void processUpdateRequestAndSpeakerCommands(YFlowRequest yFlowRequest) throws DuplicateKeyException {
    YFlowUpdateService service = makeYFlowUpdateService(0);
    service.handleRequest(yFlowRequest.getYFlowId(), new CommandContext(), yFlowRequest);
    verifyYFlowStatus(yFlowRequest.getYFlowId(), FlowStatus.IN_PROGRESS);
    handleSpeakerRequests(speakerRequest -> {
        SpeakerResponse commandResponse;
        if (speakerRequest instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
            commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
            commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
        }
        handleAsyncResponse(service, yFlowRequest.getYFlowId(), commandResponse);
    });
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)

Example 90 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class YFlowUpdateServiceTest method processUpdateRequestAndSpeakerCommands.

private void processUpdateRequestAndSpeakerCommands(YFlowRequest request, FlowStatus expectedStatus, FlowStatus expectedFirstSubFlowStatus, FlowStatus expectedSecondSubFlowStatus) throws DuplicateKeyException {
    FlowUpdateService flowUpdateService = makeFlowUpdateService(0);
    YFlowUpdateService service = makeYFlowUpdateService(flowUpdateService, 0);
    service.handleRequest(request.getYFlowId(), new CommandContext(), request);
    verifyYFlowStatus(request.getYFlowId(), expectedStatus, expectedFirstSubFlowStatus, expectedSecondSubFlowStatus);
    handleSpeakerRequests(speakerRequest -> {
        SpeakerResponse commandResponse;
        if (speakerRequest instanceof FlowSegmentRequest) {
            FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
            commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
        } else {
            BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
            commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
        }
        handleAsyncResponse(service, request.getYFlowId(), commandResponse);
    });
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerResponse(org.openkilda.floodlight.api.response.SpeakerResponse) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) FlowUpdateService(org.openkilda.wfm.topology.flowhs.service.FlowUpdateService)

Aggregations

CommandContext (org.openkilda.wfm.CommandContext)95 Test (org.junit.Test)28 Values (org.apache.storm.tuple.Values)27 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)15 Flow (org.openkilda.model.Flow)15 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)14 Tuple (org.apache.storm.tuple.Tuple)12 SwitchId (org.openkilda.model.SwitchId)11 YFlow (org.openkilda.model.YFlow)11 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)9 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)9 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 TupleImpl (org.apache.storm.tuple.TupleImpl)8 FlowPath (org.openkilda.model.FlowPath)8 ArrayList (java.util.ArrayList)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)7 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)7 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)7 List (java.util.List)6