blob: 29ecd06b30dfd7da627d71d416c4e894626181f6 [file] [log] [blame]
cameron@onlab.us1201bc42015-04-01 16:30:05 -07001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9
10
11class IntentInstallWithdrawLat:
12
13 def __init__( self ):
14 self.default = ''
15
16 def CASE1( self, main ): #This is the initialization case
17 #this case will clean up all nodes
18 import time #but only node 1 is started in this case
19
20 global clusterCount #number of nodes running
21 global ONOSIp #list of ONOS IP addresses
22 clusterCount = 1
23 ONOSIp = [ 0 ]
24
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 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
35 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
36 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
37 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
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 tempIp = []
45 for node in range( 1, clusterCount + 1):
46 tempIp.append(ONOSIp[node])
47
48 #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])
53
54 #construct the cell file
55 main.log.info("Creating cell file")
56 exec "a = main.ONOSbench.createCellFile"
57 cellIp = []
58 for node in range (1, clusterCount + 1):
59 cellIp.append(ONOSIp[node])
60 a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp)
61
62 main.step( "Applying cell file to environment" )
63 cellApplyResult = main.ONOSbench.setCell( cellName )
64
65 #Uninstall everywhere
66 main.log.step( "Cleaning Enviornment..." )
67 for i in range(1, maxNodes + 1):
68 main.log.info(" Uninstalling ONOS " + str(i) )
69 main.ONOSbench.onosUninstall( ONOSIp[i] )
70
71 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
72 if skipMvn != "yes":
73 mvnResult = main.ONOSbench.cleanInstall()
74
75 #git
76 main.step( "Git checkout and pull " + checkoutBranch )
77 if gitPull == 'on':
78 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
79 pullResult = main.ONOSbench.gitPull()
80
81 else:
82 checkoutResult = main.TRUE
83 pullResult = main.TRUE
84 main.log.info( "Skipped git checkout and pull" )
85
86 main.ONOSbench.createLinkGraphFile(BENCHIp, tempIp, switchCount)
87 main.ONOSbench.createNullDevProviderFile(BENCHIp, tempIp, switchCount)
88 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
89
90 main.step( "Creating ONOS package" )
91 packageResult = main.ONOSbench.onosPackage()
92
93 main.step( "Installing ONOS package" )
94 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
95
96 main.step( "verify cells" )
97 verifyCellResult = main.ONOSbench.verifyCell()
98
99 main.step( "Set cell for ONOS cli env" )
100 cli1 = main.ONOS1cli.startOnosCli( ONOSIp[1] )
101
102
103 def CASE2( self, main ):
104 # This case increases the cluster size by whatever scale is
105 # Note: 'scale' is the size of the step
106 # if scaling is not a part of your test, simply run this case
107 # once after CASE1 to set up your enviornment for your desired
108 # cluster size. If scaling is a part of you test call this case each time
109 # you want to increase cluster size
110
111 ''
112 'Increase number of nodes and initiate CLI'
113 ''
114 import time
115 global clusterCount
116
117 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
118 scale = int( main.params[ 'SCALE' ] )
119 clusterCount += scale
120 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
121
122 main.log.info("Creating cell file")
123 exec "a = main.ONOSbench.createCellFile"
124 cellIp = []
125 for node in range (1, clusterCount + 1):
126 cellIp.append(ONOSIp[node])
127 a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp)
128
129 main.step( "Applying cell file to environment" )
130 cellApplyResult = main.ONOSbench.setCell( cellName )
131
132 #Uninstall everywhere
133 main.log.step( "Cleaning Enviornment..." )
134 for node in range(1, maxNodes + 1):
135 main.ONOSbench.onosDie(ONOSIp[node])
136 main.log.info(" Uninstalling ONOS " + str(node) )
137 main.ONOSbench.onosUninstall( ONOSIp[node] )
138
139 tempIp = []
140 for node in range( 1, clusterCount + 1):
141 tempIp.append(ONOSIp[node])
142
143 main.ONOSbench.createLinkGraphFile(BENCHIp, tempIp, switchCount)
144 main.ONOSbench.createNullDevProviderFile(BENCHIp, tempIp, switchCount)
145 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
146
147 main.ONOSbench.onosPackage()
148
149 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
150 for node in range(1, clusterCount + 1):
151 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
152 main.ONOSbench.onosInstall( node=ONOSIp[node])
153 if node == 1:
154 main.ONOS1cli.startOnosCli( ONOSIp[1] )
155
156 for node in range(1, clusterCount + 1):
157 for i in range( 2 ):
158 isup = main.ONOSbench.isup( ONOSIp[node] )
159 if isup:
160 main.log.info("ONOS " + str(node) + " is up\n")
161 break
162 if not isup:
163 main.log.report( "ONOS " + str(node) + " didn't start!" )
164
165 def CASE3( self, main ):
166
167 import time
168 import numpy
169
170
171 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
172 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
173 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
174 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
175 debug = main.params[ 'TEST' ][ 'switchCount' ]
176 for i in range(0,len(intentsList)):
177 intentsList[i] = int(intentsList[i])
178
179 if debug == "True":
180 debug = True
181 else:
182 debug = False
183
184 linkCount = 0
185 for i in range(0,10):
186 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
187 main.ONOSbench.handle.expect(":~")
188 linkCount = main.ONOSbench.handle.before
189 if debug: main.log.info("Link Count check: " + linkCount)
190 if str((switchCount*2)-2) in linkCount:
191 break
192 time.sleep(2)
193
194 links = "--"
195 while "=null:" not in links:
196 if debug: main.log.info("top of loop")
197 main.ONOSbench.handle.sendline("onos $OC1 links")
198 main.ONOSbench.handle.expect(":~")
199 links = main.ONOSbench.handle.before
200 if debug: main.log.info(str(links))
201 time.sleep(1)
202 links = links.splitlines()
203 templinks = links
204
205 tempDevices = []
206 for line in links:
207 temp = line.split(" ")
208 temp[0].replace("src=","")
209 temp[0] = (temp[0].split("/"))[0]
210 tempDevices.append(temp[0])
211
212 tempDevices.sort()
213 devices = []
214 for i in tempDevices:
215 if "src=null" in i:
216 devices.append(i.replace("src=", ""))
217 if debug: main.log.info(str(devices))
218
219 ingress = devices[0]
220 egress = devices.pop()
221 if debug: main.log.info(ingress)
222 if debug: main.log.info(egress)
223
224 for intentSize in intentsList:
225 cmd = "onos $OC1 push-test-intents "
226 cmd += ingress + "/6 "
227 cmd += egress + "/5 "
228 cmd += str(intentSize) + " 1"
229 installed = []
230 withdrawn = []
231
232 for run in range(0, (warmUp + sampleSize)):
233 if run > warmUp:
234 time.sleep(5)
235
236 myRawResult = "--"
237 while "ms" not in myRawResult:
238 main.ONOSbench.handle.sendline(cmd)
239 main.ONOSbench.handle.expect(":~")
240 myRawResult = main.ONOSbench.handle.before
241 if debug: main.log.info(myRawResult)
242
243 if debug: main.log.info(myRawResult)
244
245 if run >= warmUp:
246 myRawResult = myRawResult.splitlines()
247 for line in myRawResult:
248 if "install" in line:
249 installed.append(int(line.split(" ")[5]))
250
251 for line in myRawResult:
252 if "withdraw" in line:
253 withdrawn.append(int(line.split(" ")[5]))
254
255 print("installed: " + str(installed))
256 print("withraw: " + str(withdrawn) + "\n")
257
258 main.log.report("----------------------------------------------------")
259 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
260 main.log.report("Installed average: " + str(numpy.mean(installed)))
261 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
262 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
263 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
264 main.log.report(" ")
265