blob: 4a09129dd93f2f0ffde6472804a9fa4c9d3c32d9 [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:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070025 if not isinstance( init, 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 -- #
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070031 if not init:
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" )
Devin Lim44075962017-08-11 10:56:37 -070038 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070039 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
You Wanga0f6ff62018-01-11 15:46:30 -080059 main.testSetUp.ONOSSetUp( 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
jenkins24dde6b2015-06-19 13:40:44 -070083 def CASE2( self, main ):
Devin Lim142b5342017-07-20 15:22:39 -070084 main.case( "Running Cbench" )
85 main.step( "Issuing cbench commands and grab returned results" )
suibin zhang8a46f2e2015-07-13 21:56:07 -070086 validFlag = False
suibin zhangacdd8fe2015-08-31 17:01:39 -070087 cbenchCMD = main.params[ 'TEST' ][ 'cbenchCMD' ]
jenkins24dde6b2015-06-19 13:40:44 -070088 mode = main.params[ 'TEST' ][ 'mode' ]
89 if mode != "t":
Jon Hall4ba53f02015-07-29 13:07:41 -070090 mode = " "
jenkins24dde6b2015-06-19 13:40:44 -070091
Devin Lim142b5342017-07-20 15:22:39 -070092 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( ":~" )
jenkins24dde6b2015-06-19 13:40:44 -070096 output = main.ONOSbench.handle.before
Devin Lim142b5342017-07-20 15:22:39 -070097 main.log.info( output )
jenkins24dde6b2015-06-19 13:40:44 -070098
99 output = output.splitlines()
Jon Hall4ba53f02015-07-29 13:07:41 -0700100 for line in output:
suibin zhang8a46f2e2015-07-13 21:56:07 -0700101 if "RESULT: " in line:
102 validFlag = True
jenkins24dde6b2015-06-19 13:40:44 -0700103 print line
Devin Lim142b5342017-07-20 15:22:39 -0700104 resultLine = line.split( " " )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700105 for word in resultLine:
Jon Hall4ba53f02015-07-29 13:07:41 -0700106 if word == "min/max/avg/stdev":
Devin Lim142b5342017-07-20 15:22:39 -0700107 resultsIndex = resultLine.index( word )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700108 print resultsIndex
109 break
jenkins24dde6b2015-06-19 13:40:44 -0700110
Devin Lim142b5342017-07-20 15:22:39 -0700111 finalDataString = resultLine[ resultsIndex + 2 ]
suibin zhang8a46f2e2015-07-13 21:56:07 -0700112 print finalDataString
Devin Lim142b5342017-07-20 15:22:39 -0700113 finalDataList = finalDataString.split( "/" )
114 avg = finalDataList[ 2 ]
115 stdev = finalDataList[ 3 ]
Jon Hall4ba53f02015-07-29 13:07:41 -0700116
Devin Lim142b5342017-07-20 15:22:39 -0700117 main.log.info( "Average: \t\t\t" + avg )
118 main.log.info( "Standard Deviation: \t" + stdev )
Jon Hall4ba53f02015-07-29 13:07:41 -0700119
suibin zhang8a46f2e2015-07-13 21:56:07 -0700120 try:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700121 dbFileName = "/tmp/CbenchDB"
Devin Lim142b5342017-07-20 15:22:39 -0700122 dbfile = open( dbFileName, "w+" )
Devin Lim58046fa2017-07-05 16:55:00 -0700123 temp = "'" + main.commit + "',"
Jon Hall4ba53f02015-07-29 13:07:41 -0700124 temp += "'" + mode + "',"
suibin zhang8a46f2e2015-07-13 21:56:07 -0700125 temp += "'" + avg + "',"
Jon Hall4ba53f02015-07-29 13:07:41 -0700126 temp += "'" + stdev + "'\n"
Devin Lim142b5342017-07-20 15:22:39 -0700127 dbfile.write( temp )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700128 dbfile.close()
Devin Lim142b5342017-07-20 15:22:39 -0700129 main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700130 except IOError:
Devin Lim142b5342017-07-20 15:22:39 -0700131 main.log.warn( "Error opening " + dbFileName + " to write results." )
Jon Hall4ba53f02015-07-29 13:07:41 -0700132
suibin zhang8a46f2e2015-07-13 21:56:07 -0700133 stepResult = main.TRUE
134 break
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700135 if not validFlag:
Devin Lim142b5342017-07-20 15:22:39 -0700136 main.log.warn( "Cbench Test produced no valid results!!!!" )
suibin zhang8a46f2e2015-07-13 21:56:07 -0700137 stepResult = main.FALSE
jenkins24dde6b2015-06-19 13:40:44 -0700138
suibin zhang8a46f2e2015-07-13 21:56:07 -0700139 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!" )