Added functionality for counting flows and groups.
This patch contains functionality for counting flows / groups.
The existing tests have been modified in order to work this way,
however, we use a flag that indicates if to check flows and groups.
As of now it is False, since I observed that between some iterations
the same test produced different flows and groups at the switches.
This might be a bug that we need to discuss about.
Change-Id: Ie56333623c6e0eb9d8e03f51894078bcd272df2e
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 49fb3ec..fe41a68 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2815,7 +2815,56 @@
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
- def checkFlowAddedCount( self, deviceId, minFlowCount=0, core=False ):
+ def groupAddedCount( self, deviceId, core=False ):
+ """
+ Determine the number of group rules for the given device id that are
+ in the added state
+ Params:
+ core: if True, only return the number of core groups added
+ """
+ try:
+ if core:
+ cmdStr = "groups any " + str( deviceId ) + " | " +\
+ "grep 'state=ADDED' | grep org.onosproject.core | wc -l"
+ else:
+ cmdStr = "groups any " + str( deviceId ) + " | " +\
+ "grep 'state=ADDED' | wc -l"
+ handle = self.sendline( cmdStr )
+ assert handle is not None, "Error in sendline"
+ assert "Command not found:" not in handle, handle
+ return handle
+ except AssertionError:
+ main.log.exception( "" )
+ return None
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanAndExit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanAndExit()
+
+ def checkGroupAddedCount( self, deviceId, expectedGroupCount=0, core=False, comparison=0):
+ """
+ Description:
+ Check whether the number of groups for the given device id that
+ are in ADDED state is bigger than minGroupCount.
+ Required:
+ * deviceId: device id to check the number of added group rules
+ Optional:
+ * minGroupCount: the number of groups to compare
+ * core: if True, only check the number of core groups added
+ * comparison: if 0, compare with greater than minFlowCount
+ * if 1, compare with equal to minFlowCount
+ Return:
+ Returns the number of groups if it is bigger than minGroupCount,
+ returns main.FALSE otherwise.
+ """
+ count = self.groupAddedCount( deviceId, core )
+ count = int( count ) if count else 0
+ return count if ((count > expectedGroupCount) if (comparison == 0) else (count == expectedGroupCount)) else main.FALSE
+
+ def checkFlowAddedCount( self, deviceId, expectedFlowCount=0, core=False, comparison=0):
"""
Description:
Check whether the number of flow rules for the given device id that
@@ -2825,13 +2874,15 @@
Optional:
* minFlowCount: the number of flow rules to compare
* core: if True, only check the number of core flows added
+ * comparison: if 0, compare with greater than minFlowCount
+ * if 1, compare with equal to minFlowCount
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
+ return count if ((count > expectedFlowCount) if (comparison == 0) else (count == expectedFlowCount)) else main.FALSE
def getAllDevicesId( self ):
"""
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
index 4735cdd..d239219 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.py
@@ -17,6 +17,7 @@
routers=1,
ipv4=1,
ipv6=0,
+ countFlowsGroups=False,
description="Ping between all ipv4 hosts in the topology")
def CASE2( self, main ):
@@ -33,6 +34,7 @@
routers=1,
ipv4=0,
ipv6=1,
+ countFlowsGroups=False,
description="Ping between all ipv6 hosts in the topology")
def CASE3( self, main ):
@@ -49,4 +51,5 @@
routers=1,
ipv4=1,
ipv6=1,
+ countFlowsGroups=False,
description="Ping between all ipv4 and ipv6 hosts in the topology")
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
index cecb915..d2cd2b5 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/SRRoutingTest.py
@@ -30,7 +30,7 @@
self.default = ''
@staticmethod
- def runTest( main, test_idx, onosNodes, dhcp, routers, ipv4, ipv6, description ):
+ def runTest( main, test_idx, onosNodes, dhcp, routers, ipv4, ipv6, description, countFlowsGroups=False):
skipPackage = False
init = False
@@ -54,6 +54,9 @@
run.loadJson( main )
run.loadChart( main )
+ if (countFlowsGroups):
+ run.loadCount( main )
+
# wait some
time.sleep( 5 )
@@ -73,7 +76,11 @@
time.sleep( 60 )
# ping hosts
- run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
+ # run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
+
+ # check flows / groups numbers
+ if (countFlowsGroups):
+ run.checkFlowsGroupsFromFile(main)
if hasattr( main, 'Mininet1' ):
run.cleanup( main )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.count b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.count
new file mode 100644
index 0000000..3d66d2e
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=0_ipv6=1_dhcp=1_routers=1.count
@@ -0,0 +1,9 @@
+{
+ "of:0000000000000001": { "flows" : 67, "groups" : 56},
+ "of:0000000000000002": { "flows" : 95, "groups" : 85},
+ "of:0000000000000003": { "flows" : 101, "groups" : 88},
+ "of:0000000000000004": { "flows" : 112, "groups" : 81},
+ "of:0000000000000005": { "flows" : 119, "groups" : 83},
+ "of:0000000000000101": { "flows" : 82, "groups" : 29},
+ "of:0000000000000102": { "flows" : 82, "groups" : 29}
+}
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.count b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.count
new file mode 100644
index 0000000..58715b1
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=0_dhcp=1_routers=1.count
@@ -0,0 +1,9 @@
+{
+ "of:0000000000000001": { "flows" : 64, "groups" : 52},
+ "of:0000000000000002": { "flows" : 91, "groups" : 77},
+ "of:0000000000000003": { "flows" : 97, "groups" : 80},
+ "of:0000000000000004": { "flows" : 108, "groups" : 77},
+ "of:0000000000000005": { "flows" : 115, "groups" : 79},
+ "of:0000000000000101": { "flows" : 74, "groups" : 29},
+ "of:0000000000000102": { "flows" : 74, "groups" : 29}
+}
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.count b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.count
new file mode 100644
index 0000000..9b3932e
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/dependencies/count/COMCAST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1.count
@@ -0,0 +1,9 @@
+{
+ "of:0000000000000001": { "flows" : 96, "groups" : 88},
+ "of:0000000000000002": { "flows" : 131, "groups" : 127},
+ "of:0000000000000003": { "flows" : 141, "groups" : 131},
+ "of:0000000000000004": { "flows" : 145, "groups" : 131},
+ "of:0000000000000005": { "flows" : 154, "groups" : 134},
+ "of:0000000000000101": { "flows" : 85, "groups" : 29},
+ "of:0000000000000102": { "flows" : 85, "groups" : 29}
+}
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index bb868df..dd93fe4 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -122,6 +122,11 @@
ctrl.CLI.logSet( "DEBUG", "org.onosproject.net.flowobjective.impl" )
@staticmethod
+ def loadCount( main ):
+ with open("%s/count/%s.count" % (main.configPath, main.cfgName)) as count:
+ main.count = json.load(count)
+
+ @staticmethod
def loadJson( main ):
with open( "%s%s.json" % ( main.configPath + main.forJson,
main.cfgName ) ) as cfg:
@@ -300,6 +305,54 @@
onfail="Flow count looks wrong. " )
@staticmethod
+ def checkFlowEqualityByDpid( main, dpid, flowCount, sleep=10):
+ main.step(
+ " Check whether the flow count of device %s is equal to %s" % ( dpid, flowCount ) )
+ count = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowAddedCount,
+ main.FALSE,
+ args=( dpid, flowCount, False, 1),
+ attempts=5,
+ sleep=sleep )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=( int( count ) == flowCount ),
+ onpass="Flow count looks correct: " + str(count) ,
+ onfail="Flow count looks wrong, should be " + str(flowCount))
+
+ @staticmethod
+ def checkGroupEqualityByDpid( main, dpid, groupCount, sleep=10):
+ main.step(
+ " Check whether the group count of device %s is equal to %s" % ( dpid, groupCount ) )
+ count = utilities.retry( main.Cluster.active( 0 ).CLI.checkGroupAddedCount,
+ main.FALSE,
+ args=( dpid, groupCount, False, 1),
+ attempts=5,
+ sleep=sleep )
+
+ utilities.assertEquals(
+ expect=True,
+ actual=( count == groupCount ),
+ onpass="Group count looks correct: " + str(count) ,
+ onfail="Group count looks wrong: should be " + str(groupCount))
+
+ @staticmethod
+ def checkFlowsGroupsFromFile(main):
+
+ for dpid, values in main.count.items():
+ flowCount = values["flows"]
+ groupCount = values["groups"]
+ main.log.report( "Check flow count for dpid " + str(dpid) +
+ ", should be " + str(flowCount))
+ Testcaselib.checkFlowEqualityByDpid(main, dpid, flowCount)
+
+ main.log.report( "Check group count for dpid " + str(dpid) +
+ ", should be " + str(groupCount))
+ Testcaselib.checkGroupEqualityByDpid(main, dpid, groupCount)
+
+ return
+
+ @staticmethod
def pingAll( main, tag="", dumpflows=True, acceptableFailed=0, basedOnIp=False ):
'''
acceptableFailed: max number of acceptable failed pings. Only works for ping6