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