[ONOS-7475] Refactoring SR tests
Change-Id: I10e51fcb8b416167e6a338e9030933162640af89
diff --git a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.params b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.params
index dfee950..517e8f0 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.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/SRHighAvailability/SRHighAvailability.py b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.py
index 91757f0..1970033 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.py
@@ -43,27 +43,17 @@
5 ) Pingall
6 ) Repeat 3 ), 4 ), 5 ) 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS failures with 2x2 Leaf-spine "
- main.case( description )
- run.config( main, '2x2' )
- run.installOnos( main )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main )
- for i in range( 0, main.failures ):
- toKill = i % main.Cluster.numCtrls
- run.killOnos( main, [ toKill ], '4', '8', '2' )
- run.pingAll( main, 'CASE1_Failure%d' % ( i + 1 ) )
- run.recoverOnos( main, [ toKill ], '4', '8', '3' )
- run.checkFlows( main, minFlowCount=116, tag='CASE1_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE1_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 1, 3, '2x2',
+ 116, False, False )
def CASE2( self, main ):
"""
@@ -74,31 +64,17 @@
5 ) Pingall
6 ) Repeat 3 ), 4 ), 5 ) 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import random
- from random import randint
- from datetime import datetime
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS random failures with 2x2 Leaf-spine "
- main.case( description )
- run.config( main, '2x2' )
- run.installOnos( main )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main )
- random.seed( datetime.now() )
- for i in range( 0, main.failures ):
- toKill = randint( 0, ( main.Cluster.numCtrls - 1 ) )
- run.killOnos( main, [ toKill ], '4', '8', '2' )
- run.pingAll( main, 'CASE2_Failure%d' % ( i + 1 ) )
- run.recoverOnos( main, [ toKill ], '4', '8', '3' )
- run.checkFlows( main, minFlowCount=116, tag='CASE2_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE2_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 2, 3, '2x2',
+ 116, True, False )
def CASE3( self, main ):
"""
@@ -109,27 +85,17 @@
5 ) Pingall
6 ) Repeat 3 ), 4 ), 5 ) 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS failures with 4x4 Leaf-spine "
- main.case( description )
- run.config( main, '4x4' )
- run.installOnos( main )
- 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 )
- for i in range( 0, main.failures ):
- toKill = i % main.Cluster.numCtrls
- run.killOnos( main, [ toKill ], '8', '32', '2' )
- run.pingAll( main, 'CASE3_Failure%d' % ( i + 1 ) )
- run.recoverOnos( main, [ toKill ], '8', '32', '3' )
- run.checkFlows( main, minFlowCount=350, tag='CASE3_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE3_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 3, 3, '4x4',
+ 350, False, False )
def CASE4( self, main ):
"""
@@ -140,31 +106,17 @@
5 ) Pingall
6 ) Repeat 3 ), 4 ), 5 ) 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import random
- from random import randint
- from datetime import datetime
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS random failures with 4x4 Leaf-spine "
- main.case( description )
- run.config( main, '4x4' )
- run.installOnos( main )
- 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 )
- random.seed( datetime.now() )
- for i in range( 0, main.failures ):
- toKill = randint( 0, ( main.Cluster.numCtrls - 1 ) )
- run.killOnos( main, [ toKill ], '8', '32', '2' )
- run.pingAll( main, 'CASE4_Failure%d' % ( i + 1 ) )
- run.recoverOnos( main, [ toKill ], '8', '32', '3' )
- run.checkFlows( main, minFlowCount=350, tag='CASE4_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE4_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 4, 3, '4x4',
+ 350, True, False )
def CASE5( self, main ):
"""
@@ -177,35 +129,17 @@
7 ) Pingall
8 ) Repeat 3 ), 4 ), 5 ), 6 ), 7 ), 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import time
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS failures and Switch failures with 2x2 Leaf-spine "
- main.case( description )
- run.config( main, '2x2' )
- run.installOnos( main )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main )
- for i in range( 0, main.failures ):
- onosToKill = i % main.Cluster.numCtrls
- switchToKill = i % len( main.spines )
- run.killOnos( main, [ onosToKill ], '4', '8', '2' )
- run.pingAll( main, 'CASE5_ONOS_Failure%d' % ( i + 1 ) )
- run.killSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='3', links='4' )
- time.sleep( main.switchSleep )
- run.pingAll( main, "CASE5_SWITCH_Failure%d" % ( i + 1 ) )
- run.recoverSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='4', links='8' )
- run.checkFlows( main, minFlowCount=116, tag="CASE5_SWITCH_Recovery%d" % ( i + 1 ) )
- run.pingAll( main, "CASE5_SWITCH_Recovery%d" % ( i + 1 ) )
- run.recoverOnos( main, [ onosToKill ], '4', '8', '3' )
- run.checkFlows( main, minFlowCount=116, tag='CASE5_ONOS_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE5_ONOS_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 5, 3, '2x2',
+ 116, False, True )
def CASE6( self, main ):
"""
@@ -218,38 +152,17 @@
7 ) Pingall
8 ) Repeat 3 ), 4 ), 5 ), 6 ), 7 ) 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import time
- import random
- from random import randint
- from datetime import datetime
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS random failures and Switch random failures with 2x2 Leaf-spine "
- main.case( description )
- run.config( main, '2x2' )
- run.installOnos( main )
- run.startMininet( main, 'cord_fabric.py' )
- # pre-configured routing and bridging test
- run.checkFlows( main, minFlowCount=116 )
- run.pingAll( main )
- for i in range( 0, main.failures ):
- onosToKill = randint( 0, ( main.Cluster.numCtrls - 1 ) )
- switchToKill = randint( 0, 1 )
- run.killOnos( main, [ onosToKill ], '4', '8', '2' )
- run.pingAll( main, 'CASE6_ONOS_Failure%d' % ( i + 1 ) )
- run.killSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='3', links='4' )
- time.sleep( main.switchSleep )
- run.pingAll( main, "CASE6_SWITCH_Failure%d" % ( i + 1 ) )
- run.recoverSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='4', links='8' )
- run.checkFlows( main, minFlowCount=116, tag="CASE6_SWITCH_Recovery%d" % ( i + 1 ) )
- run.pingAll( main, "CASE6_SWITCH_Recovery%d" % ( i + 1 ) )
- run.recoverOnos( main, [ onosToKill ], '4', '8', '3' )
- run.checkFlows( main, minFlowCount=116, tag='CASE6_ONOS_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE6_ONOS_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 6, 3, '2x2',
+ 116, True, True )
def CASE7( self, main ):
"""
@@ -262,35 +175,17 @@
7 ) Pingall
8 ) Repeat 3 ), 4 ), 5 ), 6 ), 7 ), 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import time
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS failures and Switch failures with 4x4 Leaf-spine "
- main.case( description )
- run.config( main, '4x4' )
- run.installOnos( main )
- 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 )
- for i in range( 0, main.failures ):
- onosToKill = i % main.Cluster.numCtrls
- switchToKill = i % len( main.spines )
- run.killOnos( main, [ onosToKill ], '8', '32', '2' )
- run.pingAll( main, 'CASE7_ONOS_Failure%d' % ( i + 1 ) )
- run.killSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='7', links='24' )
- time.sleep( main.switchSleep )
- run.pingAll( main, "CASE7_SWITCH_Failure%d" % ( i + 1 ) )
- run.recoverSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='8', links='32' )
- run.checkFlows( main, minFlowCount=350, tag="CASE7_SWITCH_Recovery%d" % ( i + 1 ) )
- run.pingAll( main, "CASE7_SWITCH_Recovery%d" % ( i + 1 ) )
- run.recoverOnos( main, [ onosToKill ], '8', '32', '3' )
- run.checkFlows( main, minFlowCount=350, tag='CASE7_ONOS_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE7_ONOS_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 7, 3, '4x4',
+ 350, False, True )
def CASE8( self, main ):
"""
@@ -303,35 +198,14 @@
7 ) Pingall
8 ) Repeat 3 ), 4 ), 5 ), 6 ), 7 ), 'failures' times
"""
- from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
- Testcaselib as run
- import time
- import random
- from random import randint
- from datetime import datetime
- if not hasattr( main, 'apps' ):
- run.initTest( main )
-
- description = "High Availability tests - ONOS random failures and Switch random failures with 4x4 Leaf-spine "
- main.case( description )
- run.config( main, '4x4' )
- run.installOnos( main )
- 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 )
- for i in range( 0, main.failures ):
- onosToKill = randint( 0, ( main.Cluster.numCtrls - 1 ) )
- switchToKill = randint( 0, 3 )
- run.killOnos( main, [ onosToKill ], '8', '32', '2' )
- run.pingAll( main, 'CASE8_ONOS_Failure%d' % ( i + 1 ) )
- run.killSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='7', links='24' )
- time.sleep( main.switchSleep )
- run.pingAll( main, "CASE8_SWITCH_Failure%d" % ( i + 1 ) )
- run.recoverSwitch( main, main.spines[ switchToKill ][ 'name' ], switches='8', links='32' )
- run.checkFlows( main, minFlowCount=350, tag="CASE8_SWITCH_Recovery%d" % ( i + 1 ) )
- run.pingAll( main, "CASE8_SWITCH_Recovery%d" % ( i + 1 ) )
- run.recoverOnos( main, [ onosToKill ], '8', '32', '3' )
- run.checkFlows( main, minFlowCount=350, tag='CASE8_ONOS_Recovery%d' % ( i + 1 ) )
- run.pingAll( main, 'CASE8_ONOS_Recovery%d' % ( i + 1 ) )
- run.cleanup( main )
+ try:
+ from tests.USECASE.SegmentRouting.SRHighAvailability.dependencies.SRHAFuncs import SRHAFuncs
+ except ImportError:
+ main.log.error( "SRHAFuncs not found. Exiting the test" )
+ main.cleanAndExit()
+ try:
+ main.funcs
+ except ( NameError, AttributeError ):
+ main.funcs = SRHAFuncs()
+ main.funcs.runTest( main, 8, 3, '4x4',
+ 350, True, True )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/SRHAFuncs.py b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/SRHAFuncs.py
new file mode 100644
index 0000000..5b1d137
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/SRHAFuncs.py
@@ -0,0 +1,104 @@
+"""
+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
+import time
+
+class SRHAFuncs():
+
+ def __init__( self ):
+ self.default = ''
+ self.topo = dict()
+ 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, minFlow, isRandom, isKillingSwitch ):
+ if not hasattr( main, 'apps' ):
+ run.initTest( main )
+
+ description = "High Availability tests - " + \
+ self.generateDescription( isRandom, isKillingSwitch ) + \
+ self.topo[ Topo ][ 3 ]
+ main.case( description )
+ run.config( main, Topo )
+ 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=minFlow )
+ run.pingAll( main )
+ switch = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
+ link = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
+ self.generateRandom( isRandom )
+ for i in range( 0, main.failures ):
+ toKill = self.getNextNum( isRandom, main.Cluster.numCtrls, i )
+ run.killOnos( main, [ toKill ], '{}'.format( switch ),
+ '{}'.format( link ), '{}'.format( numNodes - 1 ) )
+ run.pingAll( main, 'CASE{}_ONOS_Failure{}'.format( caseNum, i + 1 ) )
+ if isKillingSwitch:
+ self.killAndRecoverSwitch( main, caseNum, numNodes,
+ Topo, minFlow, isRandom,
+ i, switch, link )
+ run.recoverOnos( main, [ toKill ], '{}'.format( switch ),
+ '{}'.format( link ), '{}'.format( numNodes ) )
+ run.checkFlows( main, minFlowCount=minFlow,
+ tag='CASE{}_ONOS{}_Recovery'.format( caseNum, i + 1 ) )
+ run.pingAll( main, 'CASE{}_ONOS_Recovery{}'.format( caseNum, i + 1 ) )
+ # 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 generateDescription( self, isRandom, isKillingSwitch ):
+ return "ONOS " + ( "random " if isRandom else "" ) + "failures" +\
+ ( " and Switch " + ( "random " if isRandom else "" ) + "failures "
+ if isKillingSwitch else " " )
+
+ def generateRandom( self, isRandom ):
+ if isRandom:
+ random.seed( datetime.now() )
+
+ def getNextNum( self, isRandom, numCtrl, pos ):
+ return randint( 0, ( numCtrl - 1 ) ) if isRandom else pos % numCtrl
+
+ def killAndRecoverSwitch( self, main, caseNum, numNodes, Topo, minFlow, isRandom, pos, numSwitch, numLink ):
+ switchToKill = self.getNextNum( isRandom, self.topo[ Topo ][ 0 ], pos )
+ run.killSwitch( main, main.spines[ switchToKill ][ 'name' ],
+ switches='{}'.format( numSwitch - 1 ),
+ links='{}'.format( numLink - numSwitch ) )
+ time.sleep( main.switchSleep )
+ run.pingAll( main, "CASE{}_SWITCH_Failure{}".format( caseNum, pos + 1 ) )
+ run.recoverSwitch( main, main.spines[ switchToKill ][ 'name' ],
+ switches='{}'.format( numSwitch ),
+ links='{}'.format( numLink ) )
+ run.checkFlows( main, minFlowCount=minFlow,
+ tag="CASE{}_SWITCH_Recovery{}".format( caseNum, pos + 1 ) )
+ run.pingAll( main, "CASE{}_SWITCH_Recovery{}".format( caseNum, pos + 1 ) )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/dependencies/__init__.py