blob: 0ca4c9155b407078c08c08cf1f90153a0bd39571 [file] [log] [blame]
Devin Lim57221b02018-02-14 15:45:36 -08001"""
2Copyright 2017 Open Networking Foundation ( ONF )
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 ( at your option ) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
22from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
23import random
24from random import randint
25from datetime import datetime
26
27class SRDynamicFuncs():
28
29 def __init__( self ):
30 self.default = ''
31 self.topo = dict()
32 self.topo[ '0x1' ] = ( 0, 1, '--leaf=1 --spine=0', 'single switch' )
33 self.topo[ '2x2' ] = ( 2, 2, '', '2x2 Leaf-spine' )
34 self.topo[ '4x4' ] = ( 4, 4, '--leaf=4 --spine=4', '4x4 Leaf-spine' )
35
36 def runTest( self, main, caseNum, numNodes, Topo, minBeforeFlow, minAfterFlow, killOnosAndDeleteCfg ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070037 try:
38 if not hasattr( main, 'apps' ):
39 run.initTest( main )
Devin Lim57221b02018-02-14 15:45:36 -080040
Jon Hall9b0de1f2020-08-24 15:38:04 -070041 description = "Bridging and Routing sanity test with " + \
42 self.topo[ Topo ][ 3 ] + \
43 "and {} nodes.".format( numNodes ) + \
44 ( "\nAlso, killing the first Onos and removing the host cfg." if killOnosAndDeleteCfg else "" )
45 main.case( description )
Devin Lim57221b02018-02-14 15:45:36 -080046
Jon Hall9b0de1f2020-08-24 15:38:04 -070047 main.cfgName = Topo
48 main.Cluster.setRunningNode( numNodes )
49 run.installOnos( main )
50 run.loadJson( main )
51 run.loadChart( main )
52 run.startMininet( main, 'cord_fabric.py',
53 args=self.topo[ Topo ][ 2 ] )
54 # pre-configured routing and bridging test
55 run.checkFlows( main, minFlowCount=minBeforeFlow )
56 run.pingAll( main, dumpflows=False )
57 run.addHostCfg( main )
58 run.checkFlows( main, minFlowCount=minAfterFlow, dumpflows=False )
59 run.pingAll( main )
60 if killOnosAndDeleteCfg:
61 switch = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
62 link = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
63 self.killAndDelete( main, caseNum, numNodes, minBeforeFlow, switch, link )
64 # TODO Dynamic config of hosts in subnet
65 # TODO Dynamic config of host not in subnet
66 # TODO Dynamic config of vlan xconnect
67 # TODO Vrouter integration
68 # TODO Mcast integration
Jon Hall9b0de1f2020-08-24 15:38:04 -070069 except Exception as e:
70 main.log.exception( "Error in runTest" )
71 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -070072 finally:
73 run.cleanup( main )
Devin Lim57221b02018-02-14 15:45:36 -080074
75 def killAndDelete( self, main, caseNum, numNodes, minBeforeFlow, switch, link ):
76 run.killOnos( main, [ 0 ], '{}'.format( switch ), '{}'.format( link ), '{}'.format( numNodes - 1 ) )
77 run.delHostCfg( main )
78 run.checkFlows( main, minFlowCount=minBeforeFlow, dumpflows=False )
79 run.pingAll( main, "CASE{}_After".format( caseNum ) )