blob: 9a77f644b62e98c2de6821c2687a23719cfb3ea1 [file] [log] [blame]
kelvin-onlab1d381fe2015-07-14 16:24:56 -07001
2# Testing network scalability, this test suite scales up a network topology
3# using mininet and verifies ONOS stability
4
kelvin-onlabf0336882015-07-21 11:09:22 -07005class SAMPscaleTopo:
kelvin-onlab1d381fe2015-07-14 16:24:56 -07006
7 def __init__( self ):
8 self.default = ''
9
10 def CASE1( self, main ):
11 import time
12 import os
13 import imp
Jon Hallf632d202015-07-30 15:45:11 -070014 import re
kelvin-onlab1d381fe2015-07-14 16:24:56 -070015
16 """
17 - Construct tests variables
18 - GIT ( optional )
19 - Checkout ONOS master branch
20 - Pull latest ONOS code
21 - Building ONOS ( optional )
22 - Install ONOS package
23 - Build ONOS package
24 """
25
26 main.case( "Constructing test variables and building ONOS package" )
27 main.step( "Constructing test variables" )
28 stepResult = main.FALSE
29
30 # Test variables
Jon Hallf632d202015-07-30 15:45:11 -070031 main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir )
kelvin-onlab1d381fe2015-07-14 16:24:56 -070032 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
33 gitBranch = main.params[ 'GIT' ][ 'branch' ]
34 main.dependencyPath = main.testOnDirectory + \
35 main.params[ 'DEPENDENCY' ][ 'path' ]
36 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
37 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
38 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
39 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
40 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
41 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
42 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
43 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
44 gitPull = main.params[ 'GIT' ][ 'pull' ]
45 main.cellData = {} # for creating cell file
46 main.hostsData = {}
47 main.CLIs = []
48 main.ONOSip = []
49
50 main.ONOSip = main.ONOSbench.getOnosIps()
51 print main.ONOSip
52
53 # Assigning ONOS cli handles to a list
54 for i in range( 1, main.maxNodes + 1 ):
55 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
56
57 # -- INIT SECTION, ONLY RUNS ONCE -- #
58 main.startUp = imp.load_source( wrapperFile1,
59 main.dependencyPath +
60 wrapperFile1 +
61 ".py" )
62 main.scaleTopoFunction = imp.load_source( wrapperFile2,
63 main.dependencyPath +
64 wrapperFile2 +
65 ".py" )
66
67 copyResult = main.ONOSbench.copyMininetFile( main.topology,
68 main.dependencyPath,
69 main.Mininet1.user_name,
70 main.Mininet1.ip_address )
71 if main.CLIs:
72 stepResult = main.TRUE
73 else:
74 main.log.error( "Did not properly created list of ONOS CLI handle" )
75 stepResult = main.FALSE
76
77 utilities.assert_equals( expect=main.TRUE,
78 actual=stepResult,
79 onpass="Successfully construct " +
80 "test variables ",
81 onfail="Failed to construct test variables" )
82
83 if gitPull == 'True':
84 main.step( "Building ONOS in " + gitBranch + " branch" )
85 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
86 stepResult = onosBuildResult
87 utilities.assert_equals( expect=main.TRUE,
88 actual=stepResult,
89 onpass="Successfully compiled " +
90 "latest ONOS",
91 onfail="Failed to compile " +
92 "latest ONOS" )
93 else:
94 main.log.warn( "Did not pull new code so skipping mvn " +
95 "clean install" )
96
97 def CASE2( self, main ):
98 """
99 - Set up cell
100 - Create cell file
101 - Set cell file
102 - Verify cell file
103 - Kill ONOS process
104 - Uninstall ONOS cluster
105 - Verify ONOS start up
106 - Install ONOS cluster
107 - Connect to cli
108 """
109
110 # main.scale[ 0 ] determines the current number of ONOS controller
111 main.numCtrls = int( main.scale[ 0 ] )
112
113 main.case( "Starting up " + str( main.numCtrls ) +
114 " node(s) ONOS cluster" )
115
116 #kill off all onos processes
117 main.log.info( "Safety check, killing all ONOS processes" +
118 " before initiating enviornment setup" )
119
120 for i in range( main.maxNodes ):
121 main.ONOSbench.onosDie( main.ONOSip[ i ] )
122
123 print "NODE COUNT = ", main.numCtrls
124
125 tempOnosIp = []
126 for i in range( main.numCtrls ):
127 tempOnosIp.append( main.ONOSip[i] )
128
129 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
130 "temp", main.Mininet1.ip_address,
131 main.apps,
132 tempOnosIp )
133
134 main.step( "Apply cell to environment" )
135 cellResult = main.ONOSbench.setCell( "temp" )
136 verifyResult = main.ONOSbench.verifyCell()
137 stepResult = cellResult and verifyResult
138 utilities.assert_equals( expect=main.TRUE,
139 actual=stepResult,
140 onpass="Successfully applied cell to " + \
141 "environment",
142 onfail="Failed to apply cell to environment " )
143
144 main.step( "Creating ONOS package" )
145 packageResult = main.ONOSbench.onosPackage()
146 stepResult = packageResult
147 utilities.assert_equals( expect=main.TRUE,
148 actual=stepResult,
149 onpass="Successfully created ONOS package",
150 onfail="Failed to create ONOS package" )
151
152
153 # Remove the first element in main.scale list
154 main.scale.remove( main.scale[ 0 ] )
155
156 def CASE9( self, main ):
157 '''
158 Report errors/warnings/exceptions
159 '''
160 main.log.info("Error report: \n" )
161 main.ONOSbench.logReport( main.ONOSip[ 0 ],
162 [ "INFO",
163 "FOLLOWER",
164 "WARN",
165 "flow",
166 "ERROR",
167 "Except" ],
168 "s" )
169
170 def CASE11( self, main ):
171 """
172 Start mininet
173 """
174 main.log.report( "Start Mininet topology" )
175 main.log.case( "Start Mininet topology" )
176
177 main.step( "Starting Mininet Topology" )
178 topoResult = main.Mininet1.startNet( topoFile=topology )
179 stepResult = topoResult
180 utilities.assert_equals( expect=main.TRUE,
181 actual=stepResult,
182 onpass="Successfully loaded topology",
183 onfail="Failed to load topology" )
184 # Exit if topology did not load properly
185 if not topoResult:
186 main.cleanup()
187 main.exit()
188
189 def CASE1001( self, main ):
190 """
191 Test topology discovery
192 """
193 main.case( "Topology discovery test" )
194
195
196 main.step( "Torus 5-5 topology" )
197 main.topoName = "TORUS5-5"
198 mnCmd = "mn --topo=torus,5,5 --mac"
199 stepResult = main.scaleTopoFunction.testTopology( main,
200 mnCmd=mnCmd,
201 clean=False )
202 utilities.assert_equals( expect=main.TRUE,
203 actual=stepResult,
204 onpass="Torus 5-5 topology successful",
205 onfail="Torus 5-5 topology failed" )
206
207 main.topoName = "TREE3-3"
208 stepResult = main.TRUE
209 main.step( "Tree 3-3 topology" )
210 mnCmd = "mn --topo=tree,3,3 --mac"
211 stepResult = main.scaleTopoFunction.testTopology( main,
212 mnCmd=mnCmd,
213 clean=True )
214 utilities.assert_equals( expect=main.TRUE,
215 actual=stepResult,
216 onpass="Tree 3-3 topology successful",
217 onfail="Tree 3-3 topology failed" )