Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2015 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 22 | ''' |
| 23 | SCPFportLat test |
| 24 | Test latency for port status change |
| 25 | Up & Down: |
| 26 | PortStatus --- Device --- Link --- Graph |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 27 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 28 | yunpeng@onlab.us |
| 29 | ''' |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 30 | class SCPFportLat: |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 31 | def __init__( self ): |
| 32 | self.default = '' |
| 33 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 34 | def CASE0( self, main ): |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 35 | import os |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 36 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 46 | 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' ] |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 77 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 78 | if main.debug == "True": |
| 79 | main.debug = True |
| 80 | else: |
| 81 | main.debug = False |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 82 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 83 | stepResult = main.testSetUp.gitPulling() |
| 84 | main.log.info( "Create Database file " + main.dbFileName ) |
| 85 | resultsDB = open( main.dbFileName, "w+" ) |
| 86 | resultsDB.close() |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 87 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 88 | 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 ] |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 96 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 97 | def CASE1( self, main ): |
| 98 | # Clean up test environment and set up |
| 99 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 100 | 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 ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 105 | |
| 106 | main.log.info( "Configure apps" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 107 | 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" ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 113 | time.sleep(1) |
| 114 | main.log.info( "Copy topology file to Mininet" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 115 | main.ONOSbench.copyMininetFile( main.topoName, |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 116 | main.dependencyPath, |
| 117 | main.Mininet1.user_name, |
| 118 | main.Mininet1.ip_address) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 119 | 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 ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 129 | time.sleep( main.MNSleep ) |
| 130 | main.log.info( "Start new mininet topology" ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 131 | main.Mininet1.startNet() |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 132 | 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] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 136 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 137 | time.sleep(2) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 138 | |
| 139 | def CASE2( self, main ): |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 140 | import time |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 141 | import numpy |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 142 | # 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 ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 162 | else: |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 163 | # 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) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 166 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 167 | # Dictionary for result |
| 168 | maxDict = {} |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 169 | 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 |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 175 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 179 | EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ][ 'EtoE' ] ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 180 | resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 181 | if maxDict[d][ 'max' ] < EtoEtemp: |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 182 | # get max End to End latency |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 183 | 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' ] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 188 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 189 | 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' ] ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 193 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 194 | main.log.report( "=====node{} Summary:=====".format( str(i) ) ) |
| 195 | main.log.report( "=============Port {}=======".format( str(d) ) ) |
| 196 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 197 | "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 198 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 199 | "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 200 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 201 | "Package to Device average: {}".format( str(resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 202 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 203 | "Package to Device Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] ) )) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 204 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 205 | "Device to Link average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 206 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 207 | "Device to Link Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] ) )) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 208 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 209 | "Link to Grapg average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] ) ) ) |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 210 | main.log.report( |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 211 | "Link to Grapg Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] ) ) ) |
GlennRC | dc7ab01 | 2015-07-23 15:40:12 -0700 | [diff] [blame] | 212 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 213 | with open( main.dbFileName, "a" ) as dbFile: |
| 214 | # Scale number |
| 215 | temp = str( main.numCtrls ) |
| 216 | temp += ",'baremetal1'" |
| 217 | # put result |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 218 | 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' ] ) |
chengchiyu | 074e3ef | 2016-08-24 16:32:32 -0700 | [diff] [blame] | 226 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 227 | temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] ) |
| 228 | temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] ) |
chengchiyu | 074e3ef | 2016-08-24 16:32:32 -0700 | [diff] [blame] | 229 | |
YPZhang | 801d46d | 2016-08-08 13:26:28 -0700 | [diff] [blame] | 230 | temp += "\n" |
| 231 | dbFile.write( temp ) |
| 232 | dbFile.close() |