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() |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 28 | def init(){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 29 | // init step for SCPFfunctions. It has some mandatory init steps |
| 30 | |
| 31 | // none, batches, neighbors, times : to be used for extra parameters for generating graphs. |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 32 | none = [ "" ] |
| 33 | batches = [ 1, 100, 1000 ] |
| 34 | neighbors = [ 'y', 'n' ] |
| 35 | times = [ 'y', 'n' ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 36 | |
| 37 | //flows : whether the test is affected by oldFlow or newFlow |
| 38 | // test : command of the test to be executed when running the test |
| 39 | // table : name of the view table on database |
| 40 | // result : name of the actual table on database |
| 41 | // file : name of the file that contains the result of the test to be used to insert data to database |
| 42 | // 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 |
| 43 | // extra : extra condition that will be used for Rscript parameter. Some of the Rscript requires extra parameters like if it has |
| 44 | // neighbors or batches. In this case, it will generate Rscript x times of what extra has. So that it will generate one with |
| 45 | // neighbor = y and the other with neighbor = n |
| 46 | // finalResult : If you want to generate overall graph for the front page. |
| 47 | // graphTitle : title for the graph. It should contain n numbers depends on how many graphs you are generating. |
| 48 | // [Optional] |
| 49 | // dbCols : specific dbColumns to choose for 50 data overall graph if there is one. |
| 50 | // dbWhere : specific where statement that has some condition for 50 data overall graph if there is one. |
| 51 | // y_axis : title of the y_axis to be shown for 50 data overall graph if there is one. |
| 52 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 53 | SCPF = [ |
| 54 | SCPFcbench: [ flows:false, test:'SCPFcbench', table:'cbench_bm_tests', results:'cbench_bm_results', file:'CbenchDB', rFile:'SCPFcbench.R', extra:none, finalResult:1, graphTitle:[ 'Cbench Test' ], dbCols:'avg', dbWhere:'', y_axis:'Throughput (Responses/sec)' ], |
| 55 | SCPFhostLat: [ flows:false, test:'SCPFhostLat', table:'host_latency_tests', results:'host_latency_results', file:'HostAddLatency', rFile:'SCPFhostLat.R', extra:none,finalResult:1, graphTitle:[ 'Host Latency Test' ], dbCols:'avg', dbWhere:'AND scale=5', y_axis:'Latency (ms)' ], |
| 56 | SCPFportLat: [ flows:false, test:'SCPFportLat', table:'port_latency_details', results:'port_latency_results', file:'/tmp/portEventResultDb', rFile:'SCPFportLat.R', extra:none, finalResult:1, graphTitle:[ 'Port Latency Test - Port Up','Port Latency Test - Port Down' ], dbCols:[ 'up_ofp_to_dev_avg, up_dev_to_link_avg, up_link_to_graph_avg', 'down_ofp_to_dev_avg, down_dev_to_link_avg, down_link_to_graph_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ], |
| 57 | SCPFflowTp1g: [ flows:true, test:'SCPFflowTp1g', table:'flow_tp_tests', results:'flow_tp_results', file:'flowTP1gDB', rFile:'SCPFflowTp1g.R n', extra:neighbors, finalResult:1, graphTitle:[ 'Flow Throughput Test - neighbors=0', 'Flow Throughput Test - neighbors=4' ], dbCols:'avg', dbWhere:[ 'AND scale=5 AND neighbors=0 ','AND scale=5 AND NOT neighbors=0' ], y_axis:'Throughput (,000 Flows/sec)' ], |
| 58 | SCPFflowTp1gWithFlowObj: [ flows:true, test:'SCPFflowTp1g --params TEST/flowObj=True', table:'flow_tp_fobj_tests', results:'flow_tp_fobj_results', file:'flowTP1gDBFlowObj', rFile:'SCPFflowTp1g.R y', extra:neighbors, finalResult:0 ], |
| 59 | SCPFscaleTopo: [ flows:false, test:'SCPFscaleTopo', table:'scale_topo_latency_details', results:'scale_topo_latency_results', file:'/tmp/scaleTopoResultDb', rFile:'SCPFscaleTopo.R', extra:none, finalResult:1, graphTitle:[ 'Scale Topology Test' ], dbCols:[ 'first_connection_to_last_connection, last_connection_to_last_role_request, last_role_request_to_last_topology' ], dbWhere:'AND scale=20' , y_axis:'Latency (s)' ], |
Devin Lim | 99274a4 | 2018-04-20 14:30:22 -0700 | [diff] [blame] | 60 | SCPFswitchLat: [ flows:false, test:'SCPFswitchLat', table:'switch_latency_details', results:'switch_latency_results', file:'/tmp/switchEventResultDb', rFile:'SCPFswitchLat.R', extra:none, finalResult:1, graphTitle:[ 'Switch Latency Test - Switch Up','Switch Latency Test - Switch Down' ], dbCols:[ 'tcp_to_feature_reply_avg,feature_reply_to_device_avg,up_device_to_graph_avg', 'fin_ack_to_ack_avg,ack_to_device_avg,down_device_to_graph_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ], |
Devin Lim | 7869d48 | 2018-04-10 17:35:55 -0700 | [diff] [blame] | 61 | SCPFbatchFlowResp: [ flows:true, test:'SCPFbatchFlowResp', table:'batch_flow_tests', results:'batch_flow_results', file:'SCPFbatchFlowRespData', rFile:'SCPFbatchFlowResp.R', extra:none, finalResult:1, graphTitle:[ 'Batch Flow Test - Post', 'Batch Flow Test - Del' ], dbCols:[ 'elapsepost, posttoconfrm', 'elapsedel, deltoconfrm' ], dbWhere:'', y_axis:'Latency (s)' ], |
Devin Lim | f7c218c | 2018-03-22 14:23:59 -0700 | [diff] [blame] | 62 | SCPFintentEventTp: [ flows:true, test:'SCPFintentEventTp', table:'intent_tp_tests', results:'intent_tp_results', file:'IntentEventTPDB', rFile:'SCPFintentEventTp.R n', extra:neighbors, finalResult:1, graphTitle:[ 'Intent Throughput Test - neighbors=0','Intent Throughput Test - neighbors=4' ], dbCols:'SUM( avg ) as avg', dbWhere:[ 'AND scale=5 AND neighbors=0 GROUP BY date,build','AND scale=5 AND NOT neighbors=0 GROUP BY date,build' ], y_axis:'Throughput (Ops/sec)' ], |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 63 | SCPFintentRerouteLat: [ flows:true, test:'SCPFintentRerouteLat', table:'intent_reroute_latency_tests', results:'intent_reroute_latency_results', file:'IntentRerouteLatDB', rFile:'SCPFIntentInstallWithdrawRerouteLat.R n', extra:batches, finalResult:1, graphTitle:[ 'Intent Reroute Test' ], dbCols:'avg', dbWhere:'AND scale=5 AND batch_size=100', y_axis:'Latency (ms)' ], |
| 64 | SCPFscalingMaxIntents: [ flows:true, test:'SCPFscalingMaxIntents', table:'max_intents_tests', results:'max_intents_results', file:'ScalingMaxIntentDB', rFile:'SCPFscalingMaxIntents.R n', extra:none, finalResult:0 ], |
| 65 | SCPFintentEventTpWithFlowObj: [ flows:true, test:'SCPFintentEventTp --params TEST/flowObj=True', table:'intent_tp_fobj_tests', results:'intent_tp_fobj_results', file:'IntentEventTPflowObjDB', rFile:'SCPFintentEventTp.R y', extra:neighbors,finalResult:0 ], |
| 66 | SCPFintentInstallWithdrawLat: [ flows:true, test:'SCPFintentInstallWithdrawLat', table:'intent_latency_tests', results:'intent_latency_results', file:'IntentInstallWithdrawLatDB', rFile:'SCPFIntentInstallWithdrawRerouteLat.R n', extra:batches,finalResult:1, graphTitle:[ 'Intent Installation Test','Intent Withdrawal Test' ], dbCols:[ 'install_avg','withdraw_avg' ], dbWhere:'AND scale=5 AND batch_size=100', y_axis:'Latency (ms)' ], |
| 67 | SCPFintentRerouteLatWithFlowObj: [ flows:true, test:'SCPFintentRerouteLat --params TEST/flowObj=True', table:'intent_reroute_latency_fobj_tests', results:'intent_reroute_latency_fobj_results', file:'IntentRerouteLatDBWithFlowObj', rFile:'SCPFIntentInstallWithdrawRerouteLat.R y', extra:batches, finalResult:0 ], |
| 68 | SCPFscalingMaxIntentsWithFlowObj: [ flows:true, test:'SCPFscalingMaxIntents --params TEST/flowObj=True', table:'max_intents_fobj_tests', results:'max_intents_fobj_results', file:'ScalingMaxIntentDBWFO', rFile:'SCPFscalingMaxIntents.R y', extra:none, finalResult:0 ], |
| 69 | SCPFintentInstallWithdrawLatWithFlowObj: [ flows:true, test:'SCPFintentInstallWithdrawLat --params TEST/flowObj=True', table:'intent_latency_fobj_tests', results:'intent_latency_fobj_results', file:'IntentInstallWithdrawLatDBWFO', rFile:'SCPFIntentInstallWithdrawRerouteLat.R y', extra:batches, finalResult:0 ], |
| 70 | SCPFmastershipFailoverLat: [ flows:false, test:'SCPFmastershipFailoverLat', table:'mastership_failover_tests', results:'mastership_failover_results', file:'mastershipFailoverLatDB', rFile:'SCPFmastershipFailoverLat.R', extra:none, finalResult:1, graphTitle:[ 'Mastership Failover Test' ], dbCols:[ 'kill_deact_avg,deact_role_avg' ], dbWhere:'AND scale=5', y_axis:'Latency (ms)' ] |
| 71 | ] |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 72 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-BM/" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 73 | } |
| 74 | def getGraphCommand( rFileName, extras, host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 75 | // generate the list of Rscript command for individual graphs |
| 76 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 77 | result = "" |
| 78 | for( extra in extras ){ |
| 79 | result += generateGraph( rFileName, " " + extra, host, port, user, pass, testName, branchName, isOldFlow ) + ";" |
| 80 | } |
| 81 | return result |
| 82 | } |
| 83 | def generateGraph( rFileName, batch, host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 84 | // generate the Rscript command for individual graphs |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 85 | |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 86 | return generalFuncs.basicGraphPart( fileRelated.SCPFSpecificLocation + rFileName, host, port, user, pass, testName, branchName ) + |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 87 | " " + batch + " " + usingOldFlow( isOldFlow, testName ) + graph_saved_directory |
| 88 | } |
| 89 | def generateCombinedResultGraph( host, port, user, pass, testName, branchName, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 90 | // generate Rscript for overall graph for the front page. |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 91 | result = "" |
| 92 | |
| 93 | for ( int i=0; i< SCPF[ testName ][ 'graphTitle' ].size(); i++ ){ |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 94 | result += generalFuncs.basicGraphPart( fileRelated.trendSCPF, host, port, user, pass, "\"" + SCPF[ testName ][ 'graphTitle' ][ i ] + "\"", branchName ) + |
Jeremy Ronquillo | be325b5 | 2018-03-15 14:44:38 -0700 | [diff] [blame] | 95 | " " + 50 + " \"SELECT " + checkIfList( testName, 'dbCols', i ) + ", build FROM " + SCPF[ testName ][ 'table' ] + " WHERE branch=\'" + branchName + "\' " + sqlOldFlow( isOldFlow, testName ) + |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 96 | checkIfList( testName, 'dbWhere', i ) + " ORDER BY date DESC LIMIT 50\" \"" + SCPF[ testName ][ 'y_axis' ] + "\" " + hasOldFlow( isOldFlow, testName ) + graph_saved_directory + ";" |
| 97 | } |
| 98 | return result |
| 99 | } |
| 100 | def checkIfList( testName, forWhich, pos ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 101 | // check if some dictionary has list or string. |
| 102 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 103 | return SCPF[ testName ][ forWhich ].getClass().getName() != "java.lang.String" ? SCPF[ testName ][ forWhich ][ pos ] : SCPF[ testName ][ forWhich ] |
| 104 | } |
| 105 | def sqlOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 106 | // sql where command part for checking old flows. |
| 107 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 108 | return SCPF[ testName ][ 'flows' ] ? " AND " + ( isOldFlow ? "" : "NOT " ) + "is_old_flow " : "" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 109 | } |
| 110 | def oldFlowRuleCheck( isOldFlow, branch ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 111 | // checking if it is old flow |
| 112 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 113 | this.isOldFlow = isOldFlow |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 114 | if( !isOldFlow ){ |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 115 | SCPF[ 'SCPFflowTp1g' ][ 'test' ] += " --params TEST/flows=" + ( branch == "onos-1.11" ? "4000" : "3500" ) |
| 116 | } |
| 117 | } |
| 118 | def affectedByOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 119 | // 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] | 120 | return SCPF[ testName ][ 'flows' ] ? "" + isOldFlow + ", " : "" |
| 121 | } |
| 122 | def usingOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 123 | // For Rscript command : if it is using old flow. |
| 124 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 125 | return SCPF[ testName ][ 'flows' ] ? ( isOldFlow ? "y" : "n" ) + " " : "" |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 126 | } |
| 127 | def hasOldFlow( isOldFlow, testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 128 | // For Rscript command for 50 data |
| 129 | |
Devin Lim | c49c373 | 2018-04-10 18:57:17 -0700 | [diff] [blame] | 130 | return ( SCPF[ testName ][ 'flows' ] && isOldFlow ? "y" : "n" ) + " " |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 131 | } |
| 132 | def sqlCommand( testName ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 133 | // sql command for inserting data into the database |
| 134 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 135 | if ( testName == "SCPFscaleTopo" || testName == "SCPFswitchLat" || testName == "SCPFportLat" ) |
| 136 | return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" + SCPF[ testName ][ 'results' ] + "','\$BUILD_NUMBER', \$line, '\$ONOSBranch');\"" |
| 137 | return "\"INSERT INTO " + SCPF[ testName ][ 'table' ] + " VALUES( '\$DATE','" + SCPF[ testName ][ 'results' ] + "','\$BUILD_NUMBER', '\$ONOSBranch', " + affectedByOldFlow( isOldFlow, testName ) + "\$line);\"" |
| 138 | } |
| 139 | def databasePart( testName, database_command ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 140 | // read the file from the machine and insert it to the database |
| 141 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 142 | return ''' |
| 143 | cd /tmp |
| 144 | while read line |
| 145 | do |
| 146 | echo \$line |
| 147 | echo ''' + database_command + ''' |
| 148 | done< ''' + SCPF[ testName ][ 'file' ] |
| 149 | } |
| 150 | def getGraphGeneratingCommand( host, port, user, pass, testName, prop ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 151 | // returns the combined Rscript command for each test. |
| 152 | |
Devin Lim | 6164376 | 2017-12-07 15:55:38 -0800 | [diff] [blame] | 153 | return getGraphCommand( SCPF[ testName ][ 'rFile' ], SCPF[ testName ][ 'extra' ], host, port, user, pass, testName, prop[ "ONOSBranch" ], isOldFlow ) + ''' |
| 154 | ''' + ( SCPF[ testName ][ 'finalResult' ] ? generateCombinedResultGraph( host, port, user, pass, testName, prop[ "ONOSBranch" ], , isOldFlow ) : "" ) |
| 155 | } |
Devin Lim | f7c218c | 2018-03-22 14:23:59 -0700 | [diff] [blame] | 156 | return this; |