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 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 22 | main.case( "pre-condition for cbench test." ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 23 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 24 | try: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 25 | if not isinstance( init, bool ): |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 26 | init = False |
| 27 | except NameError: |
| 28 | init = False |
| 29 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 30 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 31 | if not init: |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 32 | init = True |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 33 | try: |
| 34 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 35 | main.testSetUp = ONOSSetup() |
| 36 | except ImportError: |
| 37 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 38 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 39 | main.testSetUp.envSetupDescription() |
| 40 | stepResult = main.FALSE |
| 41 | try: |
| 42 | # Load values from params file |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 43 | BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 44 | BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 45 | CBENCHuser = main.params[ 'CBENCH' ][ 'user' ] |
| 46 | MN1Ip = os.environ[ main.params[ 'MN' ][ 'ip1' ] ] |
| 47 | main.maxNodes = int( main.params[ 'availableNodes' ] ) |
| 48 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 49 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 50 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 51 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 52 | stepResult = main.testSetUp.envSetup() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 53 | except Exception as e: |
| 54 | main.testSetUp.envSetupException( e ) |
| 55 | main.testSetUp.evnSetupConclusion( stepResult ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 56 | main.commit = ( main.commit.split( " " ) )[ 1 ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 57 | # -- END OF INIT SECTION --# |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 58 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 59 | main.testSetUp.ONOSSetUp( MN1Ip, main.Cluster, True, |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 60 | cellName=main.cellName ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 61 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 62 | for i in range( 5 ): |
| 63 | main.ONOSbench.onosCfgSet( main.Cluster.active( 0 ).ipAddress, "org.onosproject.fwd.ReactiveForwarding", "packetOutOnly true" ) |
| 64 | time.sleep( 5 ) |
| 65 | main.ONOSbench.handle.sendline( "onos $OC1 cfg get|grep packetOutOnly" ) |
| 66 | main.ONOSbench.handle.expect( ":~" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 67 | check = main.ONOSbench.handle.before |
| 68 | if "value=true" in check: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 69 | main.log.info( "cfg set successful" ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 70 | stepResult = main.TRUE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 71 | break |
| 72 | if i == 4: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 73 | main.log.info( "Cfg set failed" ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 74 | stepResult = main.FALSE |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 75 | else: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 76 | time.sleep( 5 ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 77 | |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 78 | utilities.assert_equals( expect=main.TRUE, |
| 79 | actual=stepResult, |
| 80 | onpass="Successfully configure onos for cbench test ", |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 81 | onfail="Failed to configure onos for cbench test" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 82 | |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 83 | def CASE2( self, main ): |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 84 | main.case( "Running Cbench" ) |
| 85 | main.step( "Issuing cbench commands and grab returned results" ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 86 | validFlag = False |
suibin zhang | acdd8fe | 2015-08-31 17:01:39 -0700 | [diff] [blame] | 87 | cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ] |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 88 | mode = main.params[ 'TEST' ][ 'mode' ] |
| 89 | if mode != "t": |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 90 | mode = " " |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 91 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 92 | runCbench = ( "ssh " + CBENCHuser + "@" + main.Cluster.active( 0 ).ipAddress + " " + cbenchCMD + mode ) |
| 93 | main.ONOSbench.handle.sendline( runCbench ) |
| 94 | time.sleep( 30 ) |
| 95 | main.ONOSbench.handle.expect( ":~" ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 96 | output = main.ONOSbench.handle.before |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 97 | main.log.info( output ) |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 98 | |
| 99 | output = output.splitlines() |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 100 | for line in output: |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 101 | if "RESULT: " in line: |
| 102 | validFlag = True |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 103 | print line |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 104 | resultLine = line.split( " " ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 105 | for word in resultLine: |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 106 | if word == "min/max/avg/stdev": |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 107 | resultsIndex = resultLine.index( word ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 108 | print resultsIndex |
| 109 | break |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 110 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 111 | finalDataString = resultLine[ resultsIndex + 2 ] |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 112 | print finalDataString |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 113 | finalDataList = finalDataString.split( "/" ) |
| 114 | avg = finalDataList[ 2 ] |
| 115 | stdev = finalDataList[ 3 ] |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 116 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 117 | main.log.info( "Average: \t\t\t" + avg ) |
| 118 | main.log.info( "Standard Deviation: \t" + stdev ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 119 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 120 | try: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 121 | dbFileName = "/tmp/CbenchDB" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 122 | dbfile = open( dbFileName, "w+" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 123 | temp = "'" + main.commit + "'," |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 124 | temp += "'" + mode + "'," |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 125 | temp += "'" + avg + "'," |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 126 | temp += "'" + stdev + "'\n" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 127 | dbfile.write( temp ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 128 | dbfile.close() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 129 | main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 130 | except IOError: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 131 | main.log.warn( "Error opening " + dbFileName + " to write results." ) |
Jon Hall | 4ba53f0 | 2015-07-29 13:07:41 -0700 | [diff] [blame] | 132 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 133 | stepResult = main.TRUE |
| 134 | break |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 135 | if not validFlag: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 136 | main.log.warn( "Cbench Test produced no valid results!!!!" ) |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 137 | stepResult = main.FALSE |
jenkins | 24dde6b | 2015-06-19 13:40:44 -0700 | [diff] [blame] | 138 | |
suibin zhang | 8a46f2e | 2015-07-13 21:56:07 -0700 | [diff] [blame] | 139 | utilities.assert_equals( expect=main.TRUE, |
| 140 | actual=stepResult, |
| 141 | onpass="Successfully tested onos for cbench. ", |
| 142 | onfail="Failed to obtain valid onos cbench result!" ) |