jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 1 | # ScaleOutTemplate --> CbenchBM |
| 2 | # |
| 3 | # CASE1 starts number of nodes specified in param file |
| 4 | # |
| 5 | # cameron@onlab.us |
| 6 | |
| 7 | import sys |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 8 | import os |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 9 | import os.path |
| 10 | |
| 11 | |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 12 | class SCPFcbench: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 13 | |
| 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 17 | def CASE1( self, main ): |
| 18 | |
| 19 | import time |
| 20 | import os |
| 21 | global init |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 22 | main.case("pre-condition for cbench test.") |
| 23 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 24 | try: |
| 25 | if type(init) is not bool: |
| 26 | init = False |
| 27 | except NameError: |
| 28 | init = False |
| 29 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 30 | #Load values from params file |
| 31 | checkoutBranch = main.params[ 'GIT' ][ 'checkout' ] |
| 32 | gitPull = main.params[ 'GIT' ][ 'autopull' ] |
| 33 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 34 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
jenkins | f4ac82d | 2015-07-13 16:40:20 -0700 | [diff] [blame] | 35 | CBENCHuser = main.params[ 'CBENCH'][ 'user' ] |
suibin zhang | efae903 | 2015-07-13 17:14:39 -0700 | [diff] [blame] | 36 | MN1Ip = os.environ[ main.params[ 'MN' ][ 'ip1' ] ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 37 | maxNodes = int(main.params[ 'availableNodes' ]) |
| 38 | skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 39 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
GlennRC | f6826f1 | 2015-12-10 11:56:12 -0800 | [diff] [blame] | 40 | cellApps = main.params[ 'ENV' ][ 'cellApps' ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 41 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 42 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 43 | if init == False: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 44 | init = True |
| 45 | global clusterCount #number of nodes running |
| 46 | global ONOSIp #list of ONOS IP addresses |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 47 | global scale |
| 48 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 49 | clusterCount = 0 |
| 50 | ONOSIp = [ 0 ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 51 | scale = (main.params[ 'SCALE' ]).split(",") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 52 | clusterCount = int(scale[0]) |
| 53 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 54 | #Populate ONOSIp with ips from params |
| 55 | for i in range(1, maxNodes + 1): |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 56 | ipString = os.environ[main.params['CTRL']['ip1']] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 57 | ONOSIp.append(ipString) |
| 58 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 59 | #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test |
| 60 | if skipMvn != "yes": |
| 61 | mvnResult = main.ONOSbench.cleanInstall() |
| 62 | |
| 63 | #git |
| 64 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 65 | if gitPull == 'on': |
| 66 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 67 | pullResult = main.ONOSbench.gitPull() |
| 68 | |
| 69 | else: |
| 70 | checkoutResult = main.TRUE |
| 71 | pullResult = main.TRUE |
| 72 | main.log.info( "Skipped git checkout and pull" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 73 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 74 | # -- END OF INIT SECTION --# |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 75 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 76 | clusterCount = int(scale[0]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 77 | scale.remove(scale[0]) |
| 78 | |
| 79 | #kill off all onos processes |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 80 | main.log.step("Safety check, killing all ONOS processes") |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 81 | main.log.step("before initiating environment setup") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 82 | for node in range(1, maxNodes + 1): |
| 83 | main.ONOSbench.onosDie(ONOSIp[node]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 84 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 85 | #Uninstall everywhere |
| 86 | main.log.step( "Cleaning Enviornment..." ) |
| 87 | for i in range(1, maxNodes + 1): |
| 88 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 89 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 90 | |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 91 | time.sleep(10) |
| 92 | main.ONOSbench.handle.sendline(" ") |
| 93 | main.ONOSbench.handle.expect(":~") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 94 | print "pexpect: \n" + main.ONOSbench.handle.before |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 95 | |
| 96 | |
| 97 | print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp) |
GlennRC | f6826f1 | 2015-12-10 11:56:12 -0800 | [diff] [blame] | 98 | main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,cellApps,[ONOSIp[1]]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 99 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 100 | main.step( "Set Cell" ) |
| 101 | main.ONOSbench.setCell(cellName) |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 102 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 103 | #main.ONOSbench.handle.sendline(" ") |
| 104 | #main.ONOSbench.handle.expect(":~") |
| 105 | #print "pexpect: \n" + main.ONOSbench.handle.before |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 106 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 107 | main.step( "Creating ONOS package" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 108 | packageResult = main.ONOSbench.onosPackage() |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 109 | |
| 110 | main.step( "verify cells" ) |
| 111 | verifyCellResult = main.ONOSbench.verifyCell() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 112 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 113 | main.log.report( "Initializing " + str( clusterCount ) + " node cluster." ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 114 | for node in range(1, clusterCount + 1): |
| 115 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 116 | main.ONOSbench.onosInstall( ONOSIp[node]) |
| 117 | |
| 118 | for node in range(1, clusterCount + 1): |
| 119 | for i in range( 2 ): |
| 120 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 121 | if isup: |
| 122 | main.log.info("ONOS " + str(node) + " is up\n") |
| 123 | break |
| 124 | if not isup: |
| 125 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 126 | main.log.info("Startup sequence complete") |
| 127 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 128 | for i in range(5): |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 129 | main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true") |
| 130 | time.sleep(5) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 131 | main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly") |
| 132 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 133 | check = main.ONOSbench.handle.before |
| 134 | if "value=true" in check: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 135 | main.log.info("cfg set successful") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 136 | stepResult = main.TRUE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 137 | break |
| 138 | if i == 4: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 139 | main.log.info("Cfg set failed") |
| 140 | stepResult = main.FALSE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 141 | else: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 142 | time.sleep(5) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 143 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 144 | utilities.assert_equals( expect=main.TRUE, |
| 145 | actual=stepResult, |
| 146 | onpass="Successfully configure onos for cbench test ", |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 147 | onfail="Failed to configure onos for cbench test" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 148 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 149 | |
| 150 | |
| 151 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 152 | def CASE2( self, main ): |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 153 | main.case("Running Cbench") |
| 154 | main.step("Issuing cbench commands and grab returned results") |
| 155 | validFlag = False |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 156 | cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 157 | mode = main.params[ 'TEST' ][ 'mode' ] |
| 158 | if mode != "t": |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 159 | mode = " " |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 160 | |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 161 | runCbench = ( "ssh " + CBENCHuser + "@" + ONOSIp[1] + " " + cbenchCMD + mode ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 162 | main.ONOSbench.handle.sendline(runCbench) |
| 163 | time.sleep(30) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 164 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 165 | output = main.ONOSbench.handle.before |
| 166 | main.log.info(output) |
| 167 | |
| 168 | output = output.splitlines() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 169 | for line in output: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 170 | if "RESULT: " in line: |
| 171 | validFlag = True |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 172 | print line |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 173 | resultLine = line.split(" ") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 174 | for word in resultLine: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 175 | if word == "min/max/avg/stdev": |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 176 | resultsIndex = resultLine.index(word) |
| 177 | print resultsIndex |
| 178 | break |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 179 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 180 | finalDataString = resultLine[resultsIndex + 2] |
| 181 | print finalDataString |
| 182 | finalDataList = finalDataString.split("/") |
| 183 | avg = finalDataList[2] |
| 184 | stdev = finalDataList[3] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 185 | |
| 186 | main.log.info("Average: \t\t\t" + avg) |
| 187 | main.log.info("Standard Deviation: \t" + stdev) |
| 188 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 189 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 190 | commit = main.ONOSbench.getVersion() |
| 191 | commit = (commit.split(" "))[1] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 192 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 193 | try: |
| 194 | dbFileName="/tmp/CbenchDB" |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 195 | dbfile = open(dbFileName, "w+") |
| 196 | temp = "'" + commit + "'," |
| 197 | temp += "'" + mode + "'," |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 198 | temp += "'" + avg + "'," |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 199 | temp += "'" + stdev + "'\n" |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 200 | dbfile.write(temp) |
| 201 | dbfile.close() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 202 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 203 | except IOError: |
| 204 | main.log.warn("Error opening " + dbFileName + " to write results.") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 205 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 206 | stepResult = main.TRUE |
| 207 | break |
| 208 | if ( validFlag == False ): |
| 209 | main.log.warn("Cbench Test produced no valid results!!!!") |
| 210 | stepResult = main.FALSE |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 211 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 212 | utilities.assert_equals( expect=main.TRUE, |
| 213 | actual=stepResult, |
| 214 | onpass="Successfully tested onos for cbench. ", |
| 215 | onfail="Failed to obtain valid onos cbench result!" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |