Fix checkFlowsByDpid to retry
Change-Id: Ic8d556597351008cd6dbec09bc506f695a3daa6b
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index f60fc4e..f6b5d62 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2766,6 +2766,24 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
+ def checkFlowAddedCount( self, deviceId, minFlowCount=0, core=False ):
+ """
+ Description:
+ Check whether the number of flow rules for the given device id that
+ are in ADDED state is bigger than minFlowCount.
+ Required:
+ * deviceId: device id to check the number of added flow rules
+ Optional:
+ * minFlowCount: the number of flow rules to compare
+ * core: if True, only check the number of core flows added
+ Return:
+ Returns the number of flow rules if it is bigger than minFlowCount,
+ returns main.FALSE otherwise.
+ """
+ count = self.flowAddedCount( deviceId, core )
+ count = int( count ) if count else 0
+ return count if (count > minFlowCount) else main.FALSE
+
def getAllDevicesId( self ):
"""
Use 'devices' function to obtain list of all devices
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index bc021c6..97947be 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -273,17 +273,17 @@
@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, ),
+ " Check whether the flow count of device %s is bigger than %s" % ( dpid, minFlowCount ) )
+ count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowAddedCount,
+ main.FALSE,
+ args=( dpid, minFlowCount ),
attempts=5,
sleep=sleep )
utilities.assertEquals(
- expect=True,
- actual=( int( count ) > minFlowCount ),
- onpass="Flow count looks correct: " + count ,
- onfail="Flow count looks wrong: " + count )
+ expect=True,
+ actual=( count > minFlowCount ),
+ onpass="Flow count looks correct: " + str( count ),
+ onfail="Flow count looks wrong. " )
@staticmethod
def pingAllBasedOnIp( main, tag="", dumpflows=True ):