use of org.openkilda.floodlight.api.request.EgressFlowSegmentInstallRequest in project open-kilda by telstra.
the class FlowCreateServiceTest method shouldRollbackIfIngressRuleNotInstalled.
@Test
public void shouldRollbackIfIngressRuleNotInstalled() throws Exception {
when(pathComputer.getPath(any(Flow.class))).thenReturn(make3SwitchesPathPair());
String key = "failed_flow_create";
FlowRequest flowRequest = makeRequest().flowId("failed_flow_id").build();
FlowCreateService service = makeService();
service.handleRequest(key, new CommandContext(), flowRequest);
Flow inProgress = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.IN_PROGRESS);
verifyFlowPathStatus(inProgress.getForwardPath(), FlowPathStatus.IN_PROGRESS, "forward");
verifyFlowPathStatus(inProgress.getReversePath(), FlowPathStatus.IN_PROGRESS, "reverse");
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest request;
int installCommands = 0;
int deleteCommands = 0;
while ((request = requests.poll()) != null) {
try {
if (request.isVerifyRequest()) {
service.handleAsyncResponse(key, buildResponseOnVerifyRequest(request));
} else if (request.isInstallRequest()) {
installCommands++;
if (requests.size() > 1 || request instanceof EgressFlowSegmentInstallRequest) {
handleResponse(service, key, request);
} else {
handleErrorResponse(service, key, request, ErrorCode.UNKNOWN);
}
} else if (request.isRemoveRequest()) {
deleteCommands++;
handleResponse(service, key, request);
}
} catch (UnknownKeyException ex) {
// skip
}
}
assertEquals("All installed rules should be deleted", installCommands, deleteCommands);
Flow result = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.DOWN);
Assert.assertNull(result.getForwardPath());
Assert.assertNull(result.getReversePath());
}
use of org.openkilda.floodlight.api.request.EgressFlowSegmentInstallRequest in project open-kilda by telstra.
the class FlowCreateServiceTest method shouldNotRetryForever.
@Test
public void shouldNotRetryForever() throws Exception {
String key = "retries_non_ingress_installation";
FlowRequest flowRequest = makeRequest().flowId("dummy_flow_id").build();
int retriesLimit = 10;
FlowCreateService service = makeService(retriesLimit);
preparePathComputation(flowRequest.getFlowId(), make2SwitchesPathPair());
service.handleRequest(key, new CommandContext(), flowRequest);
Flow inProgress = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.IN_PROGRESS);
verifyFlowPathStatus(inProgress.getForwardPath(), FlowPathStatus.IN_PROGRESS, "forward");
verifyFlowPathStatus(inProgress.getReversePath(), FlowPathStatus.IN_PROGRESS, "reverse");
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest request;
Map<UUID, Integer> remainingRetries = new HashMap<>();
while ((request = requests.poll()) != null) {
UUID commandId = request.getCommandId();
Integer remaining = remainingRetries.getOrDefault(commandId, retriesLimit + 1);
Assert.assertTrue(0 < remaining);
try {
if (request instanceof EgressFlowSegmentInstallRequest) {
remainingRetries.put(commandId, remaining - 1);
handleErrorResponse(service, key, request, ErrorCode.SWITCH_UNAVAILABLE);
} else if (request.isVerifyRequest()) {
service.handleAsyncResponse(key, buildResponseOnVerifyRequest(request));
} else {
handleResponse(service, key, request);
}
} catch (UnknownKeyException ex) {
// skip
}
}
verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.DOWN);
}
Aggregations