blob: 3a6f5032dbde40f6cf9bbd371ceaf6b0e7784fd7 [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' ]
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' ] )
Devin Lim142b5342017-07-20 15:22:39 -070072 main.defaultTopoCfg = main.params[ 'CFG' ][ 'defaultTopo' ]
Devin Lim58046fa2017-07-05 16:55:00 -070073 main.interface = main.params[ 'TEST' ][ 'interface' ]
74 main.timeout = int( main.params[ 'TIMEOUT' ][ 'timeout' ] )
75 main.MNSleep = int( main.params[ 'SLEEP' ][ 'mininet' ] )
76 main.device = main.params[ 'TEST' ][ 'device' ]
77 main.debug = main.params[ 'TEST' ][ 'debug' ]
GlennRCdc7ab012015-07-23 15:40:12 -070078
Devin Lim58046fa2017-07-05 16:55:00 -070079 if main.debug == "True":
80 main.debug = True
81 else:
82 main.debug = False
GlennRCdc7ab012015-07-23 15:40:12 -070083
Devin Lim142b5342017-07-20 15:22:39 -070084 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070085 main.log.info( "Create Database file " + main.dbFileName )
86 resultsDB = open( main.dbFileName, "w+" )
87 resultsDB.close()
YPZhang801d46d2016-08-08 13:26:28 -070088
Devin Lim58046fa2017-07-05 16:55:00 -070089 main.portFunc = imp.load_source( main.dependencyFunc,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070090 main.dependencyPath +
91 main.dependencyFunc +
92 ".py" )
Devin Lim58046fa2017-07-05 16:55:00 -070093 except Exception as e:
94 main.testSetUp.envSetupException( e )
95 main.testSetUp.evnSetupConclusion( stepResult )
96 main.commit = main.commit.split( " " )[ 1 ]
GlennRCdc7ab012015-07-23 15:40:12 -070097
YPZhang801d46d2016-08-08 13:26:28 -070098 def CASE1( self, main ):
99 # Clean up test environment and set up
100 import time
You Wanga0f6ff62018-01-11 15:46:30 -0800101 main.testSetUp.ONOSSetUp( main.Cluster, True,
Devin Lim142b5342017-07-20 15:22:39 -0700102 cellName=main.cellName, killRemoveMax=False )
YPZhang801d46d2016-08-08 13:26:28 -0700103
104 main.log.info( "Configure apps" )
Devin Lim142b5342017-07-20 15:22:39 -0700105 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
106 "maxEvents 1" )
107 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
108 "maxBatchMs 0" )
109 main.Cluster.active( 0 ).CLI.setCfg( main.defaultTopoCfg,
110 "maxIdleMs 0" )
111 time.sleep( 1 )
YPZhang801d46d2016-08-08 13:26:28 -0700112 main.log.info( "Copy topology file to Mininet" )
Devin Lim58046fa2017-07-05 16:55:00 -0700113 main.ONOSbench.copyMininetFile( main.topoName,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700114 main.dependencyPath,
115 main.Mininet1.user_name,
116 main.Mininet1.ip_address )
Devin Lim58046fa2017-07-05 16:55:00 -0700117 try:
118 from tests.dependencies.utils import Utils
119 except ImportError:
120 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700121 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700122 try:
123 main.Utils
124 except ( NameError, AttributeError ):
125 main.Utils = Utils()
126 main.Utils.mininetCleanup( main.Mininet1 )
YPZhang801d46d2016-08-08 13:26:28 -0700127 time.sleep( main.MNSleep )
128 main.log.info( "Start new mininet topology" )
GlennRCdc7ab012015-07-23 15:40:12 -0700129 main.Mininet1.startNet()
YPZhang801d46d2016-08-08 13:26:28 -0700130 main.log.info( "Assign switch to controller to ONOS node 1" )
Devin Lim142b5342017-07-20 15:22:39 -0700131 time.sleep( 1 )
132 main.Mininet1.assignSwController( sw='s1',
133 ip=main.Cluster.active( 0 ).ipAddress )
134 main.Mininet1.assignSwController( sw='s2',
135 ip=main.Cluster.active( 0 ).ipAddress )
GlennRCdc7ab012015-07-23 15:40:12 -0700136
Devin Lim142b5342017-07-20 15:22:39 -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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700143 resultDict = { 'up': {}, 'down': {} }
YPZhang801d46d2016-08-08 13:26:28 -0700144 for d in resultDict:
Devin Lim142b5342017-07-20 15:22:39 -0700145 for i in range( 1, main.Cluster.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' ] = []
You Wang51f903b2017-08-04 16:22:48 -0700153 for i in range( 0, main.sampleSize + main.warmUp ):
YPZhang801d46d2016-08-08 13:26:28 -0700154 main.log.info( "==========================================" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700155 main.log.info( "================iteration:{}==============".format( str( i + 1 ) ) )
You Wang51f903b2017-08-04 16:22:48 -0700156 if i >= main.warmUp:
YPZhang801d46d2016-08-08 13:26:28 -0700157 # Portdown iteration
Devin Lim142b5342017-07-20 15:22:39 -0700158 main.portFunc.capturePortStatusPack( main,
159 main.device,
160 main.interface,
161 "down",
162 resultDict,
163 False )
164 time.sleep( 2 )
YPZhang801d46d2016-08-08 13:26:28 -0700165 # PortUp iteration
Devin Lim142b5342017-07-20 15:22:39 -0700166 main.portFunc.capturePortStatusPack( main,
167 main.device,
168 main.interface,
169 "up",
170 resultDict,
171 False )
GlennRCdc7ab012015-07-23 15:40:12 -0700172 else:
YPZhang801d46d2016-08-08 13:26:28 -0700173 # if warm up, keep old result dictionary
Devin Lim142b5342017-07-20 15:22:39 -0700174 main.portFunc.capturePortStatusPack( main,
175 main.device,
176 main.interface,
177 "down",
178 resultDict,
179 True )
180 main.portFunc.capturePortStatusPack( main,
181 main.device,
182 main.interface,
183 "up",
184 resultDict,
185 True )
GlennRCdc7ab012015-07-23 15:40:12 -0700186
YPZhang801d46d2016-08-08 13:26:28 -0700187 # Dictionary for result
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700188 maxDict = {}
Devin Lim58046fa2017-07-05 16:55:00 -0700189 maxDict[ 'down' ] = {}
190 maxDict[ 'up' ] = {}
191 maxDict[ 'down' ][ 'max' ] = 0
192 maxDict[ 'up' ][ 'max' ] = 0
193 maxDict[ 'down' ][ 'node' ] = 0
194 maxDict[ 'up' ][ 'node' ] = 0
YPZhang801d46d2016-08-08 13:26:28 -0700195 EtoEtemp = 0
196 for d in resultDict:
Devin Lim142b5342017-07-20 15:22:39 -0700197 for i in range( 1, main.Cluster.numCtrls + 1 ):
YPZhang801d46d2016-08-08 13:26:28 -0700198 # calculate average and std for result, and grep the max End to End data
Devin Lim142b5342017-07-20 15:22:39 -0700199 EtoEtemp = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'EtoE' ] )
200 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp
201 if maxDict[ d ][ 'max' ] < EtoEtemp:
YPZhang801d46d2016-08-08 13:26:28 -0700202 # get max End to End latency
Devin Lim142b5342017-07-20 15:22:39 -0700203 maxDict[ d ][ 'max' ] = EtoEtemp
204 maxDict[ d ][ 'node' ] = i
205 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'PtoD' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'PtoD' ] )
206 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'DtoL' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'DtoL' ] )
207 resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'LtoG' ] = numpy.average( resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700208
Devin Lim142b5342017-07-20 15:22:39 -0700209 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'EtoE' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'EtoE' ] )
210 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'PtoD' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'PtoD' ] )
211 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'DtoL' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'DtoL' ] )
212 resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'LtoG' ] = numpy.std( resultDict[ d ][ 'node' + str( i ) ][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700213
Devin Lim142b5342017-07-20 15:22:39 -0700214 main.log.report( "=====node{} Summary:=====".format( str( i ) ) )
215 main.log.report( "=============Port {}=======".format( str( d ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700216 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700217 "End to End average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700218 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700219 "End to End Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700220 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700221 "Package to Device average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700222 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700223 "Package to Device Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700224 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700225 "Device to Link average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700226 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700227 "Device to Link Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700228 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700229 "Link to Grapg average: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Ave' ][ 'LtoG' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700230 main.log.report(
Devin Lim142b5342017-07-20 15:22:39 -0700231 "Link to Grapg Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'LtoG' ] ) ) )
GlennRCdc7ab012015-07-23 15:40:12 -0700232
YPZhang801d46d2016-08-08 13:26:28 -0700233 with open( main.dbFileName, "a" ) as dbFile:
234 # Scale number
Devin Lim142b5342017-07-20 15:22:39 -0700235 temp = str( main.Cluster.numCtrls )
YPZhang801d46d2016-08-08 13:26:28 -0700236 temp += ",'baremetal1'"
237 # put result
Devin Lim58046fa2017-07-05 16:55:00 -0700238 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
239 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
240 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
241 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
242 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
243 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
244 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
245 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700246
Devin Lim58046fa2017-07-05 16:55:00 -0700247 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
248 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700249
YPZhang801d46d2016-08-08 13:26:28 -0700250 temp += "\n"
251 dbFile.write( temp )
252 dbFile.close()