blob: 7dd924d7c4cfc8955bc006a8c1129597b144e7d5 [file] [log] [blame]
cameron@onlab.us946d99c2015-07-08 15:34:37 -07001# ScaleOutTemplate -> flowTP
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 SCPFflowTp1g:
12
13 def __init__( self ):
14 self.default = ''
15
Jon Hall4ba53f02015-07-29 13:07:41 -070016 def CASE1( self, main ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070017
18 import time
19 global init
20 try:
Devin Lim58046fa2017-07-05 16:55:00 -070021 if type( init ) is not bool:
cameron@onlab.us946d99c2015-07-08 15:34:37 -070022 init = False
23 except NameError:
24 init = False
25
Devin Lim58046fa2017-07-05 16:55:00 -070026 main.log.info( "==========DEBUG VERSION 3===========" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -070027
cameron@onlab.us946d99c2015-07-08 15:34:37 -070028 # -- INIT SECTION, ONLY RUNS ONCE -- #
29 if init == False:
Devin Lim58046fa2017-07-05 16:55:00 -070030 try:
31 init = True
32 try:
33 from tests.dependencies.ONOSSetup import ONOSSetup
34 main.testSetUp = ONOSSetup()
35 except ImportError:
36 main.log.error( "ONOSSetup not found. exiting the test" )
37 main.exit()
38 main.testSetUp.envSetupDescription()
39 #Load values from params file
40 cellName = main.params[ 'ENV' ][ 'cellName' ]
41 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
42 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
43 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
44 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
45 stepResult = main.testSetUp.envSetup()
46 resultsDB = open( "/tmp/flowTP1gDB", "w+" )
47 resultsDB.close()
48 except Exception as e:
49 main.testSetUp.envSetupException( e )
50 main.testSetUp.evnSetupConclusion( stepResult )
51 main.commit = (main.commit.split(" "))[1]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070052 # -- END OF INIT SECTION --#
53
Devin Lim58046fa2017-07-05 16:55:00 -070054 main.testSetUp.ONOSSetUp( "localhost", True, cellName=cellName )
Jon Hall4ba53f02015-07-29 13:07:41 -070055
cameron@onlab.us946d99c2015-07-08 15:34:37 -070056 main.log.info("Startup sequence complete")
Devin Lim58046fa2017-07-05 16:55:00 -070057 main.ONOSbench.logReport(main.ONOSip[0], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
Chiyu Chengef109502016-11-21 15:51:38 -080058
cameron@onlab.us946d99c2015-07-08 15:34:37 -070059 def CASE2( self, main ):
60 #
Jon Hall4ba53f02015-07-29 13:07:41 -070061 # This is the flow TP test
cameron@onlab.us946d99c2015-07-08 15:34:37 -070062 #
Jon Hall4ba53f02015-07-29 13:07:41 -070063 import os.path
64 import numpy
cameron@onlab.us946d99c2015-07-08 15:34:37 -070065 import math
Jon Hall4ba53f02015-07-29 13:07:41 -070066 import time
cameron@onlab.us946d99c2015-07-08 15:34:37 -070067 import datetime
68 import traceback
69
70 global currentNeighbors
71 try:
72 currentNeighbors
73 except:
74 currentNeighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")[0]
75 else:
76 if currentNeighbors == "r": #reset
77 currentNeighbors = "0"
78 else:
79 currentNeighbors = "a"
80
81 testCMD = [ 0,0,0,0 ]
82 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
83 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
84 switches = int(main.params[ 'TEST' ][ 'switches' ])
85 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
86 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
87 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070088 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
89 cellName = main.params[ 'ENV' ][ 'cellName' ]
90 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
91 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
92 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070093 homeDir = os.path.expanduser('~')
94 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
95 main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
96
Devin Lim58046fa2017-07-05 16:55:00 -070097 servers = str( main.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -070098
Devin Lim58046fa2017-07-05 16:55:00 -070099 if main.numCtrls == 1:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700100 neighborList = ['0']
101 currentNeighbors = "r"
102 else:
103 if currentNeighbors == "a":
Devin Lim58046fa2017-07-05 16:55:00 -0700104 neighborList = [ str( main.numCtrls - 1 ) ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700105 currentNeighbors = "r"
106 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700107 neighborList = ['0']
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700108
109 main.log.info("neightborlist: " + str(neighborList))
110
111 ts = time.time()
112 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
113
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700114 for n in neighborList:
Jon Hall6509dbf2016-06-21 17:01:17 -0700115 main.step("\tSTARTING TEST")
Devin Lim58046fa2017-07-05 16:55:00 -0700116 main.step("\tLOADING FROM SERVERS: \t" + str( main.numCtrls ) )
Jon Hall6509dbf2016-06-21 17:01:17 -0700117 main.step("\tNEIGHBORS:\t" + n )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700118 main.log.info("=============================================================")
119 main.log.info("=============================================================")
120 #write file to configure nil link
121 ipCSV = ""
Devin Lim58046fa2017-07-05 16:55:00 -0700122 for i in range ( main.maxNodes ):
123 tempstr = "ip" + str( i + 1 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700124 ipCSV += main.params[ 'CTRL' ][ tempstr ]
Devin Lim58046fa2017-07-05 16:55:00 -0700125 if i + 1 < main.maxNodes:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700126 ipCSV +=","
Jon Hall4ba53f02015-07-29 13:07:41 -0700127
Devin Lim58046fa2017-07-05 16:55:00 -0700128 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupCount 1")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700129 for i in range(3):
Devin Lim58046fa2017-07-05 16:55:00 -0700130 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
131 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
132 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700133
134 time.sleep(5)
135 main.ONOSbench.handle.sendline("onos $OC1 summary")
136 main.ONOSbench.handle.expect(":~")
137 check = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700138 main.log.info("\nStart up check: \n" + check + "\n")
139 if "SCC(s)=1," in check:
suibin zhanga3746bf2015-09-05 09:36:39 -0700140 main.ONOSbench.handle.sendline( "onos $OC1 balance-masters" )
suibin zhang45efc1b2015-09-04 16:48:10 -0700141 main.ONOSbench.handle.expect( ":~" )
142 time.sleep(5)
143 main.ONOSbench.handle.sendline( "onos $OC1 roles ")
144 main.ONOSbench.handle.expect ( ":~" )
145 main.log.info( "switch masterships:" + str( main.ONOSbench.handle.before ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700146 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700147 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700148
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700149 #devide flows
150 flows = int(main.params[ 'TEST' ][ 'flows' ])
151 main.log.info("Flow Target = " + str(flows))
152
153 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
154
155 main.log.info("Flows per switch = " + str(flows))
156
157 #build list of servers in "$OC1, $OC2...." format
158 serverEnvVars = ""
Devin Lim58046fa2017-07-05 16:55:00 -0700159 for i in range( int( servers ) ):
160 serverEnvVars += ( "-s " + main.ONOSip[ i ] + " " )
Jon Hall4ba53f02015-07-29 13:07:41 -0700161
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700162 data = [[""]*int(servers)]*int(sampleSize)
163 maxes = [""]*int(sampleSize)
164
165 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
166 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
Jon Hall4ba53f02015-07-29 13:07:41 -0700167 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700168
169 main.log.info(flowCMD)
170 #time.sleep(60)
Jon Hall4ba53f02015-07-29 13:07:41 -0700171
172 for test in range(0, warmUp + sampleSize):
173 if test < warmUp:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700174 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
Jon Hall4ba53f02015-07-29 13:07:41 -0700175 else:
176 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700177
178 main.ONOSbench.handle.sendline(flowCMD)
179 main.ONOSbench.handle.expect(":~")
180 rawResult = main.ONOSbench.handle.before
181 main.log.info("Raw results: \n" + rawResult + "\n")
182
Jon Hall4ba53f02015-07-29 13:07:41 -0700183 if "failed" in rawResult:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700184 main.log.report("FLOW_TESTER.PY FAILURE")
185 main.log.report( " \n" + rawResult + " \n")
Devin Lim58046fa2017-07-05 16:55:00 -0700186 for i in range( main.numCtrls ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700187 main.log.report("=======================================================")
Devin Lim58046fa2017-07-05 16:55:00 -0700188 main.log.report(" ONOS " + str( i + 1 ) + "LOG REPORT")
189 main.ONOSbench.logReport( main.ONOSip[ i ], ["ERROR", "WARNING", "EXCEPT"], outputMode="d" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700190 main.ONOSbench.handle.sendline("onos $OC1 flows")
191 main.ONOSbench.handle.expect(":~")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700192 main.log.info(main.ONOSbench.handle.before)
193
194 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700195
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700196 ########################################################################################
Devin Lim58046fa2017-07-05 16:55:00 -0700197 result = [""]*( main.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -0700198
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700199 #print("rawResult: " + rawResult)
200
201 rawResult = rawResult.splitlines()
202
Devin Lim58046fa2017-07-05 16:55:00 -0700203 for node in range( main.numCtrls ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700204 for line in rawResult:
Jon Hall4ba53f02015-07-29 13:07:41 -0700205 #print("line: " + line)
Devin Lim58046fa2017-07-05 16:55:00 -0700206 if main.ONOSip[ node ] in line and "server" in line:
207 temp = line.split( " " )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700208 for word in temp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700209 #print ("word: " + word)
210 if "elapsed" in repr(word):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700211 index = temp.index(word) + 1
212 myParsed = (temp[index]).replace(",","")
213 myParsed = myParsed.replace("}","")
214 myParsed = int(myParsed)
Devin Lim58046fa2017-07-05 16:55:00 -0700215 result[ node ] = myParsed
216 main.log.info( main.ONOSip[ node ] + " : " + str( myParsed ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700217 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700218
219 if test >= warmUp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700220 for i in result:
221 if i == "":
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700222 main.log.error("Missing data point, critical failure incoming")
223
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700224 print result
225 maxes[test-warmUp] = max(result)
226 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
Jon Hall4ba53f02015-07-29 13:07:41 -0700227 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700228
229 data[test-warmUp] = result
230
Jon Hall4ba53f02015-07-29 13:07:41 -0700231 # wait for flows = 0
232 for checkCount in range(0,5):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700233 time.sleep(10)
234 main.ONOSbench.handle.sendline("onos $OC1 summary")
235 main.ONOSbench.handle.expect(":~")
236 flowCheck = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700237 if "flows=0," in flowCheck:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700238 main.log.info("Flows removed")
239 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700240 else:
241 for line in flowCheck.splitlines():
242 if "flows=" in line:
243 main.log.info("Current Summary: " + line)
244 if checkCount == 2:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700245 main.log.info("Flows are stuck, moving on ")
246
247
248 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700249
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700250 main.log.info("raw data: " + str(data))
251 main.log.info("maxes:" + str(maxes))
252
Jon Hall4ba53f02015-07-29 13:07:41 -0700253
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700254 # report data
255 print("")
256 main.log.info("\t Results (measurments are in milliseconds)")
257 print("")
258
259 nodeString = ""
260 for i in range(1, int(servers) + 1):
Jon Hall4ba53f02015-07-29 13:07:41 -0700261 nodeString += ("\tNode " + str(i))
262
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700263 for test in range(0, sampleSize ):
264 main.log.info("\t Test iteration " + str(test + 1) )
265 main.log.info("\t------------------")
Jon Hall4ba53f02015-07-29 13:07:41 -0700266 main.log.info(nodeString)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700267 resultString = ""
268
269 for i in range(0, int(servers) ):
Jon Hall4ba53f02015-07-29 13:07:41 -0700270 resultString += ("\t" + str(data[test][i]) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700271 main.log.info(resultString)
272
273 print("\n")
274
275 avgOfMaxes = numpy.mean(maxes)
276 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
277
278 stdOfMaxes = numpy.std(maxes)
Jon Hall4ba53f02015-07-29 13:07:41 -0700279 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700280 print("\n\n")
281
282 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
Jon Hall4ba53f02015-07-29 13:07:41 -0700283
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700284 tp = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700285 for i in maxes:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700286 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
287
288 stdTP = numpy.std(tp)
289
290 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700291 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700292
Devin Lim58046fa2017-07-05 16:55:00 -0700293 resultsLog = open( "/tmp/flowTP1gDB", "a" )
294 resultString = ( "'" + main.commit + "'," )
295 resultString += ( "'1gig'," )
296 resultString += ( (main.params[ 'TEST' ][ 'flows' ] ) + "," )
297 resultString += ( str( main.numCtrls ) + "," )
298 resultString += ( str( n ) + "," )
299 resultString += ( str( avgTP ) + "," + str( stdTP ) + "\n" )
300 resultsLog.write( resultString )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700301 resultsLog.close()
Jon Hall4ba53f02015-07-29 13:07:41 -0700302
Devin Lim58046fa2017-07-05 16:55:00 -0700303 main.log.report( "Result line to file: " + resultString )
Jon Hall4ba53f02015-07-29 13:07:41 -0700304
Devin Lim58046fa2017-07-05 16:55:00 -0700305 main.ONOSbench.logReport( main.ONOSip[ 0 ], [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )