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 | 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 | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 70 | funcs.initializeTrend( "Fabric" ) |
| 71 | funcs.initialize( "Fabric" ) |
| 72 | |
| 73 | funcs.initializeTrend( "VM" ) |
| 74 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 75 | triggerFuncs.init( funcs ) |
| 76 | |
| 77 | // list of the tests to be run will be saved in each choices. |
| 78 | day = "" |
| 79 | |
| 80 | initDates() |
| 81 | onos_branches = getONOSBranches() |
| 82 | selectedTests = getONOSTests() |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 83 | |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame] | 84 | initGraphPaths() |
| 85 | |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 86 | echo "selectedTests: " + selectedTests |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 87 | echo "onos_branches: " + onos_branches |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | def readParams(){ |
| 91 | // get post result from the params for manually run. |
| 92 | post_result = params.PostResult |
| 93 | manually_run = params.manual_run |
| 94 | onos_tag = params.ONOSTag |
| 95 | branchesParam = params.branches |
| 96 | isOldFlow = params.isOldFlow |
| 97 | testsParam = params.Tests |
| 98 | isFabric = params.isFabric |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 99 | simulateDay = params.simulate_day |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 100 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 101 | |
| 102 | // Set tests based on day of week |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 103 | def initDates(){ |
| 104 | echo "-> initDates()" |
| 105 | now = funcs.getCurrentTime() |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 106 | dayMap = [ ( Calendar.MONDAY ) : "mon", |
| 107 | ( Calendar.TUESDAY ) : "tue", |
| 108 | ( Calendar.WEDNESDAY ) : "wed", |
| 109 | ( Calendar.THURSDAY ) : "thu", |
| 110 | ( Calendar.FRIDAY ) : "fri", |
| 111 | ( Calendar.SATURDAY ) : "sat", |
| 112 | ( Calendar.SUNDAY ) : "sun" ] |
| 113 | fullDayMap = [ ( Calendar.MONDAY ) : "Monday", |
| 114 | ( Calendar.TUESDAY ) : "Tuesday", |
| 115 | ( Calendar.WEDNESDAY ) : "Wednesday", |
| 116 | ( Calendar.THURSDAY ) : "Thursday", |
| 117 | ( Calendar.FRIDAY ) : "Friday", |
| 118 | ( Calendar.SATURDAY ) : "Saturday", |
| 119 | ( Calendar.SUNDAY ) : "Sunday" ] |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 120 | if ( simulateDay == "" ){ |
| 121 | today = now[ Calendar.DAY_OF_WEEK ] |
| 122 | day = dayMap[ today ] |
| 123 | print now.toString() |
| 124 | } else { |
| 125 | day = simulateDay |
| 126 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 127 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 128 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 129 | // gets ONOS branches from params or string parameter |
| 130 | def getONOSBranches(){ |
| 131 | echo "-> getONOSBranches()" |
| 132 | if ( manually_run ){ |
| 133 | return branchesParam.tokenize( "\n;, " ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 134 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 135 | return test_list.getBranchesFromDay( day ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 136 | } |
| 137 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 138 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 139 | def getONOSTests(){ |
| 140 | echo "-> getONOSTests()" |
| 141 | if ( manually_run ){ |
| 142 | return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) ) |
| 143 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 144 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 145 | return test_list.getTestsFromDay( day ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 146 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 147 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 148 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 149 | // init paths for the files and directories. |
| 150 | def initGraphPaths(){ |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame] | 151 | graphPaths.put( "histogramMultiple", fileRelated.histogramMultiple ) |
| 152 | graphPaths.put( "pieMultiple", fileRelated.pieMultiple ) |
| 153 | graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 154 | } |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 155 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 156 | // ********************** |
| 157 | // Determine Tests to Run |
| 158 | // ********************** |
| 159 | |
| 160 | def printTestsToRun( runList ){ |
| 161 | if ( manually_run ){ |
| 162 | println "Tests to be run manually:" |
| 163 | } else { |
| 164 | if ( isFabric ){ |
| 165 | postToSlackSR() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 166 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 167 | if ( today == Calendar.MONDAY ){ |
| 168 | postToSlackTestsToRun() |
| 169 | } |
| 170 | println "Defaulting to " + day + " tests:" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 171 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 172 | for ( list in runList ){ |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 173 | echo "" + list |
| 174 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 175 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 176 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 177 | def postToSlackSR(){ |
| 178 | // If it is automated running, it will post the beginning message to the channel. |
| 179 | slackSend( channel: 'sr-failures', color: '#03CD9F', |
| 180 | message: ":sparkles:" * 16 + "\n" + |
| 181 | "Starting tests on : " + now.toString() + |
| 182 | "\n" + ":sparkles:" * 16 ) |
| 183 | } |
| 184 | |
| 185 | def postToSlackTestsToRun(){ |
| 186 | slackSend( color: '#FFD988', |
| 187 | message: "Tests to be run this weekdays : \n" + |
| 188 | triggerFuncs.printDaysForTest() ) |
| 189 | } |
| 190 | |
| 191 | // ********* |
| 192 | // Run Tests |
| 193 | // ********* |
| 194 | |
| 195 | def generateRunList(){ |
| 196 | runList = [:] |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 197 | validSchedules = test_list.getValidSchedules( day ) |
| 198 | echo "validSchedules: " + validSchedules |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 199 | for ( branch in onos_branches ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 200 | runBranch = [] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 201 | nodeLabels = test_list.getAllNodeLabels( branch, selectedTests ) |
| 202 | for ( nodeLabel in nodeLabels ){ |
| 203 | selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests ) |
| 204 | selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests ) |
| 205 | for ( category in selectedNodeLabelCategories ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 206 | selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests ) |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 207 | |
| 208 | filteredList = [:] |
| 209 | for ( key in selectedNodeLabelCategoryTests.keySet() ){ |
| 210 | for ( sch in selectedNodeLabelCategoryTests[ key ][ "schedules" ] ){ |
| 211 | if ( validSchedules.contains( sch[ "day" ] ) && sch[ "branch" ] == test_list.convertBranchToBranchCode( branch ) ){ |
| 212 | filteredList.put( key, selectedNodeLabelCategoryTests[ key ] ) |
| 213 | break |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | echo "==========================================" |
| 219 | echo "BRANCH: " + branch |
| 220 | echo "CATEGORY: " + category |
| 221 | echo "TESTS: " + filteredList |
| 222 | if ( filteredList != [:] ){ |
| 223 | exeTestList = test_list.getTestListAsString( filteredList ) |
| 224 | runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) ) |
| 225 | } |
| 226 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 227 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 228 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 229 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 230 | return runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 231 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 232 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 233 | def runTests(){ |
| 234 | runList = generateRunList() |
| 235 | printTestsToRun( runList ) |
| 236 | parallel runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 237 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 238 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 239 | // *************** |
| 240 | // Generate Graphs |
| 241 | // *************** |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 242 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 243 | def generateGraphs(){ |
| 244 | // If it is automated running, it will generate the stats graph on VM. |
| 245 | if ( !manually_run ){ |
| 246 | for ( String b in onos_branches ){ |
| 247 | funcs.generateStatGraph( "TestStation-VMs", |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 248 | test_list.addPrefixToBranch( b ), |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 249 | graphPaths[ "histogramMultiple" ], |
| 250 | graphPaths[ "pieMultiple" ], |
| 251 | graphPaths[ "saveDirectory" ] ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 252 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 253 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 254 | } |