Fix reporting of SR test results

Change-Id: Ide05cefe5e8de3c318f7384c6000122cef963f29
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
index 2952614..9c97ebb 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
@@ -656,12 +656,10 @@
                            [ "of:0000000000000003", 1 ], [ "of:0000000000000003", 3 ],
                            [ "of:0000000000000004", 1 ], [ "of:0000000000000004", 3 ],
                            [ "of:0000000000000005", 1 ], [ "of:0000000000000005", 3 ] ]
-        for dpid, port in portsToDisable:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="disable" )
+        lib.disablePortBatch( main, portsToDisable, 10, 32 )
         # TODO: check buckets in groups
         verify( main, disconnected=False )
-        for dpid, port in portsToDisable:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="enable" )
+        lib.enablePortBatch( main, portsToDisable, 10, 48 )
         # TODO: check buckets in groups
         verify( main, disconnected=False )
         lib.cleanup( main, copyKarafLog=False, removeHostComponent=True )
@@ -704,16 +702,12 @@
                            [ "of:0000000000000006", 5 ], [ "of:0000000000000006", 6 ] ]
         for i in range( 0, 3 ):
             lib.killLinkBatch( main, linksToRemove, 0, 10 )
-            for dpid, port in portsToDisable:
-                main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="disable" )
-            time.sleep( 10 )
+            lib.disablePortBatch( main, portsToDisable, 10, 0 )
             main.disconnectedIpv4Hosts = main.internalIpv4Hosts
             main.disconnectedIpv6Hosts = main.internalIpv6Hosts
             verify( main )
             lib.restoreLinkBatch( main, linksToRemove, 48, 10 )
-            for dpid, port in portsToDisable:
-                main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="enable" )
-            time.sleep( 30 )
+            lib.enablePortBatch( main, portsToDisable, 10, 48 )
             main.Network.discoverHosts( hostList=main.disconnectedIpv4Hosts + main.disconnectedIpv6Hosts )
             time.sleep( 10 )
             main.disconnectedIpv4Hosts = []
@@ -733,43 +727,27 @@
         setupTest( main, test_idx=622, onosNodes=3 )
         verify( main, disconnected=False )
         ctrl = main.Cluster.active( 0 )
-        result1 = ctrl.CLI.verifyHostLocation( "1003::3fe",
-                                               [ "of:0000000000000002/7", "of:0000000000000003/6" ] )
-        result2 = ctrl.CLI.verifyHostLocation( "1004::3fe",
-                                               [ "of:0000000000000002/8", "of:0000000000000003/7" ] )
-        result3 = ctrl.CLI.verifyHostLocation( "10.2.30.1",
-                                               [ "of:0000000000000002/10", "of:0000000000000003/10" ] )
-        result4 = ctrl.CLI.verifyHostLocation( "10.2.20.1",
-                                               [ "of:0000000000000002/11", "of:0000000000000003/11" ] )
-        utilities.assert_equals( expect=main.TRUE, actual=result1 and result2 and result3 and result4,
-                                 onpass="Host locations are correct",
-                                 onfail="Not all host locations are correct" )
+        hostLocations = { "h4v6": [ "of:0000000000000002/7", "of:0000000000000003/6" ],
+                          "h5v6": [ "of:0000000000000002/8", "of:0000000000000003/7" ],
+                          "h4v4": [ "of:0000000000000002/10", "of:0000000000000003/10" ],
+                          "h5v4": [ "of:0000000000000002/11", "of:0000000000000003/11" ] }
+        lib.verifyHostLocations( main, hostLocations )
         linksToRemove = [ ["spine101", "leaf2"], ["spine102", "leaf2"] ]
         lib.killLinkBatch( main, linksToRemove, 40, 10 )
         # TODO: more verifications are required
         verify( main )
