blob: 1de518f77729ee46b109856208a25e68105654e5 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
cameron@onlab.us946d99c2015-07-08 15:34:37 -070022# ScaleOutTemplate -> flowTP
23#
24# CASE1 starts number of nodes specified in param file
25#
26# cameron@onlab.us
27
28import sys
29import os.path
30
31
32class SCPFflowTp1g:
33
34 def __init__( self ):
35 self.default = ''
36
Jon Hall4ba53f02015-07-29 13:07:41 -070037 def CASE1( self, main ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070038
39 import time
40 global init
41 try:
Devin Lim58046fa2017-07-05 16:55:00 -070042 if type( init ) is not bool:
cameron@onlab.us946d99c2015-07-08 15:34:37 -070043 init = False
44 except NameError:
45 init = False
46
Devin Lim58046fa2017-07-05 16:55:00 -070047 main.log.info( "==========DEBUG VERSION 3===========" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -070048
cameron@onlab.us946d99c2015-07-08 15:34:37 -070049 # -- INIT SECTION, ONLY RUNS ONCE -- #
50 if init == False:
Devin Lim58046fa2017-07-05 16:55:00 -070051 try:
52 init = True
53 try:
54 from tests.dependencies.ONOSSetup import ONOSSetup
55 main.testSetUp = ONOSSetup()
56 except ImportError:
57 main.log.error( "ONOSSetup not found. exiting the test" )
58 main.exit()
59 main.testSetUp.envSetupDescription()
60 #Load values from params file
61 cellName = main.params[ 'ENV' ][ 'cellName' ]
62 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
63 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
64 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
65 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
66 stepResult = main.testSetUp.envSetup()
67 resultsDB = open( "/tmp/flowTP1gDB", "w+" )
68 resultsDB.close()
69 except Exception as e:
70 main.testSetUp.envSetupException( e )
71 main.testSetUp.evnSetupConclusion( stepResult )
72 main.commit = (main.commit.split(" "))[1]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070073 # -- END OF INIT SECTION --#
74
Devin Lim58046fa2017-07-05 16:55:00 -070075 main.testSetUp.ONOSSetUp( "localhost", True, cellName=cellName )
Jon Hall4ba53f02015-07-29 13:07:41 -070076
cameron@onlab.us946d99c2015-07-08 15:34:37 -070077 main.log.info("Startup sequence complete")
Devin Lim58046fa2017-07-05 16:55:00 -070078 main.ONOSbench.logReport(main.ONOSip[0], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
Chiyu Chengef109502016-11-21 15:51:38 -080079
cameron@onlab.us946d99c2015-07-08 15:34:37 -070080 def CASE2( self, main ):
81 #
Jon Hall4ba53f02015-07-29 13:07:41 -070082 # This is the flow TP test
cameron@onlab.us946d99c2015-07-08 15:34:37 -070083 #
Jon Hall4ba53f02015-07-29 13:07:41 -070084 import os.path
85 import numpy
cameron@onlab.us946d99c2015-07-08 15:34:37 -070086 import math
Jon Hall4ba53f02015-07-29 13:07:41 -070087 import time
cameron@onlab.us946d99c2015-07-08 15:34:37 -070088 import datetime
89 import traceback
90
91 global currentNeighbors
92 try:
93 currentNeighbors
94 except:
95 currentNeighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")[0]
96 else:
97 if currentNeighbors == "r": #reset
98 currentNeighbors = "0"
99 else:
100 currentNeighbors = "a"
101
102 testCMD = [ 0,0,0,0 ]
103 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
104 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
105 switches = int(main.params[ 'TEST' ][ 'switches' ])
106 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
107 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
108 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700109 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
110 cellName = main.params[ 'ENV' ][ 'cellName' ]
111 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
112 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
113 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700114 homeDir = os.path.expanduser('~')
115 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
116 main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
117
Devin Lim58046fa2017-07-05 16:55:00 -0700118 servers = str( main.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -0700119
Devin Lim58046fa2017-07-05 16:55:00 -0700120 if main.numCtrls == 1:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700121 neighborList = ['0']
122 currentNeighbors = "r"
123 else:
124 if currentNeighbors == "a":
Devin Lim58046fa2017-07-05 16:55:00 -0700125 neighborList = [ str( main.numCtrls - 1 ) ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700126 currentNeighbors = "r"
127 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700128 neighborList = ['0']
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700129
130 main.log.info("neightborlist: " + str(neighborList))
131
132 ts = time.time()
133 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
134
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700135 for n in neighborList:
Jon Hall6509dbf2016-06-21 17:01:17 -0700136 main.step("\tSTARTING TEST")
Devin Lim58046fa2017-07-05 16:55:00 -0700137 main.step("\tLOADING FROM SERVERS: \t" + str( main.numCtrls ) )
Jon Hall6509dbf2016-06-21 17:01:17 -0700138 main.step("\tNEIGHBORS:\t" + n )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700139 main.log.info("=============================================================")
140 main.log.info("=============================================================")
141 #write file to configure nil link
142 ipCSV = ""
Devin Lim58046fa2017-07-05 16:55:00 -0700143 for i in range ( main.maxNodes ):
144 tempstr = "ip" + str( i + 1 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700145 ipCSV += main.params[ 'CTRL' ][ tempstr ]
Devin Lim58046fa2017-07-05 16:55:00 -0700146 if i + 1 < main.maxNodes:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700147 ipCSV +=","
Jon Hall4ba53f02015-07-29 13:07:41 -0700148
Devin Lim58046fa2017-07-05 16:55:00 -0700149 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupCount 1")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700150 for i in range(3):
Devin Lim58046fa2017-07-05 16:55:00 -0700151 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
152 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
153 main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700154
155 time.sleep(5)
156 main.ONOSbench.handle.sendline("onos $OC1 summary")
157 main.ONOSbench.handle.expect(":~")
158 check = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700159 main.log.info("\nStart up check: \n" + check + "\n")
160 if "SCC(s)=1," in check:
suibin zhanga3746bf2015-09-05 09:36:39 -0700161 main.ONOSbench.handle.sendline( "onos $OC1 balance-masters" )
suibin zhang45efc1b2015-09-04 16:48:10 -0700162 main.ONOSbench.handle.expect( ":~" )
163 time.sleep(5)
164 main.ONOSbench.handle.sendline( "onos $OC1 roles ")
165 main.ONOSbench.handle.expect ( ":~" )
166 main.log.info( "switch masterships:" + str( main.ONOSbench.handle.before ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700167 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700168 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700169
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700170 #devide flows
171 flows = int(main.params[ 'TEST' ][ 'flows' ])
172 main.log.info("Flow Target = " + str(flows))
173
174 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
175
176 main.log.info("Flows per switch = " + str(flows))
177
178 #build list of servers in "$OC1, $OC2...." format
179 serverEnvVars = ""
Devin Lim58046fa2017-07-05 16:55:00 -0700180 for i in range( int( servers ) ):
181 serverEnvVars += ( "-s " + main.ONOSip[ i ] + " " )
Jon Hall4ba53f02015-07-29 13:07:41 -0700182
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700183 data = [[""]*int(servers)]*int(sampleSize)
184 maxes = [""]*int(sampleSize)
185
186 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
187 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
Jon Hall4ba53f02015-07-29 13:07:41 -0700188 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700189
190 main.log.info(flowCMD)
191 #time.sleep(60)
Jon Hall4ba53f02015-07-29 13:07:41 -0700192
193 for test in range(0, warmUp + sampleSize):
194 if test < warmUp:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700195 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
Jon Hall4ba53f02015-07-29 13:07:41 -0700196 else:
197 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700198
199 main.ONOSbench.handle.sendline(flowCMD)
200 main.ONOSbench.handle.expect(":~")
201 rawResult = main.ONOSbench.handle.before
202 main.log.info("Raw results: \n" + rawResult + "\n")
203
Jon Hall4ba53f02015-07-29 13:07:41 -0700204 if "failed" in rawResult:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700205 main.log.report("FLOW_TESTER.PY FAILURE")
206 main.log.report( " \n" + rawResult + " \n")
Devin Lim58046fa2017-07-05 16:55:00 -0700207 for i in range( main.numCtrls ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700208 main.log.report("=======================================================")
Devin Lim58046fa2017-07-05 16:55:00 -0700209 main.log.report(" ONOS " + str( i + 1 ) + "LOG REPORT")
210 main.ONOSbench.logReport( main.ONOSip[ i ], ["ERROR", "WARNING", "EXCEPT"], outputMode="d" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700211 main.ONOSbench.handle.sendline("onos $OC1 flows")
212 main.ONOSbench.handle.expect(":~")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700213 main.log.info(main.ONOSbench.handle.before)
214
215 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700216
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700217 ########################################################################################
Devin Lim58046fa2017-07-05 16:55:00 -0700218 result = [""]*( main.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -0700219
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700220 #print("rawResult: " + rawResult)
221
222 rawResult = rawResult.splitlines()
223
Devin Lim58046fa2017-07-05 16:55:00 -0700224 for node in range( main.numCtrls ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700225 for line in rawResult:
Jon Hall4ba53f02015-07-29 13:07:41 -0700226 #print("line: " + line)
Devin Lim58046fa2017-07-05 16:55:00 -0700227 if main.ONOSip[ node ] in line and "server" in line:
228 temp = line.split( " " )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700229 for word in temp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700230 #print ("word: " + word)
231 if "elapsed" in repr(word):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700232 index = temp.index(word) + 1
233 myParsed = (temp[index]).replace(",","")
234 myParsed = myParsed.replace("}","")
235 myParsed = int(myParsed)
Devin Lim58046fa2017-07-05 16:55:00 -0700236 result[ node ] = myParsed
237 main.log.info( main.ONOSip[ node ] + " : " + str( myParsed ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700238 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700239
240 if test >= warmUp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700241 for i in result:
242 if i == "":
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700243 main.log.error("Missing data point, critical failure incoming")
244
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700245 print result
246 maxes[test-warmUp] = max(result)
247 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
Jon Hall4ba53f02015-07-29 13:07:41 -0700248 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700249
250 data[test-warmUp] = result
251
Jon Hall4ba53f02015-07-29 13:07:41 -0700252 # wait for flows = 0
253 for checkCount in range(0,5):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700254 time.sleep(10)
255 main.ONOSbench.handle.sendline("onos $OC1 summary")
256 main.ONOSbench.handle.expect(":~")
257 flowCheck = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700258 if "flows=0," in flowCheck:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700259 main.log.info("Flows removed")
260 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700261 else:
262 for line in flowCheck.splitlines():
263 if "flows=" in line:
264 main.log.info("Current Summary: " + line)
265 if checkCount == 2:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700266 main.log.info("Flows are stuck, moving on ")
267
268
269 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700270
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700271 main.log.info("raw data: " + str(data))
272 main.log.info("maxes:" + str(maxes))
273
Jon Hall4ba53f02015-07-29 13:07:41 -0700274
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700275 # report data
276 print("")
277 main.log.info("\t Results (measurments are in milliseconds)")
278 print("")
279
280 nodeString = ""
281 for i in range(1, int(servers) + 1):
Jon Hall4ba53f02015-07-29 13:07:41 -0700282 nodeString += ("\tNode " + str(i))
283
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700284 for test in range(0, sampleSize ):
285 main.log.info("\t Test iteration " + str(test + 1) )
286 main.log.info("\t------------------")
Jon Hall4ba53f02015-07-29 13:07:41 -0700287 main.log.info(nodeString)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700288 resultString = ""
289
290 for i in range(0, int(servers) ):
Jon Hall4ba53f02015-07-29 13:07:41 -0700291 resultString += ("\t" + str(data[test][i]) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700292 main.log.info(resultString)
293
294 print("\n")
295
296 avgOfMaxes = numpy.mean(maxes)
297 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
298
299 stdOfMaxes = numpy.std(maxes)
Jon Hall4ba53f02015-07-29 13:07:41 -0700300 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700301 print("\n\n")
302
303 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
Jon Hall4ba53f02015-07-29 13:07:41 -0700304
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700305 tp = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700306 for i in maxes:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700307 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
308
309 stdTP = numpy.std(tp)
310
311 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700312 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700313
Devin Lim58046fa2017-07-05 16:55:00 -0700314 resultsLog = open( "/tmp/flowTP1gDB", "a" )
315 resultString = ( "'" + main.commit + "'," )
316 resultString += ( "'1gig'," )
317 resultString += ( (main.params[ 'TEST' ][ 'flows' ] ) + "," )
318 resultString += ( str( main.numCtrls ) + "," )
319 resultString += ( str( n ) + "," )
320 resultString += ( str( avgTP ) + "," + str( stdTP ) + "\n" )
321 resultsLog.write( resultString )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700322 resultsLog.close()
Jon Hall4ba53f02015-07-29 13:07:41 -0700323
Devin Lim58046fa2017-07-05 16:55:00 -0700324 main.log.report( "Result line to file: " + resultString )
Jon Hall4ba53f02015-07-29 13:07:41 -0700325
Devin Lim58046fa2017-07-05 16:55:00 -0700326 main.ONOSbench.logReport( main.ONOSip[ 0 ], [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )