blob: 79cdce23f7d23044c969484aca2fa555a66a9b4a [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' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
36 cellName = main.params[ 'ENV' ][ 'cellName' ]
37
38 # -- INIT SECTION, ONLY RUNS ONCE -- #
39 if init == False:
40 init = True
41 global clusterCount #number of nodes running
42 global ONOSIp #list of ONOS IP addresses
43 global scale
44
45 clusterCount = 0
46 ONOSIp = [ 0 ]
47 scale = (main.params[ 'SCALE' ]).split(",")
48 clusterCount = int(scale[0])
49
50 #Populate ONOSIp with ips from params
51 for i in range(1, maxNodes + 1):
Jon Hallf57a5ef2015-07-07 17:56:16 -070052 ipString = os.environ[main.params['CTRL']['ip1']]
53 ONOSIp.append(ipString)
jenkins24dde6b2015-06-19 13:40:44 -070054
55 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
56 if skipMvn != "yes":
57 mvnResult = main.ONOSbench.cleanInstall()
58
59 #git
60 main.step( "Git checkout and pull " + checkoutBranch )
61 if gitPull == 'on':
62 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
63 pullResult = main.ONOSbench.gitPull()
64
65 else:
66 checkoutResult = main.TRUE
67 pullResult = main.TRUE
68 main.log.info( "Skipped git checkout and pull" )
69
70 # -- END OF INIT SECTION --#
71
72 clusterCount = int(scale[0])
73 scale.remove(scale[0])
74
75 #kill off all onos processes
76 main.log.step("Safety check, killing all ONOS processes")
77 main.log.step("before initiating enviornment setup")
78 for node in range(1, maxNodes + 1):
79 main.ONOSbench.onosDie(ONOSIp[node])
80
81 #Uninstall everywhere
82 main.log.step( "Cleaning Enviornment..." )
83 for i in range(1, maxNodes + 1):
84 main.log.info(" Uninstalling ONOS " + str(i) )
85 main.ONOSbench.onosUninstall( ONOSIp[i] )
Jon Hallf57a5ef2015-07-07 17:56:16 -070086
87 time.sleep(10)
88 main.ONOSbench.handle.sendline(" ")
89 main.ONOSbench.handle.expect(":~")
90 print "pexpect: \n" + main.ONOSbench.handle.before
91
92
93 print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp)
94 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,"drivers,openflow,fwd",ONOSIp[1])
95
jenkins24dde6b2015-06-19 13:40:44 -070096 main.step( "Set Cell" )
97 main.ONOSbench.setCell(cellName)
Jon Hallf57a5ef2015-07-07 17:56:16 -070098
99 #main.ONOSbench.handle.sendline(" ")
100 #main.ONOSbench.handle.expect(":~")
101 #print "pexpect: \n" + main.ONOSbench.handle.before
102
jenkins24dde6b2015-06-19 13:40:44 -0700103 main.step( "Creating ONOS package" )
104 packageResult = main.ONOSbench.onosPackage()
105
106 main.step( "verify cells" )
107 verifyCellResult = main.ONOSbench.verifyCell()
108
109 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
110 for node in range(1, clusterCount + 1):
111 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
112 main.ONOSbench.onosInstall( ONOSIp[node])
113
114 for node in range(1, clusterCount + 1):
115 for i in range( 2 ):
116 isup = main.ONOSbench.isup( ONOSIp[node] )
117 if isup:
118 main.log.info("ONOS " + str(node) + " is up\n")
119 break
120 if not isup:
121 main.log.report( "ONOS " + str(node) + " didn't start!" )
122 main.log.info("Startup sequence complete")
123
124 for i in range(5):
125 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true")
126 time.sleep(5)
127 main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly")
128 main.ONOSbench.handle.expect(":~")
129 check = main.ONOSbench.handle.before
130 if "value=true" in check:
131 main.log.info("cfg set successful")
132 break
133 if i == 4:
134 main.log.info("Cfg set failed")
135 else:
136 time.sleep(5)
137
138
139
140
141
142 def CASE2( self, main ):
143
144 mode = main.params[ 'TEST' ][ 'mode' ]
145 if mode != "t":
146 mode = " "
147
148 runCbench = ( "ssh admin@" + ONOSIp[1] + " cbench -c localhost -p 6633 -m 1000 -l 25 -s 16 -M 100000 -w 15 -D 10000 -" + mode )
149 main.ONOSbench.handle.sendline(runCbench)
150 time.sleep(30)
151 main.ONOSbench.handle.expect(":~")
152 output = main.ONOSbench.handle.before
153 main.log.info(output)
154
155 output = output.splitlines()
156 for line in output:
157 if "RESULT: " in line:
158 print line
159 break
160
161 resultLine = line.split(" ")
162 for word in resultLine:
163 if word == "min/max/avg/stdev":
164 resultsIndex = resultLine.index(word)
165 print resultsIndex
166 break
167
168 finalDataString = resultLine[resultsIndex + 2]
169 print finalDataString
170 finalDataList = finalDataString.split("/")
171 avg = finalDataList[2]
172 stdev = finalDataList[3]
173
174 main.log.info("Average: \t\t\t" + avg)
175 main.log.info("Standard Deviation: \t" + stdev)
176
177 if mode == " ":
178 mode = "l"
179
180 commit = main.ONOSbench.getVersion()
181 commit = (commit.split(" "))[1]
182
Jon Hallf57a5ef2015-07-07 17:56:16 -0700183 dbfile = open("CbenchDB", "w+")
jenkins24dde6b2015-06-19 13:40:44 -0700184 temp = "'" + commit + "',"
185 temp += "'" + mode + "',"
186 temp += "'" + avg + "',"
187 temp += "'" + stdev + "'\n"
188 dbfile.write(temp)
189 dbfile.close()
190 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
191
192
193
194
195
196
197
198
199