Merge "Bug 5936 - DeviceFlowRegistry flowId bug"
authorJozef Bacigal <jbacigal@cisco.com>
Tue, 28 Jun 2016 08:40:29 +0000 (08:40 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 28 Jun 2016 08:40:29 +0000 (08:40 +0000)
25 files changed:
applications/bulk-o-matic/pom.xml
applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java
applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModule.java [deleted file]
applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModuleFactory.java [deleted file]
applications/bulk-o-matic/src/main/resources/initial/71-bulk-o-matic.xml [deleted file]
applications/bulk-o-matic/src/main/yang/bulk-o-matic.yang [deleted file]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticUtilsTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java [new file with mode: 0644]
applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java [new file with mode: 0644]
applications/forwardingrules-manager/pom.xml
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeConnectorInventoryTranslatorImpl.java
applications/statistics-manager/pom.xml
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatRpcMsgManagerImpl.java
applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessorTest.java [new file with mode: 0644]
features-he/pom.xml
features-he/src/main/features/features.xml
features/pom.xml
features/src/main/features/features.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertorTest.java

index 7b5ec1865a7f96c353d5d03bbaeac3a94f552018..a955629b847c56c7e8e237b9b386effb5abc770b 100644 (file)
             <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>
index f7d96ddb83b2b0e6702d29dac2b84e8998ef77d6..68de810198ca8317968b1095321442d191792388 100644 (file)
@@ -100,7 +100,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
         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())));
     }
 
@@ -160,7 +160,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
         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());
@@ -221,7 +221,7 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService {
         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());
diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModule.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModule.java
deleted file mode 100644 (file)
index da55a97..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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;
-    }
-}
diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModuleFactory.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/bulk/o/matic/rev150608/BulkOMaticModuleFactory.java
deleted file mode 100644 (file)
index a28c7e2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-* 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 {
-
-}
diff --git a/applications/bulk-o-matic/src/main/resources/initial/71-bulk-o-matic.xml b/applications/bulk-o-matic/src/main/resources/initial/71-bulk-o-matic.xml
deleted file mode 100644 (file)
index 0094e3f..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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&amp;revision=2013-08-19</capability>
-        <capability>urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&amp;revision=2010-09-24</capability>
-        <capability>urn:opendaylight:inventory?module=opendaylight-inventory&amp;revision=2013-08-19</capability>
-        <capability>urn:opendaylight:flow:types?module=opendaylight-flow-types&amp;revision=2013-10-26</capability>
-    </required-capabilities>
-</snapshot>
diff --git a/applications/bulk-o-matic/src/main/yang/bulk-o-matic.yang b/applications/bulk-o-matic/src/main/yang/bulk-o-matic.yang
deleted file mode 100644 (file)
index 8da9818..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-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;
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticUtilsTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/BulkOMaticUtilsTest.java
new file mode 100644 (file)
index 0000000..ae15cba
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowReaderTest.java
new file mode 100644 (file)
index 0000000..a2c46ad
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java
new file mode 100644 (file)
index 0000000..53a27b3
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java
new file mode 100644 (file)
index 0000000..b45da84
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java
new file mode 100644 (file)
index 0000000..5b57054
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java
new file mode 100644 (file)
index 0000000..9f3e239
--- /dev/null
@@ -0,0 +1,85 @@
+/**
+ * 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
diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java
new file mode 100644 (file)
index 0000000..2940240
--- /dev/null
@@ -0,0 +1,264 @@
+/**
+ * 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
index 2ef4b514e4c954a779643db4e7fd194f5cd7bd20..a95eeca7ac6bcca0b0cd12c23ad0e8c03f774e87 100644 (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>
index 08bdf848532150bbb961b4887fab6a46dab6cd2f..e4b032e370b5875e5852e1d4f4d484e9ed325f62 100644 (file)
@@ -89,7 +89,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @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);
@@ -102,7 +102,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @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
         }
     }
@@ -110,7 +110,7 @@ public class FlowNodeConnectorInventoryTranslatorImpl extends AbstractNodeConnec
     @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);
index 0425c4faf3d8e824f3f4a8bfb5213e832a918346..25ea5e9d868045acdfd46345efb49defbedf7b17 100644 (file)
       <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>
index 1717f3af4d0ca9a26472600ef6c474a788191629..43074a70bf82f626c4abbf2a6665ac7edb11adc3 100644 (file)
@@ -188,6 +188,10 @@ public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
                     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);
@@ -202,8 +206,10 @@ public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
             @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());
diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessorTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/OperationProcessorTest.java
new file mode 100644 (file)
index 0000000..68a6db2
--- /dev/null
@@ -0,0 +1,56 @@
+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
index ef1ceec9f72414bcbff242940db58ca88b3e42aa..2a2466820cb6e29f55df8ffe672f76b09e3a3dd7 100644 (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>
index a581af2ef2cfb7d5ac66633876db4e80e226c449..3a8ccfe97178d0eeed4936a88ba6cc6b97e45f3a 100644 (file)
     <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>
index f375253e25d77663c9d8ce4b669e622ba5b90dd5..7bf9ea2bea2a970d181e415cc52d77cb35c611d1 100644 (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>
         <dependency>
             <groupId>org.opendaylight.openflowplugin.applications</groupId>
             <artifactId>notification-supplier</artifactId>
index 02dc31fa816a0e7830a23dd691a4dcfcc29423ec..eb2d44a4e3160f68c1d2741e3376f5c21fedc665 100644 (file)
     <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}'>
index 7e4302a50fb9a2a334ab4480c6be25d9586078b5..5fb487c2cf408cc0546222e176214e8c1b852b3a 100644 (file)
@@ -281,11 +281,14 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
 
     @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
@@ -299,8 +302,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                         .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());
index fe0ccc1851728d9232e9288ff08ba57ebf2a5ede..0115b55560799d0c88de9a74b5f6dd42bb3b8ed4 100644 (file)
@@ -261,7 +261,7 @@ public class FlowConvertor {
     }
 
     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)) {
@@ -269,12 +269,6 @@ public class FlowConvertor {
             } 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);
-            }
         }
     }
 
index 6779145b00ffc9d45bdcf98c6be37d60b6b50023..210f9f255c06b7ee7d69760d43f6f6a7e31c73cb 100644 (file)
@@ -108,7 +108,7 @@ public class FlowConvertorTest {
                 .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