blob: faaec26530fc919e147e874525acc6ae804a965d [file] [log] [blame]
andrew@onlab.usc400b112015-01-21 15:33:19 -08001# ScaleOutTemplate --> IntentsLoad
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os
9
10
11class IntentsLoad:
12
13 def __init__( self ):
14 self.default = ''
15
16 def CASE1( self, main ):
17
18 global clusterCount
19 clusterCount = 1
20
21 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
22 gitPull = main.params[ 'GIT' ][ 'autopull' ]
23 cellName = main.params[ 'ENV' ][ 'cellName' ]
24 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
25 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
26 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
27 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
28 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
29 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
30
31 main.log.step( "Cleaning Enviornment..." )
32 main.ONOSbench.onosUninstall( ONOS1Ip )
33 main.ONOSbench.onosUninstall( ONOS2Ip )
34 main.ONOSbench.onosUninstall( ONOS3Ip )
35
36 main.step( "Git checkout and pull " + checkoutBranch )
37 if gitPull == 'on':
38 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
39 pullResult = main.ONOSbench.gitPull()
40
41 else:
42 checkoutResult = main.TRUE
43 pullResult = main.TRUE
44 main.log.info( "Skipped git checkout and pull" )
45
46 #mvnResult = main.ONOSbench.cleanInstall()
47
48 main.step( "Set cell for ONOS cli env" )
49 main.ONOS1cli.setCell( cellName )
50 main.ONOS2cli.setCell( cellName )
51 main.ONOS3cli.setCell( cellName )
52
53 main.step( "Creating ONOS package" )
54 packageResult = main.ONOSbench.onosPackage() # no file or directory
55
56 main.step( "Installing ONOS package" )
57 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
58
59 cellName = main.params[ 'ENV' ][ 'cellName' ]
60 main.step( "Applying cell file to environment" )
61 cellApplyResult = main.ONOSbench.setCell( cellName )
62 main.step( "verify cells" )
63 verifyCellResult = main.ONOSbench.verifyCell()
64
65 main.step( "Set cell for ONOS cli env" )
66 main.ONOS1cli.setCell( cellName )
67
68 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
69
70 def CASE2( self, main ):
71 """
72 Increase number of nodes and initiate CLI
73 """
74 import time
75
76 global clusterCount
77
78 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
79 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
80 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
81 #ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
82 #ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
83 #ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
84 #ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
85 cellName = main.params[ 'ENV' ][ 'cellName' ]
86 scale = int( main.params[ 'SCALE' ] )
87
88 # Cluster size increased everytime the case is defined
89 clusterCount += scale
90
91 main.log.report( "Increasing cluster size to " +
92 str( clusterCount ) )
93 installResult = main.FALSE
94
95 if scale == 2:
96 if clusterCount == 3:
97 main.log.info( "Installing nodes 2 and 3" )
98 install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
99 install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
100 cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
101 cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
102 """
103 elif clusterCount == 5:
104 main.log.info( "Installing nodes 4 and 5" )
105 node4Result = main.ONOSbench.onosInstall( node=ONOS4Ip )
106 node5Result = main.ONOSbench.onosInstall( node=ONOS5Ip )
107 installResult = node4Result and node5Result
108 time.sleep( 5 )
109 main.ONOS4cli.startOnosCli( ONOS4Ip )
110 main.ONOS5cli.startOnosCli( ONOS5Ip )
111 elif clusterCount == 7:
112 main.log.info( "Installing nodes 4 and 5" )
113 node6Result = main.ONOSbench.onosInstall( node=ONOS6Ip )
114 node7Result = main.ONOSbench.onosInstall( node=ONOS7Ip )
115 installResult = node6Result and node7Result
116 time.sleep( 5 )
117 main.ONOS6cli.startOnosCli( ONOS6Ip )
118 main.ONOS7cli.startOnosCli( ONOS7Ip )
119 """
120 if scale == 1:
121 if clusterCount == 2:
122 main.log.info( "Installing node 2" )
123 install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
124 cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
125
126 if clusterCount == 3:
127 main.log.info( "Installing node 3" )
128 install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
129 cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
130
131 def CASE3( self, main ):
132 import time
133 import json
134 import string
135
136 intentsRate = main.params[ 'JSON' ][ 'intents_rate' ]
137
138 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
139
140 main.Mininet1.assignSwController(
141 sw="1",
142 ip1=ONOS1Ip,
143 port1=defaultSwPort )
144 main.Mininet1.assignSwController(
145 sw="2",
146 ip1=ONOS1Ip,
147 port1=defaultSwPort )
148 main.Mininet1.assignSwController(
149 sw="3",
150 ip1=ONOS1Ip,
151 port1=defaultSwPort )
152 main.Mininet1.assignSwController(
153 sw="4",
154 ip1=ONOS1Ip,
155 port1=defaultSwPort )
156 main.Mininet1.assignSwController(
157 sw="5",
158 ip1=ONOS1Ip,
159 port1=defaultSwPort )
160 main.Mininet1.assignSwController(
161 sw="6",
162 ip1=ONOS1Ip,
163 port1=defaultSwPort )
164 main.Mininet1.assignSwController(
165 sw="7",
166 ip1=ONOS1Ip,
167 port1=defaultSwPort )
168
169 mnArp = main.params[ 'TEST' ][ 'arping' ]
170 main.Mininet1.handle.sendline( mnArp )
171
172 generateLoad = main.params[ 'TEST' ][ 'loadstart' ]
173
174 main.ONOS1.handle.sendline( generateLoad )
175 main.ONOS1.handle.expect( "sdn" )
176 print( "before: ", main.ONOS1.handle.before )
177 print( "after: ", main.ONOS1.handle.after )
178
179 loadConfirm = main.ONOS1.handle.after
180 if loadConfirm == "{}":
181 main.log.info( "Load started" )
182
183 else:
184 main.log.error( "Load start failure" )
185 main.log.error( "expected '{}', got: " + str( loadConfirm ) )
186
187 devicesJsonStr = main.ONOS1cli.devices()
188 devicesJsonObj = json.loads( devicesJsonStr )
189
190 getMetric = main.params[ 'TEST' ][ 'metric1' ]
191 testDuration = main.params[ 'TEST' ][ 'duration' ]
192 stop = time.time() + float( testDuration )
193
194 main.log.info( "Starting test loop..." )
195 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
196
197 while time.time() < stop:
198 time.sleep( float( logInterval ) )
199
200 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
201 intentsJsonObj1 = json.loads( intentsJsonStr1 )
202 main.log.info( "Node 1 rate: " +
203 str( intentsJsonObj1[ intentsRate ][ 'm1_rate' ] ) )
204 lastRate1 = intentsJsonObj1[ intentsRate ][ 'm1_rate' ]
205
206 stopLoad = main.params[ 'TEST' ][ 'loadstop' ]
207 main.ONOS1.handle.sendline( stopLoad )
208
209 msg = ( "Final rate on node 1: " + str( lastRate1 ) )
210 main.log.report( msg )
211
212 def CASE4( self, main ): # 2 node scale
213 import time
214 import json
215 import string
216
217 intentsRate = main.params[ 'JSON' ][ 'intents_rate' ]
218
219 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
220
221 main.Mininet1.assignSwController(
222 sw="1",
223 ip1=ONOS1Ip,
224 port1=defaultSwPort )
225 main.Mininet1.assignSwController(
226 sw="2",
227 ip1=ONOS2Ip,
228 port1=defaultSwPort )
229 main.Mininet1.assignSwController(
230 sw="3",
231 ip1=ONOS1Ip,
232 port1=defaultSwPort )
233 main.Mininet1.assignSwController(
234 sw="4",
235 ip1=ONOS2Ip,
236 port1=defaultSwPort )
237 main.Mininet1.assignSwController(
238 sw="5",
239 ip1=ONOS1Ip,
240 port1=defaultSwPort )
241 main.Mininet1.assignSwController(
242 sw="6",
243 ip1=ONOS2Ip,
244 port1=defaultSwPort )
245 main.Mininet1.assignSwController(
246 sw="7",
247 ip1=ONOS1Ip,
248 port1=defaultSwPort )
249
250 mnArp = main.params[ 'TEST' ][ 'arping' ]
251 main.Mininet1.handle.sendline( mnArp )
252
253 generateLoad = main.params[ 'TEST' ][ 'loadstart' ]
254
255 main.ONOS1.handle.sendline( generateLoad )
256 main.ONOS2.handle.sendline( generateLoad )
257
258 devicesJsonStr1 = main.ONOS1cli.devices()
259 devicesJsonObj1 = json.loads( devicesJsonStr1 )
260 devicesJsonStr2 = main.ONOS2cli.devices()
261 devicesJsonObj2 = json.loads( devicesJsonStr2 )
262
263 getMetric = main.params[ 'TEST' ][ 'metric1' ]
264 testDuration = main.params[ 'TEST' ][ 'duration' ]
265 stop = time.time() + float( testDuration )
266
267 main.log.info( "Starting test loop..." )
268 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
269
270 while time.time() < stop:
271 time.sleep( float( logInterval ) )
272
273 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
274 intentsJsonObj1 = json.loads( intentsJsonStr1 )
275 main.log.info( "Node 1 rate: " +
276 str( intentsJsonObj1[ intentsRate ][ 'm1_rate' ] ) )
277 lastRate1 = intentsJsonObj1[ intentsRate ][ 'm1_rate' ]
278
279 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
280 intentsJsonObj2 = json.loads( intentsJsonStr2 )
281 main.log.info( "Node 2 rate: " +
282 str( intentsJsonObj2[ intentsRate ][ 'm1_rate' ] ) )
283 lastRate2 = intentsJsonObj2[ intentsRate ][ 'm1_rate' ]
284
285 stopLoad = main.params[ 'TEST' ][ 'loadstop' ]
286 main.ONOS1.handle.sendline( stopLoad )
287 main.ONOS2.handle.sendline( stopLoad )
288
289 msg = ( "Final rate on node 1: " + str( lastRate1 ) )
290 main.log.report( msg )
291
292 msg = ( "Final rate on node 2: " + str( lastRate2 ) )
293 main.log.report( msg )