blob: 9df58af4fde7891f3a8e53bb5f3fa2e707f5445c [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
Jon Hallf57a5ef2015-07-07 17:56:16 -07005class SAMPstartTemplate:
cameron@onlab.us966d1be2015-05-15 14:54:09 -07006
7 def __init__( self ):
8 self.default = ''
9
10 def CASE10( self, main ):
11 import time
12 import os
kelvin-onlabbf456822015-06-22 16:53:06 -070013 import imp
cameron@onlab.us966d1be2015-05-15 14:54:09 -070014 """
15 Startup sequence:
kelvin-onlabbf456822015-06-22 16:53:06 -070016 git pull
cameron@onlab.us966d1be2015-05-15 14:54:09 -070017 cell <name>
18 onos-verify-cell
19 onos-remove-raft-log
cameron@onlab.us966d1be2015-05-15 14:54:09 -070020 mvn clean install
21 onos-package
22 onos-install -f
23 onos-wait-for-start
24 """
25 global init
26 global globalONOSip
27 try:
28 if type(init) is not bool:
29 init = False
30 except NameError:
31 init = False
32
33 #Local variables
34 cellName = main.params[ 'ENV' ][ 'cellName' ]
35 apps = main.params[ 'ENV' ][ 'cellApps' ]
36 gitBranch = main.params[ 'GIT' ][ 'branch' ]
37 benchIp = os.environ[ 'OCN' ]
38 benchUser = main.params[ 'BENCH' ][ 'user' ]
39 topology = main.params[ 'MININET' ][ 'topo' ]
40 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
41 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
42 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
kelvin-onlabbf456822015-06-22 16:53:06 -070043 main.ONOSport = []
44 main.hostsData = {}
cameron@onlab.us966d1be2015-05-15 14:54:09 -070045 PULLCODE = False
46 if main.params[ 'GIT' ][ 'pull' ] == 'True':
47 PULLCODE = True
48 main.case( "Setting up test environment" )
49 main.CLIs = []
50 for i in range( 1, int( main.numCtrls ) + 1 ):
51 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlabbf456822015-06-22 16:53:06 -070052 main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070053
54 # -- INIT SECTION, ONLY RUNS ONCE -- #
55 if init == False:
56 init = True
57
cameron@onlab.us966d1be2015-05-15 14:54:09 -070058 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
59 main.numCtrls = int( main.scale[ 0 ] )
60
61 if PULLCODE:
62 main.step( "Git checkout and pull " + gitBranch )
63 main.ONOSbench.gitCheckout( gitBranch )
64 gitPullResult = main.ONOSbench.gitPull()
65 if gitPullResult == main.ERROR:
66 main.log.error( "Error pulling git branch" )
67 main.step( "Using mvn clean & install" )
68 cleanInstallResult = main.ONOSbench.cleanInstall()
69 stepResult = cleanInstallResult
70 utilities.assert_equals( expect=main.TRUE,
71 actual=stepResult,
72 onpass="Successfully compiled " +
73 "latest ONOS",
74 onfail="Failed to compile " +
75 "latest ONOS" )
76 else:
77 main.log.warn( "Did not pull new code so skipping mvn " +
78 "clean install" )
79
80 globalONOSip = main.ONOSbench.getOnosIps()
kelvin-onlabbf456822015-06-22 16:53:06 -070081
kelvin-onlab6ff9cdb2015-06-23 15:00:36 -070082 maxNodes = ( len( globalONOSip ) - 2 )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070083
84 main.numCtrls = int( main.scale[ 0 ] )
85 main.scale.remove( main.scale[ 0 ] )
86
87 main.ONOSip = []
kelvin-onlabbf456822015-06-22 16:53:06 -070088 for i in range( maxNodes ):
89 main.ONOSip.append( globalONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070090
cameron@onlab.us966d1be2015-05-15 14:54:09 -070091 #kill off all onos processes
92 main.log.info( "Safety check, killing all ONOS processes" +
93 " before initiating enviornment setup" )
kelvin-onlab6ff9cdb2015-06-23 15:00:36 -070094 for i in range( maxNodes ):
cameron@onlab.us966d1be2015-05-15 14:54:09 -070095 main.ONOSbench.onosDie( globalONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -070096
97 print "NODE COUNT = ", main.numCtrls
98 main.log.info( "Creating cell file" )
99 cellIp = []
100 for i in range( main.numCtrls ):
101 cellIp.append( str( main.ONOSip[ i ] ) )
102 print cellIp
103 main.ONOSbench.createCellFile( benchIp, cellName, "",
104 str( apps ), *cellIp )
105
106 main.step( "Apply cell to environment" )
107 cellResult = main.ONOSbench.setCell( cellName )
108 verifyResult = main.ONOSbench.verifyCell()
109 stepResult = cellResult and verifyResult
110 utilities.assert_equals( expect=main.TRUE,
111 actual=stepResult,
112 onpass="Successfully applied cell to " + \
113 "environment",
114 onfail="Failed to apply cell to environment " )
115
116 main.step( "Creating ONOS package" )
117 packageResult = main.ONOSbench.onosPackage()
118 stepResult = packageResult
119 utilities.assert_equals( expect=main.TRUE,
120 actual=stepResult,
121 onpass="Successfully created ONOS package",
122 onfail="Failed to create ONOS package" )
123
124 main.step( "Uninstalling ONOS package" )
125 onosUninstallResult = main.TRUE
126 for i in range( main.numCtrls ):
127 onosUninstallResult = onosUninstallResult and \
128 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
129 stepResult = onosUninstallResult
130 utilities.assert_equals( expect=main.TRUE,
131 actual=stepResult,
132 onpass="Successfully uninstalled ONOS package",
133 onfail="Failed to uninstall ONOS package" )
134 time.sleep( 5 )
135 main.step( "Installing ONOS package" )
136 onosInstallResult = main.TRUE
137 for i in range( main.numCtrls ):
138 onosInstallResult = onosInstallResult and \
139 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
140 stepResult = onosInstallResult
141 utilities.assert_equals( expect=main.TRUE,
142 actual=stepResult,
143 onpass="Successfully installed ONOS package",
144 onfail="Failed to install ONOS package" )
145
146 time.sleep( 20 )
147 main.step( "Starting ONOS service" )
148 stopResult = main.TRUE
149 startResult = main.TRUE
150 onosIsUp = main.TRUE
151 for i in range( main.numCtrls ):
152 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
153 if onosIsUp == main.TRUE:
154 main.log.report( "ONOS instance is up and ready" )
155 else:
156 main.log.report( "ONOS instance may not be up, stop and " +
157 "start ONOS again " )
158 for i in range( main.numCtrls ):
159 stopResult = stopResult and \
160 main.ONOSbench.onosStop( main.ONOSip[ i ] )
161 for i in range( main.numCtrls ):
162 startResult = startResult and \
163 main.ONOSbench.onosStart( main.ONOSip[ i ] )
164 stepResult = onosIsUp and stopResult and startResult
165 utilities.assert_equals( expect=main.TRUE,
166 actual=stepResult,
167 onpass="ONOS service is ready",
168 onfail="ONOS service did not start properly" )
kelvin-onlabbf456822015-06-22 16:53:06 -0700169
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700170 main.step( "Start ONOS cli" )
171 cliResult = main.TRUE
172 for i in range( main.numCtrls ):
173 cliResult = cliResult and \
kelvin-onlabbf456822015-06-22 16:53:06 -0700174 main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700175 stepResult = cliResult
176 utilities.assert_equals( expect=main.TRUE,
177 actual=stepResult,
178 onpass="Successfully start ONOS cli",
179 onfail="Failed to start ONOS cli" )
kelvin-onlabbf456822015-06-22 16:53:06 -0700180
181 def CASE9( self, main ):
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700182 '''
kelvin-onlabbf456822015-06-22 16:53:06 -0700183 Report errors/warnings/exceptions
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700184 '''
kelvin-onlabbf456822015-06-22 16:53:06 -0700185 main.log.info("Error report: \n" )
186 main.ONOSbench.logReport( globalONOSip[ 0 ],
187 [ "INFO",
188 "FOLLOWER",
189 "WARN",
190 "flow",
191 "ERROR",
192 "Except" ],
193 "s" )
cameron@onlab.us966d1be2015-05-15 14:54:09 -0700194 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
195
196 def CASE11( self, main ):
197 """
198 Start mininet
199 """
200 main.log.report( "Start Mininet topology" )
201 main.log.case( "Start Mininet topology" )
202
203 main.step( "Starting Mininet Topology" )
204 topoResult = main.Mininet1.startNet( topoFile=topology )
205 stepResult = topoResult
206 utilities.assert_equals( expect=main.TRUE,
207 actual=stepResult,
208 onpass="Successfully loaded topology",
209 onfail="Failed to load topology" )
210 # Exit if topology did not load properly
211 if not topoResult:
212 main.cleanup()
213 main.exit()
214