blob: c2ee323b33c6025d242cd5b19978e105d8bfdcf5 [file] [log] [blame]
GlennRC5147a422015-10-06 17:26:17 -07001class FUNCflow:
2
3 def __init__( self ):
4 self.default = ''
5
6 def CASE1( self, main ):
7 import time
8 import os
9 import imp
10
11 """
12 - Construct tests variables
13 - GIT ( optional )
14 - Checkout ONOS master branch
15 - Pull latest ONOS code
16 - Building ONOS ( optional )
17 - Install ONOS package
18 - Build ONOS package
19 """
20
21 main.case( "Constructing test variables and building ONOS package" )
22 main.step( "Constructing test variables" )
23 stepResult = main.FALSE
24
25 # Test variables
26 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
27 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
28 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
29 gitBranch = main.params[ 'GIT' ][ 'branch' ]
30 main.dependencyPath = main.testOnDirectory + \
31 main.params[ 'DEPENDENCY' ][ 'path' ]
32 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
33 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
34 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
GlennRC94ed2232015-10-07 15:08:57 -070035 main.numSwitches = int( main.params[ 'TOPO' ][ 'numSwitches' ] )
36 main.numHosts = int( main.params[ 'TOPO' ][ 'numHosts' ] )
37 main.numLinks = int( main.params[ 'TOPO' ][ 'numLinks' ] )
GlennRC5147a422015-10-06 17:26:17 -070038 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
39 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
40 gitPull = main.params[ 'GIT' ][ 'pull' ]
41 main.cellData = {} # for creating cell file
42 main.CLIs = []
43 main.ONOSip = []
44
45 main.ONOSip = main.ONOSbench.getOnosIps()
46 print main.ONOSip
47
48 # Assigning ONOS cli handles to a list
49 for i in range( 1, main.maxNodes + 1 ):
50 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
51
52 # -- INIT SECTION, ONLY RUNS ONCE -- #
53 main.startUp = imp.load_source( wrapperFile1,
54 main.dependencyPath +
55 wrapperFile1 +
56 ".py" )
57
GlennRC94ed2232015-10-07 15:08:57 -070058 copyResult = main.ONOSbench.scp( main.Mininet1,
59 main.dependencyPath+main.topology,
60 main.Mininet1.home+'/custom/',
61 direction="to" )
62
GlennRC5147a422015-10-06 17:26:17 -070063 if main.CLIs:
64 stepResult = main.TRUE
65 else:
66 main.log.error( "Did not properly created list of ONOS CLI handle" )
67 stepResult = main.FALSE
68
69 utilities.assert_equals( expect=main.TRUE,
70 actual=stepResult,
71 onpass="Successfully construct " +
72 "test variables ",
73 onfail="Failed to construct test variables" )
74
75 if gitPull == 'True':
76 main.step( "Building ONOS in " + gitBranch + " branch" )
77 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
78 stepResult = onosBuildResult
79 utilities.assert_equals( expect=main.TRUE,
80 actual=stepResult,
81 onpass="Successfully compiled " +
82 "latest ONOS",
83 onfail="Failed to compile " +
84 "latest ONOS" )
85 else:
86 main.log.warn( "Did not pull new code so skipping mvn " +
87 "clean install" )
88
89 def CASE2( self, main ):
90 """
91 - Set up cell
92 - Create cell file
93 - Set cell file
94 - Verify cell file
95 - Kill ONOS process
96 - Uninstall ONOS cluster
97 - Verify ONOS start up
98 - Install ONOS cluster
99 - Connect to cli
100 """
101
102 main.numCtrls = int( main.maxNodes )
103
104 main.case( "Starting up " + str( main.numCtrls ) +
105 " node(s) ONOS cluster" )
106
107 #kill off all onos processes
108 main.log.info( "Safety check, killing all ONOS processes" +
109 " before initiating enviornment setup" )
110
111 for i in range( main.maxNodes ):
112 main.ONOSbench.onosDie( main.ONOSip[ i ] )
113
114 print "NODE COUNT = ", main.numCtrls
115
116 tempOnosIp = []
117 for i in range( main.numCtrls ):
118 tempOnosIp.append( main.ONOSip[i] )
119
120 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp )
121
122 main.step( "Apply cell to environment" )
123 cellResult = main.ONOSbench.setCell( "temp" )
124 verifyResult = main.ONOSbench.verifyCell()
125 stepResult = cellResult and verifyResult
126 utilities.assert_equals( expect=main.TRUE,
127 actual=stepResult,
128 onpass="Successfully applied cell to " + \
129 "environment",
130 onfail="Failed to apply cell to environment " )
131
132 main.step( "Creating ONOS package" )
133 packageResult = main.ONOSbench.onosPackage()
134 stepResult = packageResult
135 utilities.assert_equals( expect=main.TRUE,
136 actual=stepResult,
137 onpass="Successfully created ONOS package",
138 onfail="Failed to create ONOS package" )
139
140 time.sleep( main.startUpSleep )
141 main.step( "Uninstalling ONOS package" )
142 onosUninstallResult = main.TRUE
143 for i in range( main.numCtrls ):
144 onosUninstallResult = onosUninstallResult and \
145 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
146 stepResult = onosUninstallResult
147 utilities.assert_equals( expect=main.TRUE,
148 actual=stepResult,
149 onpass="Successfully uninstalled ONOS package",
150 onfail="Failed to uninstall ONOS package" )
151
152 time.sleep( main.startUpSleep )
153 main.step( "Installing ONOS package" )
154 onosInstallResult = main.TRUE
155 for i in range( main.numCtrls ):
156 onosInstallResult = onosInstallResult and \
157 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
158 stepResult = onosInstallResult
159 utilities.assert_equals( expect=main.TRUE,
160 actual=stepResult,
161 onpass="Successfully installed ONOS package",
162 onfail="Failed to install ONOS package" )
163
164 time.sleep( main.startUpSleep )
165 main.step( "Starting ONOS service" )
166 stopResult = main.TRUE
167 startResult = main.TRUE
168 onosIsUp = main.TRUE
169
170 for i in range( main.numCtrls ):
171 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
172 if onosIsUp == main.TRUE:
173 main.log.report( "ONOS instance is up and ready" )
174 else:
175 main.log.report( "ONOS instance may not be up, stop and " +
176 "start ONOS again " )
177 for i in range( main.numCtrls ):
178 stopResult = stopResult and \
179 main.ONOSbench.onosStop( main.ONOSip[ i ] )
180 for i in range( main.numCtrls ):
181 startResult = startResult and \
182 main.ONOSbench.onosStart( main.ONOSip[ i ] )
183 stepResult = onosIsUp and stopResult and startResult
184 utilities.assert_equals( expect=main.TRUE,
185 actual=stepResult,
186 onpass="ONOS service is ready",
187 onfail="ONOS service did not start properly" )
188
189 main.step( "Start ONOS cli" )
190 cliResult = main.TRUE
191 for i in range( main.numCtrls ):
192 cliResult = cliResult and \
193 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
194 stepResult = cliResult
195 utilities.assert_equals( expect=main.TRUE,
196 actual=stepResult,
197 onpass="Successfully start ONOS cli",
198 onfail="Failed to start ONOS cli" )
199
200 def CASE8( self, main ):
201 '''
202 Compare topology
203 '''
204
205 def CASE9( self, main ):
206 '''
207 Report errors/warnings/exceptions
208 '''
209 main.log.info("Error report: \n" )
210 main.ONOSbench.logReport( main.ONOSip[ 0 ],
211 [ "INFO",
212 "FOLLOWER",
213 "WARN",
214 "flow",
215 "ERROR",
216 "Except" ],
217 "s" )
218
219 def CASE10( self, main ):
220 '''
GlennRC94ed2232015-10-07 15:08:57 -0700221 Start Mininet with
GlennRC5147a422015-10-06 17:26:17 -0700222 '''
GlennRC94ed2232015-10-07 15:08:57 -0700223 main.case( "Setup mininet and assign switches to controllers" )
224 main.step( "Setup Mininet Topology" )
225 topology = main.Mininet1.home + '/custom/' + main.topology
226 stepResult1 = main.Mininet1.startNet( topoFile=topology )
GlennRC5147a422015-10-06 17:26:17 -0700227
GlennRC94ed2232015-10-07 15:08:57 -0700228 utilities.assert_equals( expect=main.TRUE,
229 actual=stepResult1,
230 onpass="Successfully loaded topology",
231 onfail="Failed to load topology" )
232
233 main.step( "Assign switches to controllers" )
234 for i in range( main.numSwitches ):
235 stepResult2 = main.Mininet1.assignSwController(
236 sw="s" + str( i+1 ),
237 ip=main.ONOSip )
238 if not stepResult2:
239 break
240
241 utilities.assert_equals( expect=main.TRUE,
242 actual=stepResult2,
243 onpass="Controller assignment successfull",
244 onfail="Controller assignment failed" )
245
246 caseResult = stepResult1 and stepResult2
247 if not caseResult:
248 main.cleanup()
249 main.exit()
GlennRC5147a422015-10-06 17:26:17 -0700250
251 def CASE1000( self, main ):
252 '''
253 Add flows
254 '''
255
256 def CASE2000( self, main ):
257 '''
258 Delete flows
259 '''
260
261 def CASE3000( self, main ):
262 '''
263 Modify flow rule selectors
264 '''
265
266 def CASE4000( self, main ):
267 '''
268 Modify flow rule treatment
269 '''
270
271 def CASE5000( self, main ):
272 '''
273 Modify flow rule controller
274 '''
275
276 def CASE100( self, main ):
277 '''
278 Compare switch flow table with ONOS
279 '''
280