blob: 577377e57d9df675bb94904ec7a018fd43da6cfe [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 ]
Jeremy Ronquilloe1750cb2019-05-17 15:04:30 -0700245 graph_saved_directory = fileRelated.workspaces[ "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
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700258// make the basic graph part for the Rscript
259def basicGraphPart( rFileName, host, port, user, pass, subject, branchName ){
260 return " Rscript " + rFileName + " " + host + " " + port + " " + user + " " + pass + " " + subject + " " + branchName
261}
262
Devin Lim61643762017-12-07 15:55:38 -0800263def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){
Devin Limf5175192018-05-14 19:13:22 -0700264 // generate the Rscript command for individual graphs
Devin Lim61643762017-12-07 15:55:38 -0800265
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700266 return basicGraphPart( fileRelated.rScriptPaths[ "directories" ][ "SCPF" ] + rFileName,
Jon Hall6af749d2018-05-29 12:59:47 -0700267 host, port, user, pass, testName, branchName ) +
Devin Lim61643762017-12-07 15:55:38 -0800268 " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory
269}
Jon Hall6af749d2018-05-29 12:59:47 -0700270
Devin Lim61643762017-12-07 15:55:38 -0800271def generateCombinedResultGraph( host, port, user, pass, testName, branchName, isOldFlow ){
Devin Limf5175192018-05-14 19:13:22 -0700272 // generate Rscript for overall graph for the front page.
Jon Hall6af749d2018-05-29 12:59:47 -0700273 def result = ""
Devin Lim61643762017-12-07 15:55:38 -0800274
Jon Hall6af749d2018-05-29 12:59:47 -0700275 for ( int i = 0; i < SCPF[ testName ][ 'graphTitle' ].size(); i++ ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700276 result += basicGraphPart( fileRelated.rScriptPaths[ "scripts" ][ "trendSCPF" ],
Jon Hall6af749d2018-05-29 12:59:47 -0700277 host,
278 port,
279 user,
280 pass,
281 "\"" + SCPF[ testName ][ 'graphTitle' ][ i ] + "\"",
282 branchName ) +
283 " " + 50 + " \"SELECT " +
284 checkIfList( testName, 'dbCols', i ) +
Jeremy Ronquillo76efee42020-01-13 13:27:44 -0800285 ", date, build FROM " + SCPF[ testName ][ 'table' ] + " WHERE branch=\'" + branchName + "\' " +
Jon Hall6af749d2018-05-29 12:59:47 -0700286 sqlOldFlow( isOldFlow, testName ) +
287 checkIfList( testName, 'dbWhere', i ) +
288 " ORDER BY date DESC LIMIT 50\" \"" +
289 SCPF[ testName ][ 'y_axis' ] + "\" " +
290 hasOldFlow( isOldFlow, testName ) +
291 graph_saved_directory + ";"
Devin Lim61643762017-12-07 15:55:38 -0800292 }
293 return result
294}
Jon Hall6af749d2018-05-29 12:59:47 -0700295
Devin Lim61643762017-12-07 15:55:38 -0800296def checkIfList( testName, forWhich, pos ){
Devin Limf5175192018-05-14 19:13:22 -0700297 // check if some dictionary has list or string.
298
Jon Hall6af749d2018-05-29 12:59:47 -0700299 return SCPF[ testName ][ forWhich ].getClass().getName() != "java.lang.String" ?
300 SCPF[ testName ][ forWhich ][ pos ] :
301 SCPF[ testName ][ forWhich ]
Devin Lim61643762017-12-07 15:55:38 -0800302}
Jon Hall6af749d2018-05-29 12:59:47 -0700303
Devin Lim61643762017-12-07 15:55:38 -0800304def sqlOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700305 // sql where command part for checking old flows.
306
Devin Limc49c3732018-04-10 18:57:17 -0700307 return SCPF[ testName ][ 'flows' ] ? " AND " + ( isOldFlow ? "" : "NOT " ) + "is_old_flow " : ""
Devin Lim61643762017-12-07 15:55:38 -0800308}
Jon Hall6af749d2018-05-29 12:59:47 -0700309
Devin Lim61643762017-12-07 15:55:38 -0800310def oldFlowRuleCheck( isOldFlow, branch ){
Devin Limf5175192018-05-14 19:13:22 -0700311 // checking if it is old flow
312
Devin Lim61643762017-12-07 15:55:38 -0800313 this.isOldFlow = isOldFlow
Jon Hall6af749d2018-05-29 12:59:47 -0700314 if ( !isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800315 SCPF[ 'SCPFflowTp1g' ][ 'test' ] += " --params TEST/flows=" + ( branch == "onos-1.11" ? "4000" : "3500" )
316 }
317}
Jon Hall6af749d2018-05-29 12:59:47 -0700318
Devin Lim61643762017-12-07 15:55:38 -0800319def affectedByOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700320 // 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 -0800321 return SCPF[ testName ][ 'flows' ] ? "" + isOldFlow + ", " : ""
322}
Jon Hall6af749d2018-05-29 12:59:47 -0700323
Devin Lim61643762017-12-07 15:55:38 -0800324def usingOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700325 // For Rscript command : if it is using old flow.
326
Devin Limc49c3732018-04-10 18:57:17 -0700327 return SCPF[ testName ][ 'flows' ] ? ( isOldFlow ? "y" : "n" ) + " " : ""
Devin Lim61643762017-12-07 15:55:38 -0800328}
Jon Hall6af749d2018-05-29 12:59:47 -0700329
Devin Lim61643762017-12-07 15:55:38 -0800330def hasOldFlow( isOldFlow, testName ){
Devin Limf5175192018-05-14 19:13:22 -0700331 // For Rscript command for 50 data
332
Devin Limc49c3732018-04-10 18:57:17 -0700333 return ( SCPF[ testName ][ 'flows' ] && isOldFlow ? "y" : "n" ) + " "
Devin Lim61643762017-12-07 15:55:38 -0800334}
Jon Hall6af749d2018-05-29 12:59:47 -0700335
Devin Lim61643762017-12-07 15:55:38 -0800336def sqlCommand( testName ){
Devin Limf5175192018-05-14 19:13:22 -0700337 // sql command for inserting data into the database
338
Jon Hall6af749d2018-05-29 12:59:47 -0700339 if ( testName == "SCPFscaleTopo" || testName == "SCPFswitchLat" || testName == "SCPFportLat" ){
340 return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" +
341 SCPF[ testName ][ 'results' ] + "','\$BUILD_NUMBER', \$line, '\$ONOSBranch');\""
342 }
343 return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" + SCPF[ testName ][ 'results' ] +
344 "','\$BUILD_NUMBER', '\$ONOSBranch', " + affectedByOldFlow( isOldFlow, testName ) + "\$line);\""
Devin Lim61643762017-12-07 15:55:38 -0800345}
Jon Hall6af749d2018-05-29 12:59:47 -0700346
You Wang6d171942018-10-17 11:45:05 -0700347def cleanupDatabaseFile( testName ){
348 // clean up the database file created under /tmp
You Wangae645332018-10-18 14:01:39 -0700349 return 'rm -f /tmp/' + SCPF[ testName ][ 'file' ]
You Wang6d171942018-10-17 11:45:05 -0700350}
351
Devin Lim61643762017-12-07 15:55:38 -0800352def databasePart( testName, database_command ){
Devin Limf5175192018-05-14 19:13:22 -0700353 // read the file from the machine and insert it to the database
354
Devin Lim61643762017-12-07 15:55:38 -0800355 return '''
356 cd /tmp
357 while read line
358 do
359 echo \$line
360 echo ''' + database_command + '''
361 done< ''' + SCPF[ testName ][ 'file' ]
362}
Jon Hall6af749d2018-05-29 12:59:47 -0700363
Devin Lim61643762017-12-07 15:55:38 -0800364def getGraphGeneratingCommand( host, port, user, pass, testName, prop ){
Devin Limf5175192018-05-14 19:13:22 -0700365 // returns the combined Rscript command for each test.
366
Jon Hall6af749d2018-05-29 12:59:47 -0700367 return getGraphCommand( SCPF[ testName ][ 'rFile' ],
368 SCPF[ testName ][ 'extra' ],
369 host, port, user, pass, testName,
370 prop[ "ONOSBranch" ], isOldFlow ) + '''
371 ''' + ( SCPF[ testName ][ 'finalResult' ] ?
372 generateCombinedResultGraph( host, port, user, pass, testName, prop[ "ONOSBranch" ], isOldFlow ) : "" )
Devin Lim61643762017-12-07 15:55:38 -0800373}
Jon Hall6af749d2018-05-29 12:59:47 -0700374
375return this