blob: ad6839e0c7b660cbb4433cfdac0192ef96f9bada [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 = ''
Siddesh167bc882021-03-23 21:03:43 +000031 self.topo = run.getTopo()
Devin Lim57221b02018-02-14 15:45:36 -080032
Siddesh167bc882021-03-23 21:03:43 +000033 def runTest( self, main, caseNum, numNodes, topology, minBeforeFlow, minAfterFlow, killOnosAndDeleteCfg ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070034 try:
35 if not hasattr( main, 'apps' ):
36 run.initTest( main )
Devin Lim57221b02018-02-14 15:45:36 -080037
Jon Hall9b0de1f2020-08-24 15:38:04 -070038 description = "Bridging and Routing sanity test with " + \
Siddesh167bc882021-03-23 21:03:43 +000039 self.topo[ topology ][ 'description' ] + \
Jon Hall9b0de1f2020-08-24 15:38:04 -070040 "and {} nodes.".format( numNodes ) + \
41 ( "\nAlso, killing the first Onos and removing the host cfg." if killOnosAndDeleteCfg else "" )
42 main.case( description )
Devin Lim57221b02018-02-14 15:45:36 -080043
Siddesh167bc882021-03-23 21:03:43 +000044 main.cfgName = topology
Jon Hall9b0de1f2020-08-24 15:38:04 -070045 main.Cluster.setRunningNode( numNodes )
46 run.installOnos( main )
Jon Hall06fd0df2021-01-25 15:50:06 -080047 if not main.persistentSetup:
48 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070049 run.loadChart( main )
50 run.startMininet( main, 'cord_fabric.py',
Siddesh167bc882021-03-23 21:03:43 +000051 args=self.topo[ topology ][ 'mininetArgs' ] )
Jon Hall9b0de1f2020-08-24 15:38:04 -070052 # pre-configured routing and bridging test
53 run.checkFlows( main, minFlowCount=minBeforeFlow )
Jon Hall32c90f32021-06-24 16:32:44 -070054 run.pingAll( main, dumpFlows=False )
Jon Hall9b0de1f2020-08-24 15:38:04 -070055 run.addHostCfg( main )
Jon Hall32c90f32021-06-24 16:32:44 -070056 run.checkFlows( main, minFlowCount=minAfterFlow, dumpFlows=False )
Jon Hall9b0de1f2020-08-24 15:38:04 -070057 run.pingAll( main )
58 if killOnosAndDeleteCfg:
Siddesh167bc882021-03-23 21:03:43 +000059 switch = self.topo[ topology ][ 'spines' ] + self.topo[ topology ][ 'leaves' ]
60 link = ( self.topo[ topology ][ 'spines' ] + self.topo[ topology ][ 'leaves' ] ) * self.topo[ topology ][ 'spines' ]
Jon Hall9b0de1f2020-08-24 15:38:04 -070061 self.killAndDelete( main, caseNum, numNodes, minBeforeFlow, switch, link )
62 # TODO Dynamic config of hosts in subnet
63 # TODO Dynamic config of host not in subnet
64 # TODO Dynamic config of vlan xconnect
65 # TODO Vrouter integration
66 # TODO Mcast integration
Jon Hall9b0de1f2020-08-24 15:38:04 -070067 except Exception as e:
68 main.log.exception( "Error in runTest" )
69 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -070070 finally:
71 run.cleanup( main )
Devin Lim57221b02018-02-14 15:45:36 -080072
73 def killAndDelete( self, main, caseNum, numNodes, minBeforeFlow, switch, link ):
74 run.killOnos( main, [ 0 ], '{}'.format( switch ), '{}'.format( link ), '{}'.format( numNodes - 1 ) )
75 run.delHostCfg( main )
Jon Hall32c90f32021-06-24 16:32:44 -070076 run.checkFlows( main, minFlowCount=minBeforeFlow, dumpFlows=False )
Devin Lim57221b02018-02-14 15:45:36 -080077 run.pingAll( main, "CASE{}_After".format( caseNum ) )