Search in sources :

Example 1 with SyncupEntry

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.

the class SimplifiedConfigListenerTest method testOnDataTreeChangedAdd.

@Test
public void testOnDataTreeChangedAdd() {
    Mockito.when(configModification.getDataBefore()).thenReturn(null);
    Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
    final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
    nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
    Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
    Mockito.verifyNoMoreInteractions(reactor);
    Mockito.verify(roTx).close();
}
Also used : SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Example 2 with SyncupEntry

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.

the class SimplifiedConfigListenerTest method testOnDataTreeChangedUpdate.

@Test
public void testOnDataTreeChangedUpdate() {
    Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
    Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
    final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, confgDS);
    nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
    Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
    Mockito.verifyNoMoreInteractions(reactor);
    Mockito.verify(roTx).close();
}
Also used : SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Example 3 with SyncupEntry

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.

the class SimplifiedOperationalListenerTest method testOnDataTreeChangedReconcileAndFreshOperationalNotPresentButAdd.

@Test
public void testOnDataTreeChangedReconcileAndFreshOperationalNotPresentButAdd() throws ParseException {
    Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
    operationalAdd();
    prepareFreshOperational(false);
    final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
    nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
    Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
    Mockito.verify(roTx).close();
}
Also used : SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Example 4 with SyncupEntry

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.

the class SimplifiedOperationalListenerTest method testOnDataTreeChangedReconcileAndFreshOperationalPresent.

@Test
public void testOnDataTreeChangedReconcileAndFreshOperationalPresent() throws Exception {
    Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
    operationalUpdate();
    prepareFreshOperational(true);
    final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(configNode, configDS, fcOperationalNode, operationalDS);
    nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
    Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
    Mockito.verify(roTx).close();
}
Also used : SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Example 5 with SyncupEntry

use of org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry in project openflowplugin by opendaylight.

the class SyncReactorFutureZipDecoratorTest method testSyncupRewriteZipEntryWithOperationalDelta.

@Test
public void testSyncupRewriteZipEntryWithOperationalDelta() throws Exception {
    final FlowCapableNode configBefore = Mockito.mock(FlowCapableNode.class);
    final FlowCapableNode configAfter = Mockito.mock(FlowCapableNode.class);
    final FlowCapableNode configActual = Mockito.mock(FlowCapableNode.class);
    final FlowCapableNode freshOperational = Mockito.mock(FlowCapableNode.class);
    final CountDownLatch latchForFirst = new CountDownLatch(1);
    final CountDownLatch latchForNext = new CountDownLatch(1);
    final SyncupEntry first = new SyncupEntry(configAfter, configDS, configBefore, configDS);
    final SyncupEntry second = new SyncupEntry(configActual, configDS, freshOperational, operationalDS);
    Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first))).thenAnswer(invocationOnMock -> {
        LOG.info("unlocking for fresh operational");
        latchForNext.countDown();
        latchForFirst.await();
        LOG.info("unlocking first delegate");
        return Futures.immediateFuture(Boolean.TRUE);
    });
    reactor.syncup(fcNodePath, first);
    latchForNext.await();
    mockSyncupWithEntry(second);
    reactor.syncup(fcNodePath, second);
    latchForFirst.countDown();
    syncThreadPool.shutdown();
    boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
    if (!terminated) {
        LOG.info("thread pool not terminated.");
        syncThreadPool.shutdownNow();
    }
    Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, second);
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) CountDownLatch(java.util.concurrent.CountDownLatch) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Aggregations

SyncupEntry (org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)14 Test (org.junit.Test)9 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 CountDownLatch (java.util.concurrent.CountDownLatch)3 InOrder (org.mockito.InOrder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 SynchronizationDiffInput (org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput)1 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)1 TableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1