use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowPathSwapServiceTest method shouldFailSwapOnTimeoutDuringYFlowRulesInstallation.
@Test
public void shouldFailSwapOnTimeoutDuringYFlowRulesInstallation() {
// 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) {
if (speakerRequest instanceof FlowSegmentRequest) {
service.handleAsyncResponse(dummyRequestKey, buildSpeakerResponse((FlowSegmentRequest) speakerRequest));
} else {
if (failCounter > 0) {
service.handleTimeout(dummyRequestKey);
failCounter--;
} else {
BaseSpeakerCommandsRequest speakerCommandsRequest = (BaseSpeakerCommandsRequest) speakerRequest;
service.handleAsyncResponse(dummyRequestKey, buildSuccessfulYFlowSpeakerResponse(speakerCommandsRequest));
}
}
}
// then
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathNotSwapped(origin, result);
verifyNorthboundSuccessResponse(carrier);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowPathSwapServiceTest method shouldFailSwapOnUnsuccessfulInstallation.
@Test
public void shouldFailSwapOnUnsuccessfulInstallation() {
// given
Flow origin = dummyFactory.makeFlowWithProtectedPath(flowSource, flowDestination, singletonList(islSourceDest), singletonList(islSourceDestAlt));
// when
FlowPathSwapService service = makeService();
FlowPathSwapRequest request = new FlowPathSwapRequest(origin.getFlowId(), true);
service.handleRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
int failCounter = 1;
SpeakerRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest instanceof FlowSegmentRequest) {
FlowSegmentRequest flowSegmentRequest = (FlowSegmentRequest) speakerRequest;
if (flowSegmentRequest.isInstallRequest() && failCounter > 0) {
service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().messageContext(flowSegmentRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).commandId(flowSegmentRequest.getCommandId()).metadata(flowSegmentRequest.getMetadata()).switchId(flowSegmentRequest.getSwitchId()).build());
failCounter--;
} else {
service.handleAsyncResponse(dummyRequestKey, buildSpeakerResponse(flowSegmentRequest));
}
} else {
fail();
}
}
// then
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathNotSwapped(origin, result);
verifyNorthboundSuccessResponse(carrier);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method testExpectedSuccess.
private void testExpectedSuccess(FlowRequest request, Flow origin) throws DuplicateKeyException, UnknownKeyException {
FlowUpdateService service = makeService();
service.handleUpdateRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleAsyncResponse(dummyRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldCompleteUpdateOnErrorDuringCompletingFlowPathRemoval.
@Test
public void shouldCompleteUpdateOnErrorDuringCompletingFlowPathRemoval() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowPathRepository repository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).remove(eq(origin.getForwardPathId()));
FlowUpdateService service = makeService();
service.handleUpdateRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleAsyncResponse(dummyRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldCompleteUpdateOnErrorDuringResourceDeallocation.
@Test
public void shouldCompleteUpdateOnErrorDuringResourceDeallocation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowUpdateService service = makeService();
service.handleUpdateRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
doThrow(new RuntimeException(injectedErrorMessage)).when(flowResourcesManager).deallocatePathResources(argThat(hasProperty("forward", hasProperty("pathId", equalTo(origin.getForwardPathId())))));
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleAsyncResponse(dummyRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
}
Aggregations