Update flow count check on SRBridging tests

Change-Id: I62f479a66a9fe2b96d12113464f234ea2e4e3f52
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
index 70d903a..021be12 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,21,22,23,24,25,26,27,28,31,32,33,34,35,36,37,38,41,42,43,44,45,46,47,48,51,52,53,54,55,56,57,58,61,62,63,64,65,66,67,68,71,72,73,74,75,76,77,78</testcases>
+    <testcases>5,6,7,8,15,16,17,18,25,26,27,28,35,36,37,38,45,46,47,48,55,56,57,58,65,66,67,68,75,76,77,78</testcases>
 
     <GRAPH>
         <nodeCluster>BM</nodeCluster>
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/dependencies/SRBridgingTest.py
index 108e7ea..f54de7c 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/SRBridgingTest.py
@@ -29,14 +29,13 @@
     @staticmethod
     def runTest( main, test_idx, topology, onosNodes, description, vlan = [] ):
         topo = dict()
-        # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount)
-        # TODO: Need to check correct number of minFlowCount
-        topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 15 )
-        topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 15 )
-        topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 116 )
+        # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount - leaf)
+        topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 28 )
+        topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 37 )
+        topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 37 )
         # TODO: Implement 2x3 topology
-        # topo[ '2x3' ] = ( 2, 3, True, '2x3 leaf-spine topology with dual ToR and single ToR' )
-        topo[ '2x4' ] = ( 2, 4, True, '2x4 dual-homed leaf-spine topology', 116 )
+        # topo[ '2x3' ] = ( 2, 3, True, '2x3 leaf-spine topology with dual ToR and single ToR', 28 )
+        topo[ '2x4' ] = ( 2, 4, True, '2x4 dual-homed leaf-spine topology', 53 )
 
         skipPackage = False
         init = False
@@ -60,7 +59,10 @@
             mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
 
         run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
-        # TODO: Need to check correct number of minFlowCount
-        run.checkFlows( main, minFlowCount=topo[ topology ][ 4 ], sleep=5 )
+        run.checkFlows( main, minFlowCount=topo[ topology ][ 4 ] * topo[ topology ][ 1 ], sleep=5 )
+
+        leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( topo[ topology ][ 1 ] ) ]
+        for dpid in leaf_dpid:
+            run.checkFlowsByDpid( main, dpid, topo[ topology ][ 4 ], sleep=5 )
         run.pingAll( main, 'CASE%02d' % test_idx )
         run.cleanup( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 5ffed7c..cf0d9a9 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -220,7 +220,7 @@
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
                                      main.FALSE,
                                      kwargs={ 'isPENDING': False },
-                                     attempts=4,
+                                     attempts=5,
                                      sleep=sleep )
         utilities.assertEquals(
                 expect=main.TRUE,
@@ -238,6 +238,21 @@
                                         "groupsBefore" + main.cfgName )
 
     @staticmethod
+    def checkFlowsByDpid( main, dpid, minFlowCount, sleep=10 ):
+        main.step(
+                " Check whether the flow count of device %s is bigger than %s" % ( dpid, minFlowCount ) )
+        count = utilities.retry( main.Cluster.active( 0 ).CLI.flowAddedCount,
+                                 None,
+                                 args=( dpid, ),
+                                 attempts=5,
+                                 sleep=sleep )
+        utilities.assertEquals(
+                expect=True,
+                actual=( int( count ) > minFlowCount ),
+                onpass="Flow count looks correct: " + count ,
+                onfail="Flow count looks wrong: " + count )
+
+    @staticmethod
     def pingAll( main, tag="", dumpflows=True ):
         main.log.report( "Check full connectivity" )
         print main.pingChart
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/json/CASE04.json b/TestON/tests/USECASE/SegmentRouting/dependencies/json/CASE04.json
index 924a515..443975d 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/json/CASE04.json
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/json/CASE04.json
@@ -140,7 +140,7 @@
                 "ipv4Loopback" : "192.168.0.4",
                 "routerMac" : "00:00:00:00:00:02",
                 "isEdgeRouter" : true,
-                "pairDeviceId" : "of:0000000000000002",
+                "pairDeviceId" : "of:0000000000000003",
                 "pairLocalPort" : 5,
                 "adjacencySids" : []
             },