Merge "Continuing refactoring: Added a few testcases to SRSanity and fixed a few typos"
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
index 1a58556..a757a48 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,3</testcases>
+    <testcases>1,2,3,4,5,6</testcases>
 
     <SCALE>
         <size>3</size>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
index 77e90e3..631248b 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
@@ -1,7 +1,10 @@
 # This test should always succeed. it runs cases 1,2,3
 #CASE1: 2x2 Leaf-Spine topo and test IP connectivity
 #CASE2: 4x4 topo + IP connectivity test
-#CASE3: 2x2 topo + 3-node ONOS CLUSTER + IP connectivity test
+#CASE3: Single switch topo + IP connectivity test
+#CASE4: 2x2 topo + 3-node ONOS CLUSTER + IP connectivity test
+#CASE5: 4x4 topo + 3-node ONOS CLUSTER + IP connectivity test
+#CASE6: Single switch + 3-node ONOS CLUSTER + IP connectivity test
 
 class SRSanity:
 
@@ -26,7 +29,7 @@
         run.installOnos(main)
         run.startMininet(main, 'cord_fabric.py')
         #pre-configured routing and bridging test
-        run.checkFlows(main, flowCount=116)
+        run.checkFlows(main, minFlowCount=116)
         run.pingAll(main, "CASE1")
         #TODO Dynamic config of hosts in subnet
         #TODO Dynamic config of host not in subnet
@@ -51,7 +54,7 @@
         run.installOnos(main)
         run.startMininet(main, 'cord_fabric.py', args="--leaf=4 --spine=4")
         #pre-configured routing and bridging test
-        run.checkFlows(main, flowCount=350)
+        run.checkFlows(main, minFlowCount=350)
         run.pingAll(main, 'CASE2')
         #TODO Dynamic config of hosts in subnet
         #TODO Dynamic config of host not in subnet
@@ -62,6 +65,31 @@
 
     def CASE3( self, main ):
         """
+        Sets up 1-node Onos-cluster
+        Start single switch topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+        description = "Bridging and Routing sanity test with single switch "
+        main.case( description )
+        main.cfgName = '0x1'
+        main.numCtrls = 1
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py', args="--leaf=1 --spine=0")
+        #pre-configured routing and bridging test
+        run.checkFlows(main, minFlowCount=15)
+        run.pingAll(main, 'CASE3')
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO Dynamic config of vlan xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
+
+    def CASE4( self, main ):
+        """
         Sets up 3-node Onos-cluster
         Start 2x2 Leaf-Spine topology
         Pingall
@@ -76,11 +104,61 @@
         run.installOnos(main)
         run.startMininet(main, 'cord_fabric.py')
         #pre-configured routing and bridging test
-        run.checkFlows(main, flowCount=116)
-        run.pingAll(main, 'CASE3')
+        run.checkFlows(main, minFlowCount=116)
+        run.pingAll(main, 'CASE4')
         #TODO Dynamic config of hosts in subnet
         #TODO Dynamic config of host not in subnet
         #TODO Dynamic config of vlan xconnect
         #TODO Vrouter integration
         #TODO Mcast integration
         run.cleanup(main)
+
+    def CASE5( self, main ):
+        """
+        Sets up 3-node Onos-cluster
+        Start 4x4 Leaf-Spine topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+        description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
+        main.case( description )
+        main.cfgName = '4x4'
+        main.numCtrls = 3
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py', args="--leaf=4 --spine=4")
+        #pre-configured routing and bridging test
+        run.checkFlows(main, minFlowCount=350)
+        run.pingAll(main, 'CASE5')
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO Dynamic config of vlan xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
+
+    def CASE6( self, main ):
+        """
+        Sets up 3-node Onos-cluster
+        Start single switch topology
+        Pingall
+        """
+        from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+        if not hasattr(main,'apps'):
+            run.initTest(main)
+        description = "Bridging and Routing sanity test with single switch "
+        main.case( description )
+        main.cfgName = '0x1'
+        main.numCtrls = 3
+        run.installOnos(main)
+        run.startMininet(main, 'cord_fabric.py', args="--leaf=1 --spine=0")
+        #pre-configured routing and bridging test
+        run.checkFlows(main, minFlowCount=15)
+        run.pingAll(main, 'CASE4')
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO Dynamic config of vlan xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup(main)
\ No newline at end of file
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json b/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json
new file mode 100755
index 0000000..0ba5dbd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/0x1.json
@@ -0,0 +1,53 @@
+{
+    "ports" : {
+    "of:0000000000000001/1" : {
+        "interfaces" : [
+        {
+            "ips" : [ "10.0.1.254/24" ]
+        }
+        ]
+    },
+    "of:0000000000000001/2" : {
+        "interfaces" : [
+        {
+            "ips" : [ "10.0.1.254/24" ]
+        }
+        ]
+    }
+    },
+    "devices" : {
+        "of:0000000000000001" : {
+            "basic":{ "driver" : "ofdpa-cpqd" },
+            "segmentrouting" : {
+                "name" : "Leaf-R1",
+                "nodeSid" : 1,
+                "routerIp" : "192.168.0.1",
+                "routerMac" : "10:00:00:00:00:01",
+                "isEdgeRouter" : true,
+                "adjacencySids" : []
+            }
+        }
+    },
+    "apps": {
+        "org.onosproject.segmentrouting": {
+          "segmentrouting": {
+            "hostLearning": true
+          }
+        }
+    },
+    "hosts" : {
+        "00:00:00:00:00:01/-1" : {
+            "basic": {
+                "ips": ["10.0.1.1"],
+                "location": "of:0000000000000001/1"
+            }
+        },
+        "00:00:00:00:00:02/-1" : {
+            "basic": {
+                "ips": ["10.0.1.2"],
+                "location": "of:0000000000000001/2"
+            }
+        }
+    }
+
+}
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 3bbca7d..3ba3cc0 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -17,7 +17,6 @@
             - Install ONOS package

             - Build ONOS package

         """

