protocol plugin stub node type 08/308/1
authorKalvin Hom <kahom@cisco.com>
Mon, 6 May 2013 23:11:01 +0000 (16:11 -0700)
committerKalvin Hom <kahom@cisco.com>
Tue, 7 May 2013 00:08:07 +0000 (17:08 -0700)
changed to STUB
Modified integration test to use STUB type nodes.

Change-Id: Ic6c23457400f4bbf0b6898c5238a7580ffd649ee
Signed-off-by: Kalvin Hom <kahom@cisco.com>
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java
opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java
opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java
opendaylight/switchmanager/implementation/pom.xml

index cf93fb0a37fb1381716934da2220d6df7eba456c..580dabba35a6b0ccfbe591f8cc3e288013e600ec 100644 (file)
@@ -8,6 +8,7 @@ import org.apache.felix.dm.Component;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
@@ -38,6 +39,8 @@ public class Activator extends ComponentActivatorAbstractBase {
      * 
      */
     public void init() {
+        Node.NodeIDType.registerIDType("STUB", Integer.class);
+        NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
     }
 
     /**
@@ -46,6 +49,8 @@ public class Activator extends ComponentActivatorAbstractBase {
      * 
      */
     public void destroy() {
+        Node.NodeIDType.unRegisterIDType("STUB");
+        NodeConnector.NodeConnectorIDType.unRegisterIDType("STUB");
     }
 
     /**
@@ -83,7 +88,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, Object> props = new Hashtable<String, Object>();
             // Set the protocolPluginType property which will be used
             // by SAL
-            props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
+            props.put("protocolPluginType", "STUB");
             c.setInterface(IPluginInReadService.class.getName(), props);
         }
 
@@ -92,7 +97,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, Object> props = new Hashtable<String, Object>();
             // Set the protocolPluginType property which will be used
             // by SAL
-            props.put("protocolPluginType", Node.NodeIDType.OPENFLOW);
+            props.put("protocolPluginType", "STUB");
             c.setInterface(IPluginInInventoryService.class.getName(), props);
         }
     }
index cf633a4fe6a805bcc76763a5ee346f4f6e6c25c8..0224e3ade6ea16d319b2b18572b7eaf89f5d3f1c 100644 (file)
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
 
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
@@ -141,9 +142,13 @@ public class ReadService implements IPluginInReadService {
     @Override
     public List<NodeConnectorStatistics> readAllNodeConnector(Node node,
             boolean cached) {
-        NodeConnector nc = NodeConnector.fromStringNoNode("123", node);
         NodeConnectorStatistics stats = new NodeConnectorStatistics();
-        stats.setNodeConnector(nc);
+        try{
+            NodeConnector nc = new NodeConnector("STUB", 0xCAFE, node);
+            stats.setNodeConnector(nc);
+        }catch(ConstructionException e){
+            //couldn't create nodeconnector.
+        }
         stats.setCollisionCount(4);
         stats.setReceiveByteCount(1000);
         stats.setReceiveCRCErrorCount(1);
index 251517319822f930c0d4e71eb1819c84fd574645..0fb63a369f6d79534225911b3b7760bfd936b25a 100644 (file)
@@ -19,6 +19,7 @@ import org.junit.runner.RunWith;
 import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
@@ -175,23 +176,29 @@ public class StatisticsManagerIntegrationTest {
 
     @Test
     public void testGetFlows() {
-        Node node = NodeCreator.createOFNode(1L);
-        List<FlowOnNode> flows = this.manager.getFlows(node);
-        FlowOnNode fn = flows.get(0);
-        Assert.assertTrue(fn.getByteCount() == 100);
-        Assert.assertTrue(fn.getDurationNanoseconds() == 400);
-        Assert.assertTrue(fn.getDurationSeconds() == 40);
-        Assert.assertTrue(fn.getTableId() == (byte) 0x1);
-        Assert.assertTrue(fn.getPacketCount() == 200);
-
-        Match match = new Match();
         try {
-            match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
-        } catch (UnknownHostException e) {
-            fail("Couldn't create match");
+            Node node = new Node("STUB", new Integer(0xCAFE));
+            List<FlowOnNode> flows = this.manager.getFlows(node);
+            FlowOnNode fn = flows.get(0);
+            Assert.assertTrue(fn.getByteCount() == 100);
+            Assert.assertTrue(fn.getDurationNanoseconds() == 400);
+            Assert.assertTrue(fn.getDurationSeconds() == 40);
+            Assert.assertTrue(fn.getTableId() == (byte) 0x1);
+            Assert.assertTrue(fn.getPacketCount() == 200);
+
+            Match match = new Match();
+            try {
+                match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
+            } catch (UnknownHostException e) {
+                fail("Couldn't create match");
+            }
+            Assert.assertTrue(match.equals(fn.getFlow().getMatch()));
+            Assert.assertTrue(fn.getFlow().getActions().get(0).equals(new Drop()));
+        } catch (ConstructionException e) {
+            // Got an unexpected exception
+            Assert.assertTrue(false);
         }
-        Assert.assertTrue(match.equals(fn.getFlow().getMatch()));
-        Assert.assertTrue(fn.getFlow().getActions().get(0).equals(new Drop()));
+       
     }
 
     @Test
@@ -210,81 +217,98 @@ public class StatisticsManagerIntegrationTest {
         actions.add(action);
         flow.setActions(actions);
 
-        Node node = NodeCreator.createOFNode(1L);
-        FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
-        List<FlowEntry> list = new ArrayList<FlowEntry>();
-        list.add(fe);
-        FlowEntry fe2 = new FlowEntry("g1", "f2", flow, node);
-        list.add(fe2);
-
-        Map<Node, List<FlowOnNode>> result = this.manager
-                .getFlowStatisticsForFlowList(null);
-        Assert.assertTrue(result.isEmpty());
-        result = this.manager.getFlowStatisticsForFlowList(list);
-        List<FlowOnNode> results = result.get(node);
-        FlowOnNode fn = results.get(0);
-        Assert.assertTrue(fn.getByteCount() == 100);
-        Assert.assertTrue(fn.getDurationNanoseconds() == 400);
-        Assert.assertTrue(fn.getDurationSeconds() == 40);
-        Assert.assertTrue(fn.getTableId() == (byte) 0x1);
-        Assert.assertTrue(fn.getPacketCount() == 200);
-        Assert.assertTrue(fn.getFlow().equals(flow));
+        try{
+            Node node = new Node("STUB", 0xCAFE);
+            FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
+            List<FlowEntry> list = new ArrayList<FlowEntry>();
+            list.add(fe);
+            FlowEntry fe2 = new FlowEntry("g1", "f2", flow, node);
+            list.add(fe2);
+    
+            Map<Node, List<FlowOnNode>> result = this.manager
+                    .getFlowStatisticsForFlowList(null);
+            Assert.assertTrue(result.isEmpty());
+            result = this.manager.getFlowStatisticsForFlowList(list);
+            List<FlowOnNode> results = result.get(node);
+            FlowOnNode fn = results.get(0);
+            Assert.assertTrue(fn.getByteCount() == 100);
+            Assert.assertTrue(fn.getDurationNanoseconds() == 400);
+            Assert.assertTrue(fn.getDurationSeconds() == 40);
+            Assert.assertTrue(fn.getTableId() == (byte) 0x1);
+            Assert.assertTrue(fn.getPacketCount() == 200);
+            Assert.assertTrue(fn.getFlow().equals(flow));
+        }catch(ConstructionException e){
+            Assert.assertTrue(false);
+        }
 
     }
 
     @Test
     public void testGetFlowsNumber() {
-        Node node = NodeCreator.createOFNode(1L);
-        Assert.assertTrue(this.manager.getFlowsNumber(node) == 1);
+        try{
+            Node node = new Node("STUB", 0xCAFE);
+            Assert.assertTrue(this.manager.getFlowsNumber(node) == 1);
+        }catch(ConstructionException e){
+            Assert.assertTrue(false);
+        }
     }
 
     @Test
     public void testGetNodeDescription() {
-        Node node = NodeCreator.createOFNode(1L);
-        NodeDescription desc = this.manager.getNodeDescription(node);
-        Assert.assertTrue(desc.getDescription().equals(
-                "This is a sample node description"));
-        Assert.assertTrue(desc.getHardware().equals("stub hardware"));
-        Assert.assertTrue(desc.getSoftware().equals("stub software"));
-        Assert.assertTrue(desc.getSerialNumber().equals("123"));
-        Assert.assertTrue(desc.getManufacturer().equals("opendaylight"));
+        try{
+            Node node = new Node("STUB", 0xCAFE);
+            NodeDescription desc = this.manager.getNodeDescription(node);
+            Assert.assertTrue(desc.getDescription().equals(
+                    "This is a sample node description"));
+            Assert.assertTrue(desc.getHardware().equals("stub hardware"));
+            Assert.assertTrue(desc.getSoftware().equals("stub software"));
+            Assert.assertTrue(desc.getSerialNumber().equals("123"));
+            Assert.assertTrue(desc.getManufacturer().equals("opendaylight"));
+        }catch(ConstructionException e){
+            Assert.assertTrue(false);
+        }
 
     }
 
     @Test
     public void testGetNodeConnectorStatistics() {
-        Node node = NodeCreator.createOFNode(1L);
-        List<NodeConnectorStatistics> stats = this.manager
-                .getNodeConnectorStatistics(node);
-        NodeConnectorStatistics ns = stats.get(0);
-        Assert.assertTrue(ns.getCollisionCount() == 4);
-        Assert.assertTrue(ns.getReceiveByteCount() == 1000);
-        Assert.assertTrue(ns.getReceiveCRCErrorCount() == 1);
-        Assert.assertTrue(ns.getReceiveDropCount() == 2);
-        Assert.assertTrue(ns.getReceiveErrorCount() == 3);
-        Assert.assertTrue(ns.getReceiveFrameErrorCount() == 5);
-        Assert.assertTrue(ns.getReceiveOverRunErrorCount() == 6);
-        Assert.assertTrue(ns.getReceivePacketCount() == 250);
-        Assert.assertTrue(ns.getTransmitByteCount() == 5000);
-        Assert.assertTrue(ns.getTransmitDropCount() == 50);
-        Assert.assertTrue(ns.getTransmitErrorCount() == 10);
-        Assert.assertTrue(ns.getTransmitPacketCount() == 500);
-
-        NodeConnector nc = ns.getNodeConnector();
-        NodeConnectorStatistics ns2 = this.manager
-                .getNodeConnectorStatistics(nc);
-        Assert.assertTrue(ns2.getCollisionCount() == 4);
-        Assert.assertTrue(ns2.getReceiveByteCount() == 1000);
-        Assert.assertTrue(ns2.getReceiveCRCErrorCount() == 1);
-        Assert.assertTrue(ns2.getReceiveDropCount() == 2);
-        Assert.assertTrue(ns2.getReceiveErrorCount() == 3);
-        Assert.assertTrue(ns2.getReceiveFrameErrorCount() == 5);
-        Assert.assertTrue(ns2.getReceiveOverRunErrorCount() == 6);
-        Assert.assertTrue(ns2.getReceivePacketCount() == 250);
-        Assert.assertTrue(ns2.getTransmitByteCount() == 5000);
-        Assert.assertTrue(ns2.getTransmitDropCount() == 50);
-        Assert.assertTrue(ns2.getTransmitErrorCount() == 10);
-        Assert.assertTrue(ns2.getTransmitPacketCount() == 500);
+        try{
+            Node node = new Node("STUB", 0xCAFE);
+            List<NodeConnectorStatistics> stats = this.manager
+                    .getNodeConnectorStatistics(node);
+            NodeConnectorStatistics ns = stats.get(0);
+            Assert.assertTrue(ns.getCollisionCount() == 4);
+            Assert.assertTrue(ns.getReceiveByteCount() == 1000);
+            Assert.assertTrue(ns.getReceiveCRCErrorCount() == 1);
+            Assert.assertTrue(ns.getReceiveDropCount() == 2);
+            Assert.assertTrue(ns.getReceiveErrorCount() == 3);
+            Assert.assertTrue(ns.getReceiveFrameErrorCount() == 5);
+            Assert.assertTrue(ns.getReceiveOverRunErrorCount() == 6);
+            Assert.assertTrue(ns.getReceivePacketCount() == 250);
+            Assert.assertTrue(ns.getTransmitByteCount() == 5000);
+            Assert.assertTrue(ns.getTransmitDropCount() == 50);
+            Assert.assertTrue(ns.getTransmitErrorCount() == 10);
+            Assert.assertTrue(ns.getTransmitPacketCount() == 500);
+    
+            NodeConnector nc = ns.getNodeConnector();
+            NodeConnectorStatistics ns2 = this.manager
+                    .getNodeConnectorStatistics(nc);
+            Assert.assertTrue(ns2.getCollisionCount() == 4);
+            Assert.assertTrue(ns2.getReceiveByteCount() == 1000);
+            Assert.assertTrue(ns2.getReceiveCRCErrorCount() == 1);
+            Assert.assertTrue(ns2.getReceiveDropCount() == 2);
+            Assert.assertTrue(ns2.getReceiveErrorCount() == 3);
+            Assert.assertTrue(ns2.getReceiveFrameErrorCount() == 5);
+            Assert.assertTrue(ns2.getReceiveOverRunErrorCount() == 6);
+            Assert.assertTrue(ns2.getReceivePacketCount() == 250);
+            Assert.assertTrue(ns2.getTransmitByteCount() == 5000);
+            Assert.assertTrue(ns2.getTransmitDropCount() == 50);
+            Assert.assertTrue(ns2.getTransmitErrorCount() == 10);
+            Assert.assertTrue(ns2.getTransmitPacketCount() == 500);
+        
+        }catch(ConstructionException e){
+            Assert.assertTrue(false);
+        }
     }
 
 }
index 6f7a7ea13c0ed1954dd44a9ff4602fcb4e567ac3..3477abf2c4b1f15f136bd83be7fd2838689a103f 100644 (file)
@@ -18,7 +18,7 @@
     <!-- Sonar properties using jacoco to retrieve integration test results -->
     <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-    <sonar.jacoco.Reportpath>target/jacobo.exec</sonar.jacoco.Reportpath>
+    <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
     <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.language>java</sonar.language>
   </properties>