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) |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 88 | |
| 89 | print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp) |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 90 | main.ONOSbench.createCellFile(BENCHIp, cellName, MN1Ip, |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 91 | cellApps, [ONOSIp[1]], main.ONOScli1.karafUser) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 92 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 93 | main.step( "Set Cell" ) |
| 94 | main.ONOSbench.setCell(cellName) |
Jon Hall | f57a5ef | 2015-07-07 17:56:16 -0700 | [diff] [blame] | 95 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 96 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 97 | packageResult = main.ONOSbench.buckBuild() |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 98 | |
| 99 | main.step( "verify cells" ) |
| 100 | verifyCellResult = main.ONOSbench.verifyCell() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 101 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 102 | main.log.report( "Initializing " + str( clusterCount ) + " node cluster." ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 103 | for node in range(1, clusterCount + 1): |
| 104 | main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node]) |
| 105 | main.ONOSbench.onosInstall( ONOSIp[node]) |
You Wang | b12fa3b | 2017-06-09 17:10:18 -0700 | [diff] [blame] | 106 | main.ONOSbench.onosSecureSSH( node=ONOSIp[node] ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 107 | |
| 108 | for node in range(1, clusterCount + 1): |
| 109 | for i in range( 2 ): |
| 110 | isup = main.ONOSbench.isup( ONOSIp[node] ) |
| 111 | if isup: |
| 112 | main.log.info("ONOS " + str(node) + " is up\n") |
| 113 | break |
| 114 | if not isup: |
| 115 | main.log.report( "ONOS " + str(node) + " didn't start!" ) |
| 116 | main.log.info("Startup sequence complete") |
| 117 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 118 | for i in range(5): |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 119 | main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true") |
| 120 | time.sleep(5) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 121 | main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly") |
| 122 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 123 | check = main.ONOSbench.handle.before |
| 124 | if "value=true" in check: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 125 | main.log.info("cfg set successful") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 126 | stepResult = main.TRUE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 127 | break |
| 128 | if i == 4: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 129 | main.log.info("Cfg set failed") |
| 130 | stepResult = main.FALSE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 131 | else: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 132 | time.sleep(5) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 133 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 134 | utilities.assert_equals( expect=main.TRUE, |
| 135 | actual=stepResult, |
| 136 | onpass="Successfully configure onos for cbench test ", |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 137 | onfail="Failed to configure onos for cbench test" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 138 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 139 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 140 | def CASE2( self, main ): |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 141 | main.case("Running Cbench") |
| 142 | main.step("Issuing cbench commands and grab returned results") |
| 143 | validFlag = False |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 144 | cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 145 | mode = main.params[ 'TEST' ][ 'mode' ] |
| 146 | if mode != "t": |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 147 | mode = " " |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 148 | |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 149 | runCbench = ( "ssh " + CBENCHuser + "@" + ONOSIp[1] + " " + cbenchCMD + mode ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 150 | main.ONOSbench.handle.sendline(runCbench) |
| 151 | time.sleep(30) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 152 | main.ONOSbench.handle.expect(":~") |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 153 | output = main.ONOSbench.handle.before |
| 154 | main.log.info(output) |
| 155 | |
| 156 | output = output.splitlines() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 157 | for line in output: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 158 | if "RESULT: " in line: |
| 159 | validFlag = True |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 160 | print line |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 161 | resultLine = line.split(" ") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 162 | for word in resultLine: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 163 | if word == "min/max/avg/stdev": |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 164 | resultsIndex = resultLine.index(word) |
| 165 | print resultsIndex |
| 166 | break |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 167 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 168 | finalDataString = resultLine[resultsIndex + 2] |
| 169 | print finalDataString |
| 170 | finalDataList = finalDataString.split("/") |
| 171 | avg = finalDataList[2] |
| 172 | stdev = finalDataList[3] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 173 | |
| 174 | main.log.info("Average: \t\t\t" + avg) |
| 175 | main.log.info("Standard Deviation: \t" + stdev) |
| 176 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 177 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 178 | commit = main.ONOSbench.getVersion() |
| 179 | commit = (commit.split(" "))[1] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 180 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 181 | try: |
| 182 | dbFileName="/tmp/CbenchDB" |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 183 | dbfile = open(dbFileName, "w+") |
| 184 | temp = "'" + commit + "'," |
| 185 | temp += "'" + mode + "'," |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 186 | temp += "'" + avg + "'," |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 187 | temp += "'" + stdev + "'\n" |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 188 | dbfile.write(temp) |
| 189 | dbfile.close() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 190 | main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d") |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 191 | except IOError: |
| 192 | main.log.warn("Error opening " + dbFileName + " to write results.") |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 193 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 194 | stepResult = main.TRUE |
| 195 | break |
| 196 | if ( validFlag == False ): |
| 197 | main.log.warn("Cbench Test produced no valid results!!!!") |
| 198 | stepResult = main.FALSE |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 199 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 200 | utilities.assert_equals( expect=main.TRUE, |
| 201 | actual=stepResult, |
| 202 | onpass="Successfully tested onos for cbench. ", |
| 203 | onfail="Failed to obtain valid onos cbench result!" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 204 | |