YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 1 | ''' |
| 2 | SCPFportLat test |
| 3 | Test latency for port status change |
| 4 | Up & Down: |
| 5 | PortStatus --- Device --- Link --- Graph |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 6 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 7 | yunpeng@onlab.us |
| 8 | ''' |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 9 | class SCPFportLat: |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 10 | def __init__( self ): |
| 11 | self.default = '' |
| 12 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 13 | def CASE0( self, main ): |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 14 | import os |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 15 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 25 | 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' ] |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 56 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 57 | if main.debug == "True": |
| 58 | main.debug = True |
| 59 | else: |
| 60 | main.debug = False |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 61 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 62 | stepResult = main.testSetUp.gitPulling() |
| 63 | main.log.info( "Create Database file " + main.dbFileName ) |
| 64 | resultsDB = open( main.dbFileName, "w+" ) |
| 65 | resultsDB.close() |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 66 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 67 | 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 ] |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 75 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 76 | def CASE1( self, main ): |
| 77 | # Clean up test environment and set up |
| 78 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 79 | 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 ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 84 | |
| 85 | main.log.info( "Configure apps" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 86 | 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" ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 92 | time.sleep(1) |
| 93 | main.log.info( "Copy topology file to Mininet" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 94 | main.ONOSbench.copyMininetFile( main.topoName, |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 95 | main.dependencyPath, |
| 96 | main.Mininet1.user_name, |
| 97 | main.Mininet1.ip_address) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 98 | 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 ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 108 | time.sleep( main.MNSleep ) |
| 109 | main.log.info( "Start new mininet topology" ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 110 | main.Mininet1.startNet() |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 111 | 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] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 115 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 116 | time.sleep(2) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 117 | |
| 118 | def CASE2( self, main ): |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 119 | import time |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 120 | import numpy |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 121 | # 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 ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 141 | else: |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 142 | # 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) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 145 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 146 | # Dictionary for result |
| 147 | maxDict = {} |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 148 | 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 |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 154 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 158 | EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ][ 'EtoE' ] ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 159 | resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 160 | if maxDict[d][ 'max' ] < EtoEtemp: |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 161 | # get max End to End latency |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 162 | 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' ] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 167 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 168 | 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' ] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 172 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 173 | main.log.report( "=====node{} Summary:=====".format( str(i) ) ) |
| 174 | main.log.report( "=============Port {}=======".format( str(d) ) ) |
| 175 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 176 | "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 177 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 178 | "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 179 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 180 | "Package to Device average: {}".format( str(resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 181 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 182 | "Package to Device Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] ) )) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 183 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 184 | "Device to Link average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 185 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 186 | "Device to Link Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] ) )) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 187 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 188 | "Link to Grapg average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 189 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 190 | "Link to Grapg Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] ) ) ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 191 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 192 | with open( main.dbFileName, "a" ) as dbFile: |
| 193 | # Scale number |
| 194 | temp = str( main.numCtrls ) |
| 195 | temp += ",'baremetal1'" |
| 196 | # put result |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 197 | 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' ] ) |
chengchiyu | 074e3ef | 2016-08-24 16:32:32 -0700 | [diff] [blame] | 205 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 206 | temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] ) |
| 207 | temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] ) |
chengchiyu | 074e3ef | 2016-08-24 16:32:32 -0700 | [diff] [blame] | 208 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 209 | temp += "\n" |
| 210 | dbFile.write( temp ) |
| 211 | dbFile.close() |