use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.
the class FlowPathSwapServiceTest method shouldFailSwapOnUnsuccessfulYFlowRulesInstallation.
@Test
public void shouldFailSwapOnUnsuccessfulYFlowRulesInstallation() {
// given
Flow origin = dummyFactory.makeFlowWithProtectedPath(flowSource, flowDestination, singletonList(islSourceDest), singletonList(islSourceDestAlt));
createTestYFlowForSubFlow(origin);
// when
FlowPathSwapService service = makeService();
FlowPathSwapRequest request = new FlowPathSwapRequest(origin.getFlowId(), false);
service.handleRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
int failCounter = 1;
SpeakerRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
SpeakerResponse commandResponse;
if (speakerRequest instanceof FlowSegmentRequest) {
commandResponse = buildSpeakerResponse((FlowSegmentRequest) speakerRequest);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
if (failCounter > 0) {
commandResponse = buildErrorYFlowSpeakerResponse(speakerCommandsRequest);
failCounter--;
} else {
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
}
}
service.handleAsyncResponse(dummyRequestKey, commandResponse);
}
// then
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathNotSwapped(origin, result);
verifyNorthboundSuccessResponse(carrier);
}
use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.
the class YFlowDeleteServiceTest method handleSpeakerCommandsAndTimeoutRemove.
private void handleSpeakerCommandsAndTimeoutRemove(YFlowDeleteService yFlowDeleteService, String yFlowFsmKey) {
handleSpeakerRequests(request -> {
SpeakerResponse commandResponse;
if (request instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
if (speakerCommandsRequest instanceof DeleteSpeakerCommandsRequest) {
try {
yFlowDeleteService.handleTimeout(yFlowFsmKey);
} catch (UnknownKeyException ex) {
// skip
}
} else {
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
handleAsyncResponse(yFlowDeleteService, yFlowFsmKey, commandResponse);
}
}
});
}
use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.
the class YFlowUpdateServiceTest 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.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.
the class YFlowUpdateServiceTest method handleSpeakerCommandsAndFailInstall.
private void handleSpeakerCommandsAndFailInstall(YFlowUpdateService yFlowUpdateService, String yFlowFsmKey, String commandFlowIdToFail) {
handleSpeakerRequests(request -> {
SpeakerResponse commandResponse;
if (request instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
commandResponse = flowSegmentRequest.isInstallRequest() && flowSegmentRequest.getMetadata().getFlowId().equals(commandFlowIdToFail) ? buildErrorSpeakerResponse(flowSegmentRequest) : buildSuccessfulSpeakerResponse(flowSegmentRequest);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
commandResponse = request instanceof InstallSpeakerCommandsRequest ? buildErrorYFlowSpeakerResponse(speakerCommandsRequest) : buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
}
handleAsyncResponse(yFlowUpdateService, yFlowFsmKey, commandResponse);
});
}
use of org.openkilda.floodlight.api.response.SpeakerResponse in project open-kilda by telstra.
the class YFlowUpdateServiceTest method handleSpeakerCommandsAndTimeoutInstall.
private void handleSpeakerCommandsAndTimeoutInstall(YFlowUpdateService yFlowUpdateService, String yFlowFsmKey) {
handleSpeakerRequests(request -> {
SpeakerResponse commandResponse;
if (request instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) request;
commandResponse = buildSuccessfulSpeakerResponse(flowSegmentRequest);
yFlowUpdateService.handleAsyncResponse(yFlowFsmKey, commandResponse);
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) request;
if (speakerCommandsRequest instanceof InstallSpeakerCommandsRequest) {
handleTimeout(yFlowUpdateService, yFlowFsmKey);
} else {
commandResponse = buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest);
yFlowUpdateService.handleAsyncResponse(yFlowFsmKey, commandResponse);
}
}
});
}
Aggregations