Properly adding link failure test scenario

Change-Id: Ia4abddb9a2db5f876a3e090c0054ec06dacf0890
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py b/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py
deleted file mode 100755
index db5469d..0000000
--- a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# This test should always succeed. it runs cases 1,2,3,4
-#CASE1: Get and Build ONOS
-#CASE2: Package and Install ONOS
-#CASE3: Start Mininet and check flows
-#CASE4: Ping all
-#CASE5: Link Failure
-#CASE6: Switch Failure
-#CASE7: ONOS Failure
-#CASE8: CLUSTER Failure
-#CASE10: Logging
-
-class SRLinkDown:
-
-    def __init__( self ):
-        self.default = ''
-
-    def CASE1( self, main ):
-        """
-        Sets up 1-node Onos-cluster
-        Start 2x2 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 2x2 Leaf-spine "
-        main.case( description )
-
-        main.cfgName = '2x2'
-        main.numCtrls = 1
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py')
-        #pre-configured routing and bridging test
-        run.checkFlows(main, flowCount=116)
-        run.pingAll(main)
-        run.killLink(main, 'spine101', 'leaf2', switches='4', links='6')
-        run.pingAll(main, "CASE1_AfterLinkDown")
-        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
-                        'of:0000000000000002', '2', '1', '4', '8')
-        run.pingAll(main, "CASE1_AfterLinkUp")
-        #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 CASE2( self, main ):
-        """
-        Sets up 1-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 = 1
-        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.pingAll(main)
-        run.killLink(main, 'spine101', 'leaf2', switches='8', links='30')
-        run.pingAll(main, "CASE2_AfterLinkDown")
-        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
-                    'of:0000000000000002', '2', '1', '8', '32')
-        run.pingAll(main, "CASE2_AfterLinkUp")
-        #TODO Dynamic config of hosts in subnet
-        #TODO Dynamic config of host not in subnet
-        #TODO preconfigured xconnect
-        #TODO Vrouter integration
-        #TODO Mcast integration
-        run.cleanup(main)
-
-    def CASE3( self, main ):
-        """
-        Sets up 3-node Onos-cluster
-        Start 2x2 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 2x2 Leaf-spine "
-        main.case( description )
-        main.cfgName = '2x2'
-        main.numCtrls = 3
-        run.installOnos(main)
-        run.startMininet(main, 'cord_fabric.py')
-        #pre-configured routing and bridging test
-        run.checkFlows(main, flowCount=116)
-        run.pingAll(main)
-        run.killLink(main, 'spine101', 'leaf2', switches='4', links='6')
-        run.pingAll(main, "CASE3_AfterLinkDown")
-        run.restoreLink(main, 'spine101', 'leaf2','of:0000000000000101',
-                        'of:0000000000000002', '2', '1', '4', '8')
-        run.pingAll(main, "CASE3_AfterLinkUp")
-        #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/SRLinkDown/README.md b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/README.md
similarity index 100%
rename from TestON/tests/USECASE/SegmentRouting/SRLinkDown/README.md
rename to TestON/tests/USECASE/SegmentRouting/SRLinkFailure/README.md
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.params
similarity index 95%
rename from TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params
rename to TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.params
index 1a58556..8f3ade9 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,3</testcases>
+    <testcases>1,2,4,5</testcases>
 
     <SCALE>
         <size>3</size>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py
new file mode 100755
index 0000000..025384e
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py
@@ -0,0 +1,144 @@
+#In this test we perform a link failure and then test for connectivity
+#CASE1: 2x2 topo + link failure + IP connectivity test
+#CASE2: 4x4 topo + link failure + IP connectivity test
+#CASE4: 2x2 topo + 3-node ONOS CLUSTER + link failure + IP connectivity test
+#CASE5: 4x4 topo + 3-node ONOS CLUSTER + link failure + IP connectivity test
+
+class SRLinkFailure:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        """
+        Sets up 1-node Onos-cluster
+        Start 2x2 Leaf-Spine topology
+        Pingall
+        Cause link failure
+        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 2x2 Leaf-spine "
+        main.case( description )
+
+        main.cfgName = '2x2'
+        main.numCtrls = 1
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py' )
+        #pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main )
+        #link failure
+        run.killLink( main, 'spine101', 'leaf2', switches='4', links='6' )
+        run.pingAll( main, "CASE1_Failure" )
+        run.restoreLink( main, 'spine101', 'leaf2','of:0000000000000101',
+                        'of:0000000000000002', '2', '1', '4', '8' )
+        run.pingAll( main, "CASE1_Recovery" )
+        #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 CASE2( self, main ):
+        """
+        Sets up 1-node Onos-cluster
+        Start 4x4 Leaf-Spine topology
+        Pingall
+        Cause link failure
+        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 = 1
+        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 )
+        #link failure
+        run.killLink( main, 'spine101', 'leaf2', switches='8', links='30' )
+        run.pingAll( main, "CASE2_Failure" )
+        run.restoreLink( main, 'spine101', 'leaf2','of:0000000000000101',
+                    'of:0000000000000002', '2', '1', '8', '32' )
+        run.pingAll( main, "CASE2_Recovery" )
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO preconfigured 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
+        Cause link failure
+        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 2x2 Leaf-spine "
+        main.case( description )
+        main.cfgName = '2x2'
+        main.numCtrls = 3
+        run.installOnos( main )
+        run.startMininet( main, 'cord_fabric.py' )
+        #pre-configured routing and bridging test
+        run.checkFlows( main, minFlowCount=116 )
+        run.pingAll( main )
+        #link failure
+        run.killLink( main, 'spine101', 'leaf2', switches='4', links='6' )
+        run.pingAll( main, "CASE3_Failure" )
+        run.restoreLink( main, 'spine101', 'leaf2','of:0000000000000101',
+                        'of:0000000000000002', '2', '1', '4', '8' )
+        run.pingAll( main, "CASE3_Recovery" )
+        #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 1-node Onos-cluster
+        Start 4x4 Leaf-Spine topology
+        Pingall
+        Cause link failure
+        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 )
+        #link failure
+        run.killLink( main, 'spine101', 'leaf2', switches='8', links='30' )
+        run.pingAll( main, "CASE2_Failure" )
+        run.restoreLink( main, 'spine101', 'leaf2','of:0000000000000101',
+                        'of:0000000000000002', '2', '1', '8', '32' )
+        run.pingAll( main, "CASE2_Recovery" )
+        #TODO Dynamic config of hosts in subnet
+        #TODO Dynamic config of host not in subnet
+        #TODO preconfigured xconnect
+        #TODO Vrouter integration
+        #TODO Mcast integration
+        run.cleanup( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
similarity index 61%
rename from TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo
rename to TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
index 546a023..2d69c35 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/SRLinkDown.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
@@ -21,7 +21,7 @@
             <COMPONENTS>
             </COMPONENTS>
         </ONOScli1>
-        
+
         <ONOScli2>
             <host>OC2</host>
             <user>sdn</user>
@@ -42,13 +42,45 @@
             </COMPONENTS>
         </ONOScli3>
 
+        <ONOSrest1>
+            <host>OC1</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>5</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest1>
+
+        <ONOSrest2>
+            <host>OC2</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>6</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest2>
+
+        <ONOSrest3>
+            <host>OC3</host>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>7</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSrest3>
 
         <Mininet1>
             <host>OCN</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>MininetCliDriver</type>
-            <connect_order>5</connect_order>
+            <connect_order>8</connect_order>
             <COMPONENTS>
                 <home>~/mininet/custom/</home>
             </COMPONENTS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkDown/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/__init__.py
similarity index 100%
rename from TestON/tests/USECASE/SegmentRouting/SRLinkDown/__init__.py
rename to TestON/tests/USECASE/SegmentRouting/SRLinkFailure/__init__.py
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
index c69645f..92522a0 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
@@ -1,10 +1,9 @@
-# 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: 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
+#CASE1: 2x2 Leaf-Spine topo and test IP connectivity
+#CASE2: 4x4 topo + 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:
     def __init__( self ):