Search in sources :

Example 11 with FlowThrottlingData

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

the class RerouteServiceTest method handlePathNoFoundException.

@Test
public void handlePathNoFoundException() {
    PathNode islSide = new PathNode(SWITCH_A.getSwitchId(), 1, 0);
    FlowPathRepository pathRepository = mock(FlowPathRepository.class);
    when(pathRepository.findBySegmentEndpoint(eq(islSide.getSwitchId()), eq(islSide.getPortNo()))).thenReturn(asList(regularFlow.getForwardPath(), regularFlow.getReversePath()));
    FlowRepository flowRepository = mock(FlowRepository.class);
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createPathSegmentRepository()).thenReturn(mock(PathSegmentRepository.class));
    when(repositoryFactory.createFlowPathRepository()).thenReturn(pathRepository);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
    RerouteService rerouteService = new RerouteService(persistenceManager);
    RerouteAffectedFlows request = new RerouteAffectedFlows(islSide, "dummy-reason - unittest");
    rerouteService.rerouteAffectedFlows(carrier, CORRELATION_ID, request);
    verify(flowRepository).updateStatusSafe(eq(regularFlow), eq(FlowStatus.DOWN), any());
    FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularFlow.getPriority()).timeCreate(regularFlow.getTimeCreate()).affectedIsl(Collections.singleton(new IslEndpoint(islSide.getSwitchId(), islSide.getPortNo()))).force(false).effectivelyDown(true).reason(request.getReason()).build();
    verify(carrier).emitRerouteCommand(eq(regularFlow.getFlowId()), eq(expected));
}
Also used : FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) IslEndpoint(org.openkilda.model.IslEndpoint) PathSegmentRepository(org.openkilda.persistence.repositories.PathSegmentRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 12 with FlowThrottlingData

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

the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestWithNotExistentFlow.

@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestWithNotExistentFlow() {
    String notExistentFlowId = "notExistentFlowId";
    when(flowRepository.findById(notExistentFlowId)).thenReturn(Optional.empty());
    FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
    rerouteQueueService.processManualRequest(notExistentFlowId, actual);
    assertEquals(0, rerouteQueueService.getReroutes().size());
    verify(carrier).emitFlowRerouteError(argThat(flowNotFoundErrorData(notExistentFlowId)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) Test(org.junit.Test)

Example 13 with FlowThrottlingData

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

the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestWhenAnotherRerouteIsInProgress.

@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestWhenAnotherRerouteIsInProgress() {
    FlowThrottlingData inProgress = getFlowThrottlingData(flow, "another one").build();
    RerouteQueue rerouteQueue = RerouteQueue.builder().inProgress(inProgress).build();
    rerouteQueueService.getReroutes().put(FLOW_ID, rerouteQueue);
    FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
    rerouteQueueService.processManualRequest(FLOW_ID, actual);
    verify(carrier).emitFlowRerouteError(argThat(rerouteIsInProgressErrorData(FLOW_ID)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RerouteQueue(org.openkilda.wfm.topology.reroute.model.RerouteQueue) Test(org.junit.Test)

Example 14 with FlowThrottlingData

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

the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedFlow.

@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedFlow() {
    String flowId = "test flow";
    when(flowRepository.findById(flowId)).thenReturn(Optional.of(Flow.builder().flowId(flowId).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).priority(2).pinned(true).build()));
    FlowThrottlingData actual = getFlowThrottlingData(flow, CORRELATION_ID).build();
    rerouteQueueService.processManualRequest(flowId, actual);
    assertEquals(0, rerouteQueueService.getReroutes().size());
    verify(carrier).emitFlowRerouteError(argThat(pinnedFlowErrorData(flowId)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) Test(org.junit.Test)

Example 15 with FlowThrottlingData

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

the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestWithNotExistentYFlow.

@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestWithNotExistentYFlow() {
    String notExistentFlowId = "notExistentFlowId";
    when(yFlowRepository.findById(notExistentFlowId)).thenReturn(Optional.empty());
    FlowThrottlingData actual = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
    rerouteQueueService.processManualRequest(notExistentFlowId, actual);
    assertEquals(0, rerouteQueueService.getReroutes().size());
    verify(carrier).emitFlowRerouteError(argThat(yflowNotFoundErrorData(notExistentFlowId)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) 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