<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>model-flow-base</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-api</artifactId>
- </dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
</plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/initial/71-bulk-o-matic.xml</file>
- <type>xml</type>
- <classifier>config</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
return ((InstanceIdentifier<Node>) nodeRef.getValue())
.augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(bulkFlow.getTableId()))
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow.class,
+ .child(Flow.class,
new FlowKey(new FlowId(bulkFlow.getFlowId())));
}
List<ListenableFuture<RpcResult<AddFlowOutput>>> bulkResults = new ArrayList<>();
for (BulkFlowBaseContentGrouping bulkFlow : input.getBulkFlowItem()) {
- AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder((Flow) bulkFlow);
+ AddFlowInputBuilder flowInputBuilder = new AddFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) bulkFlow);
final NodeRef nodeRef = bulkFlow.getNode();
flowInputBuilder.setNode(nodeRef);
flowInputBuilder.setTableId(bulkFlow.getTableId());
List<ListenableFuture<RpcResult<RemoveFlowOutput>>> bulkResults = new ArrayList<>();
for (BulkFlowBaseContentGrouping bulkFlow : input.getBulkFlowItem()) {
- RemoveFlowInputBuilder flowInputBuilder = new RemoveFlowInputBuilder((Flow) bulkFlow);
+ RemoveFlowInputBuilder flowInputBuilder = new RemoveFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) bulkFlow);
final NodeRef nodeRef = bulkFlow.getNode();
flowInputBuilder.setNode(nodeRef);
flowInputBuilder.setTableId(bulkFlow.getTableId());
+++ /dev/null
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608;
-
-import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public class BulkOMaticModule extends AbstractBulkOMaticModule {
- public BulkOMaticModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(identifier, dependencyResolver);
- }
-
- public BulkOMaticModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608.BulkOMaticModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(identifier, dependencyResolver, oldModule, oldInstance);
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- // Instances are created via blueprint so this in a no-op.
- return NoopAutoCloseable.INSTANCE;
- }
-}
+++ /dev/null
-/*
-* Generated file
-*
-* Generated from: yang module name: bulk-o-matic yang module local name: bulk-o-matic
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Mon Jun 08 16:32:10 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.bulk.o.matic.rev150608;
-
-/**
- * @deprecated Replaced by blueprint wiring
- */
-@Deprecated
-public class BulkOMaticModuleFactory extends AbstractBulkOMaticModuleFactory {
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- ~
- ~ This program and the accompanying materials are made available under the
- ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
- ~ and is available at http://www.eclipse.org/legal/epl-v10.html
-
- NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
- backwards compatibility. Runtime modifications are not honored.
- -->
-
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-
-<snapshot>
- <configuration>
- <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
- <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-
- <module>
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:openflow:applications:bulk-o-matic">prefix:bulk-o-matic</type>
- <name>bulk-o-matic</name>
- <data-broker>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
- <name>pingpong-binding-data-broker</name>
- </data-broker>
- <rpc-registry>
- <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
- <name>binding-rpc-broker</name>
- </rpc-registry>
- </module>
- </modules>
- </data>
- </configuration>
-
- <required-capabilities>
- <capability>urn:opendaylight:flow:inventory?module=flow-node-inventory&revision=2013-08-19</capability>
- <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24</capability>
- <capability>urn:opendaylight:inventory?module=opendaylight-inventory&revision=2013-08-19</capability>
- <capability>urn:opendaylight:flow:types?module=opendaylight-flow-types&revision=2013-10-26</capability>
- </required-capabilities>
-</snapshot>
+++ /dev/null
-module bulk-o-matic {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:bulk-o-matic";
- prefix "bulk";
- import config {prefix config; revision-date 2013-04-05;}
- import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28;}
- import opendaylight-entity-ownership-service { prefix entity-ownership-service; }
-
- description
- "End point application providing bulk operation via DS and via rpc";
-
- revision "2015-06-08" {
- description
- "Initial revision";
- }
-
- identity bulk-o-matic {
- base "config:module-type";
- config:java-name-prefix BulkOMatic;
- status deprecated;
- }
-
- augment "/config:modules/config:module/config:configuration" {
- case bulk-o-matic {
- when "/config:modules/config:module/config:type = 'bulk-o-matic'";
- container rpc-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-rpc-registry;
- }
- }
- }
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
- }
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link BulkOMaticUtils}.
+ */
+public class BulkOMaticUtilsTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(BulkOMaticUtilsTest.class);
+ private static final String FLOW_ID = "1";
+
+ @Test
+ public void testIpIntToStr() throws Exception {
+ Assert.assertEquals("255.255.255.255/32", BulkOMaticUtils.ipIntToStr(0xffffffff));
+ Assert.assertEquals("255.255.255.255/32", BulkOMaticUtils.ipIntToStr(-1));
+ Assert.assertEquals("0.0.0.0/32", BulkOMaticUtils.ipIntToStr(0));
+ Assert.assertEquals("1.2.3.4/32", BulkOMaticUtils.ipIntToStr(0x01020304));
+ }
+
+ @Test
+ public void testGetMatch() throws Exception {
+ final Match match = BulkOMaticUtils.getMatch(0xffffffff);
+ Assert.assertNotNull(match);
+ }
+
+ @Test
+ public void testBuildFlow() throws Exception {
+ final Match match = BulkOMaticUtils.getMatch(0xffffffff);
+ final Flow flow = BulkOMaticUtils.buildFlow((short)1, FLOW_ID, match);
+ Assert.assertEquals(FLOW_ID,flow.getId().getValue());
+ Assert.assertEquals((short) 1 ,flow.getTableId().shortValue());
+ }
+
+ @Test
+ public void testGetFlowInstanceIdentifier() throws Exception {
+ Assert.assertNotNull(BulkOMaticUtils.getFlowInstanceIdentifier((short)1, "1", "1"));
+ }
+
+ @Test
+ public void testGetFlowCapableNodeId() throws Exception {
+ Assert.assertNotNull(BulkOMaticUtils.getFlowCapableNodeId("1"));
+ }
+
+ @Test
+ public void testGetTableId() throws Exception {
+ Assert.assertNotNull(BulkOMaticUtils.getTableId((short)1, "1"));
+ }
+
+ @Test
+ public void testGetFlowId() throws Exception {
+ Assert.assertNotNull(BulkOMaticUtils.getFlowId(BulkOMaticUtils.getTableId((short)1, "1"), "1"));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link FlowReader}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class FlowReaderTest {
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private ReadOnlyTransaction rTx;
+ @Mock
+ private Node node;
+
+ private FlowReader flowReader;
+
+ @Before
+ public void setUp() throws Exception {
+ when(rTx.read(Mockito.any(LogicalDatastoreType.class), Mockito.<InstanceIdentifier<Node>>any()))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.of(node)));
+ when(mockDataBroker.newReadOnlyTransaction()).thenReturn(rTx);
+ flowReader = FlowReader.getNewInstance(mockDataBroker, 2, 5, true, false, (short)1, (short)2 );
+ }
+
+ @Test
+ public void testRun() throws Exception {
+ flowReader.run();
+ Assert.assertEquals(10, flowReader.getFlowCount());
+ Assert.assertEquals(FlowCounter.OperationStatus.SUCCESS.status(), flowReader.getReadOpStatus());
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.doReturn;
+
+import com.google.common.util.concurrent.Futures;
+import java.util.concurrent.ExecutorService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link FlowWriterConcurrent}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class FlowWriterConcurrentTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowWriterConcurrentTest.class);
+ private static final int FLOWS_PER_DPN = 100;
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private ExecutorService mockFlowPusher;
+ @Mock
+ private WriteTransaction wTx;
+ @Mock
+ private Nodes mockNodes;
+
+ private FlowWriterConcurrent flowWriterConcurrent;
+
+ @Before
+ public void setUp() throws Exception {
+
+ doReturn(wTx).when(mockDataBroker).newWriteOnlyTransaction();
+ Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ ((Runnable)invocation.getArguments()[0]).run();
+ return null;
+ }
+ }).when(mockFlowPusher).execute(Matchers.<Runnable>any());
+
+ flowWriterConcurrent = new FlowWriterConcurrent(mockDataBroker, mockFlowPusher);
+ }
+ @Test
+ public void testAddFlows() throws Exception {
+ flowWriterConcurrent.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any(), Matchers.<DataObject>any(), Matchers.anyBoolean());
+ }
+
+ @Test
+ public void testDeleteFlows() throws Exception {
+ flowWriterConcurrent.deleteFlows(1, FLOWS_PER_DPN, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link FlowWriterDirectOFRpc}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class FlowWriterDirectOFRpcTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowWriterDirectOFRpcTest.class);
+ private static final int FLOWS_PER_DPN = 100;
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private SalFlowService mockSalFlowService;
+ @Mock
+ private ExecutorService mockFlowPusher;
+ @Mock
+ private ReadOnlyTransaction rTx;
+ @Mock
+ private Nodes mockNodes;
+
+ private FlowWriterDirectOFRpc flowWriterDirectOFRpc;
+
+ @Before
+ public void setUp() throws Exception {
+ when(mockDataBroker.newReadOnlyTransaction()).thenReturn(rTx);
+ NodeBuilder nodeBuilder = new NodeBuilder()
+ .setId(new NodeId("1"));
+
+ final List<Node> nodes = new ArrayList<>();
+ final Node node = nodeBuilder.build();
+ nodes.add(node);
+
+ when(mockNodes.getNode()).thenReturn(nodes);
+
+ when(rTx.read(Mockito.any(LogicalDatastoreType.class), Mockito.<InstanceIdentifier<Nodes>>any()))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes)));
+
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ ((Runnable)invocation.getArguments()[0]).run();
+ return null;
+ }
+ }).when(mockFlowPusher).execute(Matchers.<Runnable>any());
+
+ flowWriterDirectOFRpc = new FlowWriterDirectOFRpc(mockDataBroker, mockSalFlowService, mockFlowPusher);
+ }
+
+ @Test
+ public void testRpcFlowAdd() throws Exception {
+ flowWriterDirectOFRpc.rpcFlowAdd("1", FLOWS_PER_DPN, 10);
+ Mockito.verify(mockSalFlowService, Mockito.times(FLOWS_PER_DPN)).addFlow(Mockito.<AddFlowInput>any());
+ }
+
+ @Test
+ public void testRpcFlowAddAll() throws Exception {
+ flowWriterDirectOFRpc.rpcFlowAddAll(FLOWS_PER_DPN, 10);
+ Mockito.verify(mockSalFlowService, Mockito.times(FLOWS_PER_DPN)).addFlow(Mockito.<AddFlowInput>any());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.doReturn;
+
+import com.google.common.util.concurrent.Futures;
+import java.util.concurrent.ExecutorService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link FlowWriterSequential}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class FlowWriterSequentialTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowWriterSequentialTest.class);
+ private static final int FLOWS_PER_DPN = 100;
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private ExecutorService mockFlowPusher;
+ @Mock
+ private WriteTransaction wTx;
+
+ private FlowWriterSequential flowWriterSequential;
+
+ @Before
+ public void setUp() throws Exception {
+
+ doReturn(wTx).when(mockDataBroker).newWriteOnlyTransaction();
+ Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ ((Runnable)invocation.getArguments()[0]).run();
+ return null;
+ }
+ }).when(mockFlowPusher).execute(Matchers.<Runnable>any());
+
+ flowWriterSequential = new FlowWriterSequential(mockDataBroker, mockFlowPusher);
+ }
+ @Test
+ public void testAddFlows() throws Exception {
+ flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any(), Matchers.<DataObject>any(), Matchers.anyBoolean());
+ }
+
+ @Test
+ public void testDeleteFlows() throws Exception {
+ flowWriterSequential.deleteFlows(1, FLOWS_PER_DPN, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.google.common.util.concurrent.Futures;
+import java.util.concurrent.ExecutorService;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link FlowWriterTxChain}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class FlowWriterTxChainTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(FlowWriterTxChainTest.class);
+ private static final int FLOWS_PER_DPN = 100;
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private ExecutorService mockFlowPusher;
+ @Mock
+ private WriteTransaction wTx;
+
+ private FlowWriterTxChain flowWriterTxChain;
+
+ @Before
+ public void setUp() throws Exception {
+
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ ((Runnable)invocation.getArguments()[0]).run();
+ return null;
+ }
+ }).when(mockFlowPusher).execute(Matchers.<Runnable>any());
+
+ final BindingTransactionChain mockedTxChain = mock(BindingTransactionChain.class);
+ when(mockedTxChain.newWriteOnlyTransaction()).thenReturn(wTx);
+ doReturn(mockedTxChain).when(mockDataBroker).createTransactionChain(Matchers.<TransactionChainListener>any());
+
+ when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+
+ flowWriterTxChain = new FlowWriterTxChain(mockDataBroker, mockFlowPusher);
+ }
+ @Test
+ public void testAddFlows() throws Exception {
+ flowWriterTxChain.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any(), Matchers.<DataObject>any(), Matchers.anyBoolean());
+ }
+
+ @Test
+ public void testDeleteFlows() throws Exception {
+ flowWriterTxChain.deleteFlows(1, FLOWS_PER_DPN, 10, (short)0, (short)1);
+ Mockito.verify(wTx, Mockito.times(FLOWS_PER_DPN)).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<DataObject>>any());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddMultipleInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddMultipleInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowRpcAddTestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.FlowTestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.ReadFlowTestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.ReadFlowTestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link SalBulkFlowServiceImpl}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SalBulkFlowServiceImplTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SalBulkFlowServiceImplTest.class);
+
+ @Mock
+ private DataBroker mockDataBroker;
+ @Mock
+ private SalFlowService mockSalFlowService;
+ @Mock
+ private WriteTransaction wTx;
+ @Mock
+ private ReadOnlyTransaction rTx;
+ @Mock
+ private Nodes mockNodes;
+ @Mock
+ private Node mockNode;
+ @Captor
+ private ArgumentCaptor<Flow> flowArgumentCaptor;
+
+ private SalBulkFlowServiceImpl salBulkFlowService;
+
+ @Before
+ public void setUp() throws Exception {
+ when(mockDataBroker.newWriteOnlyTransaction()).thenReturn(wTx);
+ when(mockDataBroker.newReadOnlyTransaction()).thenReturn(rTx);
+ when(rTx.read(Mockito.any(LogicalDatastoreType.class), Mockito.<InstanceIdentifier<Node>>any()))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNode)));
+ salBulkFlowService = new SalBulkFlowServiceImpl(mockSalFlowService, mockDataBroker);
+ }
+
+ @Test
+ public void testAddRemoveFlowsDs() throws Exception {
+ Mockito.when(wTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+
+ final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder()
+ .setFlowId(new FlowId("1"))
+ .setTableId((short)2);
+
+ final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
+ bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
+ final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
+
+ final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
+ bulkFlowDsItems.add(bulkFlowDsItem);
+
+ final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
+ addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
+
+ final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
+ salBulkFlowService.addFlowsDs(addFlowsDsInput);
+
+ verify(wTx).submit();
+ verify(wTx).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
+
+ Flow flow = flowArgumentCaptor.getValue();
+ Assert.assertEquals("1", flow.getId().getValue());
+ Assert.assertEquals((short) 2, flow.getTableId().shortValue());
+
+ final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
+ removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
+
+ final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
+
+ salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
+ verify(wTx).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
+ verify(wTx,times(2)).submit();
+ }
+
+ @Test
+ public void testAddRemoveFlowsRpc() throws Exception {
+ Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any()))
+ .thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
+
+ Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any()))
+ .thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
+
+ final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
+ final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
+ bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
+ final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
+
+ final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
+ bulkFlowItems.add(bulkFlowItem);
+
+ final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
+ addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
+
+ final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
+ salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
+
+ verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
+
+ final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
+ removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
+
+ final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
+ salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
+
+ verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
+ }
+
+ @Test
+ public void testReadFlowTest() throws Exception {
+ final ReadFlowTestInputBuilder readFlowTestInputBuilder = new ReadFlowTestInputBuilder()
+ .setDpnCount(1L)
+ .setStartTableId(1L)
+ .setEndTableId(2L)
+ .setIsConfigDs(false)
+ .setFlowsPerDpn(1L)
+ .setVerbose(true);
+
+ final ReadFlowTestInput readFlowTestInput = readFlowTestInputBuilder.build();
+ final Future<RpcResult<Void>> resultFuture = salBulkFlowService.readFlowTest(readFlowTestInput);
+
+ Assert.assertTrue(resultFuture.get().isSuccessful());
+ }
+
+ @Test
+ public void testFlowRpcAddTest() throws Exception {
+ when(rTx.read(Mockito.any(LogicalDatastoreType.class), Mockito.<InstanceIdentifier<Nodes>>any()))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes)));
+
+ final FlowRpcAddTestInputBuilder flowRpcAddTestInputBuilder = new FlowRpcAddTestInputBuilder()
+ .setFlowCount(1L)
+ .setDpnId("1")
+ .setRpcBatchSize(1L);
+
+ final FlowRpcAddTestInput flowRpcAddTestInput = flowRpcAddTestInputBuilder.build();
+ final Future<RpcResult<Void>> resultFuture = salBulkFlowService.flowRpcAddTest(flowRpcAddTestInput);
+
+ Assert.assertTrue(resultFuture.get().isSuccessful());
+ }
+
+ @Test
+ public void testFlowTest() throws Exception {
+ final FlowTestInputBuilder flowTestInputBuilder = new FlowTestInputBuilder()
+ .setBatchSize(1L)
+ .setDpnCount(1L)
+ .setEndTableId(2L)
+ .setFlowsPerDpn(1L)
+ .setIsAdd(true)
+ .setSeq(true)
+ .setSleepAfter(20L)
+ .setSleepFor(1L)
+ .setStartTableId(1L)
+ .setTxChain(true);
+
+ FlowTestInput flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+
+ flowTestInputBuilder.setIsAdd(false);
+ flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+
+ flowTestInputBuilder.setTxChain(false);
+ flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+
+ flowTestInputBuilder.setIsAdd(true);
+ flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+
+ flowTestInputBuilder.setSeq(false);
+ flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+
+ flowTestInputBuilder.setIsAdd(false);
+ flowTestInput = flowTestInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowTest(flowTestInput).get().isSuccessful());
+ }
+
+ @Test
+ public void testFlowRpcAddMultiple() throws Exception {
+ when(rTx.read(Mockito.any(LogicalDatastoreType.class), Mockito.<InstanceIdentifier<Nodes>>any()))
+ .thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNodes)));
+
+ final FlowRpcAddMultipleInputBuilder flowRpcAddMultipleInputBuilder = new FlowRpcAddMultipleInputBuilder()
+ .setFlowCount(1L)
+ .setRpcBatchSize(1L);
+
+ final FlowRpcAddMultipleInput flowRpcAddMultipleInput = flowRpcAddMultipleInputBuilder.build();
+
+ Assert.assertTrue(salBulkFlowService.flowRpcAddMultiple(flowRpcAddMultipleInput).get().isSuccessful());
+ }
+}
\ No newline at end of file
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common-util</artifactId>
@Override
public void remove(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector del, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
- LOG.warn("Node Connector removed");
+ LOG.info("Node Connector removed");
String sNodeConnectorIdentifier = nodeConnIdent
.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
long nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
@Override
public void update(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector original, FlowCapableNodeConnector update, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
- LOG.warn("Node Connector updated");
+ LOG.info("Node Connector updated");
//donot need to do anything as we are not considering updates here
}
}
@Override
public void add(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector add, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE_CONNECTOR)){
- LOG.warn("Node Connector added");
+ LOG.info("Node Connector added");
String sNodeConnectorIdentifier = nodeConnIdent
.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue();
long nDpId = getDpIdFromPortName(sNodeConnectorIdentifier);
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-config</artifactId>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
String[] multipartRequestName = result.getResult().getClass().getSimpleName().split("(?=\\p{Upper})");
LOG.warn("Node [{}] does not support statistics request type : {}",
nodeKey.getId(),Joiner.on(" ").join(Arrays.copyOfRange(multipartRequestName, 2, multipartRequestName.length-2)));
+ if (resultTransId != null) {
+ resultTransId.setException(
+ new UnsupportedOperationException());
+ }
} else {
if (resultTransId != null) {
resultTransId.set(id);
@Override
public void onFailure(final Throwable t) {
LOG.warn("Response Registration for Statistics RPC call fail!", t);
+ if (resultTransId != null) {
+ resultTransId.setException(t);
+ }
}
-
}
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallbackImpl());
--- /dev/null
+package org.opendaylight.openflowplugin.applications.topology.manager;
+
+import static org.mockito.Mockito.times;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OperationProcessorTest {
+
+
+ OperationProcessor processor;
+
+ @Mock
+ DataBroker dataBroker;
+ @Mock
+ BindingTransactionChain transactionChain;
+ @Mock
+ TransactionChainListener transactionChainListener;
+ @Mock
+ AsyncTransaction asyncTransaction;
+ @Mock
+ Throwable throwable;
+
+ @Before
+ public void setUp() {
+ Mockito.when(dataBroker.createTransactionChain(Matchers.any(OperationProcessor.class)))
+ .thenReturn(transactionChain);
+ processor = new OperationProcessor(dataBroker);
+ }
+
+ @Test
+ public void onTransactionChainFailedTest() {
+ processor.onTransactionChainFailed(transactionChain, asyncTransaction, throwable);
+ Mockito.verify(transactionChain).close();
+ //dataBroker.createTransactionChain is called 2 time
+ // (first time in constructor, second time after old chain has been closed)
+ Mockito.verify(dataBroker, times(2)).createTransactionChain(Matchers.any(OperationProcessor.class));
+ }
+
+ @Test
+ public void closeTest() {
+ processor.close();
+ Mockito.verify(transactionChain).close();
+ }
+
+
+}
\ No newline at end of file
<groupId>org.opendaylight.openflowplugin.applications</groupId>
<artifactId>bulk-o-matic</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.applications</groupId>
- <artifactId>bulk-o-matic</artifactId>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
</dependencies>
</project>
<feature name='odl-openflowplugin-app-bulk-o-matic-he' description="OpenDaylight :: Openflow Plugin :: app bulk flow operations support" version='${project.version}'>
<feature version="${project.version}">odl-openflowplugin-southbound-he</feature>
<bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}</bundle>
- <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/{{VERSION}}/xml/config</configfile>
</feature>
</features>
<groupId>org.opendaylight.openflowplugin.applications</groupId>
<artifactId>bulk-o-matic</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.applications</groupId>
- <artifactId>bulk-o-matic</artifactId>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.applications</groupId>
<artifactId>notification-supplier</artifactId>
<feature name='odl-openflowplugin-app-bulk-o-matic' description="OpenDaylight :: Openflow Plugin :: app bulk flow operations support" version='${project.version}'>
<feature version="${project.version}">odl-openflowplugin-southbound</feature>
<bundle>mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}</bundle>
- <configfile finalname="etc/opendaylight/karaf/71-bulk-o-matic.xml">mvn:org.opendaylight.openflowplugin.applications/bulk-o-matic/${project.version}/xml/config</configfile>
</feature>
<feature name='odl-openflowplugin-notifications' description="OpenDaylight :: Openflow Plugin :: app notifications supplier" version='${project.version}'>
@Override
public void processFlowRemovedMessage(final FlowRemoved flowRemoved) {
+ //1. translate to general flow (table, priority, match, cookie)
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
+ flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
+ // Trigger off a notification
+ notificationPublishService.offerNotification(flowRemovedNotification);
+
final ItemLifecycleListener itemLifecycleListener = flowLifeCycleKeeper.getItemLifecycleListener();
if (itemLifecycleListener != null) {
- //1. translate to general flow (table, priority, match, cookie)
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved flowRemovedNotification =
- flowRemovedTranslator.translate(flowRemoved, deviceInfo, null);
//2. create registry key
final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(flowRemovedNotification);
//3. lookup flowId
.child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
// b) notify listener
itemLifecycleListener.onRemoved(flowPath);
- // c) trigger off a notification
- notificationPublishService.offerNotification(flowRemovedNotification);
} else {
LOG.debug("flow id not found: nodeId={} tableId={}, priority={}",
getDeviceInfo().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
}
private static void salToOFFlowCommand(Flow flow, FlowModInputBuilder flowMod) {
- if (flow instanceof AddFlowInput) {
+ if (flow instanceof AddFlowInput || flow instanceof UpdatedFlow) {
flowMod.setCommand(FlowModCommand.OFPFCADD);
} else if (flow instanceof RemoveFlowInput) {
if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
} else {
flowMod.setCommand(FlowModCommand.OFPFCDELETE);
}
- } else if (flow instanceof UpdatedFlow) {
- if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
- flowMod.setCommand(FlowModCommand.OFPFCMODIFYSTRICT);
- } else {
- flowMod.setCommand(FlowModCommand.OFPFCMODIFY);
- }
}
}
.toFlowModInputs(flow, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"));\r
\r
Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());\r
- Assert.assertEquals("Wrong command", FlowModCommand.OFPFCMODIFYSTRICT, flowMod.get(0).getCommand());\r
+ Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());\r
}\r
\r
/**\r