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