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' ]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 38 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
GlennRC | f6826f1 | 2015-12-10 11:56:12 -0800 | [diff] [blame] | 39 | cellApps = main.params[ 'ENV' ][ 'cellApps' ] |
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 | #git |
| 59 | main.step( "Git checkout and pull " + checkoutBranch ) |
| 60 | if gitPull == 'on': |
| 61 | checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch ) |
| 62 | pullResult = main.ONOSbench.gitPull() |
| 63 | |
| 64 | else: |
| 65 | checkoutResult = main.TRUE |
| 66 | pullResult = main.TRUE |
| 67 | main.log.info( "Skipped git checkout and pull" ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 68 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 69 | # -- END OF INIT SECTION --# |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 70 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 71 | clusterCount = int(scale[0]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 72 | scale.remove(scale[0]) |
| 73 | |
| 74 | #kill off all onos processes |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 75 | main.step("Safety check, killing all ONOS processes") |
| 76 | main.step("before initiating environment setup") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 77 | for node in range(1, maxNodes + 1): |
You Wang | b98a9fa | 2017-02-15 17:27:42 -0800 | [diff] [blame] | 78 | main.ONOSbench.onosStop(ONOSIp[node]) |
| 79 | main.ONOSbench.onosKill(ONOSIp[node]) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 80 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 81 | #Uninstall everywhere |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 82 | main.step( "Cleaning Enviornment..." ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 83 | for i in range(1, maxNodes + 1): |
| 84 | main.log.info(" Uninstalling ONOS " + str(i) ) |
| 85 | main.ONOSbench.onosUninstall( ONOSIp[i] ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 86 | |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 87 | time.sleep(10) |
| 88 | main.ONOSbench.handle.sendline(" ") |
| 89 | main.ONOSbench.handle.expect(":~") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 90 | print "pexpect: \n" + main.ONOSbench.handle.before |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 91 | |
| 92 | |
| 93 | print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp) |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 94 | main.ONOSbench.createCellFile(BENCHIp, cellName, MN1Ip, |
| 95 | cellApps, [ONOSIp[1]], main.ONOScli1.user_name) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -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 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 100 | #main.ONOSbench.handle.sendline(" ") |
| 101 | #main.ONOSbench.handle.expect(":~") |
| 102 | #print "pexpect: \n" + main.ONOSbench.handle.before |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 103 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 104 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 105 | packageResult = main.ONOSbench.buckBuild() |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 106 | |
| 107 | main.step( "verify cells" ) |
| 108 | verifyCellResult = main.ONOSbench.verifyCell() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 109 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 110 | main.log.report( "Initializing " + str( clusterCount ) + " node cluster." ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 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 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 125 | for i in range(5): |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 126 | main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true") |
| 127 | time.sleep(5) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 128 | main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly") |
| 129 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 130 | check = main.ONOSbench.handle.before |
| 131 | if "value=true" in check: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 132 | main.log.info("cfg set successful") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 133 | stepResult = main.TRUE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 134 | break |
| 135 | if i == 4: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 136 | main.log.info("Cfg set failed") |
| 137 | stepResult = main.FALSE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 138 | else: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 139 | time.sleep(5) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 140 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 141 | utilities.assert_equals( expect=main.TRUE, |
| 142 | actual=stepResult, |
| 143 | onpass="Successfully configure onos for cbench test ", |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 144 | onfail="Failed to configure onos for cbench test" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 145 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 146 | |
| 147 | |
| 148 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 149 | def CASE2( self, main ): |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 150 | main.case("Running Cbench") |
| 151 | main.step("Issuing cbench commands and grab returned results") |
| 152 | validFlag = False |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 153 | cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 154 | mode = main.params[ 'TEST' ][ 'mode' ] |
| 155 | if mode != "t": |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 156 | mode = " " |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 157 | |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 158 | runCbench = ( "ssh " + CBENCHuser + "@" + ONOSIp[1] + " " + cbenchCMD + mode ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 159 | main.ONOSbench.handle.sendline(runCbench) |
| 160 | time.sleep(30) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 161 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 162 | output = main.ONOSbench.handle.before |
| 163 | main.log.info(output) |
| 164 | |
| 165 | output = output.splitlines() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 166 | for line in output: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 167 | if "RESULT: " in line: |
| 168 | validFlag = True |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 169 | print line |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 170 | resultLine = line.split(" ") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 171 | for word in resultLine: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 172 | if word == "min/max/avg/stdev": |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 173 | resultsIndex = resultLine.index(word) |
| 174 | print resultsIndex |
| 175 | break |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 176 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 177 | finalDataString = resultLine[resultsIndex + 2] |
| 178 | print finalDataString |
| 179 | finalDataList = finalDataString.split("/") |
| 180 | avg = finalDataList[2] |
| 181 | stdev = finalDataList[3] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 182 | |
| 183 | main.log.info("Average: \t\t\t" + avg) |
| 184 | main.log.info("Standard Deviation: \t" + stdev) |
| 185 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 186 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 187 | commit = main.ONOSbench.getVersion() |
| 188 | commit = (commit.split(" "))[1] |
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 | try: |
| 191 | dbFileName="/tmp/CbenchDB" |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 192 | dbfile = open(dbFileName, "w+") |
| 193 | temp = "'" + commit + "'," |
| 194 | temp += "'" + mode + "'," |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 195 | temp += "'" + avg + "'," |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 196 | temp += "'" + stdev + "'\n" |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 197 | dbfile.write(temp) |
| 198 | dbfile.close() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 199 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 200 | except IOError: |
| 201 | main.log.warn("Error opening " + dbFileName + " to write results.") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 202 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 203 | stepResult = main.TRUE |
| 204 | break |
| 205 | if ( validFlag == False ): |
| 206 | main.log.warn("Cbench Test produced no valid results!!!!") |
| 207 | stepResult = main.FALSE |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 208 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 209 | utilities.assert_equals( expect=main.TRUE, |
| 210 | actual=stepResult, |
| 211 | onpass="Successfully tested onos for cbench. ", |
| 212 | onfail="Failed to obtain valid onos cbench result!" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |