blob: 1f5861eafd47aa310a1ae925cab6e91ce24f0b23 [file] [log] [blame]
jenkins9301fd02015-02-10 14:13:33 -08001# ScaleOutTemplate --> LinkEventTP
2#
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
16 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
22
23 clusterCount = 1
24 ONOSIp = [ 0 ]
25
26 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
30 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
31 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 maxNodes = int(main.params[ 'availableNodes' ])
34 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
36 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
37 MNip = main.params[ 'TEST' ][ 'MN' ]
38
39 #Populate ONOSIp with ips from params
40 for i in range(1, maxNodes + 1):
41 ipString = 'ip' + str(i)
42 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
43
44 #kill off all onos processes
45 main.log.step("Safety check, killing all ONOS processes")
46 main.log.step("before initiating enviornment setup")
47 for node in range(1, maxNodes + 1):
48 main.ONOSbench.onosDie(ONOSIp[node])
49
50 #construct the cell file
51 main.log.step("Creating cell file")
52 exec "a = main.ONOSbench.createCellFile"
53 cellIp = []
54 for node in range (1, maxNodes + 1):
55 cellIp.append(ONOSIp[node])
56 a(BENCHIp,cellName,MNip,str(Features), *cellIp) #'0' as third arg because we are not using mininet
57
58 main.step( "Set Cell" )
59 main.ONOSbench.setCell(cellName)
60
61 #Uninstall everywhere
62 main.log.step( "Cleaning Enviornment..." )
63 for i in range(1, maxNodes + 1):
64 main.log.info(" Uninstalling ONOS " + str(i) )
65 main.ONOSbench.onosUninstall( ONOSIp[i] )
66
67 #git step - skipable
68 main.step( "Git checkout and pull " + checkoutBranch )
69 if gitPull == 'on':
70 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
71 pullResult = main.ONOSbench.gitPull()
72
73 else:
74 checkoutResult = main.TRUE
75 pullResult = main.TRUE
76 main.log.info( "Skipped git checkout and pull" )
77
78 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
79 if skipMvn != "yes":
80 mvnResult = main.ONOSbench.cleanInstall()
81
82 #configuring file to enable flicker
83 main.log.step(" Configuring null provider to enable flicker. Flicker Rate = " + flickerRate )
84 homeDir = os.path.expanduser('~')
85 main.log.info(homeDir)
86 localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
87 filePath = homeDir + localPath
88 main.log.info(filePath)
89
90 neighborsString = ""
91 for node in range(1, maxNodes + 1):
92 neighborsString += ONOSIp[node]
93 if node < maxNodes:
94 neighborsString += ","
95
96 configFile = open(filePath, 'w+')
97 main.log.info("File opened")
98 configFile.write("# Sample configurations for the NullLinkProvider.\n")
99 configFile.write("# \n")
100 configFile.write("# If enabled, sets time between linkEvent generation\n")
101 configFile.write("# in milliseconds.\n")
102 configFile.write("#\n")
103 configFile.write("eventRate = " + flickerRate)
104 configFile.write("\n")
105 configFile.write("#Set order of islands to chain together, in a line.\n")
106 configFile.write("neighbors = " + neighborsString)
107 configFile.close()
108 main.log.info("Configuration completed")
109
110 ### configure event rate file ###
111 main.log.step("Writing Default Topology Provider config file")
112 localPath = main.params[ 'TEST' ][ 'configFile' ]
113 filePath = homeDir + localPath
114 main.log.info(filePath)
115 configFile = open(filePath, 'w+')
116 main.log.info("File Opened")
117 configFile.write("maxEvents = 1\n")
118 configFile.write("maxIdleMs = 0\n")
119 configFile.write("maxBatchMs = 0\n")
120 main.log.info("File written and closed")
121
122
123 devices_by_ip = ""
124 for node in range(1, maxNodes + 1):
125 devices_by_ip += (ONOSIp[node] + ":" + str(5))
126 if node < maxNodes:
127 devices_by_ip +=(",")
128
129 main.log.step("Configuring device provider")
130 localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg"
131 filePath = homeDir + localPath
132 main.log.info(filePath)
133 configFile = open(filePath, 'w+')
134 main.log.info("Device config file opened")
135 configFile.write("devConfigs = " + devices_by_ip)
136 configFile.close()
137 main.log.info("File closed")
138
139 logFileName = main.params[ 'TEST' ][ 'logFile' ]
140 logFile = open(logFileName, 'w+')
141 main.log.info("Created log File")
142 logFile.close()
143
144 main.step( "Creating ONOS package" )
145 packageResult = main.ONOSbench.onosPackage()
146
147 main.step( "Installing ONOS package" )
148 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
149
150 main.step( "Verify cells" )
151 verifyCellResult = main.ONOSbench.verifyCell()
152
153 main.step( "Enviornment setup and verification complete." )
154 main.ONOS1cli.startOnosCli( ONOSIp[1] )
155 main.step( "ONOS 1 is up and running." )
156
157
158 def CASE2( self, main ):
159 # This case increases the cluster size by whatever scale is
160 # Note: 'scale' is the size of the step
161 # if scaling is not a part of your test, simply run this case
162 # once after CASE1 to set up your enviornment for your desired
163 # cluster size. If scaling is a part of you test call this case each time
164 # you want to increase cluster size
165
166 ''
167 'Increase number of nodes and initiate CLI'
168 ''
169 import time
170 global clusterCount
171
172 scale = int( main.params[ 'SCALE' ] )
173 clusterCount += scale
174
175 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
176 for node in range((clusterCount - scale) + 1, clusterCount + 1):
177 main.ONOSbench.onosDie(ONOSIp[node])
178 time.sleep(10)
179 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
180 main.ONOSbench.onosInstall( ONOSIp[node] )
181 exec "a = main.ONOS%scli.startOnosCli" %str(node)
182 a(ONOSIp[node])
183
184 def CASE3( self, main ):
185 import time
186 import json
187 import string
188 import csv
189 import os.path
190
191
192 linkResult = main.FALSE
193 scale = int( main.params[ 'SCALE' ] )
194
195 testDelay = main.params[ 'TEST' ][ 'wait']
196 time.sleep( float( testDelay ) )
197
198 metric1 = main.params[ 'TEST' ][ 'metric1' ]
199 metric2 = main.params[ 'TEST' ][ 'metric2' ]
200 testDuration = main.params[ 'TEST' ][ 'duration' ]
201 stop = time.time() + float( testDuration )
202
203 msg = ( "Starting test loop for " + str(testDuration) + " seconds on a " + str(clusterCount) + " node cluster" )
204 main.log.info( msg )
205 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
206
207 linkResults = [0,0,0,0,0,0,0,0]
208 graphResults = [0,0,0,0,0,0,0,0]
209 JsonStr = [ 0,0,0,0,0,0,0,0 ]
210 JsonObj = [ 0,0,0,0,0,0,0,0 ]
211
212 while time.time() < stop:
213 time.sleep( float( logInterval ) )
214 for node in range(1, clusterCount+1):
215 exec "a = main.ONOS%scli.topologyEventsMetrics" %str(node)
216 JsonStr[node] = a()
217 JsonObj[node] = json.loads( JsonStr[node] )
218 msg = ( "Node " + str(node) + " Link Event TP: " + str( JsonObj[node][ metric1 ][ 'm1_rate' ] ) )
219 main.log.info( msg )
220 msg = ( "Node " + str(node) + " Graph Event TP: " + str( JsonObj[node][ metric2 ][ 'm1_rate' ] ) )
221 main.log.info( msg )
222
223 linkResults[node] = round(JsonObj[node][ metric2 ][ 'm1_rate' ],2)
224 graphResults[node] = round(JsonObj[node][ metric1 ][ 'm1_rate' ],2)
225
226 print("")
227 print("")
228
229 main.log.info("Final Link Event TP Results on " + str(clusterCount) + " node cluster")
230 main.log.info("_______________________________________________")
231 for node in range(1, clusterCount+1):
232 main.log.info("Node " + str(node) + ": " + str(linkResults[node]))
233
234 print("")
235 print("")
236
237 main.log.info("Final Graph Event TP Results on " + str(clusterCount) + " node cluster")
238 main.log.info("_______________________________________________")
239 for node in range(1, clusterCount+1):
240 main.log.info("Node " + str(node) + ": " + str(graphResults[node]))
241
242 #################################################################################
243 # Data Logging
244
245 logFileName = main.params[ 'TEST' ][ 'logFile' ]
246 logFile = open(logFileName, 'a')
247 main.log.info("Log file opened")
248 flickerRate = main.params[ 'TEST' ][ 'flickerRate']
249
250 for node in range (1, clusterCount + 1):
251 logFile.write( str(clusterCount) + "," )
252 logFile.write("'" + "baremetal" + str(node) + "'," )
253 logFile.write( testDuration + "," )
254 logFile.write( flickerRate + "," )
255 logFile.write( str(linkResults[node]) + "," )
256 logFile.write( str(graphResults[node]) + "\n" )
257
258 logFile.close()
259 main.log.info("Log file closed")
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276