blob: eb747b0999a378c5bec874bf6eacc456fbe4fdf3 [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
Andreas Pantelopoulos2eae3242018-03-06 13:47:20 -080033 def runTest( main, test_idx, onosNodes, dhcp, routers, ipv4, ipv6,
34 description, countFlowsGroups=False, checkExternalHost=False,
You Wang27317572018-03-06 12:13:11 -080035 staticRouteConfigure=False, switchFailure=False ):
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080036
37 skipPackage = False
38 init = False
39 if not hasattr( main, 'apps' ):
40 init = True
41 run.initTest( main )
42
43 # Skip onos packaging if the cluster size stays the same
44 if not init and onosNodes == main.Cluster.numCtrls:
45 skipPackage = True
46
Devin Lim57221b02018-02-14 15:45:36 -080047 main.case( '%s, ONOS instance%s' % ( description, onosNodes ) )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080048
49 main.cfgName = 'COMCAST_CONFIG_ipv4=%d_ipv6=%d_dhcp=%d_routers=%d' % \
Devin Lim57221b02018-02-14 15:45:36 -080050 ( ipv4, ipv6, dhcp, routers )
You Wangba231e72018-03-01 13:18:21 -080051 if checkExternalHost:
52 main.cfgName += '_external=1'
Andreas Pantelopoulos2eae3242018-03-06 13:47:20 -080053 if staticRouteConfigure:
54 main.cfgName += '_static=1'
55
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080056 main.resultFileName = 'CASE%02d' % test_idx
Devin Lim57221b02018-02-14 15:45:36 -080057 main.Cluster.setRunningNode( onosNodes )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080058
Devin Lim57221b02018-02-14 15:45:36 -080059 run.installOnos( main, skipPackage=skipPackage, cliSleep=5,
60 parallel=False )
You Wang27317572018-03-06 12:13:11 -080061
62 # Load configuration files
Devin Lim57221b02018-02-14 15:45:36 -080063 run.loadJson( main )
64 run.loadChart( main )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080065
Andreas Pantelopoulos2eae3242018-03-06 13:47:20 -080066 # if static route flag add routes
67 # these routes are topology specific
68 if (staticRouteConfigure):
69 if (ipv4):
70 run.addStaticOnosRoute( main, "10.0.88.0/24", "10.0.1.1")
71 if (ipv6):
72 run.addStaticOnosRoute( main, "2000::8700/120", "2000::101")
73
You Wang27317572018-03-06 12:13:11 -080074 if countFlowsGroups:
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -080075 run.loadCount( main )
You Wang27317572018-03-06 12:13:11 -080076 if switchFailure:
77 run.loadSwitchFailureChart( main )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -080078
You Wang27317572018-03-06 12:13:11 -080079 # wait some time
Devin Lim57221b02018-02-14 15:45:36 -080080 time.sleep( 5 )
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080081
Devin Lim57221b02018-02-14 15:45:36 -080082 if hasattr( main, 'Mininet1' ):
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080083 # Run the test with Mininet
Devin Lim57221b02018-02-14 15:45:36 -080084 mininet_args = ' --dhcp=%s --routers=%s --ipv6=%s --ipv4=%s' % ( dhcp, routers, ipv6, ipv4 )
85 run.startMininet( main, 'comcast_fabric.py', args=mininet_args )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080086 else:
87 # Run the test with physical devices
88 # TODO: connect TestON to the physical network
89 pass
90
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080091 # wait some time for onos to install the rules!
Devin Lim57221b02018-02-14 15:45:36 -080092 time.sleep( 25 )
Andreas Pantelopoulos971c91d2018-02-12 11:28:10 -080093
Devin Lim57221b02018-02-14 15:45:36 -080094 if ( dhcp ):
95 time.sleep( 60 )
Andreas Pantelopoulosf6ed5012018-02-08 21:26:01 -080096
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -080097 # ping hosts
You Wangba231e72018-03-01 13:18:21 -080098 run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -080099
100 # check flows / groups numbers
You Wang27317572018-03-06 12:13:11 -0800101 if countFlowsGroups:
Andreas Pantelopoulos9173d442018-03-01 17:07:37 -0800102 run.checkFlowsGroupsFromFile(main)
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -0800103
You Wang27317572018-03-06 12:13:11 -0800104 # Test switch failures
105 if switchFailure:
106 for switch, expected in main.switchFailureChart.items():
107 run.killSwitch( main, switch, expected['switches_after_failure'], expected['links_after_failure'] )
108 run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
109 if countFlowsGroups:
110 run.checkFlowsGroupsFromFile(main)
111 run.recoverSwitch( main, switch, expected['switches_before_failure'], expected['links_before_failure'] )
112 run.pingAll( main, 'CASE%02d' % test_idx, acceptableFailed=5, basedOnIp=True )
113 if countFlowsGroups:
114 run.checkFlowsGroupsFromFile(main)
115
Devin Lim57221b02018-02-14 15:45:36 -0800116 if hasattr( main, 'Mininet1' ):
117 run.cleanup( main )
Andreas Pantelopoulos90f0b102018-02-01 13:21:45 -0800118 else:
119 # TODO: disconnect TestON from the physical network
120 pass