blob: 2458c71d73ca78fd0a0bb678f8a845597761c5e8 [file] [log] [blame]
kelvin-onlab1d381fe2015-07-14 16:24:56 -07001
2# Testing network scalability, this test suite scales up a network topology
3# using mininet and verifies ONOS stability
4
kelvin-onlabf0336882015-07-21 11:09:22 -07005class SAMPscaleTopo:
kelvin-onlab1d381fe2015-07-14 16:24:56 -07006
7 def __init__( self ):
8 self.default = ''
9
10 def CASE1( self, main ):
11 import time
12 import os
13 import imp
14
15 """
16 - Construct tests variables
17 - GIT ( optional )
18 - Checkout ONOS master branch
19 - Pull latest ONOS code
20 - Building ONOS ( optional )
21 - Install ONOS package
22 - Build ONOS package
23 """
24
25 main.case( "Constructing test variables and building ONOS package" )
26 main.step( "Constructing test variables" )
27 stepResult = main.FALSE
28
29 # Test variables
30 main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
31 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
32 gitBranch = main.params[ 'GIT' ][ 'branch' ]
33 main.dependencyPath = main.testOnDirectory + \
34 main.params[ 'DEPENDENCY' ][ 'path' ]
35 main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
36 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
37 main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
38 main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
39 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
40 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
41 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
42 main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] )
43 gitPull = main.params[ 'GIT' ][ 'pull' ]
44 main.cellData = {} # for creating cell file
45 main.hostsData = {}
46 main.CLIs = []
47 main.ONOSip = []
48
49 main.ONOSip = main.ONOSbench.getOnosIps()
50 print main.ONOSip
51
52 # Assigning ONOS cli handles to a list
53 for i in range( 1, main.maxNodes + 1 ):
54 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
55
56 # -- INIT SECTION, ONLY RUNS ONCE -- #
57 main.startUp = imp.load_source( wrapperFile1,
58 main.dependencyPath +
59 wrapperFile1 +
60 ".py" )
61 main.scaleTopoFunction = imp.load_source( wrapperFile2,
62 main.dependencyPath +
63 wrapperFile2 +
64 ".py" )
65
66 copyResult = main.ONOSbench.copyMininetFile( main.topology,
67 main.dependencyPath,
68 main.Mininet1.user_name,
69 main.Mininet1.ip_address )
70 if main.CLIs:
71 stepResult = main.TRUE
72 else:
73 main.log.error( "Did not properly created list of ONOS CLI handle" )
74 stepResult = main.FALSE
75
76 utilities.assert_equals( expect=main.TRUE,
77 actual=stepResult,
78 onpass="Successfully construct " +
79 "test variables ",
80 onfail="Failed to construct test variables" )
81
82 if gitPull == 'True':
83 main.step( "Building ONOS in " + gitBranch + " branch" )
84 onosBuildResult = main.startUp.onosBuild( main, gitBranch )
85 stepResult = onosBuildResult
86 utilities.assert_equals( expect=main.TRUE,
87 actual=stepResult,
88 onpass="Successfully compiled " +
89 "latest ONOS",
90 onfail="Failed to compile " +
91 "latest ONOS" )
92 else:
93 main.log.warn( "Did not pull new code so skipping mvn " +
94 "clean install" )
95
96 def CASE2( self, main ):
97 """
98 - Set up cell
99 - Create cell file
100 - Set cell file
101 - Verify cell file
102 - Kill ONOS process
103 - Uninstall ONOS cluster
104 - Verify ONOS start up
105 - Install ONOS cluster
106 - Connect to cli
107 """
108
109 # main.scale[ 0 ] determines the current number of ONOS controller
110 main.numCtrls = int( main.scale[ 0 ] )
111
112 main.case( "Starting up " + str( main.numCtrls ) +
113 " node(s) ONOS cluster" )
114
115 #kill off all onos processes
116 main.log.info( "Safety check, killing all ONOS processes" +
117 " before initiating enviornment setup" )
118
119 for i in range( main.maxNodes ):
120 main.ONOSbench.onosDie( main.ONOSip[ i ] )
121
122 print "NODE COUNT = ", main.numCtrls
123
124 tempOnosIp = []
125 for i in range( main.numCtrls ):
126 tempOnosIp.append( main.ONOSip[i] )
127
128 main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
129 "temp", main.Mininet1.ip_address,
130 main.apps,
131 tempOnosIp )
132
133 main.step( "Apply cell to environment" )
134 cellResult = main.ONOSbench.setCell( "temp" )
135 verifyResult = main.ONOSbench.verifyCell()
136 stepResult = cellResult and verifyResult
137 utilities.assert_equals( expect=main.TRUE,
138 actual=stepResult,
139 onpass="Successfully applied cell to " + \
140 "environment",
141 onfail="Failed to apply cell to environment " )
142
143 main.step( "Creating ONOS package" )
144 packageResult = main.ONOSbench.onosPackage()
145 stepResult = packageResult
146 utilities.assert_equals( expect=main.TRUE,
147 actual=stepResult,
148 onpass="Successfully created ONOS package",
149 onfail="Failed to create ONOS package" )
150
151
152 # Remove the first element in main.scale list
153 main.scale.remove( main.scale[ 0 ] )
154
155 def CASE9( self, main ):
156 '''
157 Report errors/warnings/exceptions
158 '''
159 main.log.info("Error report: \n" )
160 main.ONOSbench.logReport( main.ONOSip[ 0 ],
161 [ "INFO",
162 "FOLLOWER",
163 "WARN",
164 "flow",
165 "ERROR",
166 "Except" ],
167 "s" )
168
169 def CASE11( self, main ):
170 """
171 Start mininet
172 """
173 main.log.report( "Start Mininet topology" )
174 main.log.case( "Start Mininet topology" )
175
176 main.step( "Starting Mininet Topology" )
177 topoResult = main.Mininet1.startNet( topoFile=topology )
178 stepResult = topoResult
179 utilities.assert_equals( expect=main.TRUE,
180 actual=stepResult,
181 onpass="Successfully loaded topology",
182 onfail="Failed to load topology" )
183 # Exit if topology did not load properly
184 if not topoResult:
185 main.cleanup()
186 main.exit()
187
188 def CASE1001( self, main ):
189 """
190 Test topology discovery
191 """
192 main.case( "Topology discovery test" )
193
194
195 main.step( "Torus 5-5 topology" )
196 main.topoName = "TORUS5-5"
197 mnCmd = "mn --topo=torus,5,5 --mac"
198 stepResult = main.scaleTopoFunction.testTopology( main,
199 mnCmd=mnCmd,
200 clean=False )
201 utilities.assert_equals( expect=main.TRUE,
202 actual=stepResult,
203 onpass="Torus 5-5 topology successful",
204 onfail="Torus 5-5 topology failed" )
205
206 main.topoName = "TREE3-3"
207 stepResult = main.TRUE
208 main.step( "Tree 3-3 topology" )
209 mnCmd = "mn --topo=tree,3,3 --mac"
210 stepResult = main.scaleTopoFunction.testTopology( main,
211 mnCmd=mnCmd,
212 clean=True )
213 utilities.assert_equals( expect=main.TRUE,
214 actual=stepResult,
215 onpass="Tree 3-3 topology successful",
216 onfail="Tree 3-3 topology failed" )