blob: 9a6f938570c7f0390dd7bfc623cfb75c2d355622 [file] [log] [blame]
cameron@onlab.us059c2562015-04-02 14:12:51 -07001# ScaleOutTemplate
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
andrew@onlab.us10332202015-03-11 15:04:43 -07007import sys
cameron@onlab.us059c2562015-04-02 14:12:51 -07008import os.path
andrew@onlab.us10332202015-03-11 15:04:43 -07009
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080010
11class IntentEventTP:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.us059c2562015-04-02 14:12:51 -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
andrew@onlab.us10332202015-03-11 15:04:43 -070026 #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' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070033 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070034 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us10332202015-03-11 15:04:43 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070037 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -070038
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080039
cameron@onlab.us059c2562015-04-02 14:12:51 -070040 # ?? homeDir = os.path.expanduser('~')
41 # ?? main.ONOSbench.handle.sendline("export TERM=vt100")
42 # ?^ dump = main.ONOSbench.handle.expect(":~")
43
44
45 # -- INIT SECTION, ONLY RUNS ONCE -- #
46 if init == False:
47 init = True
48 global clusterCount #number of nodes running
49 global ONOSIp #list of ONOS IP addresses
50 global scale
51
52 clusterCount = 0
53 ONOSIp = [ 0 ]
54 scale = (main.params[ 'SCALE' ]).split(",")
55 clusterCount = int(scale[0])
56
57 #Populate ONOSIp with ips from params
58 for i in range(1, maxNodes + 1):
59 ipString = 'ip' + str(i)
60 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
61
62 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
63 if skipMvn != "yes":
64 mvnResult = main.ONOSbench.cleanInstall()
65
66 #git
67 main.step( "Git checkout and pull " + checkoutBranch )
68 if gitPull == 'on':
69 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
70 pullResult = main.ONOSbench.gitPull()
71
72 else:
73 checkoutResult = main.TRUE
74 pullResult = main.TRUE
75 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070076
cameron@onlab.us059c2562015-04-02 14:12:51 -070077 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
82 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070083 main.log.step("Safety check, killing all ONOS processes")
84 main.log.step("before initiating enviornment setup")
85 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070086 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -070087
andrew@onlab.us10332202015-03-11 15:04:43 -070088 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080089 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -070090 for i in range(1, maxNodes + 1):
91 main.log.info(" Uninstalling ONOS " + str(i) )
92 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -070093
94 #construct the cell file
95 main.log.info("Creating cell file")
96 cellIp = []
97 for node in range (1, clusterCount + 1):
98 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080099
cameron@onlab.us059c2562015-04-02 14:12:51 -0700100 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
101
102 main.step( "Set Cell" )
103 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800104
jenkins3af0cd82015-03-24 10:27:16 -0700105 myDistribution = []
106 for node in range (1, clusterCount + 1):
107 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800108
jenkins3af0cd82015-03-24 10:27:16 -0700109 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700110
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800111 main.step( "Creating ONOS package" )
112 packageResult = main.ONOSbench.onosPackage()
113
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800114 main.step( "verify cells" )
115 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700116
117 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700118 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700119 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700120 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700121
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700122 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700123 for i in range( 2 ):
124 isup = main.ONOSbench.isup( ONOSIp[node] )
125 if isup:
126 main.log.info("ONOS " + str(node) + " is up\n")
127 break
128 if not isup:
129 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700130 main.log.info("Startup sequence complete")
131
andrew@onlab.us10332202015-03-11 15:04:43 -0700132 lastOutput = "--"
133 origin = time.time()
134 clockStarted = False
135 while True:
136 main.ONOSbench.handle.sendline("onos $OC1 summary")
137 main.ONOSbench.handle.expect(":~")
138 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
139 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700140 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700141 break
142 if clusterCheck != lastOutput:
143 sameOutput = False
144 elif clusterCheck == lastOutput:
145 if clockStarted == False:
146 start = time.time()
147 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700148 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700149 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
150 break
151 lastOutput = clusterCheck
152 time.sleep(5)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700153
154 main.ONOSbench.configNullDev(cellIp, myDistribution)
155
156 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700157 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800158 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700159 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700160 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700161 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700162
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800163 main.log.info("Cluster Count = " + str(clusterCount))
164
andrew@onlab.us10332202015-03-11 15:04:43 -0700165 intentsRate = main.params['METRICS']['intents_rate']
166 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
167 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
168 testDuration = main.params[ 'TEST' ][ 'duration' ]
169 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
170 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700171 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
172 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
173 neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700174 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700175
cameron@onlab.us059c2562015-04-02 14:12:51 -0700176 for n in range(0, len(neighbors)):
177 if neighbors[n] == 'a':
178 neighbors[n] = str(clusterCount -1)
179 print str(neighbors)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800180
cameron@onlab.us059c2562015-04-02 14:12:51 -0700181 for n in neighbors:
182 main.log.info("Run with " + n + " neighbors")
183 time.sleep(5)
184 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
185 main.ONOSbench.handle.expect(":~")
186 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
187 main.ONOSbench.handle.expect(":~")
188 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
189 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700190
cameron@onlab.us059c2562015-04-02 14:12:51 -0700191 cmd = "onos $OC1 intent-perf-start"
192 main.ONOSbench.handle.sendline(cmd)
193 main.ONOSbench.handle.expect(":~")
194 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700195
cameron@onlab.us059c2562015-04-02 14:12:51 -0700196 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
197 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700198
cameron@onlab.us059c2562015-04-02 14:12:51 -0700199 while time.time() < stop:
200 time.sleep( float( logInterval ) )
201 groupResult = []
202 for node in range (1, clusterCount + 1):
203 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700204
cameron@onlab.us059c2562015-04-02 14:12:51 -0700205 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
206 main.log.info("COMMAND: " + str(cmd))
207
208 x = 0
209 while True:
210 main.ONOSbench.handle.sendline(cmd)
211 main.ONOSbench.handle.expect(":~")
212 raw = main.ONOSbench.handle.before
213 if "OVERALL=" in raw:
214 break
215 x += 1
216 if x > 10:
217 main.log.error("Expected output not being recieved... continuing")
218 break
219 time.sleep(2)
220
221 raw = raw.splitlines()
222 splitResults = []
223 for line in raw:
224 splitResults.extend(line.split(" "))
225
226 myResult = "--"
227 for field in splitResults:
228 if "OVERALL" in field:
229 myResult = field
230
231 if myResult == "--":
232 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
233
234 myResult = myResult.replace(";", "")
235 myResult = myResult.replace("OVERALL=","")
236 myResult = float(myResult)
237 groupResult[len(groupResult) -1] = myResult
238
239 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
240
241 main.log.report("Results from this round of polling: " + str(groupResult))
242 main.log.report("Cluster Total: " + str(numpy.sum(groupResult)) + "\n")
243
244 cmd = "onos $OC1 intent-perf-stop"
245 main.ONOSbench.handle.sendline(cmd)
246 main.ONOSbench.handle.expect(":~")
247 main.log.info("Stopping intentperf" )
248