Added functionality for dropping links in routing tests.

Change-Id: I0c4fd3b41323fd849e47b52bfb00db7488a32492
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
index dddc584..f808d4e 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
@@ -18,6 +18,7 @@
                                ipv4=1,
                                ipv6=0,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Ping between all ipv4 hosts in the topology" )
 
     def CASE2( self, main ):
@@ -35,6 +36,7 @@
                                ipv4=0,
                                ipv6=1,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Ping between all ipv6 hosts in the topology" )
 
     def CASE3( self, main ):
@@ -52,6 +54,7 @@
                                ipv4=1,
                                ipv6=1,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Ping between all ipv4 and ipv6 hosts in the topology" )
 
     def CASE4( self, main ):
@@ -70,6 +73,7 @@
                                ipv6=0,
                                description="Ping between all ipv4 hosts in the topology and check connectivity to external hosts",
                                checkExternalHost=True,
+                               linkFailure=False,
                                countFlowsGroups=False )
 
     def CASE5( self, main ):
@@ -88,6 +92,7 @@
                                ipv6=1,
                                description="Ping between all ipv6 hosts in the topology and check connectivity to external hosts",
                                checkExternalHost=True,
+                               linkFailure=False,
                                countFlowsGroups=False )
 
     def CASE6( self, main ):
@@ -106,6 +111,7 @@
                                ipv6=1,
                                description="Ping between all ipv4 and ipv6 hosts in the topology and check connectivity to external hosts",
                                checkExternalHost=True,
+                               linkFailure=False,
                                countFlowsGroups=False )
 
     def CASE7( self, main ):
@@ -127,6 +133,7 @@
                                description="Ping between from ipv4 hosts to external host configured with route-add command.",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True )
 
     def CASE8( self, main ):
@@ -148,6 +155,7 @@
                                description="Ping between from ipv6 hosts to external host configured with route-add command.",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True )
 
     def CASE9( self, main ):
@@ -169,8 +177,198 @@
                                description="Ping between from ipv4 and ipv6 hosts to external hosts configured with route-add command.",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True )
 
+    def CASE101( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv4 hosts in the topology.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=101,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=0,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               description="Test link failures with IPv4 hosts",
+                               switchFailure=False )
+
+    def CASE102( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv6 hosts in the topology.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=102,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=0,
+                               ipv6=1,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               description="Test link failures with IPv6 hosts",
+                               switchFailure=False )
+
+    def CASE103( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv4 and ipv6 hosts in the topology.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=103,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=1,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               description="Test link failures with IPv4 and IPv6 hosts",
+                               switchFailure=False )
+
+    def CASE104( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv4 hosts in the topology and check connectivity to external ipv4 hosts
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=104,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=0,
+                               description="Test link failures with IPv4 hosts (including external hosts)",
+                               checkExternalHost=True,
+                               linkFailure=True,
+                               switchFailure=False )
+
+    def CASE105( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv6 hosts in the topology and check connectivity to external ipv6 hosts
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=105,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=0,
+                               ipv6=1,
+                               description="Test link failures with IPv6 hosts (including external hosts)",
+                               checkExternalHost=True,
+                               linkFailure=True,
+                               switchFailure=False )
+
+    def CASE106( self, main ):
+        """
+        Kill and recover links
+        Ping between all ipv4 and ipv6 hosts in the topology and check connectivity to external ipv4 and ipv6 hosts
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=106,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=1,
+                               description="Test link failures with IPv4 and IPv6 hosts (including external hosts)",
+                               checkExternalHost=True,
+                               linkFailure=True,
+                               switchFailure=False )
+
+    def CASE107( self, main ):
+        """
+        Kill and recover links
+        Ping between ipv4 hosts and an external host that is not configured in
+        external router config, but reachable through the use of route-add command.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=107,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=0,
+                               description="Test link failures with IPv4 hosts (including external host configured with route-add command)",
+                               checkExternalHost=False,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               staticRouteConfigure=True,
+                               switchFailure=False )
+
+    def CASE108( self, main ):
+        """
+        Kill and recover links
+        Ping between ipv6 hosts and an external host that is not configured in
+        external router config, but reachable through the use of route-add command.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=108,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=0,
+                               ipv6=1,
+                               description="Test link failures with IPv6 hosts (including external host configured with route-add command)",
+                               checkExternalHost=False,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               staticRouteConfigure=True,
+                               switchFailure=False )
+
+    def CASE109( self, main ):
+        """
+        Kill and recover links
+        Ping between ipv4 and pv6 hosts and external hosts that is not configured in
+        external router config, but reachable through the use of route-add command.
+        """
+
+        from tests.USECASE.SegmentRouting.SRRouting.dependencies.SRRoutingTest import SRRoutingTest
+
+        SRRoutingTest.runTest( main,
+                               test_idx=109,
+                               onosNodes=3,
+                               dhcp=1,
+                               routers=1,
+                               ipv4=1,
+                               ipv6=1,
+                               description="Test link failures with IPv4 and IPv6 hosts (including external host configured with route-add command)",
+                               checkExternalHost=False,
+                               countFlowsGroups=False,
+                               linkFailure=True,
+                               staticRouteConfigure=True,
+                               switchFailure=False )
+
     def CASE201( self, main ):
         """
         Kill and recover spine switches
