use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testUpdateTableFeatures.
@Test
public void testUpdateTableFeatures() throws Exception {
Mockito.when(tableCommitter.update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.isNull(TableFeatures.class), tableFeaturesCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().build()).buildFuture());
final FlowCapableNode operational = new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setId((short) 1).build())).setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setName("test table features").setTableId((short) 1).build())).build();
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.updateTableFeatures(NODE_IDENT, operational);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<TableFeatures> groupCaptorAllValues = tableFeaturesCaptor.getAllValues();
// TODO: uncomment when enabled in impl
// Assert.assertEquals(1, groupCaptorAllValues.size());
// Assert.assertEquals("test table features", groupCaptorAllValues.get(0).getName());
// Assert.assertEquals(1, groupCaptorAllValues.get(0).getTableId().intValue());
Mockito.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method setUp.
@Before
public void setUp() throws Exception {
Mockito.when(flowCapableTxService.sendBarrier(Matchers.<SendBarrierInput>any())).thenReturn(RpcResultBuilder.success((Void) null).buildFuture());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(tableCommitter).update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.<TableFeatures>any(), Matchers.<TableFeatures>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl().setMeterForwarder(meterCommitter).setTableForwarder(tableCommitter).setGroupForwarder(groupCommitter).setFlowForwarder(flowCommitter).setTransactionService(flowCapableTxService);
counters = new SyncCrudCounters();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class NodeNotificationSupplierImplTest method testCreateChangeEvent.
@Test
public void testCreateChangeEvent() {
final TestData testData = new TestData(createTestFlowCapableNodePath(), null, createTestFlowCapableNode(), DataObjectModification.ModificationType.WRITE);
Collection<DataTreeModification<FlowCapableNode>> collection = new ArrayList<>();
collection.add(testData);
notifSupplierImpl.onDataTreeChanged(collection);
verify(notifProviderService, times(1)).publish(Matchers.any(NodeUpdated.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.
the class SyncReactorFutureZipDecoratorTest method testSyncupWithOptimizedConfigDeltaCompression.
@Test
public void testSyncupWithOptimizedConfigDeltaCompression() throws Exception {
final FlowCapableNode dataBefore = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter = Mockito.mock(FlowCapableNode.class);
final FlowCapableNode dataAfter2 = Mockito.mock(FlowCapableNode.class);
final CountDownLatch latchForFirst = new CountDownLatch(1);
final CountDownLatch latchForNext = new CountDownLatch(1);
final SyncupEntry first = new SyncupEntry(dataBefore, configDS, null, operationalDS);
final SyncupEntry second = new SyncupEntry(dataAfter, configDS, dataBefore, configDS);
final SyncupEntry third = new SyncupEntry(null, configDS, dataAfter, configDS);
final SyncupEntry fourth = new SyncupEntry(dataAfter2, configDS, null, configDS);
final SyncupEntry zipped = new SyncupEntry(dataAfter2, configDS, dataBefore, configDS);
final List<ListenableFuture<Boolean>> allResults = new ArrayList<>();
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(first))).thenAnswer(invocationOnMock -> {
LOG.info("unlocking next configs");
latchForNext.countDown();
latchForFirst.await();
LOG.info("unlocking first delegate");
return Futures.immediateFuture(Boolean.TRUE);
});
allResults.add(reactor.syncup(fcNodePath, first));
latchForNext.await();
mockSyncupWithEntry(second);
allResults.add(reactor.syncup(fcNodePath, second));
mockSyncupWithEntry(third);
allResults.add(reactor.syncup(fcNodePath, third));
mockSyncupWithEntry(fourth);
allResults.add(reactor.syncup(fcNodePath, fourth));
latchForFirst.countDown();
Futures.allAsList(allResults).get(1, TimeUnit.SECONDS);
LOG.info("all configs done");
syncThreadPool.shutdown();
boolean terminated = syncThreadPool.awaitTermination(1, TimeUnit.SECONDS);
if (!terminated) {
LOG.info("thread pool not terminated.");
syncThreadPool.shutdownNow();
}
final InOrder inOrder = Mockito.inOrder(delegate);
inOrder.verify(delegate).syncup(fcNodePath, first);
inOrder.verify(delegate).syncup(fcNodePath, zipped);
inOrder.verifyNoMoreInteractions();
}
Aggregations