Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 3 | // 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 Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 25 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 26 | |
| 27 | fileRelated.init() |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 28 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 29 | def init(){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 30 | // init step for SCPF functions. It has some mandatory init steps |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 31 | |
| 32 | // none, batches, neighbors, times : to be used for extra parameters for generating graphs. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 33 | def none = [ "" ] |
| 34 | def batches = [ 1, 100, 1000 ] |
| 35 | def neighbors = [ 'y', 'n' ] |
| 36 | def times = [ 'y', 'n' ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 37 | |
| 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 Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 54 | SCPF = [ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 55 | 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 Wang | d3e80c7 | 2018-10-19 10:45:16 -0700 | [diff] [blame] | 83 | file: 'portEventResultDb', |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 84 | 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 Wang | d3e80c7 | 2018-10-19 10:45:16 -0700 | [diff] [blame] | 117 | file: 'scaleTopoResultDb', |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 118 | 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 Wang | d3e80c7 | 2018-10-19 10:45:16 -0700 | [diff] [blame] | 129 | file: 'switchEventResultDb', |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 130 | 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 Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 244 | ] |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 245 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-BM/" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 246 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 247 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 248 | def getGraphCommand( rFileName, extras, host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 249 | // generate the list of Rscript command for individual graphs |
| 250 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 251 | result = "" |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 252 | for ( extra in extras ){ |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 253 | result += generateGraph( rFileName, " " + extra, host, port, user, pass, testName, branchName, isOldFlow ) + ";" |
| 254 | } |
| 255 | return result |
| 256 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 257 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 258 | def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 259 | // generate the Rscript command for individual graphs |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 260 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 261 | return generalFuncs.basicGraphPart( fileRelated.SCPFSpecificLocation + rFileName, |
| 262 | host, port, user, pass, testName, branchName ) + |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 263 | " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory |
| 264 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 265 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 266 | def generateCombinedResultGraph( host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 267 | // generate Rscript for overall graph for the front page. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 268 | def result = "" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 269 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 270 | 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 Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 287 | } |
| 288 | return result |
| 289 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 290 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 291 | def checkIfList( testName, forWhich, pos ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 292 | // check if some dictionary has list or string. |
| 293 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 294 | return SCPF[ testName ][ forWhich ].getClass().getName() != "java.lang.String" ? |
| 295 | SCPF[ testName ][ forWhich ][ pos ] : |
| 296 | SCPF[ testName ][ forWhich ] |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 297 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 298 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 299 | def sqlOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 300 | // sql where command part for checking old flows. |
| 301 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 302 | return SCPF[ testName ][ 'flows' ] ? " AND " + ( isOldFlow ? "" : "NOT " ) + "is_old_flow " : "" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 303 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 304 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 305 | def oldFlowRuleCheck( isOldFlow, branch ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 306 | // checking if it is old flow |
| 307 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 308 | this.isOldFlow = isOldFlow |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 309 | if ( !isOldFlow ){ |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 310 | SCPF[ 'SCPFflowTp1g' ][ 'test' ] += " --params TEST/flows=" + ( branch == "onos-1.11" ? "4000" : "3500" ) |
| 311 | } |
| 312 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 313 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 314 | def affectedByOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 315 | // For sql command : if the test is affect by old flow, it will return parameters for old flow |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 316 | return SCPF[ testName ][ 'flows' ] ? "" + isOldFlow + ", " : "" |
| 317 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 318 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 319 | def usingOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 320 | // For Rscript command : if it is using old flow. |
| 321 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 322 | return SCPF[ testName ][ 'flows' ] ? ( isOldFlow ? "y" : "n" ) + " " : "" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 323 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 324 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 325 | def hasOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 326 | // For Rscript command for 50 data |
| 327 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 328 | return ( SCPF[ testName ][ 'flows' ] && isOldFlow ? "y" : "n" ) + " " |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 329 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 330 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 331 | def sqlCommand( testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 332 | // sql command for inserting data into the database |
| 333 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 334 | 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 Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 340 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 341 | |
You Wang | 6d17194 | 2018-10-17 11:45:05 -0700 | [diff] [blame] | 342 | def cleanupDatabaseFile( testName ){ |
| 343 | // clean up the database file created under /tmp |
You Wang | ae64533 | 2018-10-18 14:01:39 -0700 | [diff] [blame] | 344 | return 'rm -f /tmp/' + SCPF[ testName ][ 'file' ] |
You Wang | 6d17194 | 2018-10-17 11:45:05 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 347 | def databasePart( testName, database_command ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 348 | // read the file from the machine and insert it to the database |
| 349 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 350 | return ''' |
| 351 | cd /tmp |
| 352 | while read line |
| 353 | do |
| 354 | echo \$line |
| 355 | echo ''' + database_command + ''' |
| 356 | done< ''' + SCPF[ testName ][ 'file' ] |
| 357 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 358 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 359 | def getGraphGeneratingCommand( host, port, user, pass, testName, prop ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 360 | // returns the combined Rscript command for each test. |
| 361 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 362 | 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 Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 368 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 369 | |
| 370 | return this |