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();
}
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;
}
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;
}
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());
}
Aggregations