@@ -187,6 +385,7 @@
                                ipv4=1,
                                ipv6=0,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Test switch failures with IPv4 hosts",
                                switchFailure=True )
 
@@ -206,6 +405,7 @@
                                ipv4=0,
                                ipv6=1,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Test switch failures with IPv6 hosts",
                                switchFailure=True )
 
@@ -225,6 +425,7 @@
                                ipv4=1,
                                ipv6=1,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                description="Test switch failures with IPv4 and IPv6 hosts",
                                switchFailure=True )
 
@@ -245,6 +446,7 @@
                                ipv6=0,
                                description="Test switch failures with IPv4 hosts (including external hosts)",
                                checkExternalHost=True,
+                               linkFailure=False,
                                switchFailure=True )
 
     def CASE205( self, main ):
@@ -264,6 +466,7 @@
                                ipv6=1,
                                description="Test switch failures with IPv6 hosts (including external hosts)",
                                checkExternalHost=True,
+                               linkFailure=False,
                                switchFailure=True )
 
     def CASE206( self, main ):
@@ -283,6 +486,7 @@
                                ipv6=1,
                                description="Test switch failures with IPv4 and IPv6 hosts (including external hosts)",
                                checkExternalHost=True,
+                               linkFailure=False,
                                switchFailure=True )
 
     def CASE207( self, main ):
@@ -304,6 +508,7 @@
                                description="Test switch failures with IPv4 hosts (including external host configured with route-add command)",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True,
                                switchFailure=True )
 
@@ -326,6 +531,7 @@
                                description="Test switch failures with IPv6 hosts (including external host configured with route-add command)",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True,
                                switchFailure=True )
 
@@ -348,5 +554,8 @@
                                description="Test switch failures with IPv4 and IPv6 hosts (including external host configured with route-add command)",
                                checkExternalHost=False,
                                countFlowsGroups=False,
+                               linkFailure=False,
                                staticRouteConfigure=True,
                                switchFailure=True )
+
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
index eb747b0..4b58d10 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
@@ -32,7 +32,7 @@
     @staticmethod
     def runTest( main, test_idx, onosNodes, dhcp, routers, ipv4, ipv6,
                  description, countFlowsGroups=False, checkExternalHost=False,
-                 staticRouteConfigure=False, switchFailure=False ):
+                 staticRouteConfigure=False, switchFailure=False, linkFailure=False ):
 
         skipPackage = False
         init = False
@@ -75,6 +75,8 @@
             run.loadCount( main )
         if switchFailure:
             run.loadSwitchFailureChart( main )
+        if linkFailure:
+            run.loadLinkFailureChart( main )
 
         # wait some time
         time.sleep( 5 )
@@ -113,6 +115,22 @@
                 if countFlowsGroups:
                     run.checkFlowsGroupsFromFile(main)
 
