blob: 437d57b8c823574fe28163c2c68571a969fd1604 [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
YPZhang801d46d2016-08-08 13:26:28 -070022'''
23 SCPFportLat test
24 Test latency for port status change
25 Up & Down:
26 PortStatus --- Device --- Link --- Graph
GlennRCdc7ab012015-07-23 15:40:12 -070027
YPZhang801d46d2016-08-08 13:26:28 -070028 yunpeng@onlab.us
29'''
GlennRCdc7ab012015-07-23 15:40:12 -070030class SCPFportLat:
GlennRCdc7ab012015-07-23 15:40:12 -070031 def __init__( self ):
32 self.default = ''
33
YPZhang801d46d2016-08-08 13:26:28 -070034 def CASE0( self, main ):
GlennRCdc7ab012015-07-23 15:40:12 -070035 import os
YPZhang801d46d2016-08-08 13:26:28 -070036 import imp
37 '''
38 - GIT
39 - BUILDING ONOS
40 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
41 This step is usually skipped. Because in a Jenkins driven automated
42 test env. We want Jenkins jobs to pull&build for flexibility to handle
43 different versions of ONOS.
44 - Construct tests variables
45 '''
Devin Lim58046fa2017-07-05 16:55:00 -070046 try:
47 from tests.dependencies.ONOSSetup import ONOSSetup
48 main.testSetUp = ONOSSetup()
49 except ImportError:
50 main.log.error( "ONOSSetup not found. exiting the test" )
51 main.exit()
52 main.testSetUp.envSetupDescription()
53 stepResult = main.FALSE
54 try:
55 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
56 main.dependencyPath = main.testOnDirectory + \
57 main.params[ 'DEPENDENCY' ][ 'path' ]
58 main.dependencyFunc = main.params[ 'DEPENDENCY' ][ 'function' ]
59 main.topoName = main.params[ 'DEPENDENCY' ][ 'topology' ]
60 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
61 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
62 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
63 main.ofportStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
64 main.tsharkResultPath = main.params[ 'TSHARK' ][ 'tsharkReusltPath' ]
65 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
66 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
67 main.maxProcessTime = int( main.params[ 'TEST' ][ 'maxProcessTime' ] )
68 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
69 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
70 main.measurementSleep = int( main.params[ 'SLEEP' ][ 'measure' ] )
71 main.maxScale = int( main.params[ 'max' ] )
72 main.interface = main.params[ 'TEST' ][ 'interface' ]
73 main.timeout = int( main.params[ 'TIMEOUT' ][ 'timeout' ] )
74 main.MNSleep = int( main.params[ 'SLEEP' ][ 'mininet' ] )
75 main.device = main.params[ 'TEST' ][ 'device' ]
76 main.debug = main.params[ 'TEST' ][ 'debug' ]
GlennRCdc7ab012015-07-23 15:40:12 -070077
Devin Lim58046fa2017-07-05 16:55:00 -070078 if main.debug == "True":
79 main.debug = True
80 else:
81 main.debug = False
GlennRCdc7ab012015-07-23 15:40:12 -070082
Devin Lim58046fa2017-07-05 16:55:00 -070083 stepResult = main.testSetUp.gitPulling()
84 main.log.info( "Create Database file " + main.dbFileName )
85 resultsDB = open( main.dbFileName, "w+" )
86 resultsDB.close()
YPZhang801d46d2016-08-08 13:26:28 -070087
Devin Lim58046fa2017-07-05 16:55:00 -070088 main.portFunc = imp.load_source( main.dependencyFunc,
89 main.dependencyPath +
90 main.dependencyFunc +
91 ".py" )
92 except Exception as e:
93 main.testSetUp.envSetupException( e )
94 main.testSetUp.evnSetupConclusion( stepResult )
95 main.commit = main.commit.split( " " )[ 1 ]
GlennRCdc7ab012015-07-23 15:40:12 -070096
YPZhang801d46d2016-08-08 13:26:28 -070097 def CASE1( self, main ):
98 # Clean up test environment and set up
99 import time
Devin Lim58046fa2017-07-05 16:55:00 -0700100 main.testSetUp.getNumCtrls( True )
101 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
102 main.testSetUp.ONOSSetUp( main.Mininet1, True,
103 cellName=main.cellName, killRemoveMax=False,
104 CtrlsSet=False )
YPZhang801d46d2016-08-08 13:26:28 -0700105
106 main.log.info( "Configure apps" )
Devin Lim58046fa2017-07-05 16:55:00 -0700107 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
108 "maxEvents 1" )
109 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
110 "maxBatchMs 0" )
111 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
112 "maxIdleMs 0" )
YPZhang801d46d2016-08-08 13:26:28 -0700113 time.sleep(1)
114 main.log.info( "Copy topology file to Mininet" )
Devin Lim58046fa2017-07-05 16:55:00 -0700115 main.ONOSbench.copyMininetFile( main.topoName,
YPZhang801d46d2016-08-08 13:26:28 -0700116 main.dependencyPath,
117 main.Mininet1.user_name,
118 main.Mininet1.ip_address)
Devin Lim58046fa2017-07-05 16:55:00 -0700119 try:
120 from tests.dependencies.utils import Utils
121 except ImportError:
122 main.log.error( "Utils not found exiting the test" )
123 main.exit()
124 try:
125 main.Utils
126 except ( NameError, AttributeError ):
127 main.Utils = Utils()
128 main.Utils.mininetCleanup( main.Mininet1 )
YPZhang801d46d2016-08-08 13:26:28 -0700129 time.sleep( main.MNSleep )
130 main.log.info( "Start new mininet topology" )
GlennRCdc7ab012015-07-23 15:40:12 -0700131 main.Mininet1.startNet()
YPZhang801d46d2016-08-08 13:26:28 -0700132 main.log.info( "Assign switch to controller to ONOS node 1" )
133 time.sleep(1)
134 main.Mininet1.assignSwController( sw='s1', ip=main.ONOSip[0] )
135 main.Mininet1.assignSwController( sw='s2', ip=main.ONOSip[0] )
GlennRCdc7ab012015-07-23 15:40:12 -0700136
YPZhang801d46d2016-08-08 13:26:28 -0700137 time.sleep(2)
GlennRCdc7ab012015-07-23 15:40:12 -0700138
139 def CASE2( self, main ):
GlennRCdc7ab012015-07-23 15:40:12 -0700140 import time
GlennRCdc7ab012015-07-23 15:40:12 -0700141 import numpy
YPZhang801d46d2016-08-08 13:26:28 -0700142 # dictionary for each node and each timestamps
143 resultDict = {'up' : {}, 'down' : {}}
144 for d in resultDict:
145 for i in range( 1, main.numCtrls + 1 ):
146 resultDict[d][ 'node' + str(i) ] = {}
147 resultDict[d][ 'node' + str(i) ][ 'Ave' ] = {}
148 resultDict[d][ 'node' + str(i) ][ 'Std' ] = {}
149 resultDict[d][ 'node' + str(i) ][ 'EtoE' ] = []
150 resultDict[d][ 'node' + str(i) ][ 'PtoD' ] = []
151 resultDict[d][ 'node' + str(i) ][ 'DtoL' ] = []
152 resultDict[d][ 'node' + str(i) ][ 'LtoG' ] = []
153 for i in range( 1, main.sampleSize + main.warmUp ):
154 main.log.info( "==========================================" )
155 main.log.info( "================iteration:{}==============".format(str (i) ) )
156 if i > main.warmUp:
157 # Portdown iteration
158 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "down", resultDict, False )
159 time.sleep(2)
160 # PortUp iteration
161 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "up", resultDict, False )
GlennRCdc7ab012015-07-23 15:40:12 -0700162 else:
YPZhang801d46d2016-08-08 13:26:28 -0700163 # if warm up, keep old result dictionary
164 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "down", resultDict, True)
165 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "up", resultDict, True)
GlennRCdc7ab012015-07-23 15:40:12 -0700166
YPZhang801d46d2016-08-08 13:26:28 -0700167 # Dictionary for result
168 maxDict = {}
Devin Lim58046fa2017-07-05 16:55:00 -0700169 maxDict[ 'down' ] = {}
170 maxDict[ 'up' ] = {}
171 maxDict[ 'down' ][ 'max' ] = 0
172 maxDict[ 'up' ][ 'max' ] = 0
173 maxDict[ 'down' ][ 'node' ] = 0
174 maxDict[ 'up' ][ 'node' ] = 0
YPZhang801d46d2016-08-08 13:26:28 -0700175 EtoEtemp = 0
176 for d in resultDict:
177 for i in range( 1, main.numCtrls + 1 ):
178 # calculate average and std for result, and grep the max End to End data
Devin Lim58046fa2017-07-05 16:55:00 -0700179 EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ][ 'EtoE' ] )
YPZhang801d46d2016-08-08 13:26:28 -0700180 resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp
Devin Lim58046fa2017-07-05 16:55:00 -0700181 if maxDict[d][ 'max' ] < EtoEtemp:
YPZhang801d46d2016-08-08 13:26:28 -0700182 # get max End to End latency
Devin Lim58046fa2017-07-05 16:55:00 -0700183 maxDict[d][ 'max' ] = EtoEtemp
184 maxDict[d][ 'node' ] = i
185 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
186 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
187 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700188
Devin Lim58046fa2017-07-05 16:55:00 -0700189 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'EtoE' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'EtoE' ] )
190 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
191 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
192 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700193
YPZhang801d46d2016-08-08 13:26:28 -0700194 main.log.report( "=====node{} Summary:=====".format( str(i) ) )
195 main.log.report( "=============Port {}=======".format( str(d) ) )
196 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700197 "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700198 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700199 "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700200 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700201 "Package to Device average: {}".format( str(resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700202 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700203 "Package to Device Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] ) ))
YPZhang801d46d2016-08-08 13:26:28 -0700204 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700205 "Device to Link average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700206 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700207 "Device to Link Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] ) ))
YPZhang801d46d2016-08-08 13:26:28 -0700208 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700209 "Link to Grapg average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700210 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700211 "Link to Grapg Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] ) ) )
GlennRCdc7ab012015-07-23 15:40:12 -0700212
YPZhang801d46d2016-08-08 13:26:28 -0700213 with open( main.dbFileName, "a" ) as dbFile:
214 # Scale number
215 temp = str( main.numCtrls )
216 temp += ",'baremetal1'"
217 # put result
Devin Lim58046fa2017-07-05 16:55:00 -0700218 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
219 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
220 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
221 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
222 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
223 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
224 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
225 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700226
Devin Lim58046fa2017-07-05 16:55:00 -0700227 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
228 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700229
YPZhang801d46d2016-08-08 13:26:28 -0700230 temp += "\n"
231 dbFile.write( temp )
232 dbFile.close()