blob: be8f38ca5ea00d52b4836f129d0cb172e4ec5197 [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
cameron@onlab.us61e06032015-04-02 10:54:26 -070016 def CASE1( self, main ):
17
18 import time
19 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
25
cameron@onlab.us1201bc42015-04-01 16:30:05 -070026 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070037 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
38
cameron@onlab.us61e06032015-04-02 10:54:26 -070039 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
41 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
44 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070045 global commit
46
cameron@onlab.us61e06032015-04-02 10:54:26 -070047 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070051
cameron@onlab.us61e06032015-04-02 10:54:26 -070052 #Populate ONOSIp with ips from params
53 for i in range(1, maxNodes + 1):
54 ipString = 'ip' + str(i)
55 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
56
57 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
58 if skipMvn != "yes":
59 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060
cameron@onlab.us1201bc42015-04-01 16:30:05 -070061 #git
62 main.step( "Git checkout and pull " + checkoutBranch )
63 if gitPull == 'on':
64 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
65 pullResult = main.ONOSbench.gitPull()
66
67 else:
68 checkoutResult = main.TRUE
69 pullResult = main.TRUE
70 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070071
72 commit = main.ONOSbench.getVersion()
73 commit = (commit.split(" "))[1]
74
75 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
76 resultsDB.close()
77
cameron@onlab.us61e06032015-04-02 10:54:26 -070078 # -- END OF INIT SECTION --#
79
80 clusterCount = int(scale[0])
81 scale.remove(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070082
cameron@onlab.us61e06032015-04-02 10:54:26 -070083 #kill off all onos processes
84 main.log.step("Safety check, killing all ONOS processes")
85 main.log.step("before initiating enviornment setup")
86 for node in range(1, maxNodes + 1):
87 main.ONOSbench.onosDie(ONOSIp[node])
88
89 #Uninstall everywhere
90 main.log.step( "Cleaning Enviornment..." )
91 for i in range(1, maxNodes + 1):
92 main.log.info(" Uninstalling ONOS " + str(i) )
93 main.ONOSbench.onosUninstall( ONOSIp[i] )
94
95 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070096 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070097 cellIp = []
98 for node in range (1, clusterCount + 1):
99 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700100
cameron@onlab.us61e06032015-04-02 10:54:26 -0700101 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700102
cameron@onlab.us61e06032015-04-02 10:54:26 -0700103 main.step( "Set Cell" )
104 main.ONOSbench.setCell(cellName)
105
cameron@onlab.us61e06032015-04-02 10:54:26 -0700106 main.step( "Creating ONOS package" )
107 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700108
cameron@onlab.us61e06032015-04-02 10:54:26 -0700109 main.step( "verify cells" )
110 verifyCellResult = main.ONOSbench.verifyCell()
111
112 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700113 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700114 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
115 main.ONOSbench.onosInstall( ONOSIp[node])
116
117 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700118 for i in range( 2 ):
119 isup = main.ONOSbench.isup( ONOSIp[node] )
120 if isup:
121 main.log.info("ONOS " + str(node) + " is up\n")
122 break
123 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700124 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700125
cameron@onlab.us61e06032015-04-02 10:54:26 -0700126 main.ONOS1cli.startOnosCli( ONOSIp[1] )
127 main.log.info("Startup sequence complete")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700128
129 time.sleep(30)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700130
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700131 main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
132 main.ONOSbench.handle.expect(":~")
133 print main.ONOSbench.handle.before
134 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
135 main.ONOSbench.handle.expect(":~")
136 print main.ONOSbench.handle.before
137 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
138 main.ONOSbench.handle.expect(":~")
139 print main.ONOSbench.handle.before
140 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
141 main.ONOSbench.handle.expect(":~")
142 print main.ONOSbench.handle.before
143 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
144 main.ONOSbench.handle.expect(":~")
145 print main.ONOSbench.handle.before
cameron@onlab.us61e06032015-04-02 10:54:26 -0700146
147 def CASE2( self, main ):
148
149 import time
150 import numpy
151
152 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700153 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
154 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
155 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
156 debug = main.params[ 'TEST' ][ 'switchCount' ]
157 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700158 intentsList[i] = int(intentsList[i])
159
160 if debug == "True":
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700161 debug = True
cameron@onlab.us61e06032015-04-02 10:54:26 -0700162 else:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700163 debug = False
cameron@onlab.us61e06032015-04-02 10:54:26 -0700164
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700165 linkCount = 0
166 for i in range(0,10):
167 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
168 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700169 linkCount = main.ONOSbench.handle.before
170 if debug: main.log.info("Link Count check: " + linkCount)
171 if str((switchCount*2)-2) in linkCount:
172 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700173 time.sleep(2)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700174
175 links = "--"
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700176 while "=null:" not in links:
177 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700178 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700179 main.ONOSbench.handle.expect(":~")
180 links = main.ONOSbench.handle.before
cameron@onlab.us61e06032015-04-02 10:54:26 -0700181 if debug: main.log.info(str(links))
182 time.sleep(1)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700183 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700184 templinks = links
185
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700186 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700187 for line in links:
188 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700189 temp[0].replace("src=","")
190 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700191 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700192
193 tempDevices.sort()
194 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700195 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700196 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700197 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700198 if debug: main.log.info(str(devices))
199
200 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700201 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700202 if debug: main.log.info(ingress)
203 if debug: main.log.info(egress)
204
205 for intentSize in intentsList:
206 cmd = "onos $OC1 push-test-intents "
207 cmd += ingress + "/6 "
208 cmd += egress + "/5 "
209 cmd += str(intentSize) + " 1"
210 installed = []
211 withdrawn = []
212
213 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700214 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700215 time.sleep(5)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700216
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700217 myRawResult = "--"
218 while "ms" not in myRawResult:
219 main.ONOSbench.handle.sendline(cmd)
220 main.ONOSbench.handle.expect(":~")
221 myRawResult = main.ONOSbench.handle.before
222 if debug: main.log.info(myRawResult)
223
cameron@onlab.us61e06032015-04-02 10:54:26 -0700224 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700225
cameron@onlab.us61e06032015-04-02 10:54:26 -0700226 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700227 myRawResult = myRawResult.splitlines()
228 for line in myRawResult:
229 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700230 installed.append(int(line.split(" ")[5]))
231
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700232 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700233 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700234 withdrawn.append(int(line.split(" ")[5]))
235
236 print("installed: " + str(installed))
237 print("withraw: " + str(withdrawn) + "\n")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700238
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700239 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700240 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
241 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700242 main.log.report("Installed average: " + str(numpy.mean(installed)))
243 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
244 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
245 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
246 main.log.report(" ")
247
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700248 resultString = "'" + commit + "',"
249 resultString += str(clusterCount) + ","
250 resultString += str(intentSize) + ","
251 resultString += str(numpy.mean(installed)) + ","
252 resultString += str(numpy.std(installed)) + ","
253 resultString += str(numpy.mean(withdrawn)) + ","
254 resultString += str(numpy.std(withdrawn)) + "\n"
255 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
256 resultsDB.write(resultString)
257 resultsDB.close()