blob: e7d2133e5284ca4771f7deefafbd8d0e38f5fc3d [file] [log] [blame]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -07001# ScaleOutTemplate --> LinkEventTP
andrew@onlab.us2ae3a112015-02-02 11:24:32 -08002#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os
9
10
11class LinkEventTP:
12
13 def __init__( self ):
14 self.default = ''
15
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070016 def CASE1( self, main ): #This is the initialization case
17 import os.path #this case will clean up all nodes
18 #but only node 1 isnodestarted in this case
19
20 global clusterCount #number of nodes running
21 global ONOSIp #list of ONOS IP addresses
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080022
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070023 clusterCount = 1
24 ONOSIp = [ 0 ]
25
26 #Load values from params file
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080027 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070030 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070033 maxNodes = int(main.params[ 'availableNodes' ])
34 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080036 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070037 deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
38 MNip = main.params[ 'TEST' ][ 'MN' ]
39
40 main.ONOSbench.handle.sendline("export TERM=vt100")
41 main.ONOSbench.handle.expect(":~")
42
43 #Populate ONOSIp with ips from params
44 for i in range(1, maxNodes + 1):
45 ipString = 'ip' + str(i)
46 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080047
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070048 #kill off all onos processes
49 main.log.step("Safety check, killing all ONOS processes")
50 main.log.step("before initiating enviornment setup")
51 for node in range(1, maxNodes + 1):
52 main.ONOSbench.onosDie(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080053
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070054 #construct the cell file
55 main.log.step("Creating cell file")
56 cellIp = []
57 for node in range (1, clusterCount + 1):
58 cellIp.append(ONOSIp[node])
59 main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
60
61 main.step( "Set Cell" )
62 main.ONOSbench.setCell(cellName)
63
64 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080065 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070066 for i in range(1, maxNodes + 1):
67 main.log.info(" Uninstalling ONOS " + str(i) )
68 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080069
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070070 myDistribution = []
71 for node in range (1, clusterCount + 1):
72 myDistribution.append(deviceDistribution[node-1])
73
74 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
75 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
76 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
77
78 #git step - skipable
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080079 main.step( "Git checkout and pull " + checkoutBranch )
80 if gitPull == 'on':
81 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
82 pullResult = main.ONOSbench.gitPull()
83
84 else:
85 checkoutResult = main.TRUE
86 pullResult = main.TRUE
87 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080088
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070089 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
90 if skipMvn != "yes":
91 mvnResult = main.ONOSbench.cleanInstall()
jenkins9301fd02015-02-10 14:13:33 -080092
93 #configuring file to enable flicker
94 main.log.step(" Configuring null provider to enable flicker. Flicker Rate = " + flickerRate )
95 homeDir = os.path.expanduser('~')
96 main.log.info(homeDir)
97 localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
98 filePath = homeDir + localPath
99 main.log.info(filePath)
100
101 neighborsString = ""
102 for node in range(1, maxNodes + 1):
103 neighborsString += ONOSIp[node]
104 if node < maxNodes:
105 neighborsString += ","
106
107 configFile = open(filePath, 'w+')
108 main.log.info("File opened")
109 configFile.write("# Sample configurations for the NullLinkProvider.\n")
110 configFile.write("# \n")
111 configFile.write("# If enabled, sets time between linkEvent generation\n")
112 configFile.write("# in milliseconds.\n")
113 configFile.write("#\n")
114 configFile.write("eventRate = " + flickerRate)
115 configFile.write("\n")
116 configFile.write("#Set order of islands to chain together, in a line.\n")
117 configFile.write("neighbors = " + neighborsString)
118 configFile.close()
119 main.log.info("Configuration completed")
120
121 ### configure event rate file ###
122 main.log.step("Writing Default Topology Provider config file")
123 localPath = main.params[ 'TEST' ][ 'configFile' ]
124 filePath = homeDir + localPath
125 main.log.info(filePath)
126 configFile = open(filePath, 'w+')
127 main.log.info("File Opened")
128 configFile.write("maxEvents = 1\n")
129 configFile.write("maxIdleMs = 0\n")
130 configFile.write("maxBatchMs = 0\n")
131 main.log.info("File written and closed")
132
133
134 devices_by_ip = ""
135 for node in range(1, maxNodes + 1):
136 devices_by_ip += (ONOSIp[node] + ":" + str(5))
137 if node < maxNodes:
138 devices_by_ip +=(",")
139
140 main.log.step("Configuring device provider")
141 localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg"
142 filePath = homeDir + localPath
143 main.log.info(filePath)
144 configFile = open(filePath, 'w+')
145 main.log.info("Device config file opened")
146 configFile.write("devConfigs = " + devices_by_ip)
147 configFile.close()
148 main.log.info("File closed")
149
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700150 logFileName = main.params[ 'TEST' ][ 'logFile' ]
151 logFile = open(logFileName, 'w+')
152 main.log.info("Created log File")
153 logFile.close()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800154
155 main.step( "Creating ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700156 packageResult = main.ONOSbench.onosPackage()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800157
158 main.step( "Installing ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700159 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800160
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700161 main.step( "Verify cells" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800162 verifyCellResult = main.ONOSbench.verifyCell()
163
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700164 main.step( "Enviornment setup and verification complete." )
165 main.ONOS1cli.startOnosCli( ONOSIp[1] )
166 main.step( "ONOS 1 is up and running." )
167 main.ONOSbench.handle.expect(":~") #there is a dangling sendline somewhere...
andrew@onlab.us8f9032d2015-03-11 15:50:49 -0700168
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800169 def CASE2( self, main ):
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700170 # This case increases the cluster size by whatever scale is
171 # Note: 'scale' is the size of the step
172 # if scaling is not a part of your test, simply run this case
173 # once after CASE1 to set up your enviornment for your desired
174 # cluster size. If scaling is a part of you test call this case each time
175 # you want to increase cluster size
176
177 ''
178 'Increase number of nodes and initiate CLI'
179 ''
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800180 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800181 global clusterCount
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700182
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800183 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700184 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
185 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
186 MNip = main.params[ 'TEST' ][ 'MN' ]
187 deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800188
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700189 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800190 clusterCount += scale
191
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700192 main.log.step( "Cleaning Enviornment..." )
193 for i in range(1, maxNodes + 1):
194 main.ONOSbench.onosDie(ONOSIp[i])
195 main.log.info(" Uninstalling ONOS " + str(i) )
196 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800197
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700198 myDistribution = []
199 for node in range (1, clusterCount + 1):
200 myDistribution.append(deviceDistribution[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800201
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700202 main.log.step("Creating cell file")
203 cellIp = []
204 for node in range (1, clusterCount + 1):
205 cellIp.append(ONOSIp[node])
206 main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800207
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700208 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
209 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
210 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800211
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700212 main.step( "Set Cell" )
213 main.ONOSbench.setCell(cellName)
214
215 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
216 for node in range(1, clusterCount + 1):
217 time.sleep(10)
218 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
219 main.ONOSbench.onosInstall( ONOSIp[node] )
220 exec "a = main.ONOS%scli.startOnosCli" %str(node)
221 a(ONOSIp[node])
andrew@onlab.us8f9032d2015-03-11 15:50:49 -0700222
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700223 for node in range(1, clusterCount + 1):
224 for i in range( 2 ):
225 isup = main.ONOSbench.isup( ONOSIp[node] )
226 if isup:
227 main.log.info("ONOS " + str(node) + " is up\n")
228 break
229 if not isup:
230 main.log.report( "ONOS " + str(node) + " didn't start!" )
231
232 def CASE3( self, main ):
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800233 import time
234 import json
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700235 import string
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800236 import csv
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700237 import os.path
238 import requests
239 import numpy
240
241 sustainability = float(main.params[ 'TEST' ][ 'linkgraphdif' ])
242 flickerRates = (main.params[ 'TEST' ][ 'flickerRates']).split(",")
243 homeDir = os.path.expanduser('~')
244
245 linkResult = main.FALSE
246 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800247
248 testDelay = main.params[ 'TEST' ][ 'wait']
249 time.sleep( float( testDelay ) )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700250
251 for node in range(1, clusterCount + 1):
252 main.log.info("Writing flicker file to node " + str(node))
253 main.ONOSbench.createNullLinkProviderFile( ONOSIp[node], eventRate=flickerRates[node-1], onNode=True )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800254
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800255 testDuration = main.params[ 'TEST' ][ 'duration' ]
256 stop = time.time() + float( testDuration )
257
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700258 msg = ( "Starting test loop for " + str(testDuration) + " seconds on a " + str(clusterCount) + " node cluster" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800259 main.log.info( msg )
260 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
261
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700262 linkResults = [0,0,0,0,0,0,0,0]
263 graphResults = [0,0,0,0,0,0,0,0]
264 JsonStr = [ 0,0,0,0,0,0,0,0 ]
265 JsonObj = [ 0,0,0,0,0,0,0,0 ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800266
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700267 while time.time() < stop:
268 time.sleep( float( logInterval ) )
269 for node in range(1, clusterCount+1):
270 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Link Events"|cut -d ' ' -f7 """)
271 main.ONOSbench.handle.expect(":~")
272 raw = (main.ONOSbench.handle.before).splitlines()
273 myresult = "--"
274 for word in raw:
275 if "m1" in word:
276 myresult = word
277 myresult = myresult.replace("m1=","")
278 break
279 if myresult == "--":
280 main.log.error("Parse error or no data error")
281 msg = ( "Node " + str(node) + " Link Event TP: " + str(myresult) )
282 main.log.info( msg )
283 linkResults[node] = round(float(myresult),2)
284 myLinkRate = round(float(myresult),2)
285
286 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Graph Events"|cut -d ' ' -f7 """)
287 main.ONOSbench.handle.expect(":~")
288 raw = (main.ONOSbench.handle.before).splitlines()
289 myresult = "--"
290 for word in raw:
291 if "m1" in word:
292 myresult = word
293 myresult = myresult.replace("m1=","")
294 break
295 if myresult == "--":
296 main.log.error("Parse error or no data error")
297 msg = ( "Node " + str(node) + " Graph Event TP: " + str(myresult) )
298 main.log.info( msg )
299 graphResults[node] = round(float(myresult),2)
300 myGraphRate = round(float(myresult),2)
301
302 difLinkGraph = float(myLinkRate - myGraphRate)
303 difLinkGraph = numpy.absolute(difLinkGraph)
304 main.log.info("Node " + str(node) + " abs(Link event - Graph event) = " + str(difLinkGraph))
305 tempx = numpy.divide(difLinkGraph,float(myLinkRate))
306 if tempx > sustainability:
307 main.log.error("Difference in link event rate and graph event rate above " + str(sustainability) + " tolerance")
308 print("")
309
310 print("")
311 print("")
312
313 main.log.report("Final Link Event TP Results on " + str(clusterCount) + " node cluster")
314 main.log.report("_______________________________________________")
315 for node in range(1, clusterCount+1):
316 main.log.report("Node " + str(node) + ": " + str(linkResults[node]))
317
318 print("")
319 print("")
320
321 main.log.report("Final Graph Event TP Results on " + str(clusterCount) + " node cluster")
322 main.log.report("_______________________________________________")
323 for node in range(1, clusterCount+1):
324 main.log.report("Node " + str(node) + ": " + str(graphResults[node]))
325
326 #################################################################################
327 # Data Logging
328
329 logFileName = main.params[ 'TEST' ][ 'logFile' ]
330 logFile = open(logFileName, 'a')
331 main.log.info("Log file opened")
332 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
333
334 for node in range (1, clusterCount + 1):
335 # replare -> logFile.write( str(clusterCount) + "," + flickerNodes + "," )
336 logFile.write("'" + "baremetal" + str(node) + "'," )
337 logFile.write( testDuration + "," )
338 logFile.write( flickerRate + "," )
339 logFile.write( str(linkResults[node]) + "," )
340 logFile.write( str(graphResults[node]) + "\n" )
341
342 logFile.close()
343 main.log.info("Log file closed")
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360