-        main.step( "Verify some dual-homed hosts become single-homed" )
-        result1 = ctrl.CLI.verifyHostLocation( "1003::3fe", "of:0000000000000003/6" )
-        result2 = ctrl.CLI.verifyHostLocation( "1004::3fe", "of:0000000000000003/7" )
-        result3 = ctrl.CLI.verifyHostLocation( "10.2.30.1", "of:0000000000000003/10" )
-        result4 = ctrl.CLI.verifyHostLocation( "10.2.20.1", "of:0000000000000003/11" )
-        utilities.assert_equals( expect=main.TRUE, actual=result1 and result2 and result3 and result4,
-                                 onpass="Host locations are correct",
-                                 onfail="Not all host locations are correct" )
+        hostLocations = { "h4v6": "of:0000000000000003/6",
+                          "h5v6": "of:0000000000000003/7",
+                          "h4v4": "of:0000000000000003/10",
+                          "h5v4": "of:0000000000000003/11" }
+        lib.verifyHostLocations( main, hostLocations )
         lib.restoreLinkBatch( main, linksToRemove, 48, 10 )
         verify( main )
-        main.step( "Verify the hosts changed back to be dual-homed" )
-        result1 = ctrl.CLI.verifyHostLocation( "1003::3fe",
-                                               [ "of:0000000000000002/7", "of:0000000000000003/6" ] )
-        result2 = ctrl.CLI.verifyHostLocation( "1004::3fe",
-                                               [ "of:0000000000000002/8", "of:0000000000000003/7" ] )
-        result3 = ctrl.CLI.verifyHostLocation( "10.2.30.1",
-                                               [ "of:0000000000000002/10", "of:0000000000000003/10" ] )
-        result4 = ctrl.CLI.verifyHostLocation( "10.2.20.1",
-                                               [ "of:0000000000000002/11", "of:0000000000000003/11" ] )
-        utilities.assert_equals( expect=main.TRUE, actual=result1 and result2 and result3 and result4,
-                                 onpass="Host locations are correct",
-                                 onfail="Not all host locations are correct" )
+        hostLocations = { "h4v6": [ "of:0000000000000002/7", "of:0000000000000003/6" ],
+                          "h5v6": [ "of:0000000000000002/8", "of:0000000000000003/7" ],
+                          "h4v4": [ "of:0000000000000002/10", "of:0000000000000003/10" ],
+                          "h5v4": [ "of:0000000000000002/11", "of:0000000000000003/11" ] }
+        lib.verifyHostLocations( main, hostLocations )
         lib.cleanup( main, copyKarafLog=False, removeHostComponent=True )
 
     def CASE630( self, main ):
@@ -813,7 +791,6 @@
         main.Cluster.active( 0 ).CLI.balanceMasters()
         time.sleep( float( main.params[ 'timers' ][ 'balanceMasterSleep' ] ) )
         verify( main )
-
         portsToDisable = [ [ "of:0000000000000001", 1 ], [ "of:0000000000000103", 1 ],
                            [ "of:0000000000000006", 1 ], [ "of:0000000000000103", 2 ],
                            [ "of:0000000000000101", 9 ], [ "of:0000000000000103", 3 ],
@@ -825,13 +802,17 @@
                            [ "of:0000000000000003", 3 ], [ "of:0000000000000102", 3 ],
                            [ "of:0000000000000004", 3 ], [ "of:0000000000000102", 5 ],
                            [ "of:0000000000000005", 3 ], [ "of:0000000000000102", 7 ] ]
-        for dpid, port in portsToDisable:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="disable" )
+        lib.disablePortBatch( main, portsToDisable,
+                              int( main.params[ "TOPO" ][ "switchNum" ] ),
+                              int( main.params[ "TOPO" ][ "linkNum" ] ) - len( portsToDisable ),
+                              sleep=0 )
         lib.killOnos( main, [ 2, ], int( main.params[ "TOPO" ][ "switchNum" ] ),
                       int( main.params[ "TOPO" ][ "linkNum" ] ) - len( portsToDisable ), 2 )
         verify( main )
