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));
}
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)));
}
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)));
}
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)));
}
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)));
}
Aggregations