Search in sources :

Example 11 with SyncupEntry

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

the class SimplifiedConfigListenerTest method testOnDataTreeChangedDelete.

@Test
public void testOnDataTreeChangedDelete() {
    Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
    Mockito.when(configModification.getDataAfter()).thenReturn(null);
    final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(null, 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 12 with SyncupEntry

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

the class SimplifiedConfigListenerTest method loadOperationalDSAndPrepareSyncupEntry.

private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
    Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath)).thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
    final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
    Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE));
    return syncupEntry;
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)

Example 13 with SyncupEntry

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

the class SimplifiedOperationalListenerTest method loadConfigDSAndPrepareSyncupEntry.

private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter, final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
    Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath)).thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
    final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
    Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(syncupEntry))).thenReturn(Futures.immediateFuture(Boolean.TRUE));
    return syncupEntry;
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry)

Example 14 with SyncupEntry

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

the class SyncReactorImplTest method testSyncup.

@Test
public void testSyncup() throws Exception {
    final FlowCapableNode configFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(1L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f1", 1))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(1L))).build();
    final FlowCapableNode operationalFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(2L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f2", 2))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(2L))).build();
    final SyncupEntry syncupEntry = new SyncupEntry(configFcn, LogicalDatastoreType.CONFIGURATION, operationalFcn, LogicalDatastoreType.OPERATIONAL);
    Mockito.when(syncPlanPushStrategy.executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), Matchers.<SynchronizationDiffInput>any(), Matchers.<SyncCrudCounters>any())).thenReturn(RpcResultBuilder.<Void>success().buildFuture());
    final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, syncupEntry);
    Assert.assertTrue(syncupResult.isDone());
    final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(voidRpcResult);
    Mockito.verify(syncPlanPushStrategy).executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), syncDiffInputCaptor.capture(), Matchers.<SyncCrudCounters>any());
    final SynchronizationDiffInput diffInput = syncDiffInputCaptor.getValue();
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
    Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
    Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
    Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
    Assert.assertEquals(1, diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
    Assert.assertEquals(0, diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
    Assert.assertEquals(1, diffInput.getMetersToRemove().getItemsToPush().size());
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) SynchronizationDiffInput(org.opendaylight.openflowplugin.applications.frsync.impl.strategy.SynchronizationDiffInput) 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