Updating test for TOST QA Pod

Add more robust topology check to Segment routing tests
Fix Typos
Include minimum flow count # in the comparision (>= vs > )
Add option for username and password in onos-app function
Don't add app prefix if it looks like it is already the full name

Change-Id: Ib4af0f72df8e7dcc5c179fafea1fd9c61d931246
(cherry picked from commit cda0902ee85041b22da8ad7638a8518914d07322)
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
index 56d44ec..f88c85a 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
@@ -29,7 +29,7 @@
         self.topo = dict()
         # TODO: Check minFlowCount of leaf for BMv2 switch
         # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount - leaf (OvS), minFlowCount - leaf (BMv2))
-        self.topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 28, 28 )
+        self.topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 28, 20 )
         self.topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 37, 37 )
         self.topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 37, 32 )
         # TODO: Implement 2x3 topology
@@ -53,6 +53,13 @@
 
             main.case( '%s, with %s, %s switches and %d ONOS instance%s' %
                        ( description, self.topo[ topology ][ 3 ], main.switchType, onosNodes, 's' if onosNodes > 1 else '' ) )
+            spines = self.topo[ topology ][ 0 ]
+            leaves = self.topo[ topology ][ 1 ]
+            switches = spines + leaves
+            links = ( spines * leaves ) * 2
+            if self.topo[ topology ][ 2 ]:
+                links += links
+                links += ( leaves - 1 ) * 2
 
             main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 )
             main.Cluster.setRunningNode( onosNodes )
@@ -91,11 +98,16 @@
 
             run.checkFlows( main, minFlowCount=self.topo[ topology ][ 5 if main.useBmv2 else 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
             if main.useBmv2:
-                leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
+                switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix' )
+                if switchPrefix == "tofino":
+                    leaf_dpid = [ "device:tofino:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
+                else:
+                    leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
             else:
                 leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ] ) ]
             for dpid in leaf_dpid:
                 run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 5 if main.useBmv2 else 4 ], sleep=5 )
+            run.verifyTopology( main, switches, links, onosNodes )
             run.pingAll( main )
         except Exception as e:
             main.log.exception( "Error in runTest" )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json
index ac9c2ca..b6699f0 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json
@@ -1,9 +1,7 @@
 {
     "devices":{
-        "of:0000000000000001":{
-            "basic":{
-                "driver":"ofdpa-ovs"
-            },
+        "device:tofino:leaf1":{
+            "basic":{},
             "segmentrouting":{
                 "adjacencySids":[],
                 "ipv4Loopback":"192.168.0.1",
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json.hw b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json.hw
index 31c166a..b2eb1e6 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json.hw
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/CASE01.json.hw
@@ -1,17 +1,17 @@
 {
     "devices":{
-        "of:0000000000000001":{
+        "device:tofino:leaf1":{
             "segmentrouting":{
                 "adjacencySids":[],
-                "ipv4Loopback":"10.128.13.232",
+                "ipv4Loopback":"10.128.13.211",
                 "ipv4NodeSid":201,
                 "isEdgeRouter":true,
-                "routerMac":"00:90:fb:64:cc:9e"
+                "routerMac":"00:00:00:00:00:01"
             }
         }
     },
     "ports":{
-        "of:0000000000000001/160":{
+        "device:tofino:leaf1/128":{
             "interfaces":[
                 {
                     "ips":[
@@ -21,7 +21,7 @@
                 }
             ]
         },
-        "of:0000000000000001/168":{
+        "device:tofino:leaf1/136":{
             "interfaces":[
                 {
                     "ips":[
@@ -32,4 +32,4 @@
             ]
         }
     }
-}
\ No newline at end of file
+}
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/tofino-onos-netcfg.json b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/tofino-onos-netcfg.json
index 5cc17ed..8c8995a 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/tofino-onos-netcfg.json
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/json/tofino-onos-netcfg.json
@@ -3,7 +3,7 @@
     "device:tofino:leaf1": {
       "basic": {
         "name": "leaf1",
-        "managementAddress": "grpc://10.128.13.232:28000?device_id=1",
+        "managementAddress": "grpc://10.128.13.211:28000?device_id=1",
         "driver": "stratum-tofino",
         "pipeconf": "org.opencord.fabric.tofino.montara_sde_9_0_0"
       }