blob: d87bc7e7ceab8aaf42cf6488b6471512bc21dded [file] [log] [blame]
jenkins24dde6b2015-06-19 13:40:44 -07001# ScaleOutTemplate --> CbenchBM
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
Jon Hallf57a5ef2015-07-07 17:56:16 -07008import os
jenkins24dde6b2015-06-19 13:40:44 -07009import os.path
10
11
Jon Hallf57a5ef2015-07-07 17:56:16 -070012class SCPFcbench:
jenkins24dde6b2015-06-19 13:40:44 -070013
14 def __init__( self ):
15 self.default = ''
16
Jon Hall4ba53f02015-07-29 13:07:41 -070017 def CASE1( self, main ):
18
19 import time
20 import os
21 global init
Devin Lim142b5342017-07-20 15:22:39 -070022 main.case( "pre-condition for cbench test." )
suibin zhang8a46f2e2015-07-13 21:56:07 -070023
Jon Hall4ba53f02015-07-29 13:07:41 -070024 try:
Devin Lim142b5342017-07-20 15:22:39 -070025 if type( init ) is not bool:
Jon Hall4ba53f02015-07-29 13:07:41 -070026 init = False
27 except NameError:
28 init = False
29
Jon Hall4ba53f02015-07-29 13:07:41 -070030 # -- INIT SECTION, ONLY RUNS ONCE -- #
31 if init == False:
jenkins24dde6b2015-06-19 13:40:44 -070032 init = True
Devin Lim58046fa2017-07-05 16:55:00 -070033 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" )
38 main.exit()
39 main.testSetUp.envSetupDescription()
40 stepResult = main.FALSE
41 try:
42 # Load values from params file
Devin Lim142b5342017-07-20 15:22:39 -070043 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 Hall4ba53f02015-07-29 13:07:41 -070051
Devin Lim142b5342017-07-20 15:22:39 -070052 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070053 except Exception as e:
54 main.testSetUp.envSetupException( e )
55 main.testSetUp.evnSetupConclusion( stepResult )
Devin Lim58046fa2017-07-05 16:55:00 -070056 main.commit = ( main.commit.split( " " ) )[ 1 ]
jenkins24dde6b2015-06-19 13:40:44 -070057 # -- END OF INIT SECTION --#
Jon Hall4ba53f02015-07-29 13:07:41 -070058
Devin Lim142b5342017-07-20 15:22:39 -070059 main.testSetUp.ONOSSetUp( MN1Ip, main.Cluster, True,
Devin Lim58046fa2017-07-05 16:55:00 -070060 cellName=main.cellName )
jenkins24dde6b2015-06-19 13:40:44 -070061
Devin Lim142b5342017-07-20 15:22:39 -070062 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( ":~" )
jenkins24dde6b2015-06-19 13:40:44 -070067 check = main.ONOSbench.handle.before
68 if "value=true" in check:
Devin Lim142b5342017-07-20 15:22:39 -070069 main.log.info( "cfg set successful" )
suibin zhang8a46f2e2015-07-13 21:56:07 -070070 stepResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -070071 break
72 if i == 4:
Devin Lim142b5342017-07-20 15:22:39 -070073 main.log.info( "Cfg set failed" )
suibin zhang8a46f2e2015-07-13 21:56:07 -070074 stepResult = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -070075 else:
Devin Lim142b5342017-07-20 15:22:39 -070076 time.sleep( 5 )
suibin zhang8a46f2e2015-07-13 21:56:07 -070077
Jon Hall4ba53f02015-07-29 13:07:41 -070078 utilities.assert_equals( expect=main.TRUE,
79 actual=stepResult,
80 onpass="Successfully configure onos for cbench test ",
suibin zhang8a46f2e2015-07-13 21:56:07 -070081 onfail="Failed to configure onos for cbench test" )
jenkins24dde6b2015-06-19 13:40:44 -070082
Jon Hall4ba53f02015-07-29 13:07:41 -070083
jenkins24dde6b2015-06-19 13:40:44 -070084 def CASE2( self, main ):
Devin Lim142b5342017-07-20 15:22:39 -070085 main.case( "Running Cbench" )
86 main.step( "Issuing cbench commands and grab returned results" )
suibin zhang8a46f2e2015-07-13 21:56:07 -070087 validFlag = False
suibin zhangacdd8fe2015-08-31 17:01:39 -070088 cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ]
jenkins24dde6b2015-06-19 13:40:44 -070089 mode = main.params[ 'TEST' ][ 'mode' ]
90 if mode != "t":
Jon Hall4ba53f02015-07-29 13:07:41 -070091 mode = " "
jenkins24dde6b2015-06-19 13:40:44 -070092
Devin Lim142b5342017-07-20 15:22:39 -070093 runCbench = ( "ssh " + CBENCHuser + "@" + main.Cluster.active( 0 ).ipAddress + " " + cbenchCMD + mode )
94 main.ONOSbench.handle.sendline( runCbench )
95 time.sleep( 30 )
96 main.ONOSbench.handle.expect( ":~" )
jenkins24dde6b2015-06-19 13:40:44 -070097 output = main.ONOSbench.handle.before
Devin Lim142b5342017-07-20 15:22:39 -070098 main.log.info( output )
jenkins24dde6b2015-06-19 13:40:44 -070099
100 output = output.splitlines()
Jon Hall4ba53f02015-07-29 13:07:41 -0700101 for line in output:
suibin zhang8a46f2e2015-07-13 21:56:07 -0700102 if "RESULT: " in line:
103 validFlag = True
jenkins24dde6b2015-06-19 13:40:44 -0700104 print line
Devin Lim142b5342017-07-20 15:22:39 -0700105 resultLine = line.split( " " )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700106 for word in resultLine:
Jon Hall4ba53f02015-07-29 13:07:41 -0700107 if word == "min/max/avg/stdev":
Devin Lim142b5342017-07-20 15:22:39 -0700108 resultsIndex = resultLine.index( word )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700109 print resultsIndex
110 break
jenkins24dde6b2015-06-19 13:40:44 -0700111
Devin Lim142b5342017-07-20 15:22:39 -0700112 finalDataString = resultLine[ resultsIndex + 2 ]
suibin zhang8a46f2e2015-07-13 21:56:07 -0700113 print finalDataString
Devin Lim142b5342017-07-20 15:22:39 -0700114 finalDataList = finalDataString.split( "/" )
115 avg = finalDataList[ 2 ]
116 stdev = finalDataList[ 3 ]
Jon Hall4ba53f02015-07-29 13:07:41 -0700117
Devin Lim142b5342017-07-20 15:22:39 -0700118 main.log.info( "Average: \t\t\t" + avg )
119 main.log.info( "Standard Deviation: \t" + stdev )
Jon Hall4ba53f02015-07-29 13:07:41 -0700120
suibin zhang8a46f2e2015-07-13 21:56:07 -0700121 try:
122 dbFileName="/tmp/CbenchDB"
Devin Lim142b5342017-07-20 15:22:39 -0700123 dbfile = open( dbFileName, "w+" )
Devin Lim58046fa2017-07-05 16:55:00 -0700124 temp = "'" + main.commit + "',"
Jon Hall4ba53f02015-07-29 13:07:41 -0700125 temp += "'" + mode + "',"
suibin zhang8a46f2e2015-07-13 21:56:07 -0700126 temp += "'" + avg + "',"
Jon Hall4ba53f02015-07-29 13:07:41 -0700127 temp += "'" + stdev + "'\n"
Devin Lim142b5342017-07-20 15:22:39 -0700128 dbfile.write( temp )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700129 dbfile.close()
Devin Lim142b5342017-07-20 15:22:39 -0700130 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700131 except IOError:
Devin Lim142b5342017-07-20 15:22:39 -0700132 main.log.warn( "Error opening " + dbFileName + " to write results." )
Jon Hall4ba53f02015-07-29 13:07:41 -0700133
suibin zhang8a46f2e2015-07-13 21:56:07 -0700134 stepResult = main.TRUE
135 break
136 if ( validFlag == False ):
Devin Lim142b5342017-07-20 15:22:39 -0700137 main.log.warn( "Cbench Test produced no valid results!!!!" )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700138 stepResult = main.FALSE
jenkins24dde6b2015-06-19 13:40:44 -0700139
suibin zhang8a46f2e2015-07-13 21:56:07 -0700140 utilities.assert_equals( expect=main.TRUE,
141 actual=stepResult,
142 onpass="Successfully tested onos for cbench. ",
143 onfail="Failed to obtain valid onos cbench result!" )
jenkins24dde6b2015-06-19 13:40:44 -0700144