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