use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnTimeoutDuringInstallation.
@Test
public void shouldFailUpdateOnTimeoutDuringInstallation() 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);
service.handleTimeout(dummyRequestKey);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isRemoveRequest()) {
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 shouldFailUpdateOnSwapPathsError.
@Ignore("FIXME: need to replace mocking of updateStatus with another approach")
@Test
public void shouldFailUpdateOnSwapPathsError() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowPathRepository flowPathRepository = setupFlowPathRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(flowPathRepository).updateStatus(eq(origin.getForwardPathId()), eq(FlowPathStatus.IN_PROGRESS));
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);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldSuccessfullyUpdateFlowDeleteFlowLoop.
@Test
public void shouldSuccessfullyUpdateFlowDeleteFlowLoop() throws DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
transactionManager.doInTransaction(() -> {
Flow flow = repositoryFactory.createFlowRepository().findById(origin.getFlowId()).get();
flow.setLoopSwitchId(origin.getDestSwitchId());
});
DeleteFlowLoopRequest request = new DeleteFlowLoopRequest(origin.getFlowId());
FlowUpdateService service = makeService();
service.handleDeleteFlowLoopRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
Set<Class> allowedRequestTypes = Sets.newHashSet(IngressFlowLoopSegmentRemoveRequest.class, TransitFlowLoopSegmentRemoveRequest.class);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (!allowedRequestTypes.contains(speakerRequest.getClass())) {
throw new IllegalStateException(String.format("Not allowed request found %s", speakerRequest));
}
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);
assertFalse(result.isLooped());
assertNull(result.getLoopSwitchId());
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnErrorDuringCompletingFlowPathInstallation.
@Test
public void shouldFailUpdateOnErrorDuringCompletingFlowPathInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowPathRepository repository = setupFlowPathRepositorySpy();
Set<PathId> originalPaths = origin.getPaths().stream().map(FlowPath::getPathId).collect(Collectors.toSet());
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).updateStatus(ArgumentMatchers.argThat(argument -> !originalPaths.contains(argument)), eq(FlowPathStatus.ACTIVE));
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);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.floodlight.api.request.FlowSegmentRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldSuccessfullyUpdateFlowCreateFlowLoop.
@Test
public void shouldSuccessfullyUpdateFlowCreateFlowLoop() throws DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
CreateFlowLoopRequest request = new CreateFlowLoopRequest(origin.getFlowId(), origin.getSrcSwitchId());
FlowUpdateService service = makeService();
service.handleCreateFlowLoopRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
Set<Class> allowedRequestTypes = Sets.newHashSet(IngressFlowLoopSegmentInstallRequest.class, IngressFlowLoopSegmentVerifyRequest.class, TransitFlowLoopSegmentInstallRequest.class, TransitFlowLoopSegmentVerifyRequest.class);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (!allowedRequestTypes.contains(speakerRequest.getClass())) {
throw new IllegalStateException(String.format("Not allowed request found %s", speakerRequest));
}
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);
assertTrue(result.isLooped());
assertEquals(request.getSwitchId(), result.getLoopSwitchId());
}
Aggregations