blob: 33840f6218c3fd35c9100edb19252e390473c86c [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
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"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070021"""
YPZhang801d46d2016-08-08 13:26:28 -070022 SCPFportLat test
23 Test latency for port status change
24 Up & Down:
25 PortStatus --- Device --- Link --- Graph
GlennRCdc7ab012015-07-23 15:40:12 -070026
YPZhang801d46d2016-08-08 13:26:28 -070027 yunpeng@onlab.us
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070028"""
GlennRCdc7ab012015-07-23 15:40:12 -070029class SCPFportLat:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070030
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070037 """
YPZhang801d46d2016-08-08 13:26:28 -070038 - 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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070045 """
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" )
Devin Lim44075962017-08-11 10:56:37 -070051 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070052 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' ]
You Wangb2043922020-10-28 18:45:24 -070065 main.tsharkInterface = main.params[ 'TSHARK' ][ 'tsharkInterface' ]
Devin Lim58046fa2017-07-05 16:55:00 -070066 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
67 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
68 main.maxProcessTime = int( main.params[ 'TEST' ][ 'maxProcessTime' ] )
69 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
70 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
71 main.measurementSleep = int( main.params[ 'SLEEP' ][ 'measure' ] )
72 main.maxScale = int( main.params[ 'max' ] )
Devin Lim142b5342017-07-20 15:22:39 -070073 main.defaultTopoCfg = main.params[ 'CFG' ][ 'defaultTopo' ]
Devin Lim58046fa2017-07-05 16:55:00 -070074 main.interface = main.params[ 'TEST' ][ 'interface' ]
75 main.timeout = int( main.params[ 'TIMEOUT' ][ 'timeout' ] )
76 main.MNSleep = int( main.params[ 'SLEEP' ][ 'mininet' ] )
77 main.device = main.params[ 'TEST' ][ 'device' ]
78 main.debug = main.params[ 'TEST' ][ 'debug' ]
GlennRCdc7ab012015-07-23 15:40:12 -070079
Devin Lim58046fa2017-07-05 16:55:00 -070080 if main.debug == "True":
81 main.debug = True
82 else:
83 main.debug = False
GlennRCdc7ab012015-07-23 15:40:12 -070084
Devin Lim142b5342017-07-20 15:22:39 -070085 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070086 main.log.info( "Create Database file " + main.dbFileName )
87 resultsDB = open( main.dbFileName, "w+" )
88 resultsDB.close()
YPZhang801d46d2016-08-08 13:26:28 -070089
Devin Lim58046fa2017-07-05 16:55:00 -070090 main.portFunc = imp.load_source( main.dependencyFunc,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070091 main.dependencyPath +
92 main.dependencyFunc +
93 ".py" )
Devin Lim58046fa2017-07-05 16:55:00 -070094 except Exception as e:
95 main.testSetUp.envSetupException( e )
Jon Hallaa1d9b82020-07-30 13:49:42 -070096 main.testSetUp.envSetupConclusion( stepResult )
Devin Lim58046fa2017-07-05 16:55:00 -070097 main.commit = main.commit.split( " " )[ 1 ]
GlennRCdc7ab012015-07-23 15:40:12 -070098
YPZhang801d46d2016-08-08 13:26:28 -070099 def CASE1( self, main ):
100 # Clean up test environment and set up
101 import time
You Wanga0f6ff62018-01-11 15:46:30 -0800102 main.testSetUp.ONOSSetUp( main.Cluster, True,
Devin Lim142b5342017-07-20 15:22:39 -0700103 cellName=main.cellName, killRemoveMax=False )
YPZhang801d46d2016-08-08 13:26:28 -0700104
105 main.log.info( "Configure apps" )
Devin Lim142b5342017-07-20 15:22:39 -0700106 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
107 "maxEvents 1" )
108 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
109 "maxBatchMs 0" )
110 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
111 "maxIdleMs 0" )
112 time.sleep( 1 )
YPZhang801d46d2016-08-08 13:26:28 -0700113 main.log.info( "Copy topology file to Mininet" )
Devin Lim58046fa2017-07-05 16:55:00 -0700114 main.ONOSbench.copyMininetFile( main.topoName,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700115 main.dependencyPath,
116 main.Mininet1.user_name,
117 main.Mininet1.ip_address )
Devin Lim58046fa2017-07-05 16:55:00 -0700118 try:
119 from tests.dependencies.utils import Utils
120 except ImportError:
121 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700122 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700123 try:
124 main.Utils
125 except ( NameError, AttributeError ):
126 main.Utils = Utils()
127 main.Utils.mininetCleanup( main.Mininet1 )
YPZhang801d46d2016-08-08 13:26:28 -0700128 time.sleep( main.MNSleep )
129 main.log.info( "Start new mininet topology" )
GlennRCdc7ab012015-07-23 15:40:12 -0700130 main.Mininet1.startNet()
YPZhang801d46d2016-08-08 13:26:28 -0700131 main.log.info( "Assign switch to controller to ONOS node 1" )
Devin Lim142b5342017-07-20 15:22:39 -0700132 time.sleep( 1 )
133 main.Mininet1.assignSwController( sw='s1',
134 ip=main.Cluster.active( 0 ).ipAddress )
135 main.Mininet1.assignSwController( sw='s2',
136 ip=main.Cluster.active( 0 ).ipAddress )
GlennRCdc7ab012015-07-23 15:40:12 -0700137
Devin Lim142b5342017-07-20 15:22:39 -0700138 time.sleep( 2 )
GlennRCdc7ab012015-07-23 15:40:12 -0700139
140 def CASE2( self, main ):
GlennRCdc7ab012015-07-23 15:40:12 -0700141 import time
GlennRCdc7ab012015-07-23 15:40:12 -0700142 import numpy
YPZhang801d46d2016-08-08 13:26:28 -0700143 # dictionary for each node and each timestamps
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700144 resultDict = { 'up': {}, 'down': {} }
YPZhang801d46d2016-08-08 13:26:28 -0700145 for d in resultDict:
Devin Lim142b5342017-07-20 15:22:39 -0700146 for i in range( 1, main.Cluster.numCtrls + 1 ):
147 resultDict[ d ][ 'node' + str( i ) ] = {}
148 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ] = {}
149 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ] = {}
150 resultDict[ d ][ 'node' + str( i ) ][ 'EtoE' ] = []
151 resultDict[ d ][ 'node' + str( i ) ][ 'PtoD' ] = []
152 resultDict[ d ][ 'node' + str( i ) ][ 'DtoL' ] = []
153 resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] = []
You Wang51f903b2017-08-04 16:22:48 -0700154 for i in range( 0, main.sampleSize + main.warmUp ):
YPZhang801d46d2016-08-08 13:26:28 -0700155 main.log.info( "==========================================" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700156 main.log.info( "================iteration:{}==============".format( str( i + 1 ) ) )
You Wang51f903b2017-08-04 16:22:48 -0700157 if i >= main.warmUp:
YPZhang801d46d2016-08-08 13:26:28 -0700158 # Portdown iteration
Devin Lim142b5342017-07-20 15:22:39 -0700159 main.portFunc.capturePortStatusPack( main,
160 main.device,
161 main.interface,
162 "down",
163 resultDict,
You Wangb2043922020-10-28 18:45:24 -0700164 False,
165 main.tsharkInterface )
Devin Lim142b5342017-07-20 15:22:39 -0700166 time.sleep( 2 )
YPZhang801d46d2016-08-08 13:26:28 -0700167 # PortUp iteration
Devin Lim142b5342017-07-20 15:22:39 -0700168 main.portFunc.capturePortStatusPack( main,
169 main.device,
170 main.interface,
171 "up",
172 resultDict,
You Wangb2043922020-10-28 18:45:24 -0700173 False,
174 main.tsharkInterface )
GlennRCdc7ab012015-07-23 15:40:12 -0700175 else:
YPZhang801d46d2016-08-08 13:26:28 -0700176 # if warm up, keep old result dictionary
Devin Lim142b5342017-07-20 15:22:39 -0700177 main.portFunc.capturePortStatusPack( main,
178 main.device,
179 main.interface,
180 "down",
181 resultDict,
You Wangb2043922020-10-28 18:45:24 -0700182 True,
183 main.tsharkInterface )
Devin Lim142b5342017-07-20 15:22:39 -0700184 main.portFunc.capturePortStatusPack( main,
185 main.device,
186 main.interface,
187 "up",
188 resultDict,
You Wangb2043922020-10-28 18:45:24 -0700189 True,
190 main.tsharkInterface )
GlennRCdc7ab012015-07-23 15:40:12 -0700191
YPZhang801d46d2016-08-08 13:26:28 -0700192 # Dictionary for result
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700193 maxDict = {}
Devin Lim58046fa2017-07-05 16:55:00 -0700194 maxDict[ 'down' ] = {}
195 maxDict[ 'up' ] = {}
196 maxDict[ 'down' ][ 'max' ] = 0
197 maxDict[ 'up' ][ 'max' ] = 0
198 maxDict[ 'down' ][ 'node' ] = 0
199 maxDict[ 'up' ][ 'node' ] = 0
YPZhang801d46d2016-08-08 13:26:28 -0700200 EtoEtemp = 0
201 for d in resultDict:
Devin Lim142b5342017-07-20 15:22:39 -0700202 for i in range( 1, main.Cluster.numCtrls + 1 ):
YPZhang801d46d2016-08-08 13:26:28 -0700203 # calculate average and std for result, and grep the max End to End data
Devin Lim142b5342017-07-20 15:22:39 -0700204 EtoEtemp = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'EtoE' ] )
205 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp
206 if maxDict[ d ][ 'max' ] < EtoEtemp:
YPZhang801d46d2016-08-08 13:26:28 -0700207 # get max End to End latency
Devin Lim142b5342017-07-20 15:22:39 -0700208 maxDict[ d ][ 'max' ] = EtoEtemp
209 maxDict[ d ][ 'node' ] = i
210 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'PtoD' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'PtoD' ] )
211 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'DtoL' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'DtoL' ] )
212 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'LtoG' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700213
Devin Lim142b5342017-07-20 15:22:39 -0700214 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'EtoE' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'EtoE' ] )
215 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'PtoD' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'PtoD' ] )
216 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'DtoL' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'DtoL' ] )
217 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'LtoG' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700218
Devin Lim142b5342017-07-20 15:22:39 -0700219 main.log.report( "=====node{} Summary:=====".format( str( i ) ) )
220 main.log.report( "=============Port {}=======".format( str( d ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700221 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700222 "End to End average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700223 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700224 "End to End Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700225 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700226 "Package to Device average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700227 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700228 "Package to Device Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700229 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700230 "Device to Link average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700231 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700232 "Device to Link Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700233 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700234 "Link to Grapg average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'LtoG' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700235 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700236 "Link to Grapg Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'LtoG' ] ) ) )
GlennRCdc7ab012015-07-23 15:40:12 -0700237
You Wanga8e75022019-02-21 15:38:26 -0800238 # Check if any result is abnormal
You Wangaa7bc722019-02-21 17:55:39 -0800239 # Port-up
You Wanga8e75022019-02-21 15:38:26 -0800240 result = resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ]
You Wangaa7bc722019-02-21 17:55:39 -0800241 threshold = float( main.params[ 'ALARM' ][ 'maxPortUpAvg' ].split( ',' )[ main.cycle - 1 ] )
242 if result > threshold:
243 main.log.alarm( "{}-node port-up avg: {} ms > {} ms".format( main.Cluster.numCtrls, result, threshold ) )
You Wanga8e75022019-02-21 15:38:26 -0800244 result = resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ]
You Wangaa7bc722019-02-21 17:55:39 -0800245 threshold = float( main.params[ 'ALARM' ][ 'maxPortUpStd' ].split( ',' )[ main.cycle - 1 ] )
246 if result > threshold:
247 main.log.alarm( "{}-node port-up std: {} ms > {} ms".format( main.Cluster.numCtrls, result, threshold ) )
248 # Port-down
You Wanga8e75022019-02-21 15:38:26 -0800249 result = resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ]
You Wangaa7bc722019-02-21 17:55:39 -0800250 threshold = float( main.params[ 'ALARM' ][ 'maxPortDownAvg' ].split( ',' )[ main.cycle - 1 ] )
251 if result > threshold:
252 main.log.alarm( "{}-node port-down avg: {} ms > {} ms".format( main.Cluster.numCtrls, result, threshold ) )
You Wanga8e75022019-02-21 15:38:26 -0800253 result = resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ]
You Wangaa7bc722019-02-21 17:55:39 -0800254 threshold = float( main.params[ 'ALARM' ][ 'maxPortDownStd' ].split( ',' )[ main.cycle - 1 ] )
255 if result > threshold:
256 main.log.alarm( "{}-node port-down std: {} ms > {} ms".format( main.Cluster.numCtrls, result, threshold ) )
You Wanga8e75022019-02-21 15:38:26 -0800257
YPZhang801d46d2016-08-08 13:26:28 -0700258 with open( main.dbFileName, "a" ) as dbFile:
259 # Scale number
Devin Lim142b5342017-07-20 15:22:39 -0700260 temp = str( main.Cluster.numCtrls )
YPZhang801d46d2016-08-08 13:26:28 -0700261 temp += ",'baremetal1'"
262 # put result
Devin Lim58046fa2017-07-05 16:55:00 -0700263 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
264 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
265 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
266 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
267 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
268 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
269 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
270 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700271
Devin Lim58046fa2017-07-05 16:55:00 -0700272 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
273 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700274
YPZhang801d46d2016-08-08 13:26:28 -0700275 temp += "\n"
276 dbFile.write( temp )
277 dbFile.close()