[ONOS-7475] Refactoring SR tests
Change-Id: I10e51fcb8b416167e6a338e9030933162640af89
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params
index fceb91a..d32d1a6 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.params
@@ -13,6 +13,8 @@
</SCALE>
<DEPENDENCY>
+ <useCommonConf>True</useCommonConf>
+ <useCommonTopo>True</useCommonTopo>
<topology>cord_fabric.py</topology>
</DEPENDENCY>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py
index 6a228f3..d0cc985 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.py
@@ -37,25 +37,17 @@
Start 2x2 Leaf-Spine topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
- description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
- main.case( description )
-
- main.cfgName = '2x2'
- main.Cluster.setRunningNode( 1 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main, dumpflows=False, )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=140, dumpflows=False )
- run.pingAll( main )
- run.cleanup( main )
+ main.funcs.runTest( main, 1, 1, '2x2', 116, 140, False )
def CASE2( self, main ):
"""
@@ -63,24 +55,17 @@
Start 4x4 Leaf-Spine topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
- description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
- main.case( description )
- main.cfgName = '4x4'
- main.Cluster.setRunningNode( 1 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py',
- args="--leaf=4 --spine=4" )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=350 )
- run.pingAll( main, dumpflows=False )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=380, dumpflows=False )
- run.pingAll( main )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
+
+ main.funcs.runTest( main, 2, 1, '4x4', 350, 380, False )
def CASE3( self, main ):
"""
@@ -88,24 +73,17 @@
Start single switch topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
- description = "Bridging and Routing sanity test with single switch "
- main.case( description )
- main.cfgName = '0x1'
- main.Cluster.setRunningNode( 1 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py',
- args="--leaf=1 --spine=0" )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=15 )
- run.pingAll( main, dumpflows=False )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=18, dumpflows=False )
- run.pingAll( main )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
+
+ main.funcs.runTest( main, 3, 1, '0x1', 15, 18, False )
def CASE4( self, main ):
"""
@@ -113,28 +91,17 @@
Start 2x2 Leaf-Spine topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
- description = "Bridging and Routing sanity test with 2x2 Leaf-spine "
- main.case( description )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
- main.cfgName = '2x2'
- main.Cluster.setRunningNode( 3 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main, dumpflows=False )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=140, dumpflows=False )
- run.pingAll( main )
- run.killOnos( main, [ 0 ], '4', '8', '2' )
- run.delHostCfg( main )
- run.checkFlows( main, minFlowCount=116, dumpflows=False )
- run.pingAll( main, "CASE4_after" )
- run.cleanup( main )
+ main.funcs.runTest( main, 4, 3, '2x2', 116, 140, True )
def CASE5( self, main ):
"""
@@ -142,28 +109,17 @@
Start 4x4 Leaf-Spine topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
- description = "Bridging and Routing sanity test with 4x4 Leaf-spine "
- main.case( description )
- main.cfgName = '4x4'
- main.Cluster.setRunningNode( 3 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py',
- args="--leaf=4 --spine=4" )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=350 )
- run.pingAll( main, dumpflows=False )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=380, dumpflows=False )
- run.pingAll( main )
- run.killOnos( main, [ 0 ], '8', '32', '2' )
- run.delHostCfg( main )
- run.checkFlows( main, minFlowCount=350, dumpflows=False )
- run.pingAll( main, "CASE5_After" )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
+
+ main.funcs.runTest( main, 5, 3, '4x4', 350, 380, True )
def CASE6( self, main ):
"""
@@ -171,25 +127,14 @@
Start single switch topology
Pingall
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
- description = "Bridging and Routing sanity test with single switch "
- main.case( description )
- main.cfgName = '0x1'
- main.Cluster.setRunningNode( 3 )
- run.installOnos( main, vlanCfg=False )
- run.startMininet( main, 'cord_fabric.py',
- args="--leaf=1 --spine=0" )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=15 )
- run.pingAll( main, dumpflows=False )
- run.addHostCfg( main )
- run.checkFlows( main, minFlowCount=20, dumpflows=False )
- run.pingAll( main )
- run.killOnos( main, [ 0 ], '1', '0', '2' )
- run.delHostCfg( main )
- run.checkFlows( main, minFlowCount=15, dumpflows=False )
- run.pingAll( main, "CASE6_After" )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRDynamic.dependencies.SRDynamicFuncs import SRDynamicFuncs
+ except ImportError:
+ main.log.error( "SRClusterRestartFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRDynamicFuncs()
+
+ main.funcs.runTest( main, 6, 3, '0x1', 15, 20, True )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/SRDynamicFuncs.py b/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/SRDynamicFuncs.py
new file mode 100644
index 0000000..e4390de
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/SRDynamicFuncs.py
@@ -0,0 +1,78 @@
+"""
+Copyright 2017 Open Networking Foundation ( ONF )
+
+Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
+the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
+or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
+
+ TestON is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ ( at your option ) any later version.
+
+ TestON is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with TestON. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
+import random
+from random import randint
+from datetime import datetime
+
+class SRDynamicFuncs():
+
+ def __init__( self ):
+ self.default = ''
+ self.topo = dict()
+ self.topo[ '0x1' ] = ( 0, 1, '--leaf=1 --spine=0', 'single switch' )
+ self.topo[ '2x2' ] = ( 2, 2, '', '2x2 Leaf-spine' )
+ self.topo[ '4x4' ] = ( 4, 4, '--leaf=4 --spine=4', '4x4 Leaf-spine' )
+
+ def runTest( self, main, caseNum, numNodes, Topo, minBeforeFlow, minAfterFlow, killOnosAndDeleteCfg ):
+ if not hasattr( main, 'apps' ):
+ run.initTest( main )
+
+ description = "Bridging and Routing sanity test with " + \
+ self.topo[ Topo ][ 3 ] + \
+ "and {} nodes.".format( numNodes ) + \
+ ( "\nAlso, killing the first Onos and removing the host cfg." if killOnosAndDeleteCfg else "" )
+ main.case( description )
+
+ main.cfgName = Topo
+ main.Cluster.setRunningNode( numNodes )
+ run.installOnos( main )
+ run.loadJson( main )
+ run.loadChart( main )
+ run.startMininet( main, 'cord_fabric.py',
+ args=self.topo[ Topo ][ 2 ] )
+ # pre-configured routing and bridging test
+ run.checkFlows( main, minFlowCount=minBeforeFlow )
+ run.pingAll( main, dumpflows=False )
+ run.addHostCfg( main )
+ run.checkFlows( main, minFlowCount=minAfterFlow, dumpflows=False )
+ run.pingAll( main )
+ if killOnosAndDeleteCfg:
+ switch = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
+ link = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
+ self.killAndDelete( main, caseNum, numNodes, minBeforeFlow, switch, link )
+ # TODO Dynamic config of hosts in subnet
+ # TODO Dynamic config of host not in subnet
+ # TODO Dynamic config of vlan xconnect
+ # TODO Vrouter integration
+ # TODO Mcast integration
+ if hasattr( main, 'Mininet1' ):
+ run.cleanup( main )
+ else:
+ # TODO: disconnect TestON from the physical network
+ pass
+
+ def killAndDelete( self, main, caseNum, numNodes, minBeforeFlow, switch, link ):
+ run.killOnos( main, [ 0 ], '{}'.format( switch ), '{}'.format( link ), '{}'.format( numNodes - 1 ) )
+ run.delHostCfg( main )
+ run.checkFlows( main, minFlowCount=minBeforeFlow, dumpflows=False )
+ run.pingAll( main, "CASE{}_After".format( caseNum ) )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/dependencies/__init__.py