-        main.case( "Constructing test variables and building ONOS" )

         main.step( "Constructing test variables" )

         # Test variables

         main.cellName = main.params[ 'ENV' ][ 'cellName' ]

@@ -192,13 +191,13 @@
             main.exit()

 

     @staticmethod

-    def checkFlows( main, flowCount ):

-        main.step(" Check whether the flow count is bigger than %s" % flowCount)

-        count =  utilities.retry( main.CLIs[main.active].checkFlowCount,

-                                  main.FALSE,

-                                  kwargs={'min':flowCount},

-                                  attempts=10,

-                                  sleep=10 )

+    def checkFlows(main, minFlowCount):

+        main.step(" Check whether the flow count is bigger than %s" % minFlowCount)

+        count =  utilities.retry(main.CLIs[main.active].checkFlowCount,

+                                 main.FALSE,

+                                 kwargs={'min':minFlowCount},

+                                 attempts=10,

+                                 sleep=10)

         utilities.assertEquals( \

                 expect=True,

                 actual=(count>0),

@@ -229,7 +228,6 @@
         utilities.assert_equals( expect=main.TRUE, actual=pa,

                                  onpass="Full connectivity successfully tested",

                                  onfail="Full connectivity failed" )

-        ##FIXME choose valid onos instead of 0

         main.ONOSbench.dumpFlows( main.ONOSip[main.active],

                                   main.logdir, "flowsOn" + tag)

         main.ONOSbench.dumpGroups( main.ONOSip[main.active],

@@ -245,10 +243,8 @@
         main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )

         main.step( "Kill link between %s and %s" %(end1, end2))

         LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" )

-        main.log.info( "Waiting %s seconds for link up to be discovered" % (main.linkSleep) )

-        # TODO Maybe parameterize number of expected links

+        main.log.info( "Waiting %s seconds for link down to be discovered" % main.linkSleep )

         time.sleep( main.linkSleep )

-        ##FIXME CLI for active node instead of 0

         topology =  utilities.retry( main.CLIs[main.active].checkStatus,

                                      main.FALSE,

                                      kwargs={'numoswitch':switches, 'numolink':links},

@@ -265,7 +261,7 @@
         Params:

             end1,end2: identify the end switches, ex.: 'leaf1', 'spine1'

             dpid1, dpid2: dpid of the end switches respectively, ex.: 'of:0000000000000002'

-            port1, port2: respective port of the end switchs that connects to the link, ex.:'1'

+            port1, port2: respective port of the end switches that connects to the link, ex.:'1'

             switches, links: number of expected switches and links after linkDown, ex.: '4', '6'

         Kill a link and verify ONOS can see the proper link change

         """

@@ -276,7 +272,7 @@
             count+=0

             main.Mininet1.link( END1=end1, END2=end2, OPTION="up" )

             main.Mininet1.link( END2=end1, END1=end2, OPTION="up" )

-            main.log.info( "Waiting %s seconds for link up to be discovered" % (main.linkSleep) )

+            main.log.info( "Waiting %s seconds for link up to be discovered" % main.linkSleep )

             time.sleep( main.linkSleep )

             main.CLIs[main.active].portstate( dpid=dpid1, port=port1 )

             main.CLIs[main.active].portstate( dpid=dpid2, port=port2 )

@@ -293,7 +289,7 @@
     def killSwitch( main, switch, switches, links ):

         """

         Params: switches, links: number of expected switches and links after SwitchDown, ex.: '4', '6'

-        Kill a switch and verify ONOS can see the proper change

+        Completely kill a switch and verify ONOS can see the proper change

         """

         main.switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )

         main.step( "Kill " + switch )