YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 1 | ''' |
| 2 | SCPFswitchLat |
| 3 | Test Switch add/remove latency |
| 4 | calculate package latency between switch and ONOS |
| 5 | Switch UP: |
| 6 | TCP -- Feature Reply -- Role Request -- Role Reply -- Device -- Graph |
| 7 | Siwtch Down: |
| 8 | Openflow FIN/ACK -- ACK -- Device -- Graph |
| 9 | ''' |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 10 | |
| 11 | class SCPFswitchLat: |
| 12 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 13 | def __init__(self): |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 14 | self.default = '' |
| 15 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 16 | def CASE0( self, main ): |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 17 | import os |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 18 | import imp |
| 19 | ''' |
| 20 | - GIT |
| 21 | - BUILDING ONOS |
| 22 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 23 | This step is usually skipped. Because in a Jenkins driven automated |
| 24 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 25 | different versions of ONOS. |
| 26 | - Construct tests variables |
| 27 | ''' |
| 28 | gitPull = main.params['GIT']['gitPull'] |
| 29 | gitBranch = main.params['GIT']['gitBranch'] |
| 30 | |
| 31 | main.case( "Pull onos branch and build onos on Teststation." ) |
| 32 | |
| 33 | if gitPull == 'True': |
| 34 | main.step( "Git Checkout ONOS branch: " + gitBranch ) |
| 35 | stepResult = main.ONOSbench.gitCheckout( branch=gitBranch ) |
| 36 | utilities.assert_equals(expect=main.TRUE, |
| 37 | actual=stepResult, |
| 38 | onpass="Successfully checkout onos branch.", |
| 39 | onfail="Failed to checkout onos branch. Exiting test...") |
| 40 | if not stepResult: main.exit() |
| 41 | |
| 42 | main.step( "Git Pull on ONOS branch:" + gitBranch ) |
| 43 | stepResult = main.ONOSbench.gitPull() |
| 44 | utilities.assert_equals(expect=main.TRUE, |
| 45 | actual=stepResult, |
| 46 | onpass="Successfully pull onos. ", |
| 47 | onfail="Failed to pull onos. Exiting test ...") |
| 48 | if not stepResult: main.exit() |
| 49 | |
| 50 | main.step( "Building ONOS branch: " + gitBranch ) |
| 51 | stepResult = main.ONOSbench.cleanInstall( skipTest=True ) |
| 52 | utilities.assert_equals(expect=main.TRUE, |
| 53 | actual=stepResult, |
| 54 | onpass="Successfully build onos.", |
| 55 | onfail="Failed to build onos. Exiting test...") |
| 56 | if not stepResult: main.exit() |
| 57 | |
| 58 | else: |
| 59 | main.log.warn( "Skipped pulling onos and Skipped building ONOS" ) |
chengchiyu | 08303a0 | 2016-09-08 17:40:26 -0700 | [diff] [blame] | 60 | # The dictionary to record different type of wrongs |
| 61 | main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0, |
| 62 | 'TypeError' : 0, 'decodeJasonError': 0, |
| 63 | 'checkResultIncorrect': 0} |
| 64 | main.maxWrong = int( main.params['TEST'] ['MaxWrong'] ) |
| 65 | main.resultRange = main.params['TEST']['ResultRange'] |
| 66 | main.searchTerm = main.params['TEST']['SearchTerm'] |
| 67 | main.testOnDirectory = os.path.dirname( os.getcwd() ) |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 68 | main.MN1Ip = main.params['MN']['ip1'] |
| 69 | main.dependencyPath = main.testOnDirectory + \ |
| 70 | main.params['DEPENDENCY']['path'] |
| 71 | main.topoName = main.params['DEPENDENCY']['topology'] |
| 72 | main.dependencyFunc = main.params['DEPENDENCY']['function'] |
| 73 | main.cellName = main.params['ENV']['cellName'] |
| 74 | main.Apps = main.params['ENV']['cellApps'] |
| 75 | main.scale = (main.params['SCALE']).split(",") |
| 76 | |
| 77 | main.ofPackage = main.params['TSHARK'] |
| 78 | |
| 79 | main.tsharkResultPath = main.params['TEST']['tsharkResultPath'] |
| 80 | main.sampleSize = int(main.params['TEST']['sampleSize']) |
| 81 | main.warmUp = int(main.params['TEST']['warmUp']) |
| 82 | main.dbFileName = main.params['DATABASE']['dbName'] |
| 83 | main.startUpSleep = int(main.params['SLEEP']['startup']) |
| 84 | main.measurementSleep = int( main.params['SLEEP']['measure'] ) |
chengchiyu | 08303a0 | 2016-09-08 17:40:26 -0700 | [diff] [blame] | 85 | main.deleteSwSleep = int( main.params['SLEEP']['deleteSW'] ) |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 86 | main.maxScale = int( main.params['max'] ) |
| 87 | main.timeout = int( main.params['TIMEOUT']['timeout'] ) |
| 88 | main.MNSleep = int( main.params['SLEEP']['mininet']) |
| 89 | main.device = main.params['TEST']['device'] |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 90 | main.log.info("Create Database file " + main.dbFileName) |
| 91 | resultsDB = open(main.dbFileName, "w+") |
| 92 | resultsDB.close() |
| 93 | |
| 94 | main.switchFunc = imp.load_source(main.dependencyFunc, |
| 95 | main.dependencyPath + |
| 96 | main.dependencyFunc + |
| 97 | ".py") |
| 98 | |
| 99 | def CASE1(self, main): |
| 100 | # Clean up test environment and set up |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 101 | import time |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 102 | main.log.info("Get ONOS cluster IP") |
| 103 | print(main.scale) |
| 104 | main.numCtrls = int(main.scale.pop(0)) |
| 105 | main.ONOSip = [] |
| 106 | main.maxNumBatch = 0 |
| 107 | main.AllONOSip = main.ONOSbench.getOnosIps() |
| 108 | for i in range(main.numCtrls): |
| 109 | main.ONOSip.append(main.AllONOSip[i]) |
| 110 | main.log.info(main.ONOSip) |
| 111 | main.CLIs = [] |
| 112 | main.log.info("Creating list of ONOS cli handles") |
| 113 | for i in range(main.numCtrls): |
| 114 | main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1))) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 115 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 116 | if not main.CLIs: |
| 117 | main.log.error("Failed to create the list of ONOS cli handles") |
| 118 | main.cleanup() |
| 119 | main.exit() |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 120 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 121 | main.commit = main.ONOSbench.getVersion(report=True) |
| 122 | main.commit = main.commit.split(" ")[1] |
| 123 | main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls) |
| 124 | main.log.info("Safety check, killing all ONOS processes" + |
| 125 | " before initiating environment setup") |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 126 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 127 | for i in range(main.numCtrls): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 128 | main.ONOSbench.onosStop(main.ONOSip[i]) |
| 129 | main.ONOSbench.onosKill(main.ONOSip[i]) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 130 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 131 | main.log.info("NODE COUNT = %s" % main.numCtrls) |
| 132 | main.ONOSbench.createCellFile(main.ONOSbench.ip_address, |
| 133 | main.cellName, |
| 134 | main.MN1Ip, |
| 135 | main.Apps, |
| 136 | main.ONOSip) |
| 137 | main.step("Apply cell to environment") |
| 138 | cellResult = main.ONOSbench.setCell(main.cellName) |
| 139 | verifyResult = main.ONOSbench.verifyCell() |
| 140 | stepResult = cellResult and verifyResult |
| 141 | utilities.assert_equals(expect=main.TRUE, |
| 142 | actual=stepResult, |
| 143 | onpass="Successfully applied cell to " + \ |
| 144 | "environment", |
| 145 | onfail="Failed to apply cell to environment ") |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 146 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 147 | main.step("Creating ONOS package") |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 148 | packageResult = main.ONOSbench.buckBuild() |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 149 | stepResult = packageResult |
| 150 | utilities.assert_equals(expect=main.TRUE, |
| 151 | actual=stepResult, |
| 152 | onpass="Successfully created ONOS package", |
| 153 | onfail="Failed to create ONOS package") |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 154 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 155 | main.step("Uninstall ONOS package on all Nodes") |
| 156 | uninstallResult = main.TRUE |
| 157 | for i in range(int(main.numCtrls)): |
| 158 | main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i]) |
| 159 | u_result = main.ONOSbench.onosUninstall(main.ONOSip[i]) |
| 160 | utilities.assert_equals(expect=main.TRUE, actual=u_result, |
| 161 | onpass="Test step PASS", |
| 162 | onfail="Test step FAIL") |
| 163 | uninstallResult = (uninstallResult and u_result) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 164 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 165 | main.step("Install ONOS package on all Nodes") |
| 166 | installResult = main.TRUE |
| 167 | for i in range(int(main.numCtrls)): |
| 168 | main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i]) |
| 169 | i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i]) |
| 170 | utilities.assert_equals(expect=main.TRUE, actual=i_result, |
| 171 | onpass="Test step PASS", |
| 172 | onfail="Test step FAIL") |
| 173 | installResult = installResult and i_result |
| 174 | |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 175 | main.step( "Set up ONOS secure SSH" ) |
| 176 | secureSshResult = main.TRUE |
| 177 | for i in range( int( main.numCtrls ) ): |
| 178 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] ) |
| 179 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 180 | onpass="Test step PASS", |
| 181 | onfail="Test step FAIL" ) |
| 182 | |
You Wang | 0357c43 | 2017-01-09 16:13:33 -0800 | [diff] [blame] | 183 | time.sleep( main.startUpSleep ) |
| 184 | main.step( "Starting ONOS service" ) |
| 185 | stopResult = main.TRUE |
| 186 | startResult = main.TRUE |
| 187 | onosIsUp = main.TRUE |
| 188 | for i in range( main.numCtrls ): |
| 189 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 190 | if onosIsUp == main.TRUE: |
| 191 | main.log.report( "ONOS instance is up and ready" ) |
| 192 | else: |
| 193 | main.log.report( "ONOS instance may not be up, stop and " + |
| 194 | "start ONOS again " ) |
| 195 | for i in range( main.numCtrls ): |
| 196 | stopResult = stopResult and \ |
| 197 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 198 | for i in range( main.numCtrls ): |
| 199 | startResult = startResult and \ |
| 200 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 201 | stepResult = onosIsUp and stopResult and startResult |
| 202 | utilities.assert_equals( expect=main.TRUE, |
| 203 | actual=stepResult, |
| 204 | onpass="ONOS service is ready", |
| 205 | onfail="ONOS service did not start properly" ) |
| 206 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 207 | time.sleep(2) |
| 208 | main.step("Start ONOS CLI on all nodes") |
| 209 | cliResult = main.TRUE |
| 210 | main.step(" Start ONOS cli using thread ") |
| 211 | startCliResult = main.TRUE |
| 212 | pool = [] |
| 213 | main.threadID = 0 |
| 214 | for i in range(int(main.numCtrls)): |
| 215 | t = main.Thread(target=main.CLIs[i].startOnosCli, |
| 216 | threadID=main.threadID, |
| 217 | name="startOnosCli", |
| 218 | args=[main.ONOSip[i]], |
| 219 | kwargs={"onosStartTimeout": main.timeout}) |
| 220 | pool.append(t) |
| 221 | t.start() |
| 222 | main.threadID = main.threadID + 1 |
| 223 | for t in pool: |
| 224 | t.join() |
| 225 | startCliResult = startCliResult and t.result |
| 226 | time.sleep(main.startUpSleep) |
| 227 | |
| 228 | main.log.info("Configure apps") |
| 229 | main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider", |
| 230 | "maxEvents 1") |
| 231 | main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider", |
| 232 | "maxBatchMs 0") |
| 233 | main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider", |
| 234 | "maxIdleMs 0") |
chengchiyu | 08303a0 | 2016-09-08 17:40:26 -0700 | [diff] [blame] | 235 | for i in range(main.numCtrls): |
| 236 | main.CLIs[i].logSet( "DEBUG", "org.onosproject.metrics.topology") |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 237 | time.sleep(1) |
| 238 | |
| 239 | main.log.info("Copy topology file to Mininet") |
| 240 | main.ONOSbench.copyMininetFile(main.topoName, |
| 241 | main.dependencyPath, |
| 242 | main.Mininet1.user_name, |
| 243 | main.Mininet1.ip_address) |
| 244 | main.log.info("Stop Mininet...") |
| 245 | main.Mininet1.stopNet() |
| 246 | time.sleep(main.MNSleep) |
| 247 | main.log.info("Start new mininet topology") |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 248 | main.Mininet1.startNet() |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 249 | main.log.info("Assign switch to controller to ONOS node 1") |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 250 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 251 | time.sleep(2) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 252 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 253 | def CASE2(self,main): |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 254 | import time |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 255 | import json |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 256 | import numpy |
| 257 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 258 | resultDict = {'up' : {}, 'down' : {}} |
| 259 | for i in range(1, main.numCtrls + 1): |
| 260 | resultDict['up'][ 'node' + str(i) ] = {} |
| 261 | resultDict['up'][ 'node' + str(i) ][ 'Ave' ] = {} |
| 262 | resultDict['up'][ 'node' + str(i) ][ 'Std' ] = {} |
| 263 | resultDict['up'][ 'node' + str(i) ][ 'T_F' ] = []#TCP to Feature |
| 264 | resultDict['up'][ 'node' + str(i) ][ 'F_R' ] = []#Feature to Role |
| 265 | resultDict['up'][ 'node' + str(i) ][ 'RQ_RR' ] = []#role request to role reply |
| 266 | resultDict['up'][ 'node' + str(i) ][ 'RR_D' ] = []#role reply to Device |
| 267 | resultDict['up'][ 'node' + str(i) ][ 'D_G' ] = []#Device to Graph |
| 268 | resultDict['up'][ 'node' + str(i) ][ 'E_E' ] = []#TCP to Graph |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 269 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 270 | for i in range(1,main.numCtrls + 1): |
| 271 | resultDict['down'][ 'node' + str(i) ] = {} |
| 272 | resultDict['down'][ 'node' + str(i) ][ 'Ave' ] = {} |
| 273 | resultDict['down'][ 'node' + str(i) ][ 'Std' ] = {} |
| 274 | resultDict['down'][ 'node' + str(i) ][ 'FA_A' ] = []#Fin_ack to ACK |
| 275 | resultDict['down'][ 'node' + str(i) ][ 'A_D' ] = []#Ack to Device |
| 276 | resultDict['down'][ 'node' + str(i) ][ 'D_G' ] = []#Device to Graph |
| 277 | resultDict['down'][ 'node' + str(i) ][ 'E_E' ] = []#fin_ack to Graph |
| 278 | for i in range(1 , main.sampleSize + main.warmUp): |
| 279 | main.log.info("************************************************************") |
| 280 | main.log.info("************************ Iteration: {} **********************" .format(str( i )) ) |
| 281 | if i < main.warmUp: |
| 282 | main.switchFunc.captureOfPack( main, main.device, main.ofPackage, |
| 283 | "up", resultDict, True ) |
| 284 | main.switchFunc.captureOfPack( main, main.device, main.ofPackage, |
| 285 | "down", resultDict, True ) |
chengchiyu | 08303a0 | 2016-09-08 17:40:26 -0700 | [diff] [blame] | 286 | main.CLIs[0].removeDevice( "of:0000000000000001" ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 287 | else: |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 288 | main.switchFunc.captureOfPack( main, main.device, main.ofPackage, |
| 289 | "up", resultDict, False ) |
| 290 | main.switchFunc.captureOfPack (main, main.device, main.ofPackage, |
| 291 | "down", resultDict, False ) |
chengchiyu | 08303a0 | 2016-09-08 17:40:26 -0700 | [diff] [blame] | 292 | main.CLIs[0].removeDevice( "of:0000000000000001" ) |
| 293 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 294 | # Dictionary for result |
| 295 | maxDict = {} |
| 296 | maxDict['down'] = {} |
| 297 | maxDict['up'] = {} |
| 298 | maxDict['down']['max'] = 0 |
| 299 | maxDict['up']['max'] = 0 |
| 300 | maxDict['down']['node'] = 0 |
| 301 | maxDict['up']['node'] = 0 |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 302 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 303 | for i in range(1, main.numCtrls + 1): |
| 304 | # calculate average and std for result, and grep the max End to End data |
| 305 | EtoEtemp = numpy.average( resultDict['up'][ 'node' + str(i) ]['E_E'] ) |
| 306 | resultDict['up'][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ] = EtoEtemp |
| 307 | if maxDict['up']['max'] < EtoEtemp: |
| 308 | # get max End to End latency |
| 309 | maxDict['up']['max'] = EtoEtemp |
| 310 | maxDict['up']['node'] = i |
| 311 | resultDict['up']['node' + str(i)]['Ave']['T_F'] = numpy.average(resultDict['up']['node' + str(i)]['T_F']) |
| 312 | resultDict['up']['node' + str(i)]['Ave']['F_R'] = numpy.average(resultDict['up']['node' + str(i)]['F_R']) |
| 313 | resultDict['up']['node' + str(i)]['Ave']['RQ_RR'] = numpy.average(resultDict['up']['node' + str(i)]['RQ_RR']) |
| 314 | resultDict['up']['node' + str(i)]['Ave']['RR_D'] = numpy.average(resultDict['up']['node' + str(i)]['RR_D']) |
| 315 | resultDict['up']['node' + str(i)]['Ave']['D_G'] = numpy.average(resultDict['up']['node' + str(i)]['D_G']) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 316 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 317 | resultDict['up'][ 'node' + str(i) ][ 'Std' ][ 'E_E' ] = numpy.std( resultDict['up'][ 'node' + str(i) ]['E_E'] ) |
| 318 | resultDict['up']['node' + str(i)]['Std']['T_F'] = numpy.std(resultDict['up']['node' + str(i)]['T_F']) |
| 319 | resultDict['up']['node' + str(i)]['Std']['F_R'] = numpy.std(resultDict['up']['node' + str(i)]['F_R']) |
| 320 | resultDict['up']['node' + str(i)]['Std']['RQ_RR'] = numpy.std(resultDict['up']['node' + str(i)]['RQ_RR']) |
| 321 | resultDict['up']['node' + str(i)]['Std']['RR_D'] = numpy.std(resultDict['up']['node' + str(i)]['RR_D']) |
| 322 | resultDict['up']['node' + str(i)]['Std']['D_G'] = numpy.std(resultDict['up']['node' + str(i)]['D_G']) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 323 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 324 | # calculate average and std for result, and grep the max End to End data |
| 325 | EtoEtemp = numpy.average( resultDict['down'][ 'node' + str(i) ]['E_E'] ) |
| 326 | resultDict['down'][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ] = EtoEtemp |
| 327 | if maxDict['down']['max'] < EtoEtemp: |
| 328 | # get max End to End latency |
| 329 | maxDict['down']['max'] = EtoEtemp |
| 330 | maxDict['down']['node'] = i |
| 331 | resultDict['down']['node' + str(i)]['Ave']['FA_A'] = numpy.average(resultDict['down']['node' + str(i)]['FA_A']) |
| 332 | resultDict['down']['node' + str(i)]['Ave']['A_D'] = numpy.average(resultDict['down']['node' + str(i)]['A_D']) |
| 333 | resultDict['down']['node' + str(i)]['Ave']['D_G'] = numpy.average(resultDict['down']['node' + str(i)]['D_G']) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 334 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 335 | resultDict['down'][ 'node' + str(i) ][ 'Std' ][ 'E_E' ] = numpy.std( resultDict['down'][ 'node' + str(i) ]['E_E'] ) |
| 336 | resultDict['down']['node' + str(i)]['Std']['FA_A'] = numpy.std(resultDict['down']['node' + str(i)]['FA_A']) |
| 337 | resultDict['down']['node' + str(i)]['Std']['A_D'] = numpy.std(resultDict['down']['node' + str(i)]['A_D']) |
| 338 | resultDict['down']['node' + str(i)]['Std']['D_G'] = numpy.std(resultDict['down']['node' + str(i)]['D_G']) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 339 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 340 | main.log.report( "=====node{} Summary:=====".format( str(i) ) ) |
| 341 | main.log.report( "=============Switch up=======" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 342 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 343 | main.log.report( |
| 344 | "End to End average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ]) ) ) |
| 345 | main.log.report( |
| 346 | "End to End Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'E_E' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 347 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 348 | main.log.report( |
| 349 | "TCP to Feature average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'T_F' ]) ) ) |
| 350 | main.log.report( |
| 351 | "TCP to Feature Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'T_F' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 352 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 353 | main.log.report( |
| 354 | "Feature to Role average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'F_R' ]) ) ) |
| 355 | main.log.report( |
| 356 | "Feature to Role Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'F_R' ]) ) ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 357 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 358 | main.log.report( |
| 359 | "Role request to Role reply average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'RQ_RR' ]) ) ) |
| 360 | main.log.report( |
| 361 | "Role request to Role reply Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'RQ_RR' ]) ) ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 362 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 363 | main.log.report( |
| 364 | "Role reply to Device average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'RR_D' ]) ) ) |
| 365 | main.log.report( |
| 366 | "Role reply to Device Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'RR_D' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 367 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 368 | main.log.report( |
| 369 | "Device to Graph average: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Ave' ][ 'D_G' ]) ) ) |
| 370 | main.log.report( |
| 371 | "Device to Graph Std: {}".format( str(resultDict["up"][ 'node' + str(i) ][ 'Std' ][ 'D_G' ]) ) ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 372 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 373 | main.log.report( "=============Switch down=======" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 374 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 375 | main.log.report( |
| 376 | "End to End average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'E_E' ]) ) ) |
| 377 | main.log.report( |
| 378 | "End to End Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'E_E' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 379 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 380 | main.log.report( |
| 381 | "Fin_ACK to ACK average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'FA_A' ]) ) ) |
| 382 | main.log.report( |
| 383 | "Fin_ACK to ACK Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'FA_A' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 384 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 385 | main.log.report( |
| 386 | "ACK to Device average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'A_D' ]) ) ) |
| 387 | main.log.report( |
| 388 | "ACK to Device Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'A_D' ]) ) ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 389 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 390 | main.log.report( |
| 391 | "Device to Graph average: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Ave' ][ 'D_G' ]) ) ) |
| 392 | main.log.report( |
| 393 | "Device to Graph Std: {}".format( str(resultDict["down"][ 'node' + str(i) ][ 'Std' ][ 'D_G' ]) ) ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 394 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 395 | with open(main.dbFileName, "a") as dbFile: |
| 396 | # TODO: Save STD to Database |
| 397 | # Scale number |
| 398 | temp = str(main.numCtrls) |
| 399 | temp += ",'baremetal1'" |
| 400 | # put result |
| 401 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'E_E' ] ) |
| 402 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'T_F' ] ) |
| 403 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'F_R' ] ) |
| 404 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'RQ_RR' ] ) |
| 405 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'RR_D' ] ) |
| 406 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'D_G' ] ) |
cameron@onlab.us | 21106ea | 2015-07-23 15:32:51 -0700 | [diff] [blame] | 407 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 408 | temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'E_E' ] ) |
| 409 | temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'FA_A' ] ) |
| 410 | temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'A_D' ] ) |
| 411 | temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'D_G' ] ) |
chengchiyu | c6f4cc0 | 2016-08-24 14:04:20 -0700 | [diff] [blame] | 412 | |
| 413 | temp += "," + str( "%.2f" % resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Std' ][ 'E_E' ] ) |
| 414 | temp += "," + str( "%.2f" % resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Std' ][ 'E_E' ] ) |
| 415 | |
YPZhang | 38fb119 | 2016-08-11 11:03:38 -0700 | [diff] [blame] | 416 | temp += "\n" |
| 417 | dbFile.write( temp ) |
| 418 | dbFile.close() |