Search in sources :

Example 26 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData in project open-kilda by telstra.

the class RerouteQueueServiceTest method shouldPrioritizeLowBandwidthFlowWithCostAndAvailableBandwidthPathComputationStrategy.

@Test
public void shouldPrioritizeLowBandwidthFlowWithCostAndAvailableBandwidthPathComputationStrategy() {
    FlowThrottlingData first = getFlowThrottlingData(flow, CORRELATION_ID).priority(100).build();
    FlowThrottlingData second = getFlowThrottlingData(flow, CORRELATION_ID).pathComputationStrategy(PathComputationStrategy.COST_AND_AVAILABLE_BANDWIDTH).bandwidth(100).build();
    FlowThrottlingData third = getFlowThrottlingData(flow, CORRELATION_ID).pathComputationStrategy(PathComputationStrategy.COST_AND_AVAILABLE_BANDWIDTH).bandwidth(1000).build();
    RerouteQueue firstQueue = RerouteQueue.builder().throttling(first).build();
    RerouteQueue secondQueue = RerouteQueue.builder().throttling(second).build();
    RerouteQueue thirdQueue = RerouteQueue.builder().throttling(third).build();
    rerouteQueueService.getReroutes().put("third flow", thirdQueue);
    rerouteQueueService.getReroutes().put("second flow", secondQueue);
    rerouteQueueService.getReroutes().put("first flow", firstQueue);
    rerouteQueueService.flushThrottling();
    verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("first flow", first)));
    verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("second flow", second)));
    verify(carrier).sendRerouteRequest(any(String.class), eq(getFlowRerouteRequest("third flow", third)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Test(org.junit.Test)

Example 27 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData 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 28 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData 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 29 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData 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 30 with FlowThrottlingData

use of org.openkilda.wfm.topology.reroute.model.FlowThrottlingData 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

FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)34 Test (org.junit.Test)26 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)17 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)9 IslEndpoint (org.openkilda.model.IslEndpoint)8 PersistenceManager (org.openkilda.persistence.PersistenceManager)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)6 RerouteResultInfoData (org.openkilda.messaging.info.reroute.RerouteResultInfoData)6 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)6 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)6 YFlow (org.openkilda.model.YFlow)5 PathNode (org.openkilda.messaging.info.event.PathNode)4 SpeakerRequestError (org.openkilda.messaging.info.reroute.error.SpeakerRequestError)4 Flow (org.openkilda.model.Flow)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)4 SwitchId (org.openkilda.model.SwitchId)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)2