+        # Test link failures
+        if linkFailure:
+            for link_batch_name, info in main.linkFailureChart.items():
+
+                linksToRemove = info['links'].values()
+                linksBefore = info['links_before']
+                linksAfter = info['links_after']
+
+                run.killLinkBatch( main, linksToRemove, linksAfter )
+                run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
+
+                run.restoreLinkBatch( main, linksToRemove, linksBefore )
+                run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
+                if countFlowsGroups:
+                    run.checkFlowsGroupsFromFile(main)
+
         if hasattr( main, 'Mininet1' ):
             run.cleanup( main )
         else:
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_external=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_external=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_external=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_static=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_static=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1_static=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_external=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart
new file mode 100644
index 0000000..9d971dd
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/linkFailure/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1_static=1.linkFailureChart
@@ -0,0 +1,19 @@
+{
+    "link_batch_1" : { "links" : { "link1" : ["leaf1", "spine101"],
+		      		   "link2" : ["leaf2", "spine101"],
+	              		   "link3" : ["leaf3", "spine101"],
+		      		   "link4" : ["leaf4", "spine101"],
+		      	           "link5" : ["leaf5", "spine101"] },
+			"links_before" : 40,
+			"links_after" : 22 },
+    "link_batch_2" : { "links" : { "link1" : ["leaf1", "spine102"],
+		      		   "link2" : ["leaf2", "spine102"],
+	              		   "link3" : ["leaf3", "spine102"],
+		      		   "link4" : ["leaf4", "spine102"],
+		      	           "link5" : ["leaf5", "spine102"] },
+			"links_before" : 40,
+			"links_after" : 22 }
+	
+	
+}
+
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index a063761..0125da6 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -66,6 +66,7 @@
             main.forConfig = "conf/"
             main.forHost = "host/"
             main.forSwitchFailure = "switchFailure/"
+            main.forLinkFailure = "linkFailure/"
             main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
             main.topologyLib = main.params[ 'DEPENDENCY' ][ 'lib' ] if 'lib' in main.params[ 'DEPENDENCY' ] else None
             main.topologyConf = main.params[ 'DEPENDENCY' ][ 'conf' ] if 'conf' in main.params[ 'DEPENDENCY' ] else None
@@ -155,6 +156,12 @@
             main.switchFailureChart = json.load( sfc )
 
     @staticmethod
+    def loadLinkFailureChart( main ):
+        with open( "%s%s.linkFailureChart" % ( main.configPath + main.forLinkFailure,
+                                                 main.cfgName ) ) as sfc:
+            main.linkFailureChart = json.load( sfc )
+
+    @staticmethod
     def startMininet( main, topology, args="" ):
         copyResult = main.ONOSbench.scp( main.Mininet1,
                                          main.topoPath + main.topology,
@@ -468,6 +475,54 @@
                                  onfail="Failed to turn off link?" )
 
     @staticmethod
+    def killLinkBatch( main, links, linksAfter, switches=7):
+        """
+        links = list of links (src, dst) to bring down.
+        """
+
+        main.step("Killing a batch of links {0}".format(links))
+
+        for end1, end2 in links:
+            main.Network.link( END1=end1, END2=end2, OPTION="down")
+            main.Network.link( END1=end2, END2=end1, OPTION="down")
+
+        main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        main.log.info(
+                "Waiting %s seconds for links down to be discovered" % main.linkSleep )
+        time.sleep( main.linkSleep )
+
+        topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
+                                    main.FALSE,
+                                    kwargs={ 'numoswitch': switches,
+                                             'numolink': linksAfter },
+                                    attempts=10,
+                                    sleep=main.linkSleep )
+
+    @staticmethod
+    def restoreLinkBatch( main, links, linksAfter, switches=7):
+        """
+        links = list of link (src, dst) to bring up again.
+        """
+
+        main.step("Restoring a batch of links {0}".format(links))
+
+        for end1, end2 in links:
+            main.Network.link( END1=end1, END2=end2, OPTION="up")
+            main.Network.link( END1=end2, END2=end1, OPTION="up")
+
+        main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        main.log.info(
+                "Waiting %s seconds for links down to be discovered" % main.linkSleep )
+        time.sleep( main.linkSleep )
+
+        topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
+                                    main.FALSE,
+                                    kwargs={ 'numoswitch': switches,
+                                             'numolink': linksAfter },
+                                    attempts=10,
+                                    sleep=main.linkSleep )
+
+    @staticmethod
     def restoreLink( main, end1, end2, dpid1, dpid2, port1, port2, switches,
                      links ):
         """