blob: b2e2a6a2b5f7f1301d98868587e36f601b0901c0 [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-onlab5c2df432015-06-11 17:29:56 -070050 main.ONOSport = []
kelvin-onlab10e8d392015-06-03 13:53:45 -070051 main.hostsData = {}
kelvin-onlabfa6ada82015-06-11 13:06:24 -070052 main.topoName = " "
kelvin-onlaba297c4d2015-06-01 13:53:55 -070053 PULLCODE = False
54 if main.params[ 'GIT' ][ 'pull' ] == 'True':
55 PULLCODE = True
56 main.case( "Setting up test environment" )
57 main.CLIs = []
kelvin-onlab10e8d392015-06-03 13:53:45 -070058 main.nodes = []
kelvin-onlaba297c4d2015-06-01 13:53:55 -070059 for i in range( 1, int( main.numCtrls ) + 1 ):
60 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
kelvin-onlab10e8d392015-06-03 13:53:45 -070061 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
kelvin-onlab5c2df432015-06-11 17:29:56 -070062 main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + str( i ) ] )
kelvin-onlaba297c4d2015-06-01 13:53:55 -070063
64 # -- INIT SECTION, ONLY RUNS ONCE -- #
65 if init == False:
66 init = True
67
kelvin-onlaba297c4d2015-06-01 13:53:55 -070068 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
69 main.numCtrls = int( main.scale[ 0 ] )
70
71 if PULLCODE:
72 main.step( "Git checkout and pull " + gitBranch )
73 main.ONOSbench.gitCheckout( gitBranch )
74 gitPullResult = main.ONOSbench.gitPull()
75 if gitPullResult == main.ERROR:
76 main.log.error( "Error pulling git branch" )
77 main.step( "Using mvn clean & install" )
78 cleanInstallResult = main.ONOSbench.cleanInstall()
79 stepResult = cleanInstallResult
80 utilities.assert_equals( expect=main.TRUE,
81 actual=stepResult,
82 onpass="Successfully compiled " +
83 "latest ONOS",
84 onfail="Failed to compile " +
85 "latest ONOS" )
86 else:
87 main.log.warn( "Did not pull new code so skipping mvn " +
88 "clean install" )
89
90 globalONOSip = main.ONOSbench.getOnosIps()
91 maxNodes = ( len(globalONOSip) - 2 )
92
93 main.numCtrls = int( main.scale[ 0 ] )
94 main.scale.remove( main.scale[ 0 ] )
95
96 main.ONOSip = []
97 for i in range( maxNodes ):
98 main.ONOSip.append( globalONOSip[i] )
99
100 #kill off all onos processes
101 main.log.info( "Safety check, killing all ONOS processes" +
102 " before initiating enviornment setup" )
103 for i in range(maxNodes):
104 main.ONOSbench.onosDie( globalONOSip[ i ] )
105
106 print "NODE COUNT = ", main.numCtrls
107 main.log.info( "Creating cell file" )
108 cellIp = []
109 for i in range( main.numCtrls ):
110 cellIp.append( str( main.ONOSip[ i ] ) )
111 print cellIp
112 main.ONOSbench.createCellFile( benchIp, cellName, "",
113 str( apps ), *cellIp )
114
115 main.step( "Apply cell to environment" )
116 cellResult = main.ONOSbench.setCell( cellName )
117 verifyResult = main.ONOSbench.verifyCell()
118 stepResult = cellResult and verifyResult
119 utilities.assert_equals( expect=main.TRUE,
120 actual=stepResult,
121 onpass="Successfully applied cell to " + \
122 "environment",
123 onfail="Failed to apply cell to environment " )
124
125 main.step( "Creating ONOS package" )
126 packageResult = main.ONOSbench.onosPackage()
127 stepResult = packageResult
128 utilities.assert_equals( expect=main.TRUE,
129 actual=stepResult,
130 onpass="Successfully created ONOS package",
131 onfail="Failed to create ONOS package" )
132
133 main.step( "Uninstalling ONOS package" )
134 onosUninstallResult = main.TRUE
135 for i in range( main.numCtrls ):
136 onosUninstallResult = onosUninstallResult and \
137 main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
138 stepResult = onosUninstallResult
139 utilities.assert_equals( expect=main.TRUE,
140 actual=stepResult,
141 onpass="Successfully uninstalled ONOS package",
142 onfail="Failed to uninstall ONOS package" )
143 time.sleep( 5 )
144 main.step( "Installing ONOS package" )
145 onosInstallResult = main.TRUE
146 for i in range( main.numCtrls ):
147 onosInstallResult = onosInstallResult and \
148 main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
149 stepResult = onosInstallResult
150 utilities.assert_equals( expect=main.TRUE,
151 actual=stepResult,
152 onpass="Successfully installed ONOS package",
153 onfail="Failed to install ONOS package" )
154
kelvin-onlabfa6ada82015-06-11 13:06:24 -0700155 time.sleep( 10 )
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700156 main.step( "Starting ONOS service" )
157 stopResult = main.TRUE
158 startResult = main.TRUE
159 onosIsUp = main.TRUE
160 for i in range( main.numCtrls ):
161 onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
162 if onosIsUp == main.TRUE:
163 main.log.report( "ONOS instance is up and ready" )
164 else:
165 main.log.report( "ONOS instance may not be up, stop and " +
166 "start ONOS again " )
167 for i in range( main.numCtrls ):
168 stopResult = stopResult and \
169 main.ONOSbench.onosStop( main.ONOSip[ i ] )
170 for i in range( main.numCtrls ):
171 startResult = startResult and \
172 main.ONOSbench.onosStart( main.ONOSip[ i ] )
173 stepResult = onosIsUp and stopResult and startResult
174 utilities.assert_equals( expect=main.TRUE,
175 actual=stepResult,
176 onpass="ONOS service is ready",
177 onfail="ONOS service did not start properly" )
178
kelvin-onlaba297c4d2015-06-01 13:53:55 -0700179 def CASE9( self, main ):
180 '''
181 Report errors/warnings/exceptions
182 '''
183 main.log.info("Error report: \n")
184 main.ONOSbench.logReport( globalONOSip[0],
185 [ "INFO","FOLLOWER","WARN",
186 "flow","ERROR","Except" ],
187 "s" )
188 #main.ONOSbench.logReport( globalONOSip[1], [ "INFO" ], "d" )
189
kelvin-onlab10e8d392015-06-03 13:53:45 -0700190 def CASE1001( self, main ):
191 """
192 Test topology discovery
193 """
194 main.case( "Topology discovery test" )
kelvin-onlabf512e942015-06-08 19:42:59 -0700195
kelvin-onlabf512e942015-06-08 19:42:59 -0700196
kelvin-onlab9f108d72015-06-08 15:58:43 -0700197 main.step( "Torus 5-5 topology" )
198 main.topoName = "TORUS5-5"
kelvin-onlab5c2df432015-06-11 17:29:56 -0700199 mnCmd = "mn --topo=torus,5,5 --mac"
kelvin-onlab10e8d392015-06-03 13:53:45 -0700200 stepResult = main.wrapper.testTopology( main,
201 mnCmd=mnCmd,
kelvin-onlabbf456822015-06-22 16:53:06 -0700202 clean=False )
kelvin-onlab10e8d392015-06-03 13:53:45 -0700203 utilities.assert_equals( expect=main.TRUE,
204 actual=stepResult,
kelvin-onlab9f108d72015-06-08 15:58:43 -0700205 onpass="Torus 5-5 topology successful",
206 onfail="Torus 5-5 topology failed" )
kelvin-onlabf512e942015-06-08 19:42:59 -0700207
kelvin-onlabbf456822015-06-22 16:53:06 -0700208 main.topoName = "TREE3-3"
209 stepResult = main.TRUE
210 main.step( "Tree 3-3 topology" )
211 mnCmd = "mn --topo=tree,3,3 --mac"
212 stepResult = main.wrapper.testTopology( main,
213 mnCmd=mnCmd,
214 clean=True )
215 utilities.assert_equals( expect=main.TRUE,
216 actual=stepResult,
217 onpass="Tree 3-3 topology successful",
218 onfail="Tree 3-3 topology failed" )