blob: a4bc0aa6649326f493bf919be0a41d2908b7feea [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' ]
jenkinsb8dd1aa2015-03-24 10:31:10 -070039 logFileName = main.params[ 'TEST' ][ 'logFile' ]
40 onBaremetal = main.params[ 'ENV' ][ 'onBaremetal' ]
41
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070042 main.ONOSbench.handle.sendline("export TERM=vt100")
43 main.ONOSbench.handle.expect(":~")
jenkinsb8dd1aa2015-03-24 10:31:10 -070044 homeDir = os.path.expanduser('~')
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070045
46 #Populate ONOSIp with ips from params
47 for i in range(1, maxNodes + 1):
48 ipString = 'ip' + str(i)
49 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080050
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070051 #kill off all onos processes
52 main.log.step("Safety check, killing all ONOS processes")
53 main.log.step("before initiating enviornment setup")
54 for node in range(1, maxNodes + 1):
55 main.ONOSbench.onosDie(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080056
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070057 #construct the cell file
58 main.log.step("Creating cell file")
59 cellIp = []
60 for node in range (1, clusterCount + 1):
61 cellIp.append(ONOSIp[node])
62 main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
63
64 main.step( "Set Cell" )
65 main.ONOSbench.setCell(cellName)
66
67 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080068 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070069 for i in range(1, maxNodes + 1):
70 main.log.info(" Uninstalling ONOS " + str(i) )
71 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080072
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070073 myDistribution = []
74 for node in range (1, clusterCount + 1):
75 myDistribution.append(deviceDistribution[node-1])
76
77 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
78 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
79 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
80
81 #git step - skipable
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080082 main.step( "Git checkout and pull " + checkoutBranch )
83 if gitPull == 'on':
84 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
85 pullResult = main.ONOSbench.gitPull()
86
87 else:
88 checkoutResult = main.TRUE
89 pullResult = main.TRUE
90 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080091
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070092 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
93 if skipMvn != "yes":
94 mvnResult = main.ONOSbench.cleanInstall()
jenkins9301fd02015-02-10 14:13:33 -080095
jenkins9301fd02015-02-10 14:13:33 -080096 ### configure event rate file ###
97 main.log.step("Writing Default Topology Provider config file")
98 localPath = main.params[ 'TEST' ][ 'configFile' ]
99 filePath = homeDir + localPath
100 main.log.info(filePath)
101 configFile = open(filePath, 'w+')
102 main.log.info("File Opened")
103 configFile.write("maxEvents = 1\n")
104 configFile.write("maxIdleMs = 0\n")
105 configFile.write("maxBatchMs = 0\n")
106 main.log.info("File written and closed")
jenkins9301fd02015-02-10 14:13:33 -0800107 configFile.close()
jenkins9301fd02015-02-10 14:13:33 -0800108
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700109 logFile = open(logFileName, 'w+')
110 main.log.info("Created log File")
111 logFile.close()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800112
jenkinsb8dd1aa2015-03-24 10:31:10 -0700113 if onBaremetal == "true":
114 filename = "/onos/tools/package/bin/onos-service"
115 serviceConfig = open(homeDir + filename, 'w+')
116 serviceConfig.write("#!/bin/bash\n ")
117 serviceConfig.write("#------------------------------------- \n ")
118 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
119 serviceConfig.write("#------------------------------------- \n ")
120 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
121 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms256m -Xmx8G}" \n """)
122 serviceConfig.write("")
123 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
124 serviceConfig.write("")
125 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
126 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
127 serviceConfig.close()
128
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800129 main.step( "Creating ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700130 packageResult = main.ONOSbench.onosPackage()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800131
132 main.step( "Installing ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700133 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800134
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700135 main.step( "Verify cells" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800136 verifyCellResult = main.ONOSbench.verifyCell()
137
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700138 main.step( "Enviornment setup and verification complete." )
139 main.ONOS1cli.startOnosCli( ONOSIp[1] )
140 main.step( "ONOS 1 is up and running." )
141 main.ONOSbench.handle.expect(":~") #there is a dangling sendline somewhere...
andrew@onlab.us8f9032d2015-03-11 15:50:49 -0700142
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800143 def CASE2( self, main ):
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700144 # This case increases the cluster size by whatever scale is
145 # Note: 'scale' is the size of the step
146 # if scaling is not a part of your test, simply run this case
147 # once after CASE1 to set up your enviornment for your desired
148 # cluster size. If scaling is a part of you test call this case each time
149 # you want to increase cluster size
150
151 ''
152 'Increase number of nodes and initiate CLI'
153 ''
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800154 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800155 global clusterCount
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700156
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800157 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700158 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
159 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
160 MNip = main.params[ 'TEST' ][ 'MN' ]
161 deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800162
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700163 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800164 clusterCount += scale
165
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700166 main.log.step( "Cleaning Enviornment..." )
167 for i in range(1, maxNodes + 1):
168 main.ONOSbench.onosDie(ONOSIp[i])
169 main.log.info(" Uninstalling ONOS " + str(i) )
170 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800171
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700172 myDistribution = []
173 for node in range (1, clusterCount + 1):
174 myDistribution.append(deviceDistribution[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800175
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700176 main.log.step("Creating cell file")
177 cellIp = []
178 for node in range (1, clusterCount + 1):
179 cellIp.append(ONOSIp[node])
180 main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800181
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700182 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
183 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
184 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800185
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700186 main.step( "Set Cell" )
187 main.ONOSbench.setCell(cellName)
188
jenkinsb8dd1aa2015-03-24 10:31:10 -0700189 main.step( "Packaging" )
190 main.ONOSbench.onosPackage()
191
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700192 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
193 for node in range(1, clusterCount + 1):
194 time.sleep(10)
195 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
jenkinsb8dd1aa2015-03-24 10:31:10 -0700196 main.ONOSbench.onosInstall( node=ONOSIp[node] )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700197 exec "a = main.ONOS%scli.startOnosCli" %str(node)
198 a(ONOSIp[node])
andrew@onlab.us8f9032d2015-03-11 15:50:49 -0700199
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700200 for node in range(1, clusterCount + 1):
201 for i in range( 2 ):
202 isup = main.ONOSbench.isup( ONOSIp[node] )
203 if isup:
204 main.log.info("ONOS " + str(node) + " is up\n")
205 break
206 if not isup:
207 main.log.report( "ONOS " + str(node) + " didn't start!" )
208
209 def CASE3( self, main ):
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800210 import time
211 import json
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700212 import string
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800213 import csv
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700214 import os.path
215 import requests
216 import numpy
217
218 sustainability = float(main.params[ 'TEST' ][ 'linkgraphdif' ])
219 flickerRates = (main.params[ 'TEST' ][ 'flickerRates']).split(",")
220 homeDir = os.path.expanduser('~')
221
222 linkResult = main.FALSE
223 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800224
jenkinsb8dd1aa2015-03-24 10:31:10 -0700225 testDelay = main.params[ 'TEST' ][ 'wait' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700226
227 for node in range(1, clusterCount + 1):
228 main.log.info("Writing flicker file to node " + str(node))
229 main.ONOSbench.createNullLinkProviderFile( ONOSIp[node], eventRate=flickerRates[node-1], onNode=True )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800230
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800231 testDuration = main.params[ 'TEST' ][ 'duration' ]
232 stop = time.time() + float( testDuration )
233
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700234 msg = ( "Starting test loop for " + str(testDuration) + " seconds on a " + str(clusterCount) + " node cluster" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800235 main.log.info( msg )
236 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
237
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700238 linkResults = [0,0,0,0,0,0,0,0]
239 graphResults = [0,0,0,0,0,0,0,0]
240 JsonStr = [ 0,0,0,0,0,0,0,0 ]
241 JsonObj = [ 0,0,0,0,0,0,0,0 ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800242
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700243 while time.time() < stop:
244 time.sleep( float( logInterval ) )
245 for node in range(1, clusterCount+1):
246 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Link Events"|cut -d ' ' -f7 """)
247 main.ONOSbench.handle.expect(":~")
248 raw = (main.ONOSbench.handle.before).splitlines()
249 myresult = "--"
250 for word in raw:
251 if "m1" in word:
252 myresult = word
253 myresult = myresult.replace("m1=","")
254 break
255 if myresult == "--":
256 main.log.error("Parse error or no data error")
257 msg = ( "Node " + str(node) + " Link Event TP: " + str(myresult) )
258 main.log.info( msg )
259 linkResults[node] = round(float(myresult),2)
260 myLinkRate = round(float(myresult),2)
261
262 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Graph Events"|cut -d ' ' -f7 """)
263 main.ONOSbench.handle.expect(":~")
264 raw = (main.ONOSbench.handle.before).splitlines()
265 myresult = "--"
266 for word in raw:
267 if "m1" in word:
268 myresult = word
269 myresult = myresult.replace("m1=","")
270 break
271 if myresult == "--":
272 main.log.error("Parse error or no data error")
273 msg = ( "Node " + str(node) + " Graph Event TP: " + str(myresult) )
274 main.log.info( msg )
275 graphResults[node] = round(float(myresult),2)
276 myGraphRate = round(float(myresult),2)
277
278 difLinkGraph = float(myLinkRate - myGraphRate)
279 difLinkGraph = numpy.absolute(difLinkGraph)
280 main.log.info("Node " + str(node) + " abs(Link event - Graph event) = " + str(difLinkGraph))
281 tempx = numpy.divide(difLinkGraph,float(myLinkRate))
282 if tempx > sustainability:
283 main.log.error("Difference in link event rate and graph event rate above " + str(sustainability) + " tolerance")
284 print("")
285
286 print("")
287 print("")
288
289 main.log.report("Final Link Event TP Results on " + str(clusterCount) + " node cluster")
290 main.log.report("_______________________________________________")
291 for node in range(1, clusterCount+1):
292 main.log.report("Node " + str(node) + ": " + str(linkResults[node]))
293
294 print("")
295 print("")
296
297 main.log.report("Final Graph Event TP Results on " + str(clusterCount) + " node cluster")
298 main.log.report("_______________________________________________")
299 for node in range(1, clusterCount+1):
300 main.log.report("Node " + str(node) + ": " + str(graphResults[node]))
301
302 #################################################################################
303 # Data Logging
304
305 logFileName = main.params[ 'TEST' ][ 'logFile' ]
306 logFile = open(logFileName, 'a')
307 main.log.info("Log file opened")
308 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
309
310 for node in range (1, clusterCount + 1):
311 # replare -> logFile.write( str(clusterCount) + "," + flickerNodes + "," )
312 logFile.write("'" + "baremetal" + str(node) + "'," )
313 logFile.write( testDuration + "," )
314 logFile.write( flickerRate + "," )
315 logFile.write( str(linkResults[node]) + "," )
316 logFile.write( str(graphResults[node]) + "\n" )
317
318 logFile.close()
319 main.log.info("Log file closed")
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336