Search in sources :

Example 11 with RepositoryFactory

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
}
Also used : FlowRepository(org.openkilda.persistence.repositories.FlowRepository) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) FlowPath(org.openkilda.model.FlowPath)

Example 12 with RepositoryFactory

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);
}
Also used : TransactionCallback(org.openkilda.persistence.tx.TransactionCallback) SwitchOnlineStatusMonitor(org.openkilda.wfm.topology.network.utils.SwitchOnlineStatusMonitor) EndpointStatusMonitor(org.openkilda.wfm.topology.network.utils.EndpointStatusMonitor) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) TransactionCallbackWithoutResult(org.openkilda.persistence.tx.TransactionCallbackWithoutResult) Before(org.junit.Before)

Example 13 with RepositoryFactory

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);
}
Also used : RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Before(org.junit.Before)

Example 14 with 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);
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) BeforeClass(org.junit.BeforeClass)

Example 15 with RepositoryFactory

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);
}
Also used : FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Test(org.junit.Test)

Aggregations

RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)23 PersistenceManager (org.openkilda.persistence.PersistenceManager)13 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)11 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)11 Test (org.junit.Test)10 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)10 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)6 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 PathSegmentRepository (org.openkilda.persistence.repositories.PathSegmentRepository)5 SwitchRepository (org.openkilda.persistence.repositories.SwitchRepository)4 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)3 PathNode (org.openkilda.messaging.info.event.PathNode)3 FlowPath (org.openkilda.model.FlowPath)3 IslRepository (org.openkilda.persistence.repositories.IslRepository)3 PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)2 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)2 IslEndpoint (org.openkilda.model.IslEndpoint)2 PathSegment (org.openkilda.model.PathSegment)2 SwitchId (org.openkilda.model.SwitchId)2