[ONOS-7488] Add retries to ping for SRRouting

Change-Id: If616185a41b1d54d2ebdc99f7a87a8cd2a9f449e
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
index b1c8ea1..7566ff4 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
@@ -73,7 +73,7 @@
             time.sleep(60)
 
         # ping hosts
-        run.pingAllBasedOnIp( main, 'CASE%02d' % test_idx )
+        run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
 
         if hasattr(main, 'Mininet1'):
             run.cleanup(main)
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index bc021c6..c5271f5 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -286,7 +286,11 @@
                 onfail="Flow count looks wrong: " + count )
 
     @staticmethod
-    def pingAllBasedOnIp( main, tag="", dumpflows=True ):
+    def pingAll( main, tag="", dumpflows=True, acceptableFailed=0, basedOnIp=False ):
+        '''
+        acceptableFailed: max number of acceptable failed pings. Only works for ping6
+        basedOnIp: if True, run ping or ping6 based on suffix of host names
+        '''
         main.log.report( "Check full connectivity" )
         print main.pingChart
         if tag == "":
@@ -300,16 +304,22 @@
                 expect = main.FALSE
             main.step( "Connectivity for %s %s" % ( str( hosts ), tag ) )
 
-            if ("v4" in hosts[0]):
+            if basedOnIp:
+                if ("v4" in hosts[0]):
+                    pa = main.Network.pingallHosts( hosts )
+                    utilities.assert_equals( expect=expect, actual=pa,
+                                             onpass="IPv4 connectivity successfully tested",
+                                             onfail="IPv4 connectivity failed" )
+                if ("v6" in hosts[0]):
+                    pa = main.Network.pingIpv6Hosts( hosts, acceptableFailed=acceptableFailed )
+                    utilities.assert_equals( expect=expect, actual=pa,
+                                             onpass="IPv6 connectivity successfully tested",
+                                             onfail="IPv6 connectivity failed" )
+            else:
                 pa = main.Network.pingallHosts( hosts )
                 utilities.assert_equals( expect=expect, actual=pa,
-                                         onpass="IPv4 connectivity successfully tested",
-                                         onfail="IPv4 connectivity failed" )
-            if ("v6" in hosts[0]):
-                pa = main.Network.pingIpv6Hosts( hosts )
-                utilities.assert_equals( expect=expect, actual=pa,
-                                         onpass="IPv6 connectivity successfully tested",
-                                         onfail="IPv6 connectivity failed" )
+                                         onpass="IP connectivity successfully tested",
+                                         onfail="IP connectivity failed" )
 
         if dumpflows:
             main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
@@ -322,35 +332,6 @@
                                         tag + "_GroupsOn" )
 
     @staticmethod
-    def pingAll( main, tag="", dumpflows=True ):
-        main.log.report( "Check full connectivity" )
-        print main.pingChart
-        if tag == "":
-            tag = 'CASE%d' % main.CurrentTestCaseNumber
-        for entry in main.pingChart.itervalues():
-            print entry
-            hosts, expect = entry[ 'hosts' ], entry[ 'expect' ]
-            try:
-                expect = main.TRUE if str(expect).lower() == 'true' else main.FALSE
-            except:
-                expect = main.FALSE
-            main.step( "Connectivity for %s %s" % ( str( hosts ), tag ) )
-            pa = main.Network.pingallHosts( hosts )
-
-            utilities.assert_equals( expect=expect, actual=pa,
-                                     onpass="IP connectivity successfully tested",
-                                     onfail="IP connectivity failed" )
-        if dumpflows:
-            main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
-                                        "flows",
-                                        main.logdir,
-                                        tag + "_FlowsOn" )
-            main.ONOSbench.dumpONOSCmd( main.Cluster.active( 0 ).ipAddress,
-                                        "groups",
-                                        main.logdir,
-                                        tag + "_GroupsOn" )
-
-    @staticmethod
     def killLink( main, end1, end2, switches, links ):
         """
         end1,end2: identify the switches, ex.: 'leaf1', 'spine1'