blob: c34adeaf2ad49c4d512edeeaa4ab346d195e82ff [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
Devin Limd2f199a2017-08-04 12:02:47 -070037 def CASE0( self, main ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070038
39 import time
cameron@onlab.us946d99c2015-07-08 15:34:37 -070040 try:
Devin Limd2f199a2017-08-04 12:02:47 -070041 from tests.dependencies.ONOSSetup import ONOSSetup
42 main.testSetUp = ONOSSetup()
43 except ImportError:
44 main.log.error("ONOSSetup not found. exiting the test")
45 main.exit()
46 main.testSetUp.envSetupDescription()
47 try:
48 #Load values from params file
49 cellName = main.params[ 'ENV' ][ 'cellName' ]
50 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
51 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
52 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
53 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
54 main.flowRuleCfg = main.params[ 'CFG' ][ 'flowRule' ]
55 main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
56 stepResult = main.testSetUp.envSetup()
57 resultsDB = open( "/tmp/flowTP1gDB", "w+" )
58 resultsDB.close()
59 except Exception as e:
60 main.testSetUp.envSetupException( e )
61 main.testSetUp.evnSetupConclusion( stepResult )
62 main.commit = ( main.commit.split( " " ) )[ 1 ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070063
Devin Limd2f199a2017-08-04 12:02:47 -070064 def CASE1( self, main ):
Devin Lim142b5342017-07-20 15:22:39 -070065 main.testSetUp.ONOSSetUp( "localhost", main.Cluster, True, cellName=cellName )
Jon Hall4ba53f02015-07-29 13:07:41 -070066
Devin Lim142b5342017-07-20 15:22:39 -070067 main.log.info( "Startup sequence complete" )
68 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
Chiyu Chengef109502016-11-21 15:51:38 -080069
cameron@onlab.us946d99c2015-07-08 15:34:37 -070070 def CASE2( self, main ):
71 #
Jon Hall4ba53f02015-07-29 13:07:41 -070072 # This is the flow TP test
cameron@onlab.us946d99c2015-07-08 15:34:37 -070073 #
Jon Hall4ba53f02015-07-29 13:07:41 -070074 import os.path
75 import numpy
cameron@onlab.us946d99c2015-07-08 15:34:37 -070076 import math
Jon Hall4ba53f02015-07-29 13:07:41 -070077 import time
cameron@onlab.us946d99c2015-07-08 15:34:37 -070078 import datetime
79 import traceback
80
81 global currentNeighbors
82 try:
83 currentNeighbors
84 except:
Devin Lim142b5342017-07-20 15:22:39 -070085 currentNeighbors = ( main.params[ 'TEST' ][ 'neighbors' ] ).split( "," )[ 0 ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070086 else:
87 if currentNeighbors == "r": #reset
88 currentNeighbors = "0"
89 else:
90 currentNeighbors = "a"
91
Devin Lim142b5342017-07-20 15:22:39 -070092 testCMD = [ 0, 0, 0, 0 ]
93 warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
94 sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
95 switches = int( main.params[ 'TEST' ][ 'switches' ] )
96 neighborList = ( main.params[ 'TEST' ][ 'neighbors' ] ).split( "," )
97 testCMD[ 0 ] = main.params[ 'TEST' ][ 'testCMD0' ]
98 testCMD[ 1 ] = main.params[ 'TEST' ][ 'testCMD1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -070099 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
100 cellName = main.params[ 'ENV' ][ 'cellName' ]
101 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
102 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
103 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
Devin Lim142b5342017-07-20 15:22:39 -0700104 homeDir = os.path.expanduser( '~' )
105 flowRuleBackup = str( main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ] )
106 main.log.info( "Flow Rule Backup is set to:" + flowRuleBackup )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700107
Devin Lim142b5342017-07-20 15:22:39 -0700108 servers = str( main.Cluster.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -0700109
Devin Lim142b5342017-07-20 15:22:39 -0700110 if main.Cluster.numCtrls == 1:
111 neighborList = [ '0' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700112 currentNeighbors = "r"
113 else:
114 if currentNeighbors == "a":
Devin Lim142b5342017-07-20 15:22:39 -0700115 neighborList = [ str( main.Cluster.numCtrls - 1 ) ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700116 currentNeighbors = "r"
117 else:
Devin Lim142b5342017-07-20 15:22:39 -0700118 neighborList = [ '0' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700119
Devin Lim142b5342017-07-20 15:22:39 -0700120 main.log.info( "neightborlist: " + str( neighborList ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700121
122 ts = time.time()
Devin Lim142b5342017-07-20 15:22:39 -0700123 st = datetime.datetime.fromtimestamp( ts ).strftime( '%Y-%m-%d %H:%M:%S' )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700124
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700125 for n in neighborList:
Devin Lim142b5342017-07-20 15:22:39 -0700126 main.step( "\tSTARTING TEST" )
127 main.step( "\tLOADING FROM SERVERS: \t" + str( main.Cluster.numCtrls ) )
128 main.step( "\tNEIGHBORS:\t" + n )
129 main.log.info( "=============================================================" )
130 main.log.info( "=============================================================" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700131 #write file to configure nil link
132 ipCSV = ""
Devin Lim142b5342017-07-20 15:22:39 -0700133 for i in range ( main.Cluster.maxCtrls ):
Devin Lim58046fa2017-07-05 16:55:00 -0700134 tempstr = "ip" + str( i + 1 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700135 ipCSV += main.params[ 'CTRL' ][ tempstr ]
Devin Lim142b5342017-07-20 15:22:39 -0700136 if i + 1 < main.Cluster.maxCtrls:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700137 ipCSV +=","
Jon Hall4ba53f02015-07-29 13:07:41 -0700138
Devin Lim142b5342017-07-20 15:22:39 -0700139 main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
140 main.flowRuleCfg,
141 "backupCount 1" )
142 for i in range( 3 ):
143 main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
144 main.nullProviderCfg,
145 "deviceCount 35" )
146 main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
147 main.nullProviderCfg,
148 "topoShape linear" )
149 main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress,
150 main.nullProviderCfg,
151 "enabled true" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700152
Devin Lim142b5342017-07-20 15:22:39 -0700153 time.sleep( 5 )
154 main.ONOSbench.handle.sendline( "onos $OC1 summary" )
155 main.ONOSbench.handle.expect( ":~" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700156 check = main.ONOSbench.handle.before
Devin Lim142b5342017-07-20 15:22:39 -0700157 main.log.info( "\nStart up check: \n" + check + "\n" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700158 if "SCC(s)=1," in check:
suibin zhanga3746bf2015-09-05 09:36:39 -0700159 main.ONOSbench.handle.sendline( "onos $OC1 balance-masters" )
suibin zhang45efc1b2015-09-04 16:48:10 -0700160 main.ONOSbench.handle.expect( ":~" )
Devin Lim142b5342017-07-20 15:22:39 -0700161 time.sleep( 5 )
162 main.ONOSbench.handle.sendline( "onos $OC1 roles " )
suibin zhang45efc1b2015-09-04 16:48:10 -0700163 main.ONOSbench.handle.expect ( ":~" )
164 main.log.info( "switch masterships:" + str( main.ONOSbench.handle.before ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700165 break
Devin Lim142b5342017-07-20 15:22:39 -0700166 time.sleep( 5 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700167
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700168 #devide flows
Devin Lim142b5342017-07-20 15:22:39 -0700169 flows = int( main.params[ 'TEST' ][ 'flows' ] )
170 main.log.info( "Flow Target = " + str( flows ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700171
Devin Lim142b5342017-07-20 15:22:39 -0700172 flows = ( flows *max( int( n )+1, int( servers ) ) )/( ( int( n ) + 1 ) * int( servers )*( switches ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700173
Devin Lim142b5342017-07-20 15:22:39 -0700174 main.log.info( "Flows per switch = " + str( flows ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700175
176 #build list of servers in "$OC1, $OC2...." format
177 serverEnvVars = ""
Devin Lim58046fa2017-07-05 16:55:00 -0700178 for i in range( int( servers ) ):
Devin Lim142b5342017-07-20 15:22:39 -0700179 serverEnvVars += ( "-s " + main.Cluster.active( i ).ipAddress + " " )
Jon Hall4ba53f02015-07-29 13:07:41 -0700180
Devin Lim142b5342017-07-20 15:22:39 -0700181 data = [ [ "" ]*int( servers ) ]*int( sampleSize )
182 maxes = [ "" ]*int( sampleSize )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700183
184 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
Devin Lim142b5342017-07-20 15:22:39 -0700185 flowCMD += testCMD[ 0 ] + " " + str( flows ) + " " + testCMD[ 1 ]
186 flowCMD += " " + str( n ) + " " + str( serverEnvVars ) + "-j"
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700187
Devin Lim142b5342017-07-20 15:22:39 -0700188 main.log.info( flowCMD )
189 #time.sleep( 60 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700190
Devin Lim142b5342017-07-20 15:22:39 -0700191 for test in range( 0, warmUp + sampleSize ):
Jon Hall4ba53f02015-07-29 13:07:41 -0700192 if test < warmUp:
Devin Lim142b5342017-07-20 15:22:39 -0700193 main.log.info( "Warm up " + str( test + 1 ) + " of " + str( warmUp ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700194 else:
Devin Lim142b5342017-07-20 15:22:39 -0700195 main.log.info( "====== Test run: " + str( test-warmUp+1 ) + " ======" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700196
Devin Lim142b5342017-07-20 15:22:39 -0700197 main.ONOSbench.handle.sendline( flowCMD )
198 main.ONOSbench.handle.expect( ":~" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700199 rawResult = main.ONOSbench.handle.before
Devin Lim142b5342017-07-20 15:22:39 -0700200 main.log.info( "Raw results: \n" + rawResult + "\n" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700201
Jon Hall4ba53f02015-07-29 13:07:41 -0700202 if "failed" in rawResult:
Devin Lim142b5342017-07-20 15:22:39 -0700203 main.log.report( "FLOW_TESTER.PY FAILURE" )
204 main.log.report( " \n" + rawResult + " \n" )
205 for ctrl in main.Cluster.active():
206 main.log.report( "=======================================================" )
207 main.log.report( ctrl.name + "LOG REPORT" )
208 main.ONOSbench.logReport( ctrl.ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
209 main.ONOSbench.handle.sendline( "onos $OC1 flows" )
210 main.ONOSbench.handle.expect( ":~" )
211 main.log.info( main.ONOSbench.handle.before )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700212
213 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700214
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700215 ########################################################################################
Devin Lim142b5342017-07-20 15:22:39 -0700216 result = [ "" ]*( main.Cluster.numCtrls )
Jon Hall4ba53f02015-07-29 13:07:41 -0700217
Devin Lim142b5342017-07-20 15:22:39 -0700218 #print( "rawResult: " + rawResult )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700219
220 rawResult = rawResult.splitlines()
221
Devin Lim142b5342017-07-20 15:22:39 -0700222 for node in range( main.Cluster.numCtrls ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700223 for line in rawResult:
Devin Lim142b5342017-07-20 15:22:39 -0700224 #print( "line: " + line )
225 if main.Cluster.active( node ).ipAddress in line and "server" in line:
Devin Lim58046fa2017-07-05 16:55:00 -0700226 temp = line.split( " " )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700227 for word in temp:
Devin Lim142b5342017-07-20 15:22:39 -0700228 #print ( "word: " + word )
229 if "elapsed" in repr( word ):
230 index = temp.index( word ) + 1
231 myParsed = ( temp[ index ] ).replace( ",", "" )
232 myParsed = myParsed.replace( "}", "" )
233 myParsed = int( myParsed )
Devin Lim58046fa2017-07-05 16:55:00 -0700234 result[ node ] = myParsed
Devin Lim142b5342017-07-20 15:22:39 -0700235 main.log.info( main.Cluster.active( node ).ipAddress + " : " + str( myParsed ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700236 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700237
238 if test >= warmUp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700239 for i in result:
240 if i == "":
Devin Lim142b5342017-07-20 15:22:39 -0700241 main.log.error( "Missing data point, critical failure incoming" )
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700242
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700243 print result
Devin Lim142b5342017-07-20 15:22:39 -0700244 maxes[ test-warmUp ] = max( result )
245 main.log.info( "Data collection iteration: " + str( test-warmUp ) + " of " + str( sampleSize ) )
246 main.log.info( "Throughput time: " + str( maxes[ test-warmUp ] ) + "(ms)" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700247
Devin Lim142b5342017-07-20 15:22:39 -0700248 data[ test-warmUp ] = result
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700249
Jon Hall4ba53f02015-07-29 13:07:41 -0700250 # wait for flows = 0
Devin Lim142b5342017-07-20 15:22:39 -0700251 for checkCount in range( 0, 5 ):
252 time.sleep( 10 )
253 main.ONOSbench.handle.sendline( "onos $OC1 summary" )
254 main.ONOSbench.handle.expect( ":~" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700255 flowCheck = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700256 if "flows=0," in flowCheck:
Devin Lim142b5342017-07-20 15:22:39 -0700257 main.log.info( "Flows removed" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700258 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700259 else:
260 for line in flowCheck.splitlines():
261 if "flows=" in line:
Devin Lim142b5342017-07-20 15:22:39 -0700262 main.log.info( "Current Summary: " + line )
Jon Hall4ba53f02015-07-29 13:07:41 -0700263 if checkCount == 2:
Devin Lim142b5342017-07-20 15:22:39 -0700264 main.log.info( "Flows are stuck, moving on " )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700265
266
Devin Lim142b5342017-07-20 15:22:39 -0700267 time.sleep( 5 )
Jon Hall4ba53f02015-07-29 13:07:41 -0700268
Devin Lim142b5342017-07-20 15:22:39 -0700269 main.log.info( "raw data: " + str( data ) )
270 main.log.info( "maxes:" + str( maxes ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700271
Jon Hall4ba53f02015-07-29 13:07:41 -0700272
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700273 # report data
Devin Lim142b5342017-07-20 15:22:39 -0700274 print( "" )
275 main.log.info( "\t Results (measurments are in milliseconds)" )
276 print( "" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700277
278 nodeString = ""
Devin Lim142b5342017-07-20 15:22:39 -0700279 for i in range( 1, int( servers ) + 1 ):
280 nodeString += ( "\tNode " + str( i ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700281
Devin Lim142b5342017-07-20 15:22:39 -0700282 for test in range( 0, sampleSize ):
283 main.log.info( "\t Test iteration " + str( test + 1 ) )
284 main.log.info( "\t------------------" )
285 main.log.info( nodeString )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700286 resultString = ""
287
Devin Lim142b5342017-07-20 15:22:39 -0700288 for i in range( 0, int( servers ) ):
289 resultString += ( "\t" + str( data[ test ][ i ] ) )
290 main.log.info( resultString )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700291
Devin Lim142b5342017-07-20 15:22:39 -0700292 print( "\n" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700293
Devin Lim142b5342017-07-20 15:22:39 -0700294 avgOfMaxes = numpy.mean( maxes )
295 main.log.info( "Average of max value from each test iteration: " + str( avgOfMaxes ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700296
Devin Lim142b5342017-07-20 15:22:39 -0700297 stdOfMaxes = numpy.std( maxes )
298 main.log.info( "Standard Deviation of max values: " + str( stdOfMaxes ) )
299 print( "\n\n" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700300
Devin Lim142b5342017-07-20 15:22:39 -0700301 avgTP = int( main.params[ 'TEST' ][ 'flows' ] ) / avgOfMaxes #result in kflows/second
Jon Hall4ba53f02015-07-29 13:07:41 -0700302
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700303 tp = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700304 for i in maxes:
Devin Lim142b5342017-07-20 15:22:39 -0700305 tp.append( ( int( main.params[ 'TEST' ][ 'flows' ] ) / i ) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700306
Devin Lim142b5342017-07-20 15:22:39 -0700307 stdTP = numpy.std( tp )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700308
Devin Lim142b5342017-07-20 15:22:39 -0700309 main.log.info( "Average thoughput: " + str( avgTP ) + " Kflows/second" )
310 main.log.info( "Standard deviation of throughput: " + str( stdTP ) + " Kflows/second" )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700311
Devin Lim58046fa2017-07-05 16:55:00 -0700312 resultsLog = open( "/tmp/flowTP1gDB", "a" )
313 resultString = ( "'" + main.commit + "'," )
314 resultString += ( "'1gig'," )
Devin Lim142b5342017-07-20 15:22:39 -0700315 resultString += ( ( main.params[ 'TEST' ][ 'flows' ] ) + "," )
316 resultString += ( str( main.Cluster.numCtrls ) + "," )
Devin Lim58046fa2017-07-05 16:55:00 -0700317 resultString += ( str( n ) + "," )
318 resultString += ( str( avgTP ) + "," + str( stdTP ) + "\n" )
319 resultsLog.write( resultString )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700320 resultsLog.close()
Jon Hall4ba53f02015-07-29 13:07:41 -0700321
Devin Lim58046fa2017-07-05 16:55:00 -0700322 main.log.report( "Result line to file: " + resultString )
Jon Hall4ba53f02015-07-29 13:07:41 -0700323
Devin Lim142b5342017-07-20 15:22:39 -0700324 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )