use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowRerouteServiceTest method shouldFailOnUnsuccessfulMeterInstallation.
@Test
public void shouldFailOnUnsuccessfulMeterInstallation() throws RecoverableException, UnroutableFlowException, 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);
YFlowRerouteService service = makeYFlowRerouteService(0);
// when
service.handleRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS, FlowStatus.IN_PROGRESS, FlowStatus.UP);
// and
handleSpeakerCommandsAndFailInstall(service, request.getYFlowId(), "test_successful_yflow");
// then
verifyNorthboundSuccessResponse(yFlowRerouteHubCarrier, YFlowRerouteResponse.class);
verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
verifyAffinity(request.getYFlowId());
verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(new RerouteError("Received error response(s) for 2 install commands")), anyString());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowRerouteServiceTest method processRerouteRequestAndSpeakerCommands.
private void processRerouteRequestAndSpeakerCommands(YFlowRerouteRequest request) throws DuplicateKeyException {
FlowRerouteService flowRerouteService = makeFlowRerouteService(0);
YFlowRerouteService service = makeYFlowRerouteService(flowRerouteService, 0);
service.handleRequest(request.getYFlowId(), new CommandContext(), request);
verifyYFlowStatus(request.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, request.getYFlowId(), commandResponse);
});
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowRerouteServiceTest method processCreateRequestAndSpeakerCommands.
private void processCreateRequestAndSpeakerCommands(YFlowRequest yFlowRequest) throws DuplicateKeyException {
YFlowCreateService service = makeYFlowCreateService(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);
});
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowRerouteServiceTest method processRerouteRequestAndSpeakerCommands.
private void processRerouteRequestAndSpeakerCommands(YFlowRerouteRequest request, FlowStatus expectedStatus, FlowStatus expectedFirstSubFlowStatus, FlowStatus expectedSecondSubFlowStatus) throws DuplicateKeyException {
FlowRerouteService flowRerouteService = makeFlowRerouteService(0);
YFlowRerouteService service = makeYFlowRerouteService(flowRerouteService, 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);
});
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class YFlowValidationHubServiceTest method shouldFailIfNoYFlowFound.
@Test
public void shouldFailIfNoYFlowFound() throws DuplicateKeyException {
// given
String yFlowId = "fake_test_y_flow";
YFlowValidationHubService service = makeYFlowValidationHubService();
service.handleRequest(yFlowId, new CommandContext(), yFlowId);
// when
handleSpeakerRequests(service, yFlowId, emptyMap(), emptyMap(), emptyMap());
// then
verifyNorthboundErrorResponse(yFlowValidationHubCarrier, ErrorType.NOT_FOUND);
}
Aggregations