blob: 4beefae506dd8782e394ee0264ebff0864c813b2 [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
18 """
19 Startup sequence:
20 cell <name>
21 onos-verify-cell
22 onos-remove-raft-log
23 git pull
24 mvn clean install
25 onos-package
26 onos-install -f
27 onos-wait-for-start
28 """
29 global init
30 global globalONOSip
31 try:
32 if type(init) is not bool:
33 init = False
34 except NameError:
35 init = False
36
37 #Local variables
38 cellName = main.params[ 'ENV' ][ 'cellName' ]
39 apps = main.params[ 'ENV' ][ 'cellApps' ]
40 gitBranch = main.params[ 'GIT' ][ 'branch' ]
41 benchIp = os.environ[ 'OCN' ]
42 benchUser = main.params[ 'BENCH' ][ 'user' ]
43 topology = main.params[ 'MININET' ][ 'topo' ]
44 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
45 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
46 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
47 PULLCODE = False
48 if main.params[ 'GIT' ][ 'pull' ] == 'True':
49 PULLCODE = True
50 main.case( "Setting up test environment" )
51 main.CLIs = []
52 for i in range( 1, int( main.numCtrls ) + 1 ):
53 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
54
55 # -- INIT SECTION, ONLY RUNS ONCE -- #
56 if init == False:
57 init = True
58
59 main.ONOSport = []
60 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
61 main.numCtrls = int( main.scale[ 0 ] )
62
63 if PULLCODE:
64 main.step( "Git checkout and pull " + gitBranch )
65 main.ONOSbench.gitCheckout( gitBranch )
66 gitPullResult = main.ONOSbench.gitPull()
67 if gitPullResult == main.ERROR:
68 main.log.error( "Error pulling git branch" )
69 main.step( "Using mvn clean & install" )
70 cleanInstallResult = main.ONOSbench.cleanInstall()
71 stepResult = cleanInstallResult
72 utilities.assert_equals( expect=main.TRUE,
73 actual=stepResult,
74 onpass="Successfully compiled " +
75 "latest ONOS",
76 onfail="Failed to compile " +
77 "latest ONOS" )
78 else:
79 main.log.warn( "Did not pull new code so skipping mvn " +
80 "clean install" )
81
82 globalONOSip = main.ONOSbench.getOnosIps()
83
84 maxNodes = ( len(globalONOSip) - 2 )
85
86 main.numCtrls = int( main.scale[ 0 ] )
87 main.scale.remove( main.scale[ 0 ] )
88
89 main.ONOSip = []
90 for i in range( maxNodes ):
91 main.ONOSip.append( globalONOSip[i] )
92
93
94
95 #kill off all onos processes
96 main.log.info( "Safety check, killing all ONOS processes" +
97 " before initiating enviornment setup" )
98 for i in range(maxNodes):
99 main.ONOSbench.onosDie( globalONOSip[ i ] )
100
101 """
102 main.step( "Apply cell to environment" )
103 cellResult = main.ONOSbench.setCell( cellName )
104 verifyResult = main.ONOSbench.verifyCell()
105 stepResult = cellResult and verifyResult
106 utilities.assert_equals( expect=main.TRUE,
107 actual=stepResult,
108 onpass="Successfully applied cell to " + \
109 "environment",
110 onfail="Failed to apply cell to environment " )
111 """
112 """main.step( "Removing raft logs" )
113 removeRaftResult = main.ONOSbench.onosRemoveRaftLogs()
114 stepResult = removeRaftResult
115 utilities.assert_equals( expect=main.TRUE,
116 actual=stepResult,
117 onpass="Successfully removed raft logs",
118 onfail="Failed to remove raft logs" )
119 """
120
121 print "NODE COUNT = ", main.numCtrls
122 main.log.info( "Creating cell file" )
123 cellIp = []
124 for i in range( main.numCtrls ):
125 cellIp.append( str( main.ONOSip[ i ] ) )
126 print cellIp
127 main.ONOSbench.createCellFile( benchIp, cellName, "",
128 str( apps ), *cellIp )
129
130 main.step( "Apply cell to environment" )
131 cellResult = main.ONOSbench.setCell( cellName )
132 verifyResult = main.ONOSbench.verifyCell()
133 stepResult = cellResult and verifyResult
134 utilities.assert_equals( expect=main.TRUE,
135 actual=stepResult,
136 onpass="Successfully applied cell to " + \
137 "environment",
138 onfail="Failed to apply cell to environment " )
139
140 main.step( "Creating ONOS package" )
141 packageResult = main.ONOSbench.onosPackage()
142 stepResult = packageResult
143 utilities.assert_equals( expect=main.TRUE,
144 actual=stepResult,
145 onpass="Successfully created ONOS package",
146 onfail="Failed to create ONOS package" )
147
148 main.step( "Uninstalling ONOS package" )
149 onosUninstallResult = main.TRUE
150 for i in range( main.numCtrls ):
151 onosUninstallResult = onosUninstallResult and \
152 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
153 stepResult = onosUninstallResult
154 utilities.assert_equals( expect=main.TRUE,
155 actual=stepResult,
156 onpass="Successfully uninstalled ONOS package",
157 onfail="Failed to uninstall ONOS package" )
158 time.sleep( 5 )
159 main.step( "Installing ONOS package" )
160 onosInstallResult = main.TRUE
161 for i in range( main.numCtrls ):
162 onosInstallResult = onosInstallResult and \
163 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
164 stepResult = onosInstallResult
165 utilities.assert_equals( expect=main.TRUE,
166 actual=stepResult,
167 onpass="Successfully installed ONOS package",
168 onfail="Failed to install ONOS package" )
169
170 time.sleep( 20 )
171 main.step( "Starting ONOS service" )
172 stopResult = main.TRUE
173 startResult = main.TRUE
174 onosIsUp = main.TRUE
175 for i in range( main.numCtrls ):
176 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
177 if onosIsUp == main.TRUE:
178 main.log.report( "ONOS instance is up and ready" )
179 else:
180 main.log.report( "ONOS instance may not be up, stop and " +
181 "start ONOS again " )
182 for i in range( main.numCtrls ):
183 stopResult = stopResult and \
184 main.ONOSbench.onosStop( main.ONOSip[ i ] )
185 for i in range( main.numCtrls ):
186 startResult = startResult and \
187 main.ONOSbench.onosStart( main.ONOSip[ i ] )
188 stepResult = onosIsUp and stopResult and startResult
189 utilities.assert_equals( expect=main.TRUE,
190 actual=stepResult,
191 onpass="ONOS service is ready",
192 onfail="ONOS service did not start properly" )
193
194 main.step( "Start ONOS cli" )
195 cliResult = main.TRUE
196 for i in range( main.numCtrls ):
197 cliResult = cliResult and \
198 main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
199 stepResult = cliResult
200 utilities.assert_equals( expect=main.TRUE,
201 actual=stepResult,
202 onpass="Successfully start ONOS cli",
203 onfail="Failed to start ONOS cli" )
204
205 def CASE9( self, main ):
206 '''
207 Report errors/warnings/exceptions
208 '''
209 main.log.info("Error report: \n")
210 main.ONOSbench.logReport( globalONOSip[0], [ "INFO","FOLLOWER","WARN","flow","ERROR","Except" ], "s" )
211 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
212
213 def CASE11( self, main ):
214 """
215 Start mininet
216 """
217 main.log.report( "Start Mininet topology" )
218 main.log.case( "Start Mininet topology" )
219
220 main.step( "Starting Mininet Topology" )
221 topoResult = main.Mininet1.startNet( topoFile=topology )
222 stepResult = topoResult
223 utilities.assert_equals( expect=main.TRUE,
224 actual=stepResult,
225 onpass="Successfully loaded topology",
226 onfail="Failed to load topology" )
227 # Exit if topology did not load properly
228 if not topoResult:
229 main.cleanup()
230 main.exit()
231