-        for dpid, port in portsToDisable:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="enable" )
+        lib.enablePortBatch( main, portsToDisable,
+                             int( main.params[ "TOPO" ][ "switchNum" ] ),
+                             int( main.params[ "TOPO" ][ "linkNum" ] ),
+                             sleep=0 )
         lib.recoverOnos( main, [ 2, ], int( main.params[ "TOPO" ][ "switchNum" ] ),
                          int( main.params[ "TOPO" ][ "linkNum" ] ), 3 )
         verify( main )
@@ -857,7 +838,6 @@
         main.Cluster.active( 0 ).CLI.balanceMasters()
         time.sleep( float( main.params[ 'timers' ][ 'balanceMasterSleep' ] ) )
         verify( main )
-
         portsToDisable = [ [ "of:0000000000000001", 1 ], [ "of:0000000000000103", 1 ],
                            [ "of:0000000000000006", 1 ], [ "of:0000000000000103", 2 ],
                            [ "of:0000000000000101", 9 ], [ "of:0000000000000103", 3 ],
@@ -869,20 +849,13 @@
                            [ "of:0000000000000003", 3 ], [ "of:0000000000000102", 3 ],
                            [ "of:0000000000000004", 3 ], [ "of:0000000000000102", 5 ],
                            [ "of:0000000000000005", 3 ], [ "of:0000000000000102", 7 ] ]
-        for dpid, port in portsToDisable[ : -1 ]:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="disable" )
-        # To trigger sleep for link down discovery and topology check
-        lib.portstate( main, portsToDisable[ -1 ][ 0 ], portsToDisable[ -1 ][ 1 ], "disable",
-                       int( main.params[ "TOPO" ][ "switchNum" ] ),
-                       int( main.params[ "TOPO" ][ "linkNum" ] ) - len( portsToDisable ) )
-
+        lib.disablePortBatch( main, portsToDisable,
+                              int( main.params[ "TOPO" ][ "switchNum" ] ),
+                              int( main.params[ "TOPO" ][ "linkNum" ] ) - len( portsToDisable ) )
         verify( main )
