use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeRequestsInThrottling.
@Test
public void shouldMergeRequestsInThrottling() {
FlowThrottlingData first = FlowThrottlingData.builder().correlationId("another").priority(1).timeCreate(Instant.now().plus(1, MINUTES)).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(false).effectivelyDown(false).reason("another reason").build();
rerouteQueueService.getReroutes().put(FLOW_ID, RerouteQueue.builder().throttling(first).build());
FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
rerouteQueueService.processAutomaticRequest(FLOW_ID, actual);
assertEquals(1, rerouteQueueService.getReroutes().size());
assertNotNull(rerouteQueueService.getReroutes().get(FLOW_ID));
RerouteQueue rerouteQueue = rerouteQueueService.getReroutes().get(FLOW_ID);
assertNull(rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
actual.setReason(first.getReason());
assertEquals(actual, rerouteQueue.getThrottling());
verify(carrier).sendExtendTimeWindowEvent();
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMovePendingToInProcessWhenReceivedSuccessfulResult.
@Test
public void shouldMovePendingToInProcessWhenReceivedSuccessfulResult() {
String pendingCorrelationId = "pending";
FlowThrottlingData inProgress = getFlowThrottlingData(flow, CORRELATION_ID).build();
FlowThrottlingData pending = getFlowThrottlingData(flow, pendingCorrelationId).build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
RerouteResultInfoData rerouteResultInfoData = RerouteResultInfoData.builder().flowId(FLOW_ID).success(true).build();
rerouteQueueService.processRerouteResult(rerouteResultInfoData, CORRELATION_ID);
assertNull(rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
FlowRerouteRequest expected = getFlowRerouteRequest(FLOW_ID, pending);
verify(carrier).sendRerouteRequest(eq(pendingCorrelationId), eq(expected));
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendManualRerouteRequestWithoutThrottlingForYFlow.
@Test
public void shouldSendManualRerouteRequestWithoutThrottlingForYFlow() {
FlowThrottlingData throttling = getFlowThrottlingData(yFlow, "another one").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().throttling(throttling).build();
rerouteQueueService.getReroutes().put(YFLOW_ID, rerouteQueue);
FlowThrottlingData actual = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
rerouteQueueService.processManualRequest(YFLOW_ID, actual);
assertEquals(1, rerouteQueueService.getReroutes().size());
assertEquals(actual, rerouteQueue.getInProgress());
assertNull(rerouteQueue.getPending());
assertEquals(throttling, rerouteQueue.getThrottling());
YFlowRerouteRequest expected = getYFlowRerouteRequest(YFLOW_ID, actual);
verify(carrier).sendRerouteRequest(eq(CORRELATION_ID), eq(expected));
}
use of org.openkilda.wfm.topology.reroute.model.RerouteQueue in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldMergeThrottledAndPendingRequestOnFlushWindowEvent.
@Test
public void shouldMergeThrottledAndPendingRequestOnFlushWindowEvent() {
FlowThrottlingData inProgress = FlowThrottlingData.builder().correlationId("in progress").priority(flow.getPriority()).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(false).effectivelyDown(false).reason("first reason").build();
FlowThrottlingData pending = FlowThrottlingData.builder().correlationId("pending").priority(flow.getPriority()).timeCreate(flow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_B, 1))).force(false).effectivelyDown(true).reason("second reason").build();
FlowThrottlingData throttling = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(7).timeCreate(Instant.now().plus(1, MINUTES)).affectedIsl(Collections.singleton(new IslEndpoint(SWITCH_ID_A, 1))).force(true).effectivelyDown(false).reason("third reason").build();
RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).pending(pending).throttling(throttling).build();
rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
rerouteQueueService.flushThrottling();
assertNotNull(rerouteQueue.getInProgress());
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(rerouteQueue.getPending().getCorrelationId()).priority(throttling.getPriority()).timeCreate(throttling.getTimeCreate()).affectedIsl(Sets.newHashSet(new IslEndpoint(SWITCH_ID_A, 1), new IslEndpoint(SWITCH_ID_B, 1))).force(true).effectivelyDown(true).reason(pending.getReason()).build();
assertEquals(expected, rerouteQueue.getPending());
assertNull(rerouteQueue.getThrottling());
}
Aggregations