Search in sources :

Example 16 with RerouteQueue

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();
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Test(org.junit.Test)

Example 17 with RerouteQueue

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));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteResultInfoData(org.openkilda.messaging.info.reroute.RerouteResultInfoData) Test(org.junit.Test)

Example 18 with RerouteQueue

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));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) Test(org.junit.Test)

Example 19 with RerouteQueue

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());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Test(org.junit.Test)

Aggregations

RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)19 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)17 Test (org.junit.Test)15 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)7 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)6 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)5 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)4 IslEndpoint (org.openkilda.model.IslEndpoint)4 Flow (org.openkilda.model.Flow)3 YFlow (org.openkilda.model.YFlow)3 YSubFlow (org.openkilda.model.YSubFlow)3 ErrorData (org.openkilda.messaging.error.ErrorData)2 NoPathFoundError (org.openkilda.messaging.info.reroute.error.NoPathFoundError)2 RerouteError (org.openkilda.messaging.info.reroute.error.RerouteError)2 RerouteInProgressError (org.openkilda.messaging.info.reroute.error.RerouteInProgressError)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 String.format (java.lang.String.format)1 Instant (java.time.Instant)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1