blob: eefdb397df782a57fa1b7cdc5aa943ea14f2e31b [file] [log] [blame]
kelvin-onlaba297c4d2015-06-01 13:53:55 -07001
2# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
4
5import time
6import json
7
8class FuncTopo:
9
10 def __init__( self ):
11 self.default = ''
12
13 def CASE10( self, main ):
14 import time
15 import os
kelvin-onlab10e8d392015-06-03 13:53:45 -070016 import imp
kelvin-onlaba297c4d2015-06-01 13:53:55 -070017 """
18 Startup sequence:
19 cell <name>
20 onos-verify-cell
21 onos-remove-raft-log
22 git pull
23 mvn clean install
24 onos-package
25 onos-install -f
26 onos-wait-for-start
27 """
28 global init
29 global globalONOSip
30 try:
31 if type(init) is not bool:
32 init = False
33 except NameError:
34 init = False
35
kelvin-onlab10e8d392015-06-03 13:53:45 -070036 main.wrapper = imp.load_source( 'FuncTopoFunction', '/home/admin/' +
37 'TestON/tests/FuncTopo/Dependency/' +
38 'FuncTopoFunction.py')
39
kelvin-onlaba297c4d2015-06-01 13:53:55 -070040 #Local variables
41 cellName = main.params[ 'ENV' ][ 'cellName' ]
42 apps = main.params[ 'ENV' ][ 'cellApps' ]
43 gitBranch = main.params[ 'GIT' ][ 'branch' ]
44 benchIp = os.environ[ 'OCN' ]
45 benchUser = main.params[ 'BENCH' ][ 'user' ]
46 topology = main.params[ 'MININET' ][ 'topo' ]
47 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
48 main.numLinks = int( main.params[ 'MININET' ][ 'links' ] )
49 main.numCtrls = main.params[ 'CTRL' ][ 'num' ]
kelvin-onlab10e8d392015-06-03 13:53:45 -070050 main.hostsData = {}
kelvin-onlaba297c4d2015-06-01 13:53:55 -070051 PULLCODE = False
52 if main.params[ 'GIT' ][ 'pull' ] == 'True':
53 PULLCODE = True
54 main.case( "Setting up test environment" )
55 main.CLIs = []
kelvin-onlab10e8d392015-06-03 13:53:45 -070056 main.nodes = []
kelvin-onlaba297c4d2015-06-01 13:53:55 -070057 for i in range( 1, int( main.numCtrls ) + 1 ):
58 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlab10e8d392015-06-03 13:53:45 -070059 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
kelvin-onlaba297c4d2015-06-01 13:53:55 -070060
61 # -- INIT SECTION, ONLY RUNS ONCE -- #
62 if init == False:
63 init = True
64
65 main.ONOSport = []
66 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
67 main.numCtrls = int( main.scale[ 0 ] )
68
69 if PULLCODE:
70 main.step( "Git checkout and pull " + gitBranch )
71 main.ONOSbench.gitCheckout( gitBranch )
72 gitPullResult = main.ONOSbench.gitPull()
73 if gitPullResult == main.ERROR:
74 main.log.error( "Error pulling git branch" )
75 main.step( "Using mvn clean & install" )
76 cleanInstallResult = main.ONOSbench.cleanInstall()
77 stepResult = cleanInstallResult
78 utilities.assert_equals( expect=main.TRUE,
79 actual=stepResult,
80 onpass="Successfully compiled " +
81 "latest ONOS",
82 onfail="Failed to compile " +
83 "latest ONOS" )
84 else:
85 main.log.warn( "Did not pull new code so skipping mvn " +
86 "clean install" )
87
88 globalONOSip = main.ONOSbench.getOnosIps()
89 maxNodes = ( len(globalONOSip) - 2 )
90
91 main.numCtrls = int( main.scale[ 0 ] )
92 main.scale.remove( main.scale[ 0 ] )
93
94 main.ONOSip = []
95 for i in range( maxNodes ):
96 main.ONOSip.append( globalONOSip[i] )
97
98 #kill off all onos processes
99 main.log.info( "Safety check, killing all ONOS processes" +
100 " before initiating enviornment setup" )
101 for i in range(maxNodes):
102 main.ONOSbench.onosDie( globalONOSip[ i ] )
103
104 print "NODE COUNT = ", main.numCtrls
105 main.log.info( "Creating cell file" )
106 cellIp = []
107 for i in range( main.numCtrls ):
108 cellIp.append( str( main.ONOSip[ i ] ) )
109 print cellIp
110 main.ONOSbench.createCellFile( benchIp, cellName, "",
111 str( apps ), *cellIp )
112
113 main.step( "Apply cell to environment" )
114 cellResult = main.ONOSbench.setCell( cellName )
115 verifyResult = main.ONOSbench.verifyCell()
116 stepResult = cellResult and verifyResult
117 utilities.assert_equals( expect=main.TRUE,
118 actual=stepResult,
119 onpass="Successfully applied cell to " + \
120 "environment",
121 onfail="Failed to apply cell to environment " )
122
123 main.step( "Creating ONOS package" )
124 packageResult = main.ONOSbench.onosPackage()
125 stepResult = packageResult
126 utilities.assert_equals( expect=main.TRUE,
127 actual=stepResult,
128 onpass="Successfully created ONOS package",
129 onfail="Failed to create ONOS package" )
130
131 main.step( "Uninstalling ONOS package" )
132 onosUninstallResult = main.TRUE
133 for i in range( main.numCtrls ):
134 onosUninstallResult = onosUninstallResult and \
135 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
136 stepResult = onosUninstallResult
137 utilities.assert_equals( expect=main.TRUE,
138 actual=stepResult,
139 onpass="Successfully uninstalled ONOS package",
140 onfail="Failed to uninstall ONOS package" )
141 time.sleep( 5 )
142 main.step( "Installing ONOS package" )
143 onosInstallResult = main.TRUE
144 for i in range( main.numCtrls ):
145 onosInstallResult = onosInstallResult and \
146 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
147 stepResult = onosInstallResult
148 utilities.assert_equals( expect=main.TRUE,
149 actual=stepResult,
150 onpass="Successfully installed ONOS package",
151 onfail="Failed to install ONOS package" )
152
153 time.sleep( 20 )
154 main.step( "Starting ONOS service" )
155 stopResult = main.TRUE
156 startResult = main.TRUE
157 onosIsUp = main.TRUE
158 for i in range( main.numCtrls ):
159 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
160 if onosIsUp == main.TRUE:
161 main.log.report( "ONOS instance is up and ready" )
162 else:
163 main.log.report( "ONOS instance may not be up, stop and " +
164 "start ONOS again " )
165 for i in range( main.numCtrls ):
166 stopResult = stopResult and \
167 main.ONOSbench.onosStop( main.ONOSip[ i ] )
168 for i in range( main.numCtrls ):
169 startResult = startResult and \
170 main.ONOSbench.onosStart( main.ONOSip[ i ] )
171 stepResult = onosIsUp and stopResult and startResult
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
174 onpass="ONOS service is ready",
175 onfail="ONOS service did not start properly" )
176
177 main.step( "Start ONOS cli" )
178 cliResult = main.TRUE
179 for i in range( main.numCtrls ):
180 cliResult = cliResult and \
181 main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
182 stepResult = cliResult
183 utilities.assert_equals( expect=main.TRUE,
184 actual=stepResult,
185 onpass="Successfully start ONOS cli",
186 onfail="Failed to start ONOS cli" )
187
188 def CASE9( self, main ):
189 '''
190 Report errors/warnings/exceptions
191 '''
192 main.log.info("Error report: \n")
193 main.ONOSbench.logReport( globalONOSip[0],
194 [ "INFO","FOLLOWER","WARN",
195 "flow","ERROR","Except" ],
196 "s" )
197 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
198
kelvin-onlab10e8d392015-06-03 13:53:45 -0700199 def CASE1001( self, main ):
200 """
201 Test topology discovery
202 """
203 main.case( "Topology discovery test" )
kelvin-onlab9f108d72015-06-08 15:58:43 -0700204 main.step( "Torus 5-5 topology" )
205 main.topoName = "TORUS5-5"
206 mnCmd = "mn --topo=torus,5,5 --controller=remote,ip=$OC1 --mac"
kelvin-onlab10e8d392015-06-03 13:53:45 -0700207 stepResult = main.wrapper.testTopology( main,
208 mnCmd=mnCmd,
kelvin-onlab9f108d72015-06-08 15:58:43 -0700209 clean=False)
kelvin-onlab10e8d392015-06-03 13:53:45 -0700210 utilities.assert_equals( expect=main.TRUE,
211 actual=stepResult,
kelvin-onlab9f108d72015-06-08 15:58:43 -0700212 onpass="Torus 5-5 topology successful",
213 onfail="Torus 5-5 topology failed" )