blob: 414575ce1486db943a426e5719b660e5242bf15a [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
17 def CASE1( self, main ):
18
Jon Hallf57a5ef2015-07-07 17:56:16 -070019 import time
20 import os
jenkins24dde6b2015-06-19 13:40:44 -070021 global init
22 try:
23 if type(init) is not bool:
24 init = False
25 except NameError:
26 init = False
27
28 #Load values from params file
29 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
30 gitPull = main.params[ 'GIT' ][ 'autopull' ]
31 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
jenkinsf4ac82d2015-07-13 16:40:20 -070033 CBENCHuser = main.params[ 'CBENCH'][ 'user' ]
jenkins24dde6b2015-06-19 13:40:44 -070034 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
35 maxNodes = int(main.params[ 'availableNodes' ])
36 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
37 cellName = main.params[ 'ENV' ][ 'cellName' ]
38
39 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
41 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
44 global scale
45
46 clusterCount = 0
47 ONOSIp = [ 0 ]
48 scale = (main.params[ 'SCALE' ]).split(",")
49 clusterCount = int(scale[0])
50
51 #Populate ONOSIp with ips from params
52 for i in range(1, maxNodes + 1):
Jon Hallf57a5ef2015-07-07 17:56:16 -070053 ipString = os.environ[main.params['CTRL']['ip1']]
54 ONOSIp.append(ipString)
jenkins24dde6b2015-06-19 13:40:44 -070055
56 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
59
60 #git
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 else:
67 checkoutResult = main.TRUE
68 pullResult = main.TRUE
69 main.log.info( "Skipped git checkout and pull" )
70
71 # -- END OF INIT SECTION --#
72
73 clusterCount = int(scale[0])
74 scale.remove(scale[0])
75
76 #kill off all onos processes
77 main.log.step("Safety check, killing all ONOS processes")
78 main.log.step("before initiating enviornment setup")
79 for node in range(1, maxNodes + 1):
80 main.ONOSbench.onosDie(ONOSIp[node])
81
82 #Uninstall everywhere
83 main.log.step( "Cleaning Enviornment..." )
84 for i in range(1, maxNodes + 1):
85 main.log.info(" Uninstalling ONOS " + str(i) )
86 main.ONOSbench.onosUninstall( ONOSIp[i] )
Jon Hallf57a5ef2015-07-07 17:56:16 -070087
88 time.sleep(10)
89 main.ONOSbench.handle.sendline(" ")
90 main.ONOSbench.handle.expect(":~")
91 print "pexpect: \n" + main.ONOSbench.handle.before
92
93
94 print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp)
jenkinsf4ac82d2015-07-13 16:40:20 -070095 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,"drivers,openflow,fwd",[ONOSIp[1]])
Jon Hallf57a5ef2015-07-07 17:56:16 -070096
jenkins24dde6b2015-06-19 13:40:44 -070097 main.step( "Set Cell" )
98 main.ONOSbench.setCell(cellName)
Jon Hallf57a5ef2015-07-07 17:56:16 -070099
100 #main.ONOSbench.handle.sendline(" ")
101 #main.ONOSbench.handle.expect(":~")
102 #print "pexpect: \n" + main.ONOSbench.handle.before
103
jenkins24dde6b2015-06-19 13:40:44 -0700104 main.step( "Creating ONOS package" )
105 packageResult = main.ONOSbench.onosPackage()
106
107 main.step( "verify cells" )
108 verifyCellResult = main.ONOSbench.verifyCell()
109
110 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
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
125 for i in range(5):
126 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true")
127 time.sleep(5)
128 main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly")
129 main.ONOSbench.handle.expect(":~")
130 check = main.ONOSbench.handle.before
131 if "value=true" in check:
132 main.log.info("cfg set successful")
133 break
134 if i == 4:
135 main.log.info("Cfg set failed")
136 else:
137 time.sleep(5)
138
139
140
141
142
143 def CASE2( self, main ):
144
145 mode = main.params[ 'TEST' ][ 'mode' ]
146 if mode != "t":
147 mode = " "
148
jenkinsf4ac82d2015-07-13 16:40:20 -0700149 runCbench = ( "ssh " + CBENCHuser + "@" + ONOSIp[1] + " cbench -c localhost -p 6633 -m 1000 -l 25 -s 16 -M 100000 -w 15 -D 10000 -" + mode )
jenkins24dde6b2015-06-19 13:40:44 -0700150 main.ONOSbench.handle.sendline(runCbench)
151 time.sleep(30)
152 main.ONOSbench.handle.expect(":~")
153 output = main.ONOSbench.handle.before
154 main.log.info(output)
155
156 output = output.splitlines()
157 for line in output:
158 if "RESULT: " in line:
159 print line
160 break
161
jenkinsf4ac82d2015-07-13 16:40:20 -0700162 try:
163 resultLine = line.split(" ")
164 for word in resultLine:
165 if word == "min/max/avg/stdev":
166 resultsIndex = resultLine.index(word)
167 print resultsIndex
168 break
jenkins24dde6b2015-06-19 13:40:44 -0700169
jenkinsf4ac82d2015-07-13 16:40:20 -0700170 finalDataString = resultLine[resultsIndex + 2]
171 print finalDataString
172 finalDataList = finalDataString.split("/")
173 avg = finalDataList[2]
174 stdev = finalDataList[3]
jenkins24dde6b2015-06-19 13:40:44 -0700175
jenkinsf4ac82d2015-07-13 16:40:20 -0700176 main.log.info("Average: \t\t\t" + avg)
177 main.log.info("Standard Deviation: \t" + stdev)
jenkins24dde6b2015-06-19 13:40:44 -0700178
jenkinsf4ac82d2015-07-13 16:40:20 -0700179 if mode == " ":
180 mode = "l"
jenkins24dde6b2015-06-19 13:40:44 -0700181
jenkinsf4ac82d2015-07-13 16:40:20 -0700182 commit = main.ONOSbench.getVersion()
183 commit = (commit.split(" "))[1]
jenkins24dde6b2015-06-19 13:40:44 -0700184
jenkinsf4ac82d2015-07-13 16:40:20 -0700185 dbfile = open("CbenchDB", "w+")
186 temp = "'" + commit + "',"
187 temp += "'" + mode + "',"
188 temp += "'" + avg + "',"
189 temp += "'" + stdev + "'\n"
190 dbfile.write(temp)
191 dbfile.close()
192 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
193 except:
194 main.log.warn("Cbench test produced no valid results!!!")
jenkins24dde6b2015-06-19 13:40:44 -0700195
196
197
198
199
200
201
202