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