-        for dpid, port in portsToDisable[ : -1 ]:
-            main.Cluster.active( 0 ).CLI.portstate( dpid=dpid, port=port, state="enable" )
-        # To trigger sleep for link up discovery and topology check
-        lib.portstate( main, portsToDisable[ -1 ][ 0 ], portsToDisable[ -1 ][ 1 ], "enable",
-                       int( main.params[ "TOPO" ][ "switchNum" ] ),
-                       int( main.params[ "TOPO" ][ "linkNum" ] ) )
+        lib.enablePortBatch( main, portsToDisable,
+                             int( main.params[ "TOPO" ][ "switchNum" ] ),
+                             int( main.params[ "TOPO" ][ "linkNum" ] ) )
         lib.killOnos( main, [ 2, ], int( main.params[ "TOPO" ][ "switchNum" ] ),
                       int( main.params[ "TOPO" ][ "linkNum" ] ), 2 )
         verify( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
index 0d7c6f8..f4b5481 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
@@ -88,23 +88,25 @@
     """
     from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as lib
     # Verify connected hosts
-    main.step("Verify reachability of connected internal hosts")
     if ipv4:
         lib.verifyPing( main,
                         [ h for h in main.internalIpv4Hosts if h not in main.disconnectedIpv4Hosts ],
-                        [ h for h in main.internalIpv4Hosts if h not in main.disconnectedIpv4Hosts ] )
+                        [ h for h in main.internalIpv4Hosts if h not in main.disconnectedIpv4Hosts ],
+                        stepMsg="Verify reachability of connected internal IPv4 hosts" )
     if ipv6:
         lib.verifyPing( main,
                         [ h for h in main.internalIpv6Hosts if h not in main.disconnectedIpv6Hosts ],
                         [ h for h in main.internalIpv6Hosts if h not in main.disconnectedIpv6Hosts ],
-                        ipv6=True, acceptableFailed=7 )
+                        ipv6=True, acceptableFailed=7,
+                        stepMsg="Verify reachability of connected internal IPv6 hosts" )
     # Verify disconnected hosts
     if disconnected:
-        main.step("Verify unreachability of disconnected internal hosts")
         if main.disconnectedIpv4Hosts:
-            lib.verifyPing( main, main.internalIpv4Hosts, main.disconnectedIpv4Hosts, expect=False )
+            lib.verifyPing( main, main.internalIpv4Hosts, main.disconnectedIpv4Hosts, expect=False,
+                            stepMsg="Verify unreachability of disconnected internal IPv4 hosts" )
         if main.disconnectedIpv6Hosts:
-            lib.verifyPing( main, main.internalIpv6Hosts, main.disconnectedIpv6Hosts, ipv6=True, expect=False )
+            lib.verifyPing( main, main.internalIpv6Hosts, main.disconnectedIpv6Hosts, ipv6=True, expect=False,
+                            stepMsg="Verify unreachability of disconnected internal IPv6 hosts" )
 
 def verifyPingExternal( main, ipv4=True, ipv6=True, disconnected=True ):
     """
@@ -113,39 +115,43 @@
     """
     from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as lib
     # Verify connected hosts
-    main.step("Verify reachability from connected internal hosts to external hosts")
     if ipv4:
         lib.verifyPing( main,
                         [ h for h in main.internalIpv4Hosts if h not in main.disconnectedIpv4Hosts ],
-                        [ h for h in main.externalIpv4Hosts if h not in main.disconnectedExternalIpv4Hosts ] )
+                        [ h for h in main.externalIpv4Hosts if h not in main.disconnectedExternalIpv4Hosts ],
+                        stepMsg="Verify reachability from connected internal IPv4 hosts to external IPv4 hosts" )
     if ipv6:
         lib.verifyPing( main,
                         [ h for h in main.internalIpv6Hosts if h not in main.disconnectedIpv6Hosts ],
                         [ h for h in main.externalIpv6Hosts if h not in main.disconnectedExternalIpv6Hosts ],
-                        ipv6=True, acceptableFailed=7 )
+                        ipv6=True, acceptableFailed=7,
+                        stepMsg="Verify reachability from connected internal IPv6 hosts to external IPv6 hosts" )
     # Verify disconnected hosts
     if disconnected:
-        main.step("Verify unreachability of disconnected internal hosts to external hosts")
         # Disconnected internal to connected external
         if main.disconnectedIpv4Hosts:
             lib.verifyPing( main, main.disconnectedIpv4Hosts,
                             [ h for h in main.externalIpv4Hosts if h not in main.disconnectedExternalIpv4Hosts ],
-                            expect=False )
+                            expect=False,
+                            stepMsg="Verify unreachability of disconnected internal IPv4 hosts to connected external IPv4 hosts" )
         if main.disconnectedIpv6Hosts:
             lib.verifyPing( main, main.disconnectedIpv6Hosts,
                             [ h for h in main.externalIpv6Hosts if h not in main.disconnectedExternalIpv6Hosts ],
-                            ipv6=True, expect=False )
+                            ipv6=True, expect=False,
+                            stepMsg="Verify unreachability of disconnected internal IPv6 hosts to connected external IPv6 hosts" )
         # Connected internal to disconnected external
         if main.disconnectedExternalIpv4Hosts:
             lib.verifyPing( main,
                             [ h for h in main.internalIpv4Hosts if h not in main.disconnectedIpv4Hosts ],
                             main.disconnectedExternalIpv4Hosts,
-                            expect=False )
+                            expect=False,
+                            stepMsg="Verify unreachability of connected internal IPv4 hosts to disconnected external IPv4 hosts" )
         if main.disconnectedExternalIpv6Hosts:
             lib.verifyPing( main,
                             [ h for h in main.internalIpv6Hosts if h not in main.disconnectedIpv6Hosts ],
                             main.disconnectedExternalIpv6Hosts,
-                            ipv6=True, expect=False )
+                            ipv6=True, expect=False,
+                            stepMsg="Verify unreachability of connected internal IPv6 hosts to disconnected external IPv6 hosts" )
 
 def verifyPing( main, ipv4=True, ipv6=True, disconnected=False, internal=True, external=True ):
     """