blob: 52fb795db0313d3097b8bcd774ff2a8b254ffbef [file] [log] [blame]
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -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
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080023import time
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080024
25class SRRoutingTest ():
26
27 topo = {}
28
29 def __init__( self ):
30 self.default = ''
31
32 @staticmethod
You Wangba231e72018-03-01 13:18:21 -080033 def runTest( main, test_idx, onosNodes, dhcp, routers, ipv4, ipv6, description, countFlowsGroups=False, checkExternalHost=False ):
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080034
35 skipPackage = False
36 init = False
37 if not hasattr( main, 'apps' ):
38 init = True
39 run.initTest( main )
40
41 # Skip onos packaging if the cluster size stays the same
42 if not init and onosNodes == main.Cluster.numCtrls:
43 skipPackage = True
44
Devin Lim57221b02018-02-14 15:45:36 -080045 main.case( '%s, ONOS instance%s' % ( description, onosNodes ) )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080046
47 main.cfgName = 'COMCAST_CONFIG_ipv4=%d_ipv6=%d_dhcp=%d_routers=%d' % \
Devin Lim57221b02018-02-14 15:45:36 -080048 ( ipv4, ipv6, dhcp, routers )
You Wangba231e72018-03-01 13:18:21 -080049 if checkExternalHost:
50 main.cfgName += '_external=1'
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080051 main.resultFileName = 'CASE%02d' % test_idx
Devin Lim57221b02018-02-14 15:45:36 -080052 main.Cluster.setRunningNode( onosNodes )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080053
Devin Lim57221b02018-02-14 15:45:36 -080054 run.installOnos( main, skipPackage=skipPackage, cliSleep=5,
55 parallel=False )
56 run.loadJson( main )
57 run.loadChart( main )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080058
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -080059 if (countFlowsGroups):
60 run.loadCount( main )
61
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080062 # wait some
Devin Lim57221b02018-02-14 15:45:36 -080063 time.sleep( 5 )
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080064
Devin Lim57221b02018-02-14 15:45:36 -080065 if hasattr( main, 'Mininet1' ):
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080066 # Run the test with Mininet
Devin Lim57221b02018-02-14 15:45:36 -080067 mininet_args = ' --dhcp=%s --routers=%s --ipv6=%s --ipv4=%s' % ( dhcp, routers, ipv6, ipv4 )
68 run.startMininet( main, 'comcast_fabric.py', args=mininet_args )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080069 else:
70 # Run the test with physical devices
71 # TODO: connect TestON to the physical network
72 pass
73
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080074 # wait some time for onos to install the rules!
Devin Lim57221b02018-02-14 15:45:36 -080075 time.sleep( 25 )
Andreas Pantelopoulos971c91d2018-02-12 11:28:10 -080076
Devin Lim57221b02018-02-14 15:45:36 -080077 if ( dhcp ):
78 time.sleep( 60 )
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080079
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080080 # ping hosts
You Wangba231e72018-03-01 13:18:21 -080081 run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -080082
83 # check flows / groups numbers
84 if (countFlowsGroups):
85 run.checkFlowsGroupsFromFile(main)
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080086
Devin Lim57221b02018-02-14 15:45:36 -080087 if hasattr( main, 'Mininet1' ):
88 run.cleanup( main )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080089 else:
90 # TODO: disconnect TestON from the physical network
91 pass