From 225f154730ea6187ebcd9f2e23e30d59c2ff080b Mon Sep 17 00:00:00 2001 From: Kalvin Hom Date: Mon, 6 May 2013 16:11:01 -0700 Subject: [PATCH] protocol plugin stub node type changed to STUB Modified integration test to use STUB type nodes. Change-Id: Ic6c23457400f4bbf0b6898c5238a7580ffd649ee Signed-off-by: Kalvin Hom --- .../stub/internal/Activator.java | 9 +- .../stub/internal/ReadService.java | 9 +- .../StatisticsManagerIntegrationTest.java | 176 ++++++++++-------- .../switchmanager/implementation/pom.xml | 2 +- 4 files changed, 115 insertions(+), 81 deletions(-) diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java index cf93fb0a37..580dabba35 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/Activator.java @@ -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 props = new Hashtable(); // 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 props = new Hashtable(); // 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); } } diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java index cf633a4fe6..0224e3ade6 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java @@ -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 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); diff --git a/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java b/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java index 2515173198..0fb63a369f 100644 --- a/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java +++ b/opendaylight/statisticsmanager/integrationtest/src/test/java/org/opendaylight/controller/statisticsmanager/internal/StatisticsManagerIntegrationTest.java @@ -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 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 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 list = new ArrayList(); - list.add(fe); - FlowEntry fe2 = new FlowEntry("g1", "f2", flow, node); - list.add(fe2); - - Map> result = this.manager - .getFlowStatisticsForFlowList(null); - Assert.assertTrue(result.isEmpty()); - result = this.manager.getFlowStatisticsForFlowList(list); - List 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 list = new ArrayList(); + list.add(fe); + FlowEntry fe2 = new FlowEntry("g1", "f2", flow, node); + list.add(fe2); + + Map> result = this.manager + .getFlowStatisticsForFlowList(null); + Assert.assertTrue(result.isEmpty()); + result = this.manager.getFlowStatisticsForFlowList(list); + List 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 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 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); + } } } diff --git a/opendaylight/switchmanager/implementation/pom.xml b/opendaylight/switchmanager/implementation/pom.xml index 6f7a7ea13c..3477abf2c4 100644 --- a/opendaylight/switchmanager/implementation/pom.xml +++ b/opendaylight/switchmanager/implementation/pom.xml @@ -18,7 +18,7 @@ jacoco reuseReports - target/jacobo.exec + target/jacoco.exec target/jacoco-it.exec java -- 2.36.6