blob: 4e185fc76feed555c520c3b6af43eb7bf4509226 [file] [log] [blame]
Devin Lime1346f42018-05-15 15:41:36 -07001#!groovy
2
Devin Limf5175192018-05-14 19:13:22 -07003// Copyright 2017 Open Networking Foundation (ONF)
4//
5// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
8//
9// TestON is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 2 of the License, or
12// (at your option) any later version.
13//
14// TestON is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with TestON. If not, see <http://www.gnu.org/licenses/>.
21
22// This is the dependency Jenkins script.
23// This will provide the SCPF specific functions
24
Devin Limb734ea52018-05-14 14:13:05 -070025fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Devin Limfe9a4cb2018-05-11 17:06:21 -070026
27fileRelated.init()
Jon Hall6af749d2018-05-29 12:59:47 -070028
Devin Lim61643762017-12-07 15:55:38 -080029def init(){
Jon Hall6af749d2018-05-29 12:59:47 -070030 // init step for SCPF functions. It has some mandatory init steps
Devin Limf5175192018-05-14 19:13:22 -070031
32 // none, batches, neighbors, times : to be used for extra parameters for generating graphs.
Jon Hall6af749d2018-05-29 12:59:47 -070033 def none = [ "" ]
34 def batches = [ 1, 100, 1000 ]
35 def neighbors = [ 'y', 'n' ]
36 def times = [ 'y', 'n' ]
Devin Limf5175192018-05-14 19:13:22 -070037
38 //flows : whether the test is affected by oldFlow or newFlow
39 // test : command of the test to be executed when running the test
40 // table : name of the view table on database
41 // result : name of the actual table on database
42 // file : name of the file that contains the result of the test to be used to insert data to database
43 // rFile : specific Rscript file name to be used to generate each SCPF graph. For with flowObj graphs, you need to put 'n' or 'y' after the test name
44 // extra : extra condition that will be used for Rscript parameter. Some of the Rscript requires extra parameters like if it has
45 // neighbors or batches. In this case, it will generate Rscript x times of what extra has. So that it will generate one with
46 // neighbor = y and the other with neighbor = n
47 // finalResult : If you want to generate overall graph for the front page.
48 // graphTitle : title for the graph. It should contain n numbers depends on how many graphs you are generating.
49 // [Optional]
50 // dbCols : specific dbColumns to choose for 50 data overall graph if there is one.
51 // dbWhere : specific where statement that has some condition for 50 data overall graph if there is one.
52 // y_axis : title of the y_axis to be shown for 50 data overall graph if there is one.
53
Devin Lim61643762017-12-07 15:55:38 -080054 SCPF = [
Jon Hall6af749d2018-05-29 12:59:47 -070055 SCPFcbench: [ flows: false,
56 test: 'SCPFcbench',
57 table: 'cbench_bm_tests',
58 results: 'cbench_bm_results',
59 file: 'CbenchDB',
60 rFile: 'SCPFcbench.R',
61 extra: none,
62 finalResult: 1,
63 graphTitle: [ 'Cbench Test' ],
64 dbCols: 'avg',
65 dbWhere: '',
66 y_axis: 'Throughput (Responses/sec)' ],
67 SCPFhostLat: [ flows: false,
68 test: 'SCPFhostLat',
69 table: 'host_latency_tests',
70 results: 'host_latency_results',
71 file: 'HostAddLatency',
72 rFile: 'SCPFhostLat.R',
73 extra: none,
74 finalResult: 1,
75 graphTitle: [ 'Host Latency Test' ],
76 dbCols: 'avg',
77 dbWhere: 'AND scale=5',
78 y_axis: 'Latency (ms)' ],
79 SCPFportLat: [ flows: false,
80 test: 'SCPFportLat',
81 table: 'port_latency_details',
82 results: 'port_latency_results',
You Wangd3e80c72018-10-19 10:45:16 -070083 file: 'portEventResultDb',
Jon Hall6af749d2018-05-29 12:59:47 -070084 rFile: 'SCPFportLat.R',
85 extra: none,
86 finalResult: 1,
87 graphTitle: [ 'Port Latency Test - Port Up', 'Port Latency Test - Port Down' ],
88 dbCols: [ 'up_ofp_to_dev_avg, up_dev_to_link_avg, up_link_to_graph_avg',
89 'down_ofp_to_dev_avg, down_dev_to_link_avg, down_link_to_graph_avg' ],
90 dbWhere: 'AND scale=5', y_axis: 'Latency (ms)' ],
91 SCPFflowTp1g: [ flows: true,
92 test: 'SCPFflowTp1g',
93 table: 'flow_tp_tests',
94 results: 'flow_tp_results',
95 file: 'flowTP1gDB',
96 rFile: 'SCPFflowTp1g.R n',
97 extra: neighbors,
98 finalResult: 1,
99 graphTitle: [ 'Flow Throughput Test - neighbors=0',
100 'Flow Throughput Test - neighbors=4' ],
101 dbCols: 'avg',
102 dbWhere: [ 'AND scale=5 AND neighbors=0 ',
103 'AND scale=5 AND NOT neighbors=0' ],
104 y_axis: 'Throughput (,000 Flows/sec)' ],
105 SCPFflowTp1gWithFlowObj: [ flows: true,
106 test: 'SCPFflowTp1g --params TEST/flowObj=True',
107 table: 'flow_tp_fobj_tests',
108 results: 'flow_tp_fobj_results',
109 file: 'flowTP1gDBFlowObj',
110 rFile: 'SCPFflowTp1g.R y',
111 extra: neighbors,
112 finalResult: 0 ],
113 SCPFscaleTopo: [ flows: false,
114 test: 'SCPFscaleTopo',
115 table: 'scale_topo_latency_details',
116 results: 'scale_topo_latency_results',
You Wangd3e80c72018-10-19 10:45:16 -0700117 file: 'scaleTopoResultDb',
Jon Hall6af749d2018-05-29 12:59:47 -0700118 rFile: 'SCPFscaleTopo.R',
119 extra: none,
120 finalResult: 1,
121 graphTitle: [ 'Scale Topology Test' ],
122 dbCols: [ 'first_connection_to_last_connection, last_connection_to_last_role_request, last_role_request_to_last_topology' ],
123 dbWhere: 'AND scale=20',
124 y_axis: 'Latency (s)' ],
125 SCPFswitchLat: [ flows: false,
126 test: 'SCPFswitchLat',
127 table: 'switch_latency_details',
128 results: 'switch_latency_results',
You Wangd3e80c72018-10-19 10:45:16 -0700129 file: 'switchEventResultDb',
Jon Hall6af749d2018-05-29 12:59:47 -0700130 rFile: 'SCPFswitchLat.R',
131 extra: none,
132 finalResult: 1,
133 graphTitle: [ 'Switch Latency Test - Switch Up',
134 'Switch Latency Test - Switch Down' ],
135 dbCols: [ 'tcp_to_feature_reply_avg,feature_reply_to_device_avg,up_device_to_graph_avg',
136 'fin_ack_to_ack_avg,ack_to_device_avg,down_device_to_graph_avg' ],
137 dbWhere: 'AND scale=5',
138 y_axis: 'Latency (ms)' ],
139 SCPFbatchFlowResp: [ flows: true,
140 test: 'SCPFbatchFlowResp',
141 table: 'batch_flow_tests',
142 results: 'batch_flow_results',
143 file: 'SCPFbatchFlowRespData',
144 rFile: 'SCPFbatchFlowResp.R',
145 extra: none,
146 finalResult: 1,
147 graphTitle: [ 'Batch Flow Test - Post',
148 'Batch Flow Test - Del' ],
149 dbCols: [ 'elapsepost, posttoconfrm',
150 'elapsedel, deltoconfrm' ],
151 dbWhere: '',
152 y_axis: 'Latency (s)' ],
153 SCPFintentEventTp: [ flows: true,
154 test: 'SCPFintentEventTp',
155 table: 'intent_tp_tests',
156 results: 'intent_tp_results',
157 file: 'IntentEventTPDB',
158 rFile: 'SCPFintentEventTp.R n',
159 extra: neighbors,
160 finalResult: 1,
161 graphTitle: [ 'Intent Throughput Test - neighbors=0',
162 'Intent Throughput Test - neighbors=4' ],
163 dbCols: 'SUM( avg ) as avg',
164 dbWhere: [ 'AND scale=5 AND neighbors=0 GROUP BY date,build',
165 'AND scale=5 AND NOT neighbors=0 GROUP BY date,build' ],
166 y_axis: 'Throughput (Ops/sec)' ],
167 SCPFintentRerouteLat: [ flows: true,
168 test: 'SCPFintentRerouteLat',
169 table: 'intent_reroute_latency_tests',
170 results: 'intent_reroute_latency_results',
171 file: 'IntentRerouteLatDB',
172 rFile: 'SCPFIntentInstallWithdrawRerouteLat.R n',
173 extra: batches,
174 finalResult: 1,
175 graphTitle: [ 'Intent Reroute Test' ],
176 dbCols: 'avg',
177 dbWhere: 'AND scale=5 AND batch_size=100',
178 y_axis: 'Latency (ms)' ],
179 SCPFscalingMaxIntents: [ flows: true,
180 test: 'SCPFscalingMaxIntents',
181 table: 'max_intents_tests',
182 results: 'max_intents_results',
183 file: 'ScalingMaxIntentDB',
184 rFile: 'SCPFscalingMaxIntents.R n',
185 extra: none,
186 finalResult: 0 ],
187 SCPFintentEventTpWithFlowObj: [ flows: true,
188 test: 'SCPFintentEventTp --params TEST/flowObj=True',
189 table: 'intent_tp_fobj_tests',
190 results: 'intent_tp_fobj_results',
191 file: 'IntentEventTPflowObjDB',
192 rFile: 'SCPFintentEventTp.R y',
193 extra: neighbors,
194 finalResult: 0 ],
195 SCPFintentInstallWithdrawLat: [ flows: true,
196 test: 'SCPFintentInstallWithdrawLat',
197 table: 'intent_latency_tests',
198 results: 'intent_latency_results',
199 file: 'IntentInstallWithdrawLatDB',
200 rFile: 'SCPFIntentInstallWithdrawRerouteLat.R n',
201 extra: batches,
202 finalResult: 1,
203 graphTitle: [ 'Intent Installation Test',
204 'Intent Withdrawal Test' ],
205 dbCols: [ 'install_avg', 'withdraw_avg' ],
206 dbWhere: 'AND scale=5 AND batch_size=100',
207 y_axis: 'Latency (ms)' ],
208 SCPFintentRerouteLatWithFlowObj: [ flows: true,
209 test: 'SCPFintentRerouteLat --params TEST/flowObj=True',
210 table: 'intent_reroute_latency_fobj_tests',
211 results: 'intent_reroute_latency_fobj_results',
212 file: 'IntentRerouteLatDBWithFlowObj',
213 rFile: 'SCPFIntentInstallWithdrawRerouteLat.R y',
214 extra: batches,
215 finalResult: 0 ],
216 SCPFscalingMaxIntentsWithFlowObj: [ flows: true,
217 test: 'SCPFscalingMaxIntents --params TEST/flowObj=True',
218 table: 'max_intents_fobj_tests',
219 results: 'max_intents_fobj_results',
220 file: 'ScalingMaxIntentDBWFO',
221 rFile: 'SCPFscalingMaxIntents.R y',
222 extra: none,
223 finalResult: 0 ],
224 SCPFintentInstallWithdrawLatWithFlowObj: [ flows: true,
225 test: 'SCPFintentInstallWithdrawLat --params TEST/flowObj=True',
226 table: 'intent_latency_fobj_tests',
227 results: 'intent_latency_fobj_results',
228 file: 'IntentInstallWithdrawLatDBWFO',
229 rFile: 'SCPFIntentInstallWithdrawRerouteLat.R y',
230 extra: batches,
231 finalResult: 0 ],
232 SCPFmastershipFailoverLat: [ flows: false,
233 test: 'SCPFmastershipFailoverLat',
234 table: 'mastership_failover_tests',
235 results: 'mastership_failover_results',
236 file: 'mastershipFailoverLatDB',
237 rFile: 'SCPFmastershipFailoverLat.R',
238 extra: none,
239 finalResult: 1,
240 graphTitle: [ 'Mastership Failover Test' ],
241 dbCols: [ 'kill_deact_avg,deact_role_avg' ],
242 dbWhere: 'AND scale=5',
243 y_axis: 'Latency (ms)' ]
Devin Lim61643762017-12-07 15:55:38 -0800244 ]
Devin Limfe9a4cb2018-05-11 17:06:21 -0700245 graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-BM/"
Devin Lim61643762017-12-07 15:55:38 -0800246}
Jon Hall6af749d2018-05-29 12:59:47 -0700247
Devin Lim61643762017-12-07 15:55:38 -0800248def getGraphCommand( rFileName, extras, host, port, user, pass, testName, branchName, isOldFlow ){
Devin Limf5175192018-05-14 19:13:22 -0700249 // generate the list of Rscript command for individual graphs
250
Devin Lim61643762017-12-07 15:55:38 -0800251 result = ""
Jon Hall6af749d2018-05-29 12:59:47 -0700252 for ( extra in extras ){
Devin Lim61643762017-12-07 15:55:38 -0800253 result += generateGraph( rFileName, " " + extra, host, port, user, pass, testName, branchName, isOldFlow ) + ";"
254 }
255 return result
256}
Jon Hall6af749d2018-05-29 12:59:47 -0700257
Devin Lim61643762017-12-07 15:55:38 -0800258def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){
Devin Limf5175192018-05-14 19:13:22 -0700259 // generate the Rscript command for individual graphs
Devin Lim61643762017-12-07 15:55:38 -0800260
Jon Hall6af749d2018-05-29 12:59:47 -0700261 return generalFuncs.basicGraphPart( fileRelated.SCPFSpecificLocation + rFileName,
262 host, port, user, pass, testName, branchName ) +
Devin Lim61643762017-12-07 15:55:38 -0800263 " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory
264}
Jon Hall6af749d2018-05-29 12:59:47 -0700265
Devin Lim61643762017-12-07 15:55:38 -0800266def generateCombinedResultGraph( host, port, user, pass, testName, branchName, isOldFlow ){
Devin Limf5175192018-05-14 19:13:22 -0700267 // generate Rscript for overall graph for the front page.
Jon Hall6af749d2018-05-29 12:59:47 -0700268 def result = ""
Devin Lim61643762017-12-07 15:55:38 -0800269
Jon Hall6af749d2018-05-29 12:59:47 -0700270 for ( int i = 0; i < SCPF[ testName ][ 'graphTitle' ].size(); i++ ){
271 result += generalFuncs.basicGraphPart( fileRelated.trendSCPF,
272 host,
273 port,
274 user,
275 pass,
276 "\"" + SCPF[ testName ][ 'graphTitle' ][ i ] + "\"",
277 branchName ) +
278 " " + 50 + " \"SELECT " +
279 checkIfList( testName, 'dbCols', i ) +
280 ", build FROM " + SCPF[ testName ][ 'table' ] + " WHERE branch=\'" + branchName + "\' " +
281 sqlOldFlow( isOldFlow, testName ) +
282 checkIfList( testName, 'dbWhere', i ) +
283 " ORDER BY date DESC LIMIT 50\" \"" +
284 SCPF[ testName ][ 'y_axis' ] + "\" " +
285 hasOldFlow( isOldFlow, testName ) +
286 graph_saved_directory + ";"
Devin Lim61643762017-12-07 15:55:38 -0800287 }
288 return result
289}
Jon Hall6af749d2018-05-29 12:59:47 -0700290
Devin Lim61643762017-12-07 15:55:38 -0800291def checkIfList( testName, forWhich, pos ){
Devin Limf5175192018-05-14 19:13:22 -0700292 // check if some dictionary has list or string.
293
Jon Hall6af749d2018-05-29 12:59:47 -0700294 return SCPF[ testName ][ forWhich ].getClass().getName() != "java.lang.String" ?
295 SCPF[ testName ][ forWhich ][ pos ] :
296 SCPF[ testName ][ forWhich ]
Devin Lim61643762017-12-07 15:55:38 -0800297}
Jon Hall6af749d2018-05-29 12:59:47 -0700298
Devin Lim61643762017-12-07 15:55:38 -0800299def sqlOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700300 // sql where command part for checking old flows.
301
Devin Limc49c3732018-04-10 18:57:17 -0700302 return SCPF[ testName ][ 'flows' ] ? " AND " + ( isOldFlow ? "" : "NOT " ) + "is_old_flow " : ""
Devin Lim61643762017-12-07 15:55:38 -0800303}
Jon Hall6af749d2018-05-29 12:59:47 -0700304
Devin Lim61643762017-12-07 15:55:38 -0800305def oldFlowRuleCheck( isOldFlow, branch ){
Devin Limf5175192018-05-14 19:13:22 -0700306 // checking if it is old flow
307
Devin Lim61643762017-12-07 15:55:38 -0800308 this.isOldFlow = isOldFlow
Jon Hall6af749d2018-05-29 12:59:47 -0700309 if ( !isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800310 SCPF[ 'SCPFflowTp1g' ][ 'test' ] += " --params TEST/flows=" + ( branch == "onos-1.11" ? "4000" : "3500" )
311 }
312}
Jon Hall6af749d2018-05-29 12:59:47 -0700313
Devin Lim61643762017-12-07 15:55:38 -0800314def affectedByOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700315 // For sql command : if the test is affect by old flow, it will return parameters for old flow
Devin Lim61643762017-12-07 15:55:38 -0800316 return SCPF[ testName ][ 'flows' ] ? "" + isOldFlow + ", " : ""
317}
Jon Hall6af749d2018-05-29 12:59:47 -0700318
Devin Lim61643762017-12-07 15:55:38 -0800319def usingOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700320 // For Rscript command : if it is using old flow.
321
Devin Limc49c3732018-04-10 18:57:17 -0700322 return SCPF[ testName ][ 'flows' ] ? ( isOldFlow ? "y" : "n" ) + " " : ""
Devin Lim61643762017-12-07 15:55:38 -0800323}
Jon Hall6af749d2018-05-29 12:59:47 -0700324
Devin Lim61643762017-12-07 15:55:38 -0800325def hasOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700326 // For Rscript command for 50 data
327
Devin Limc49c3732018-04-10 18:57:17 -0700328 return ( SCPF[ testName ][ 'flows' ] && isOldFlow ? "y" : "n" ) + " "
Devin Lim61643762017-12-07 15:55:38 -0800329}
Jon Hall6af749d2018-05-29 12:59:47 -0700330
Devin Lim61643762017-12-07 15:55:38 -0800331def sqlCommand( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700332 // sql command for inserting data into the database
333
Jon Hall6af749d2018-05-29 12:59:47 -0700334 if ( testName == "SCPFscaleTopo" || testName == "SCPFswitchLat" || testName == "SCPFportLat" ){
335 return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" +
336 SCPF[ testName ][ 'results' ] + "','\$BUILD_NUMBER', \$line, '\$ONOSBranch');\""
337 }
338 return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" + SCPF[ testName ][ 'results' ] +
339 "','\$BUILD_NUMBER', '\$ONOSBranch', " + affectedByOldFlow( isOldFlow, testName ) + "\$line);\""
Devin Lim61643762017-12-07 15:55:38 -0800340}
Jon Hall6af749d2018-05-29 12:59:47 -0700341
You Wang6d171942018-10-17 11:45:05 -0700342def cleanupDatabaseFile( testName ){
343 // clean up the database file created under /tmp
You Wangae645332018-10-18 14:01:39 -0700344 return 'rm -f /tmp/' + SCPF[ testName ][ 'file' ]
You Wang6d171942018-10-17 11:45:05 -0700345}
346
Devin Lim61643762017-12-07 15:55:38 -0800347def databasePart( testName, database_command ){
Devin Limf5175192018-05-14 19:13:22 -0700348 // read the file from the machine and insert it to the database
349
Devin Lim61643762017-12-07 15:55:38 -0800350 return '''
351 cd /tmp
352 while read line
353 do
354 echo \$line
355 echo ''' + database_command + '''
356 done< ''' + SCPF[ testName ][ 'file' ]
357}
Jon Hall6af749d2018-05-29 12:59:47 -0700358
Devin Lim61643762017-12-07 15:55:38 -0800359def getGraphGeneratingCommand( host, port, user, pass, testName, prop ){
Devin Limf5175192018-05-14 19:13:22 -0700360 // returns the combined Rscript command for each test.
361
Jon Hall6af749d2018-05-29 12:59:47 -0700362 return getGraphCommand( SCPF[ testName ][ 'rFile' ],
363 SCPF[ testName ][ 'extra' ],
364 host, port, user, pass, testName,
365 prop[ "ONOSBranch" ], isOldFlow ) + '''
366 ''' + ( SCPF[ testName ][ 'finalResult' ] ?
367 generateCombinedResultGraph( host, port, user, pass, testName, prop[ "ONOSBranch" ], isOldFlow ) : "" )
Devin Lim61643762017-12-07 15:55:38 -0800368}
Jon Hall6af749d2018-05-29 12:59:47 -0700369
370return this