use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.
the class FlowValidatorTest method setup.
@BeforeClass
public static void setup() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createFlowRepository()).thenReturn(mock(FlowRepository.class));
when(repositoryFactory.createSwitchRepository()).thenReturn(mock(SwitchRepository.class));
when(repositoryFactory.createIslRepository()).thenReturn(mock(IslRepository.class));
when(repositoryFactory.createSwitchPropertiesRepository()).thenReturn(mock(SwitchPropertiesRepository.class));
when(repositoryFactory.createFlowMirrorPathRepository()).thenReturn(mock(FlowMirrorPathRepository.class));
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
flowValidator = new FlowValidator(persistenceManager);
}
use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.
the class PingTopology method flowFetcher.
private void flowFetcher(TopologyBuilder topology) {
PersistenceManager persistenceManager = new PersistenceManager(configurationProvider);
FlowResourcesConfig flowResourcesConfig = configurationProvider.getConfiguration(FlowResourcesConfig.class);
FlowFetcher bolt = new FlowFetcher(persistenceManager, flowResourcesConfig, topologyConfig.getPeriodicPingCacheExpirationInterval());
declareBolt(topology, bolt, FlowFetcher.BOLT_ID).globalGrouping(TickDeduplicator.BOLT_ID, TickDeduplicator.STREAM_PING_ID).shuffleGrouping(InputRouter.BOLT_ID, InputRouter.STREAM_ON_DEMAND_REQUEST_ID).shuffleGrouping(InputRouter.BOLT_ID, InputRouter.STREAM_ON_DEMAND_Y_FLOW_REQUEST_ID).allGrouping(InputRouter.BOLT_ID, InputRouter.STREAM_PERIODIC_PING_UPDATE_REQUEST_ID);
}
use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.
the class RerouteServiceTest method shouldSkipRerouteRequestsForFlowWithoutAffectedPathSegment.
@Test
public void shouldSkipRerouteRequestsForFlowWithoutAffectedPathSegment() {
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);
PathSegmentRepository pathSegmentRepository = mock(PathSegmentRepository.class);
doThrow(new EntityNotFoundException("Not found")).when(pathSegmentRepository).updateFailedStatus(any(), any(), anyBoolean());
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createPathSegmentRepository()).thenReturn(pathSegmentRepository);
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);
verifyZeroInteractions(carrier);
}
use of org.openkilda.persistence.PersistenceManager 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.persistence.PersistenceManager in project open-kilda by telstra.
the class RerouteServiceTest method processManualRerouteRequestForYFlow.
@Test
public void processManualRerouteRequestForYFlow() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
YFlowRepository yFlowRepository = mock(YFlowRepository.class);
when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(regularYFlow));
RerouteService rerouteService = new RerouteService(persistenceManager);
YFlowRerouteRequest request = new YFlowRerouteRequest(regularYFlow.getYFlowId(), Collections.emptySet(), true, "reason", false);
rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularYFlow.getPriority()).timeCreate(regularYFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).reason("reason").yFlow(true).build();
verify(carrier).emitManualRerouteCommand(eq(regularYFlow.getYFlowId()), eq(expected));
}
Aggregations