use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteOnTimeoutDuringValidation.
@Test
public void shouldFailRerouteOnTimeoutDuringValidation() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
GetPathsResult newPathPair = make3SwitchesPathPair();
preparePathComputation(origin.getFlowId(), newPathPair);
FlowRerouteService service = makeService();
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
service.handleRequest(currentRequestKey, request, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleTimeout(currentRequestKey);
} else {
produceAsyncResponse(service, speakerRequest);
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
verify(carrier).sendRerouteResultStatus(eq(origin.getFlowId()), argThat(hasProperty("message", equalTo("Failed to validate rules"))), any(String.class));
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound.
@Test
public void shouldMoveFlowToDegradedIfPathWithRequiredLatencyNotFound() throws Exception {
Flow origin = makeFlow();
origin.setTargetPathComputationStrategy(MAX_LATENCY);
setupFlowRepositorySpy().findById(origin.getFlowId()).ifPresent(foundPath -> foundPath.setTargetPathComputationStrategy(MAX_LATENCY));
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), any(Collection.class))).thenReturn(make3SwitchesPathPair(true));
FlowRerouteService service = makeService();
IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
service.handleRequest(currentRequestKey, request, commandContext);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
produceAsyncResponse(service, speakerRequest);
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.DEGRADED);
verifyPathReplace(origin, result);
assertEquals(MAX_LATENCY, result.getPathComputationStrategy());
assertNull(result.getTargetPathComputationStrategy());
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulValidation.
@Test
public void shouldFailUpdateOnUnsuccessfulValidation() 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);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
} 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);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulInstallation.
@Test
public void shouldFailUpdateOnUnsuccessfulInstallation() 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);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isInstallRequest()) {
service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().messageContext(speakerRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description("Switch is unavailable").commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
} 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);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class EmitNonIngressRulesVerifyRequestsAction method perform.
@Override
public void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
Map<UUID, FlowSegmentRequestFactory> requestsStorage = stateMachine.getNonIngressCommands();
List<FlowSegmentRequestFactory> requestFactories = new ArrayList<>(requestsStorage.values());
requestsStorage.clear();
stateMachine.clearPendingAndRetriedAndFailedCommands();
if (requestFactories.isEmpty()) {
stateMachine.saveActionToHistory("No need to validate non ingress rules");
stateMachine.fire(Event.RULES_VALIDATED);
} else {
for (FlowSegmentRequestFactory factory : requestFactories) {
FlowSegmentRequest request = factory.makeVerifyRequest(commandIdGenerator.generate());
// TODO ensure no conflicts
requestsStorage.put(request.getCommandId(), factory);
stateMachine.getCarrier().sendSpeakerRequest(request);
}
requestsStorage.forEach((key, value) -> stateMachine.addPendingCommand(key, value.getSwitchId()));
stateMachine.saveActionToHistory("Started validation of installed non ingress rules");
}
}
Aggregations