Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 2 | // Copyright 2017 Open Networking Foundation (ONF) |
| 3 | // |
| 4 | // Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | // the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | // or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | // |
| 8 | // TestON is free software: you can redistribute it and/or modify |
| 9 | // it under the terms of the GNU General Public License as published by |
| 10 | // the Free Software Foundation, either version 2 of the License, or |
| 11 | // (at your option) any later version. |
| 12 | // |
| 13 | // TestON is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | // This is the Jenkins script for vm-pipeline-trigger or bm-pipeline-trigger |
| 22 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 23 | // set the functions of the dependencies. |
Devin Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 24 | funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' ) |
Devin Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 25 | triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' ) |
| 26 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 27 | test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 28 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 29 | onos_tag = null |
| 30 | manually_run = null |
| 31 | now = null |
| 32 | today = null |
| 33 | onos_branches = null |
| 34 | day = null |
| 35 | post_result = null |
| 36 | branchesParam = null |
| 37 | isFabric = null |
| 38 | testsParam = null |
Jeremy Ronquillo | 4fd8244 | 2019-05-21 20:56:58 -0700 | [diff] [blame] | 39 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 40 | dayMap = [:] |
| 41 | fullDayMap = [:] |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 42 | all_testcases = [:] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 43 | runTest = [:] |
| 44 | selectedTests = [:] |
| 45 | graphPaths = [:] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 46 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 47 | main() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 48 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 49 | def main() { |
| 50 | init() |
| 51 | runTests() |
| 52 | generateGraphs() |
| 53 | } |
| 54 | |
| 55 | // ************** |
| 56 | // Initialization |
| 57 | // ************** |
| 58 | |
| 59 | // initialize file scope vars |
| 60 | def init(){ |
| 61 | // get the name of the job. |
| 62 | jobName = env.JOB_NAME |
| 63 | |
| 64 | // set the versions of the onos |
| 65 | fileRelated.init() |
| 66 | test_list.init() |
| 67 | readParams() |
| 68 | |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 69 | funcs.initializeTrend( "Fabric" ) |
| 70 | funcs.initialize( "Fabric" ) |
| 71 | |
| 72 | funcs.initializeTrend( "VM" ) |
| 73 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 74 | triggerFuncs.init( funcs ) |
| 75 | |
| 76 | // list of the tests to be run will be saved in each choices. |
| 77 | day = "" |
| 78 | |
| 79 | initDates() |
| 80 | onos_branches = getONOSBranches() |
| 81 | selectedTests = getONOSTests() |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 82 | |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame^] | 83 | initGraphPaths() |
| 84 | |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 85 | echo "selectedTests: " + selectedTests |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | def readParams(){ |
| 89 | // get post result from the params for manually run. |
| 90 | post_result = params.PostResult |
| 91 | manually_run = params.manual_run |
| 92 | onos_tag = params.ONOSTag |
| 93 | branchesParam = params.branches |
| 94 | isOldFlow = params.isOldFlow |
| 95 | testsParam = params.Tests |
| 96 | isFabric = params.isFabric |
| 97 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 98 | |
| 99 | // Set tests based on day of week |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 100 | def initDates(){ |
| 101 | echo "-> initDates()" |
| 102 | now = funcs.getCurrentTime() |
| 103 | today = now[ Calendar.DAY_OF_WEEK ] |
| 104 | dayMap = [ ( Calendar.MONDAY ) : "mon", |
| 105 | ( Calendar.TUESDAY ) : "tue", |
| 106 | ( Calendar.WEDNESDAY ) : "wed", |
| 107 | ( Calendar.THURSDAY ) : "thu", |
| 108 | ( Calendar.FRIDAY ) : "fri", |
| 109 | ( Calendar.SATURDAY ) : "sat", |
| 110 | ( Calendar.SUNDAY ) : "sun" ] |
| 111 | fullDayMap = [ ( Calendar.MONDAY ) : "Monday", |
| 112 | ( Calendar.TUESDAY ) : "Tuesday", |
| 113 | ( Calendar.WEDNESDAY ) : "Wednesday", |
| 114 | ( Calendar.THURSDAY ) : "Thursday", |
| 115 | ( Calendar.FRIDAY ) : "Friday", |
| 116 | ( Calendar.SATURDAY ) : "Saturday", |
| 117 | ( Calendar.SUNDAY ) : "Sunday" ] |
| 118 | print now.toString() |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 119 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 120 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 121 | // gets ONOS branches from params or string parameter |
| 122 | def getONOSBranches(){ |
| 123 | echo "-> getONOSBranches()" |
| 124 | if ( manually_run ){ |
| 125 | return branchesParam.tokenize( "\n;, " ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 126 | } else { |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 127 | return test_list.getBranchesFromDay( dayMap[ today ] ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 128 | } |
| 129 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 130 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 131 | def getONOSTests(){ |
| 132 | echo "-> getONOSTests()" |
| 133 | if ( manually_run ){ |
| 134 | return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) ) |
| 135 | } else { |
| 136 | day = dayMap[ today ] |
| 137 | return test_list.getTestsFromDay( day ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 138 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 139 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 140 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 141 | // init paths for the files and directories. |
| 142 | def initGraphPaths(){ |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame^] | 143 | graphPaths.put( "histogramMultiple", fileRelated.histogramMultiple ) |
| 144 | graphPaths.put( "pieMultiple", fileRelated.pieMultiple ) |
| 145 | graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 146 | } |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 147 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 148 | // ********************** |
| 149 | // Determine Tests to Run |
| 150 | // ********************** |
| 151 | |
| 152 | def printTestsToRun( runList ){ |
| 153 | if ( manually_run ){ |
| 154 | println "Tests to be run manually:" |
| 155 | } else { |
| 156 | if ( isFabric ){ |
| 157 | postToSlackSR() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 158 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 159 | if ( today == Calendar.MONDAY ){ |
| 160 | postToSlackTestsToRun() |
| 161 | } |
| 162 | println "Defaulting to " + day + " tests:" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 163 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 164 | for ( list in runList ){ |
| 165 | // triggerFuncs.print_tests( all_testcases[ b ] ) |
| 166 | echo "" + list |
| 167 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 168 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 169 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 170 | def postToSlackSR(){ |
| 171 | // If it is automated running, it will post the beginning message to the channel. |
| 172 | slackSend( channel: 'sr-failures', color: '#03CD9F', |
| 173 | message: ":sparkles:" * 16 + "\n" + |
| 174 | "Starting tests on : " + now.toString() + |
| 175 | "\n" + ":sparkles:" * 16 ) |
| 176 | } |
| 177 | |
| 178 | def postToSlackTestsToRun(){ |
| 179 | slackSend( color: '#FFD988', |
| 180 | message: "Tests to be run this weekdays : \n" + |
| 181 | triggerFuncs.printDaysForTest() ) |
| 182 | } |
| 183 | |
| 184 | // ********* |
| 185 | // Run Tests |
| 186 | // ********* |
| 187 | |
| 188 | def generateRunList(){ |
| 189 | runList = [:] |
| 190 | for ( branch in onos_branches ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 191 | runBranch = [] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 192 | nodeLabels = test_list.getAllNodeLabels( branch, selectedTests ) |
| 193 | for ( nodeLabel in nodeLabels ){ |
| 194 | selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests ) |
| 195 | selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests ) |
| 196 | for ( category in selectedNodeLabelCategories ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 197 | selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 198 | exeTestList = test_list.getTestListAsString( selectedNodeLabelCategoryTests ) |
Jeremy Ronquillo | f3b173d | 2019-06-07 14:53:25 -0700 | [diff] [blame] | 199 | runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 200 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 201 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 202 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 203 | return runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 204 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 205 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 206 | def runTests(){ |
| 207 | runList = generateRunList() |
| 208 | printTestsToRun( runList ) |
| 209 | parallel runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 210 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 211 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 212 | // *************** |
| 213 | // Generate Graphs |
| 214 | // *************** |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 215 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 216 | def generateGraphs(){ |
| 217 | // If it is automated running, it will generate the stats graph on VM. |
| 218 | if ( !manually_run ){ |
| 219 | for ( String b in onos_branches ){ |
| 220 | funcs.generateStatGraph( "TestStation-VMs", |
| 221 | funcs.branchWithPrefix( b ), |
| 222 | graphPaths[ "histogramMultiple" ], |
| 223 | graphPaths[ "pieMultiple" ], |
| 224 | graphPaths[ "saveDirectory" ] ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 225 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 226 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 227 | } |