blob: ab490a9bcf37c833f5c634700e13352dfe6ba087 [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()
92
93 logFileName = main.params[ 'TEST' ][ 'logFile' ]
94 logFile = open(logFileName, 'w+')
95 main.log.info("Created log File")
96 logFile.close()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080097
98 main.step( "Creating ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -070099 packageResult = main.ONOSbench.onosPackage()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800100
101 main.step( "Installing ONOS package" )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700102 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800103
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700104 main.step( "Verify cells" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800105 verifyCellResult = main.ONOSbench.verifyCell()
106
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700107 main.step( "Enviornment setup and verification complete." )
108 main.ONOS1cli.startOnosCli( ONOSIp[1] )
109 main.step( "ONOS 1 is up and running." )
110 main.ONOSbench.handle.expect(":~") #there is a dangling sendline somewhere...
111
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800112 def CASE2( self, main ):
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700113 # This case increases the cluster size by whatever scale is
114 # Note: 'scale' is the size of the step
115 # if scaling is not a part of your test, simply run this case
116 # once after CASE1 to set up your enviornment for your desired
117 # cluster size. If scaling is a part of you test call this case each time
118 # you want to increase cluster size
119
120 ''
121 'Increase number of nodes and initiate CLI'
122 ''
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800123 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800124 global clusterCount
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700125
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800126 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700127 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
128 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
129 MNip = main.params[ 'TEST' ][ 'MN' ]
130 deviceDistribution = (main.params[ 'TEST' ][ 'devicesPerNode']).split(",")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800131
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700132 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800133 clusterCount += scale
134
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700135 main.log.step( "Cleaning Enviornment..." )
136 for i in range(1, maxNodes + 1):
137 main.ONOSbench.onosDie(ONOSIp[i])
138 main.log.info(" Uninstalling ONOS " + str(i) )
139 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800140
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700141 myDistribution = []
142 for node in range (1, clusterCount + 1):
143 myDistribution.append(deviceDistribution[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800144
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700145 main.log.step("Creating cell file")
146 cellIp = []
147 for node in range (1, clusterCount + 1):
148 cellIp.append(ONOSIp[node])
149 main.ONOSbench.createCellFile(BENCHIp,cellName,MNip,str(Features), *cellIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800150
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700151 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
152 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
153 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800154
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700155 main.step( "Set Cell" )
156 main.ONOSbench.setCell(cellName)
157
158 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
159 for node in range(1, clusterCount + 1):
160 time.sleep(10)
161 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
162 main.ONOSbench.onosInstall( ONOSIp[node] )
163 exec "a = main.ONOS%scli.startOnosCli" %str(node)
164 a(ONOSIp[node])
165
166 for node in range(1, clusterCount + 1):
167 for i in range( 2 ):
168 isup = main.ONOSbench.isup( ONOSIp[node] )
169 if isup:
170 main.log.info("ONOS " + str(node) + " is up\n")
171 break
172 if not isup:
173 main.log.report( "ONOS " + str(node) + " didn't start!" )
174
175 def CASE3( self, main ):
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800176 import time
177 import json
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700178 import string
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800179 import csv
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700180 import os.path
181 import requests
182 import numpy
183
184 sustainability = float(main.params[ 'TEST' ][ 'linkgraphdif' ])
185 flickerRates = (main.params[ 'TEST' ][ 'flickerRates']).split(",")
186 homeDir = os.path.expanduser('~')
187
188 linkResult = main.FALSE
189 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800190
191 testDelay = main.params[ 'TEST' ][ 'wait']
192 time.sleep( float( testDelay ) )
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700193
194 for node in range(1, clusterCount + 1):
195 main.log.info("Writing flicker file to node " + str(node))
196 main.ONOSbench.createNullLinkProviderFile( ONOSIp[node], eventRate=flickerRates[node-1], onNode=True )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800197
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800198 testDuration = main.params[ 'TEST' ][ 'duration' ]
199 stop = time.time() + float( testDuration )
200
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700201 msg = ( "Starting test loop for " + str(testDuration) + " seconds on a " + str(clusterCount) + " node cluster" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800202 main.log.info( msg )
203 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
204
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700205 linkResults = [0,0,0,0,0,0,0,0]
206 graphResults = [0,0,0,0,0,0,0,0]
207 JsonStr = [ 0,0,0,0,0,0,0,0 ]
208 JsonObj = [ 0,0,0,0,0,0,0,0 ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800209
andrew@onlab.us30d9ba42015-03-11 15:05:24 -0700210 while time.time() < stop:
211 time.sleep( float( logInterval ) )
212 for node in range(1, clusterCount+1):
213 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Link Events"|cut -d ' ' -f7 """)
214 main.ONOSbench.handle.expect(":~")
215 raw = (main.ONOSbench.handle.before).splitlines()
216 myresult = "--"
217 for word in raw:
218 if "m1" in word:
219 myresult = word
220 myresult = myresult.replace("m1=","")
221 break
222 if myresult == "--":
223 main.log.error("Parse error or no data error")
224 msg = ( "Node " + str(node) + " Link Event TP: " + str(myresult) )
225 main.log.info( msg )
226 linkResults[node] = round(float(myresult),2)
227 myLinkRate = round(float(myresult),2)
228
229 main.ONOSbench.handle.sendline("""onos $OC1 topology-events-metrics|grep "Topology Graph Events"|cut -d ' ' -f7 """)
230 main.ONOSbench.handle.expect(":~")
231 raw = (main.ONOSbench.handle.before).splitlines()
232 myresult = "--"
233 for word in raw:
234 if "m1" in word:
235 myresult = word
236 myresult = myresult.replace("m1=","")
237 break
238 if myresult == "--":
239 main.log.error("Parse error or no data error")
240 msg = ( "Node " + str(node) + " Graph Event TP: " + str(myresult) )
241 main.log.info( msg )
242 graphResults[node] = round(float(myresult),2)
243 myGraphRate = round(float(myresult),2)
244
245 difLinkGraph = float(myLinkRate - myGraphRate)
246 difLinkGraph = numpy.absolute(difLinkGraph)
247 main.log.info("Node " + str(node) + " abs(Link event - Graph event) = " + str(difLinkGraph))
248 tempx = numpy.divide(difLinkGraph,float(myLinkRate))
249 if tempx > sustainability:
250 main.log.error("Difference in link event rate and graph event rate above " + str(sustainability) + " tolerance")
251 print("")
252
253 print("")
254 print("")
255
256 main.log.report("Final Link Event TP Results on " + str(clusterCount) + " node cluster")
257 main.log.report("_______________________________________________")
258 for node in range(1, clusterCount+1):
259 main.log.report("Node " + str(node) + ": " + str(linkResults[node]))
260
261 print("")
262 print("")
263
264 main.log.report("Final Graph Event TP Results on " + str(clusterCount) + " node cluster")
265 main.log.report("_______________________________________________")
266 for node in range(1, clusterCount+1):
267 main.log.report("Node " + str(node) + ": " + str(graphResults[node]))
268
269 #################################################################################
270 # Data Logging
271
272 logFileName = main.params[ 'TEST' ][ 'logFile' ]
273 logFile = open(logFileName, 'a')
274 main.log.info("Log file opened")
275 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
276
277 for node in range (1, clusterCount + 1):
278 # replare -> logFile.write( str(clusterCount) + "," + flickerNodes + "," )
279 logFile.write("'" + "baremetal" + str(node) + "'," )
280 logFile.write( testDuration + "," )
281 logFile.write( flickerRate + "," )
282 logFile.write( str(linkResults[node]) + "," )
283 logFile.write( str(graphResults[node]) + "\n" )
284
285 logFile.close()
286 main.log.info("Log file closed")
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303