Search in sources :

Example 1 with FlowCapableNode

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());
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) 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) UpdateTableOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder) Test(org.junit.Test)

Example 2 with FlowCapableNode

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();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Before(org.junit.Before)

Example 3 with FlowCapableNode

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));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) NodeUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with FlowCapableNode

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

Example 5 with FlowCapableNode

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();
}
Also used : InOrder(org.mockito.InOrder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) CountDownLatch(java.util.concurrent.CountDownLatch) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) Test(org.junit.Test)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)48 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)26 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)22 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)20 ArrayList (java.util.ArrayList)17 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)15 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)15 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)15 Test (org.junit.Test)14 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)14 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)10 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)8