use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendManualRerouteRequestWithoutThrottling.
@Test
public void shouldSendManualRerouteRequestWithoutThrottling() {
FlowThrottlingData throttling = getFlowThrottlingData(flow, "another one").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().throttling(throttling).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
rerouteQueueService.processManualRequest(FLOW_ID, actual);
assertEquals(1, rerouteQueueService.getReroutes().size());
assertEquals(actual, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertEquals(throttling, rerouteQueue.getThrottling());
FlowRerouteRequest expected = getFlowRerouteRequest(FLOW_ID, actual);
verify(carrier).sendRerouteRequest(eq(CORRELATION_ID), eq(expected));
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendThrottledRequestOnFlushWindowEvent.
@Test
public void shouldSendThrottledRequestOnFlushWindowEvent() {
FlowThrottlingData throttling = getFlowThrottlingData(flow, CORRELATION_ID).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().throttling(throttling).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
rerouteQueueService.flushThrottling();
assertEquals(throttling, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
FlowRerouteRequest expectedRequest = getFlowRerouteRequest(FLOW_ID, throttling);
verify(carrier).sendRerouteRequest(any(String.class), eq(expectedRequest));
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch.
@Test
public void shouldMergeAndSendRetryWithPendingRequestWhenReceivedFailedRuleInstallResponseOnTransitSwitch() {
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(7).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(true).reason("another reason").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(false).rerouteError(new SpeakerRequestError("Failed to install rules", Collections.singleton(SWITCH_C.getSwitchId()))).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
String retryCorrelationId = CORRELATION_ID + " : retry #1 ignore_bw false";
FlowThrottlingData expected = getFlowThrottlingData(flow, retryCorrelationId).build();
expected.setPriority(pending.getPriority());
expected.setReason(pending.getReason());
assertEquals(expected, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
FlowRerouteRequest expectedRequest = getFlowRerouteRequest(FLOW_ID, expected);
verify(carrier).sendRerouteRequest(eq(retryCorrelationId), eq(expectedRequest));
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteOnUnsuccessfulInstallation.
@Test
public void shouldFailRerouteOnUnsuccessfulInstallation() 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.isInstallRequest()) {
service.handleAsyncResponse(currentRequestKey, FlowErrorResponse.errorBuilder().messageContext(speakerRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
} 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 install rules"))), any(String.class));
}
use of org.openkilda.messaging.command.flow.FlowRerouteRequest in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldCompleteRerouteOnErrorDuringResourceDeallocation.
@Test
public void shouldCompleteRerouteOnErrorDuringResourceDeallocation() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
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);
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(currentRequestKey, buildResponseOnVerifyRequest(speakerRequest));
} else {
produceAsyncResponse(service, speakerRequest);
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyPathReplace(origin, result);
}
Aggregations