blob: f00af9129e4328f998d464314a1675b6d5704113 [file] [log] [blame]
YPZhang801d46d2016-08-08 13:26:28 -07001'''
2 SCPFportLat test
3 Test latency for port status change
4 Up & Down:
5 PortStatus --- Device --- Link --- Graph
GlennRCdc7ab012015-07-23 15:40:12 -07006
YPZhang801d46d2016-08-08 13:26:28 -07007 yunpeng@onlab.us
8'''
GlennRCdc7ab012015-07-23 15:40:12 -07009class SCPFportLat:
GlennRCdc7ab012015-07-23 15:40:12 -070010 def __init__( self ):
11 self.default = ''
12
YPZhang801d46d2016-08-08 13:26:28 -070013 def CASE0( self, main ):
GlennRCdc7ab012015-07-23 15:40:12 -070014 import os
YPZhang801d46d2016-08-08 13:26:28 -070015 import imp
16 '''
17 - GIT
18 - BUILDING ONOS
19 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
20 This step is usually skipped. Because in a Jenkins driven automated
21 test env. We want Jenkins jobs to pull&build for flexibility to handle
22 different versions of ONOS.
23 - Construct tests variables
24 '''
Devin Lim58046fa2017-07-05 16:55:00 -070025 try:
26 from tests.dependencies.ONOSSetup import ONOSSetup
27 main.testSetUp = ONOSSetup()
28 except ImportError:
29 main.log.error( "ONOSSetup not found. exiting the test" )
30 main.exit()
31 main.testSetUp.envSetupDescription()
32 stepResult = main.FALSE
33 try:
34 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
35 main.dependencyPath = main.testOnDirectory + \
36 main.params[ 'DEPENDENCY' ][ 'path' ]
37 main.dependencyFunc = main.params[ 'DEPENDENCY' ][ 'function' ]
38 main.topoName = main.params[ 'DEPENDENCY' ][ 'topology' ]
39 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
40 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
41 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
42 main.ofportStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
43 main.tsharkResultPath = main.params[ 'TSHARK' ][ 'tsharkReusltPath' ]
44 main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
45 main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
46 main.maxProcessTime = int( main.params[ 'TEST' ][ 'maxProcessTime' ] )
47 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
48 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
49 main.measurementSleep = int( main.params[ 'SLEEP' ][ 'measure' ] )
50 main.maxScale = int( main.params[ 'max' ] )
51 main.interface = main.params[ 'TEST' ][ 'interface' ]
52 main.timeout = int( main.params[ 'TIMEOUT' ][ 'timeout' ] )
53 main.MNSleep = int( main.params[ 'SLEEP' ][ 'mininet' ] )
54 main.device = main.params[ 'TEST' ][ 'device' ]
55 main.debug = main.params[ 'TEST' ][ 'debug' ]
GlennRCdc7ab012015-07-23 15:40:12 -070056
Devin Lim58046fa2017-07-05 16:55:00 -070057 if main.debug == "True":
58 main.debug = True
59 else:
60 main.debug = False
GlennRCdc7ab012015-07-23 15:40:12 -070061
Devin Lim58046fa2017-07-05 16:55:00 -070062 stepResult = main.testSetUp.gitPulling()
63 main.log.info( "Create Database file " + main.dbFileName )
64 resultsDB = open( main.dbFileName, "w+" )
65 resultsDB.close()
YPZhang801d46d2016-08-08 13:26:28 -070066
Devin Lim58046fa2017-07-05 16:55:00 -070067 main.portFunc = imp.load_source( main.dependencyFunc,
68 main.dependencyPath +
69 main.dependencyFunc +
70 ".py" )
71 except Exception as e:
72 main.testSetUp.envSetupException( e )
73 main.testSetUp.evnSetupConclusion( stepResult )
74 main.commit = main.commit.split( " " )[ 1 ]
GlennRCdc7ab012015-07-23 15:40:12 -070075
YPZhang801d46d2016-08-08 13:26:28 -070076 def CASE1( self, main ):
77 # Clean up test environment and set up
78 import time
Devin Lim58046fa2017-07-05 16:55:00 -070079 main.testSetUp.getNumCtrls( True )
80 main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
81 main.testSetUp.ONOSSetUp( main.Mininet1, True,
82 cellName=main.cellName, killRemoveMax=False,
83 CtrlsSet=False )
YPZhang801d46d2016-08-08 13:26:28 -070084
85 main.log.info( "Configure apps" )
Devin Lim58046fa2017-07-05 16:55:00 -070086 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
87 "maxEvents 1" )
88 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
89 "maxBatchMs 0" )
90 main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
91 "maxIdleMs 0" )
YPZhang801d46d2016-08-08 13:26:28 -070092 time.sleep(1)
93 main.log.info( "Copy topology file to Mininet" )
Devin Lim58046fa2017-07-05 16:55:00 -070094 main.ONOSbench.copyMininetFile( main.topoName,
YPZhang801d46d2016-08-08 13:26:28 -070095 main.dependencyPath,
96 main.Mininet1.user_name,
97 main.Mininet1.ip_address)
Devin Lim58046fa2017-07-05 16:55:00 -070098 try:
99 from tests.dependencies.utils import Utils
100 except ImportError:
101 main.log.error( "Utils not found exiting the test" )
102 main.exit()
103 try:
104 main.Utils
105 except ( NameError, AttributeError ):
106 main.Utils = Utils()
107 main.Utils.mininetCleanup( main.Mininet1 )
YPZhang801d46d2016-08-08 13:26:28 -0700108 time.sleep( main.MNSleep )
109 main.log.info( "Start new mininet topology" )
GlennRCdc7ab012015-07-23 15:40:12 -0700110 main.Mininet1.startNet()
YPZhang801d46d2016-08-08 13:26:28 -0700111 main.log.info( "Assign switch to controller to ONOS node 1" )
112 time.sleep(1)
113 main.Mininet1.assignSwController( sw='s1', ip=main.ONOSip[0] )
114 main.Mininet1.assignSwController( sw='s2', ip=main.ONOSip[0] )
GlennRCdc7ab012015-07-23 15:40:12 -0700115
YPZhang801d46d2016-08-08 13:26:28 -0700116 time.sleep(2)
GlennRCdc7ab012015-07-23 15:40:12 -0700117
118 def CASE2( self, main ):
GlennRCdc7ab012015-07-23 15:40:12 -0700119 import time
GlennRCdc7ab012015-07-23 15:40:12 -0700120 import numpy
YPZhang801d46d2016-08-08 13:26:28 -0700121 # dictionary for each node and each timestamps
122 resultDict = {'up' : {}, 'down' : {}}
123 for d in resultDict:
124 for i in range( 1, main.numCtrls + 1 ):
125 resultDict[d][ 'node' + str(i) ] = {}
126 resultDict[d][ 'node' + str(i) ][ 'Ave' ] = {}
127 resultDict[d][ 'node' + str(i) ][ 'Std' ] = {}
128 resultDict[d][ 'node' + str(i) ][ 'EtoE' ] = []
129 resultDict[d][ 'node' + str(i) ][ 'PtoD' ] = []
130 resultDict[d][ 'node' + str(i) ][ 'DtoL' ] = []
131 resultDict[d][ 'node' + str(i) ][ 'LtoG' ] = []
132 for i in range( 1, main.sampleSize + main.warmUp ):
133 main.log.info( "==========================================" )
134 main.log.info( "================iteration:{}==============".format(str (i) ) )
135 if i > main.warmUp:
136 # Portdown iteration
137 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "down", resultDict, False )
138 time.sleep(2)
139 # PortUp iteration
140 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "up", resultDict, False )
GlennRCdc7ab012015-07-23 15:40:12 -0700141 else:
YPZhang801d46d2016-08-08 13:26:28 -0700142 # if warm up, keep old result dictionary
143 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "down", resultDict, True)
144 main.portFunc.capturePortStatusPack( main, main.device, main.interface, "up", resultDict, True)
GlennRCdc7ab012015-07-23 15:40:12 -0700145
YPZhang801d46d2016-08-08 13:26:28 -0700146 # Dictionary for result
147 maxDict = {}
Devin Lim58046fa2017-07-05 16:55:00 -0700148 maxDict[ 'down' ] = {}
149 maxDict[ 'up' ] = {}
150 maxDict[ 'down' ][ 'max' ] = 0
151 maxDict[ 'up' ][ 'max' ] = 0
152 maxDict[ 'down' ][ 'node' ] = 0
153 maxDict[ 'up' ][ 'node' ] = 0
YPZhang801d46d2016-08-08 13:26:28 -0700154 EtoEtemp = 0
155 for d in resultDict:
156 for i in range( 1, main.numCtrls + 1 ):
157 # calculate average and std for result, and grep the max End to End data
Devin Lim58046fa2017-07-05 16:55:00 -0700158 EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ][ 'EtoE' ] )
YPZhang801d46d2016-08-08 13:26:28 -0700159 resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp
Devin Lim58046fa2017-07-05 16:55:00 -0700160 if maxDict[d][ 'max' ] < EtoEtemp:
YPZhang801d46d2016-08-08 13:26:28 -0700161 # get max End to End latency
Devin Lim58046fa2017-07-05 16:55:00 -0700162 maxDict[d][ 'max' ] = EtoEtemp
163 maxDict[d][ 'node' ] = i
164 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
165 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
166 resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700167
Devin Lim58046fa2017-07-05 16:55:00 -0700168 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'EtoE' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'EtoE' ] )
169 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
170 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
171 resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
GlennRCdc7ab012015-07-23 15:40:12 -0700172
YPZhang801d46d2016-08-08 13:26:28 -0700173 main.log.report( "=====node{} Summary:=====".format( str(i) ) )
174 main.log.report( "=============Port {}=======".format( str(d) ) )
175 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700176 "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700177 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700178 "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700179 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700180 "Package to Device average: {}".format( str(resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700181 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700182 "Package to Device Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] ) ))
YPZhang801d46d2016-08-08 13:26:28 -0700183 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700184 "Device to Link average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700185 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700186 "Device to Link Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] ) ))
YPZhang801d46d2016-08-08 13:26:28 -0700187 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700188 "Link to Grapg average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] ) ) )
YPZhang801d46d2016-08-08 13:26:28 -0700189 main.log.report(
Devin Lim58046fa2017-07-05 16:55:00 -0700190 "Link to Grapg Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] ) ) )
GlennRCdc7ab012015-07-23 15:40:12 -0700191
YPZhang801d46d2016-08-08 13:26:28 -0700192 with open( main.dbFileName, "a" ) as dbFile:
193 # Scale number
194 temp = str( main.numCtrls )
195 temp += ",'baremetal1'"
196 # put result
Devin Lim58046fa2017-07-05 16:55:00 -0700197 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
198 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
199 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
200 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
201 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
202 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
203 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
204 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700205
Devin Lim58046fa2017-07-05 16:55:00 -0700206 temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
207 temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
chengchiyu074e3ef2016-08-24 16:32:32 -0700208
YPZhang801d46d2016-08-08 13:26:28 -0700209 temp += "\n"
210 dbFile.write( temp )
211 dbFile.close()