blob: 59c242cab3b17f514f3b4e21cffffce9100e7232 [file] [log] [blame]
cameron@onlab.us966d1be2015-05-15 14:54:09 -07001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
8time.sleep( 1 )
9
10class FuncStartTemplate:
11
12 def __init__( self ):
13 self.default = ''
14
15 def CASE10( self, main ):
16 import time
17 import os
kelvin-onlabbf456822015-06-22 16:53:06 -070018 import imp
cameron@onlab.us966d1be2015-05-15 14:54:09 -070019 """
20 Startup sequence:
kelvin-onlabbf456822015-06-22 16:53:06 -070021 git pull
cameron@onlab.us966d1be2015-05-15 14:54:09 -070022 cell <name>
23 onos-verify-cell
24 onos-remove-raft-log
cameron@onlab.us966d1be2015-05-15 14:54:09 -070025 mvn clean install
26 onos-package
27 onos-install -f
28 onos-wait-for-start
29 """
30 global init
31 global globalONOSip
32 try:
33 if type(init) is not bool:
34 init = False
35 except NameError:
36 init = False
37
38 #Local variables
39 cellName = main.params[ 'ENV' ][ 'cellName' ]
40 apps = main.params[ 'ENV' ][ 'cellApps' ]
41 gitBranch = main.params[ 'GIT' ][ 'branch' ]
42 benchIp = os.environ[ 'OCN' ]
43 benchUser = main.params[ 'BENCH' ][ 'user' ]
44 topology = main.params[ 'MININET' ][ 'topo' ]
45 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
46 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
47 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
kelvin-onlabbf456822015-06-22 16:53:06 -070048 main.ONOSport = []
49 main.hostsData = {}
cameron@onlab.us966d1be2015-05-15 14:54:09 -070050 PULLCODE = False
51 if main.params[ 'GIT' ][ 'pull' ] == 'True':
52 PULLCODE = True
53 main.case( "Setting up test environment" )
54 main.CLIs = []
55 for i in range( 1, int( main.numCtrls ) + 1 ):
56 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabbf456822015-06-22 16:53:06 -070057 main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070058
59 # -- INIT SECTION, ONLY RUNS ONCE -- #
60 if init == False:
61 init = True
62
cameron@onlab.us966d1be2015-05-15 14:54:09 -070063 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
64 main.numCtrls = int( main.scale[ 0 ] )
65
66 if PULLCODE:
67 main.step( "Git checkout and pull " + gitBranch )
68 main.ONOSbench.gitCheckout( gitBranch )
69 gitPullResult = main.ONOSbench.gitPull()
70 if gitPullResult == main.ERROR:
71 main.log.error( "Error pulling git branch" )
72 main.step( "Using mvn clean & install" )
73 cleanInstallResult = main.ONOSbench.cleanInstall()
74 stepResult = cleanInstallResult
75 utilities.assert_equals( expect=main.TRUE,
76 actual=stepResult,
77 onpass="Successfully compiled " +
78 "latest ONOS",
79 onfail="Failed to compile " +
80 "latest ONOS" )
81 else:
82 main.log.warn( "Did not pull new code so skipping mvn " +
83 "clean install" )
84
85 globalONOSip = main.ONOSbench.getOnosIps()
kelvin-onlabbf456822015-06-22 16:53:06 -070086
kelvin-onlab6ff9cdb2015-06-23 15:00:36 -070087 maxNodes = ( len( globalONOSip ) - 2 )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070088
89 main.numCtrls = int( main.scale[ 0 ] )
90 main.scale.remove( main.scale[ 0 ] )
91
92 main.ONOSip = []
kelvin-onlabbf456822015-06-22 16:53:06 -070093 for i in range( maxNodes ):
94 main.ONOSip.append( globalONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070095
cameron@onlab.us966d1be2015-05-15 14:54:09 -070096 #kill off all onos processes
97 main.log.info( "Safety check, killing all ONOS processes" +
98 " before initiating enviornment setup" )
kelvin-onlab6ff9cdb2015-06-23 15:00:36 -070099 for i in range( maxNodes ):
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700100 main.ONOSbench.onosDie( globalONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700101
102 print "NODE COUNT = ", main.numCtrls
103 main.log.info( "Creating cell file" )
104 cellIp = []
105 for i in range( main.numCtrls ):
106 cellIp.append( str( main.ONOSip[ i ] ) )
107 print cellIp
108 main.ONOSbench.createCellFile( benchIp, cellName, "",
109 str( apps ), *cellIp )
110
111 main.step( "Apply cell to environment" )
112 cellResult = main.ONOSbench.setCell( cellName )
113 verifyResult = main.ONOSbench.verifyCell()
114 stepResult = cellResult and verifyResult
115 utilities.assert_equals( expect=main.TRUE,
116 actual=stepResult,
117 onpass="Successfully applied cell to " + \
118 "environment",
119 onfail="Failed to apply cell to environment " )
120
121 main.step( "Creating ONOS package" )
122 packageResult = main.ONOSbench.onosPackage()
123 stepResult = packageResult
124 utilities.assert_equals( expect=main.TRUE,
125 actual=stepResult,
126 onpass="Successfully created ONOS package",
127 onfail="Failed to create ONOS package" )
128
129 main.step( "Uninstalling ONOS package" )
130 onosUninstallResult = main.TRUE
131 for i in range( main.numCtrls ):
132 onosUninstallResult = onosUninstallResult and \
133 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
134 stepResult = onosUninstallResult
135 utilities.assert_equals( expect=main.TRUE,
136 actual=stepResult,
137 onpass="Successfully uninstalled ONOS package",
138 onfail="Failed to uninstall ONOS package" )
139 time.sleep( 5 )
140 main.step( "Installing ONOS package" )
141 onosInstallResult = main.TRUE
142 for i in range( main.numCtrls ):
143 onosInstallResult = onosInstallResult and \
144 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
145 stepResult = onosInstallResult
146 utilities.assert_equals( expect=main.TRUE,
147 actual=stepResult,
148 onpass="Successfully installed ONOS package",
149 onfail="Failed to install ONOS package" )
150
151 time.sleep( 20 )
152 main.step( "Starting ONOS service" )
153 stopResult = main.TRUE
154 startResult = main.TRUE
155 onosIsUp = main.TRUE
156 for i in range( main.numCtrls ):
157 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
158 if onosIsUp == main.TRUE:
159 main.log.report( "ONOS instance is up and ready" )
160 else:
161 main.log.report( "ONOS instance may not be up, stop and " +
162 "start ONOS again " )
163 for i in range( main.numCtrls ):
164 stopResult = stopResult and \
165 main.ONOSbench.onosStop( main.ONOSip[ i ] )
166 for i in range( main.numCtrls ):
167 startResult = startResult and \
168 main.ONOSbench.onosStart( main.ONOSip[ i ] )
169 stepResult = onosIsUp and stopResult and startResult
170 utilities.assert_equals( expect=main.TRUE,
171 actual=stepResult,
172 onpass="ONOS service is ready",
173 onfail="ONOS service did not start properly" )
kelvin-onlabbf456822015-06-22 16:53:06 -0700174
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700175 main.step( "Start ONOS cli" )
176 cliResult = main.TRUE
177 for i in range( main.numCtrls ):
178 cliResult = cliResult and \
kelvin-onlabbf456822015-06-22 16:53:06 -0700179 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700180 stepResult = cliResult
181 utilities.assert_equals( expect=main.TRUE,
182 actual=stepResult,
183 onpass="Successfully start ONOS cli",
184 onfail="Failed to start ONOS cli" )
kelvin-onlabbf456822015-06-22 16:53:06 -0700185
186 def CASE9( self, main ):
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700187 '''
kelvin-onlabbf456822015-06-22 16:53:06 -0700188 Report errors/warnings/exceptions
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700189 '''
kelvin-onlabbf456822015-06-22 16:53:06 -0700190 main.log.info("Error report: \n" )
191 main.ONOSbench.logReport( globalONOSip[ 0 ],
192 [ "INFO",
193 "FOLLOWER",
194 "WARN",
195 "flow",
196 "ERROR",
197 "Except" ],
198 "s" )
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700199 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
200
201 def CASE11( self, main ):
202 """
203 Start mininet
204 """
205 main.log.report( "Start Mininet topology" )
206 main.log.case( "Start Mininet topology" )
207
208 main.step( "Starting Mininet Topology" )
209 topoResult = main.Mininet1.startNet( topoFile=topology )
210 stepResult = topoResult
211 utilities.assert_equals( expect=main.TRUE,
212 actual=stepResult,
213 onpass="Successfully loaded topology",
214 onfail="Failed to load topology" )
215 # Exit if topology did not load properly
216 if not topoResult:
217 main.cleanup()
218 main.exit()
219