Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 2 | // Copyright 2019 Open Networking Foundation (ONF) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 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 | |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 21 | // This is the Jenkins script for master-trigger |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 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 | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 39 | simulateDay = null |
Jeremy Ronquillo | 4fd8244 | 2019-05-21 20:56:58 -0700 | [diff] [blame] | 40 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 41 | dayMap = [:] |
| 42 | fullDayMap = [:] |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 43 | all_testcases = [:] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 44 | runTest = [:] |
| 45 | selectedTests = [:] |
| 46 | graphPaths = [:] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 47 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 48 | main() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 49 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 50 | def main() { |
| 51 | init() |
| 52 | runTests() |
| 53 | generateGraphs() |
| 54 | } |
| 55 | |
| 56 | // ************** |
| 57 | // Initialization |
| 58 | // ************** |
| 59 | |
| 60 | // initialize file scope vars |
| 61 | def init(){ |
| 62 | // get the name of the job. |
| 63 | jobName = env.JOB_NAME |
| 64 | |
| 65 | // set the versions of the onos |
| 66 | fileRelated.init() |
| 67 | test_list.init() |
| 68 | readParams() |
| 69 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 70 | // list of the tests to be run will be saved in each choices. |
| 71 | day = "" |
| 72 | |
| 73 | initDates() |
| 74 | onos_branches = getONOSBranches() |
| 75 | selectedTests = getONOSTests() |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 76 | |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame] | 77 | initGraphPaths() |
| 78 | |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 79 | echo "selectedTests: " + selectedTests |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 80 | echo "onos_branches: " + onos_branches |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | def readParams(){ |
| 84 | // get post result from the params for manually run. |
| 85 | post_result = params.PostResult |
| 86 | manually_run = params.manual_run |
| 87 | onos_tag = params.ONOSTag |
| 88 | branchesParam = params.branches |
| 89 | isOldFlow = params.isOldFlow |
| 90 | testsParam = params.Tests |
| 91 | isFabric = params.isFabric |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 92 | simulateDay = params.simulate_day |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 93 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 94 | |
| 95 | // Set tests based on day of week |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 96 | def initDates(){ |
| 97 | echo "-> initDates()" |
| 98 | now = funcs.getCurrentTime() |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 99 | dayMap = [ ( Calendar.MONDAY ) : "mon", |
| 100 | ( Calendar.TUESDAY ) : "tue", |
| 101 | ( Calendar.WEDNESDAY ) : "wed", |
| 102 | ( Calendar.THURSDAY ) : "thu", |
| 103 | ( Calendar.FRIDAY ) : "fri", |
| 104 | ( Calendar.SATURDAY ) : "sat", |
| 105 | ( Calendar.SUNDAY ) : "sun" ] |
| 106 | fullDayMap = [ ( Calendar.MONDAY ) : "Monday", |
| 107 | ( Calendar.TUESDAY ) : "Tuesday", |
| 108 | ( Calendar.WEDNESDAY ) : "Wednesday", |
| 109 | ( Calendar.THURSDAY ) : "Thursday", |
| 110 | ( Calendar.FRIDAY ) : "Friday", |
| 111 | ( Calendar.SATURDAY ) : "Saturday", |
| 112 | ( Calendar.SUNDAY ) : "Sunday" ] |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 113 | if ( simulateDay == "" ){ |
| 114 | today = now[ Calendar.DAY_OF_WEEK ] |
| 115 | day = dayMap[ today ] |
| 116 | print now.toString() |
| 117 | } else { |
| 118 | day = simulateDay |
| 119 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 120 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 121 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 122 | // gets ONOS branches from params or string parameter |
| 123 | def getONOSBranches(){ |
| 124 | echo "-> getONOSBranches()" |
| 125 | if ( manually_run ){ |
| 126 | return branchesParam.tokenize( "\n;, " ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 127 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 128 | return test_list.getBranchesFromDay( day ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 129 | } |
| 130 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 131 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 132 | def getONOSTests(){ |
| 133 | echo "-> getONOSTests()" |
| 134 | if ( manually_run ){ |
| 135 | return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) ) |
| 136 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 137 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 138 | return test_list.getTestsFromDay( day ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 139 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 140 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 141 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 142 | // init paths for the files and directories. |
| 143 | def initGraphPaths(){ |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 144 | graphPaths.put( "histogramMultiple", fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ] ) |
| 145 | graphPaths.put( "pieMultiple", fileRelated.rScriptPaths[ "scripts" ][ "pieMultiple" ] ) |
| 146 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "VM" ] ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 147 | } |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 148 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 149 | // ********************** |
| 150 | // Determine Tests to Run |
| 151 | // ********************** |
| 152 | |
| 153 | def printTestsToRun( runList ){ |
| 154 | if ( manually_run ){ |
| 155 | println "Tests to be run manually:" |
| 156 | } else { |
| 157 | if ( isFabric ){ |
| 158 | postToSlackSR() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 159 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 160 | if ( today == Calendar.MONDAY ){ |
| 161 | postToSlackTestsToRun() |
| 162 | } |
| 163 | println "Defaulting to " + day + " tests:" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 164 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 165 | for ( list in runList ){ |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 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 = [:] |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 190 | validSchedules = test_list.getValidSchedules( day ) |
| 191 | echo "validSchedules: " + validSchedules |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 192 | for ( branch in onos_branches ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 193 | runBranch = [] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 194 | nodeLabels = test_list.getAllNodeLabels( branch, selectedTests ) |
| 195 | for ( nodeLabel in nodeLabels ){ |
| 196 | selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests ) |
| 197 | selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests ) |
| 198 | for ( category in selectedNodeLabelCategories ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 199 | selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests ) |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 200 | |
| 201 | filteredList = [:] |
| 202 | for ( key in selectedNodeLabelCategoryTests.keySet() ){ |
| 203 | for ( sch in selectedNodeLabelCategoryTests[ key ][ "schedules" ] ){ |
Jeremy Ronquillo | bd26bdb | 2019-07-08 16:15:45 -0700 | [diff] [blame] | 204 | if ( validSchedules.contains( sch[ "day" ] ) && sch[ "branch" ] == test_list.convertBranchToBranchCode( branch ) || manually_run ){ |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 205 | filteredList.put( key, selectedNodeLabelCategoryTests[ key ] ) |
| 206 | break |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | echo "==========================================" |
| 212 | echo "BRANCH: " + branch |
| 213 | echo "CATEGORY: " + category |
| 214 | echo "TESTS: " + filteredList |
| 215 | if ( filteredList != [:] ){ |
| 216 | exeTestList = test_list.getTestListAsString( filteredList ) |
| 217 | runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) ) |
| 218 | } |
| 219 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 220 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 221 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 222 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 223 | return runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 224 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 225 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 226 | def runTests(){ |
| 227 | runList = generateRunList() |
| 228 | printTestsToRun( runList ) |
| 229 | parallel runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 230 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 231 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 232 | // *************** |
| 233 | // Generate Graphs |
| 234 | // *************** |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 235 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 236 | def generateGraphs(){ |
| 237 | // If it is automated running, it will generate the stats graph on VM. |
| 238 | if ( !manually_run ){ |
| 239 | for ( String b in onos_branches ){ |
| 240 | funcs.generateStatGraph( "TestStation-VMs", |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 241 | test_list.addPrefixToBranch( b ), |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 242 | graphPaths[ "histogramMultiple" ], |
| 243 | graphPaths[ "pieMultiple" ], |
| 244 | graphPaths[ "saveDirectory" ] ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 245 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 246 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 247 | } |