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