use of org.openkilda.persistence.repositories.RepositoryFactory in project open-kilda by telstra.
the class FlowDeleteServiceTest method verifyFlowIsMissing.
private void verifyFlowIsMissing(Flow flow) {
RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
FlowRepository flowRepository = repositoryFactory.createFlowRepository();
FlowPathRepository flowPathRepository = repositoryFactory.createFlowPathRepository();
Assert.assertFalse(flowRepository.findById(flow.getFlowId()).isPresent());
for (FlowPath path : flow.getPaths()) {
Assert.assertFalse(String.format("Flow path %s still exists", path.getPathId()), flowPathRepository.findById(path.getPathId()).isPresent());
}
// TODO(surabujin): maybe we should make more deep scanning for flow related resources and nested objects
}
use of org.openkilda.persistence.repositories.RepositoryFactory in project open-kilda by telstra.
the class NetworkBfdSessionServiceTest method setUp.
@Before
public void setUp() throws Exception {
RepositoryFactory repositoryFactory = Mockito.mock(RepositoryFactory.class);
when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
when(repositoryFactory.createBfdSessionRepository()).thenReturn(bfdSessionRepository);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
doAnswer(invocation -> {
TransactionCallbackWithoutResult<?> tr = invocation.getArgument(0);
tr.doInTransaction();
return null;
}).when(transactionManager).doInTransaction(Mockito.any(TransactionCallbackWithoutResult.class));
doAnswer(invocation -> {
TransactionCallback<?, ?> tr = invocation.getArgument(0);
return tr.doInTransaction();
}).when(transactionManager).doInTransaction(Mockito.any(TransactionCallback.class));
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
switchOnlineStatusMonitor = new SwitchOnlineStatusMonitor();
endpointStatusMonitor = new EndpointStatusMonitor();
setupCarrier();
service = new NetworkBfdSessionService(persistenceManager, switchOnlineStatusMonitor, endpointStatusMonitor, carrier);
}
use of org.openkilda.persistence.repositories.RepositoryFactory in project open-kilda by telstra.
the class PersistenceDataAdapterTest method setup.
@Before
public void setup() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
when(repositoryFactory.createSwitchPropertiesRepository()).thenReturn(switchPropertiesRepository);
when(repositoryFactory.createTransitVlanRepository()).thenReturn(transitVlanRepository);
when(repositoryFactory.createVxlanRepository()).thenReturn(vxlanRepository);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
}
use of org.openkilda.persistence.repositories.RepositoryFactory in project open-kilda by telstra.
the class SwitchOperationsServiceTest method setUpOnce.
@BeforeClass
public static void setUpOnce() {
RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
switchRepository = repositoryFactory.createSwitchRepository();
switchPropertiesRepository = repositoryFactory.createSwitchPropertiesRepository();
portPropertiesRepository = repositoryFactory.createPortPropertiesRepository();
flowRepository = repositoryFactory.createFlowRepository();
mirrorGroupRepository = repositoryFactory.createMirrorGroupRepository();
flowMirrorPointsRepository = repositoryFactory.createFlowMirrorPointsRepository();
flowMirrorPathRepository = repositoryFactory.createFlowMirrorPathRepository();
lagLogicalPortRepository = repositoryFactory.createLagLogicalPortRepository();
SwitchOperationsServiceCarrier carrier = new SwitchOperationsServiceCarrier() {
@Override
public void requestSwitchSync(SwitchId switchId) {
}
@Override
public void enableServer42FlowRttOnSwitch(SwitchId switchId) {
}
@Override
public void disableServer42FlowRttOnSwitch(SwitchId switchId) {
}
@Override
public void enableServer42IslRttOnSwitch(SwitchId switchId) {
}
@Override
public void disableServer42IslRttOnSwitch(SwitchId switchId) {
}
};
ILinkOperationsServiceCarrier linkCarrier = new ILinkOperationsServiceCarrier() {
@Override
public void islBfdPropertiesChanged(Endpoint source, Endpoint destination) {
}
};
switchOperationsService = new SwitchOperationsService(persistenceManager.getRepositoryFactory(), persistenceManager.getTransactionManager(), carrier, linkCarrier);
}
use of org.openkilda.persistence.repositories.RepositoryFactory in project open-kilda by telstra.
the class RerouteServiceTest method handleRerouteInactiveAffectedFlows.
@Test
public void handleRerouteInactiveAffectedFlows() {
FlowPathRepository pathRepository = mock(FlowPathRepository.class);
when(pathRepository.findInactiveBySegmentSwitch(regularFlow.getSrcSwitchId())).thenReturn(asList(regularFlow.getForwardPath(), regularFlow.getReversePath()));
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createFlowPathRepository()).thenReturn(pathRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
RerouteService rerouteService = new RerouteService(persistenceManager);
regularFlow.setStatus(FlowStatus.DOWN);
rerouteService.rerouteInactiveAffectedFlows(carrier, CORRELATION_ID, regularFlow.getSrcSwitchId());
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularFlow.getPriority()).timeCreate(regularFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(false).effectivelyDown(true).reason(format("Switch '%s' online", regularFlow.getSrcSwitchId())).build();
verify(carrier).emitRerouteCommand(eq(regularFlow.getFlowId()), eq(expected));
regularFlow.setStatus(FlowStatus.UP);
}
Aggregations