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' ) |
| 25 | test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
| 26 | triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' ) |
| 27 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 28 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 29 | // set the versions of the onos |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 30 | fileRelated.init() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 31 | current_version = "master" |
| 32 | previous_version = "1.13" |
| 33 | before_previous_version = "1.12" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 34 | |
| 35 | // init trend graphs to be on VM. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 36 | funcs.initializeTrend( "VM" ); |
| 37 | triggerFuncs.init( funcs ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 38 | |
| 39 | // contents for page https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule |
| 40 | // which will demonstrates the list of the scheduled tests on the days. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 41 | wikiContents = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 42 | |
| 43 | // default FUNC,HA to be VM, SCPF,USECASE to be BM. |
| 44 | // SR will not be used in here. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 45 | testcases = [ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 46 | "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| 47 | "HA": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| 48 | "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ], |
| 49 | "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ], |
| 50 | "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 51 | ] |
| 52 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 53 | // read the parameters from the Jenkins |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 54 | manually_run = params.manual_run |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 55 | |
| 56 | // set default onos_b to be current_version. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 57 | onos_b = current_version |
| 58 | test_branch = "" |
| 59 | onos_tag = params.ONOSTag |
| 60 | isOldFlow = true |
| 61 | |
| 62 | // Set tests based on day of week |
| 63 | def now = funcs.getCurrentTime() |
| 64 | print now.toString() |
| 65 | today = now[ Calendar.DAY_OF_WEEK ] |
| 66 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 67 | // get branch from parameter if it is manually running |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 68 | if ( manually_run ){ |
| 69 | onos_b = params.ONOSVersion |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 70 | } |
| 71 | else { |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 72 | // otherwise, the version would be different over the weekend. |
| 73 | // If today is weekdays, it will be default to current_version. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 74 | if ( today == Calendar.SATURDAY ){ |
| 75 | onos_b = previous_version |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 76 | } |
| 77 | else if ( today == Calendar.SUNDAY ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 78 | onos_b = before_previous_version |
| 79 | } |
| 80 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 81 | |
| 82 | // Get all the list of the tests from the JenkinsTestONTests.groovy |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 83 | AllTheTests = test_lists.getAllTheTests( onos_b ) |
| 84 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 85 | // list of the tests to be run will be saved in each choices. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 86 | day = "" |
| 87 | SCPF_choices = "" |
| 88 | USECASE_choices = "" |
| 89 | FUNC_choices = "" |
| 90 | HA_choices = "" |
| 91 | SR_choices = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 92 | |
| 93 | // init some paths for the files and directories. |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 94 | stat_graph_generator_file = fileRelated.histogramMultiple |
| 95 | pie_graph_generator_file = fileRelated.pieMultiple |
| 96 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 97 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 98 | // get post result from the params for manually run. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 99 | post_result = params.PostResult |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 100 | |
| 101 | // if automatically run, it will remove the comma at the end after dividing the tests. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 102 | if ( !manually_run ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 103 | testDivider( today ) |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 104 | FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices ) |
| 105 | HA_choices = triggerFuncs.lastCommaRemover( HA_choices ) |
| 106 | SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices ) |
| 107 | USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices ) |
| 108 | SR_choices = triggerFuncs.lastCommaRemover( SR_choices ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 111 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 112 | if ( manually_run ){ |
| 113 | testcases = triggerFuncs.organize_tests( params.Tests, testcases ) |
| 114 | |
| 115 | isOldFlow = params.isOldFlow |
| 116 | println "Tests to be run manually : " |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 117 | } |
| 118 | else { |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 119 | testcases[ "SCPF" ][ "tests" ] = SCPF_choices |
| 120 | testcases[ "USECASE" ][ "tests" ] = USECASE_choices |
| 121 | testcases[ "FUNC" ][ "tests" ] = FUNC_choices |
| 122 | testcases[ "HA" ][ "tests" ] = HA_choices |
| 123 | testcases[ "SR" ][ "tests" ] = SR_choices |
| 124 | println "Defaulting to " + day + " tests:" |
| 125 | } |
| 126 | |
| 127 | triggerFuncs.print_tests( testcases ) |
| 128 | |
| 129 | def runTest = [ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 130 | "VM": [ : ], |
| 131 | "BM": [ : ] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 132 | ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 133 | |
| 134 | // set the test running function into the dictionary. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 135 | for ( String test in testcases.keySet() ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 136 | println test |
| 137 | if ( testcases[ test ][ "tests" ] != "" ){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 138 | runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs. |
| 139 | trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test, |
| 140 | manually_run, onos_tag ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 141 | } |
| 142 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 143 | def finalList = [ : ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 144 | |
| 145 | // get the name of the job. |
Devin Lim | b91bf79 | 2018-05-10 15:09:52 -0700 | [diff] [blame] | 146 | jobName = env.JOB_NAME |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 147 | |
| 148 | // first set the list of the functions to be run. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 149 | finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] ) |
| 150 | finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 151 | |
| 152 | // if first two character of the job name is vm, only call VM. |
| 153 | // else, only on BM |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 154 | if ( jobName.take( 2 ) == "vm" ){ |
Devin Lim | b91bf79 | 2018-05-10 15:09:52 -0700 | [diff] [blame] | 155 | finalList[ "VM" ].call() |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 156 | } |
| 157 | else { |
Devin Lim | b91bf79 | 2018-05-10 15:09:52 -0700 | [diff] [blame] | 158 | finalList[ "BM" ].call() |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 159 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 160 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 161 | // If it is automated running, it will generate the stats graph on VM. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 162 | if ( !manually_run ){ |
| 163 | funcs.generateStatGraph( "TestStation-VMs", |
| 164 | funcs.branchWithPrefix( onos_b ), |
| 165 | AllTheTests, |
| 166 | stat_graph_generator_file, |
| 167 | pie_graph_generator_file, |
| 168 | graph_saved_directory ) |
| 169 | } |
| 170 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 171 | // function that will divide tests depends on which day it is. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 172 | def testDivider( today ){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 173 | switch ( today ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 174 | case Calendar.MONDAY: |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 175 | // THe reason Monday calls all the days is because we want to post the test schedules on the wiki |
| 176 | // and slack channel every monday. |
| 177 | // It will only generate the list of the test for monday. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 178 | initHtmlForWiki() |
| 179 | monday( true ) |
| 180 | tuesday( true, false ) |
| 181 | wednesday( true, false ) |
| 182 | thursday( true, false ) |
| 183 | friday( true, false ) |
| 184 | saturday( false, false ) |
| 185 | sunday( false, false ) |
| 186 | day = "Monday" |
| 187 | closeHtmlForWiki() |
| 188 | postToWiki( wikiContents ) |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 189 | slackSend( color: '#FFD988', |
| 190 | message: "Tests to be run this weekdays : \n" + |
| 191 | triggerFuncs.printDaysForTest( AllTheTests ) ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 192 | break |
| 193 | case Calendar.TUESDAY: |
| 194 | tuesday( false, true ) |
| 195 | day = "Tuesday" |
| 196 | break |
| 197 | case Calendar.WEDNESDAY: |
| 198 | wednesday( false, true ) |
| 199 | day = "Wednesday" |
| 200 | break |
| 201 | case Calendar.THURSDAY: |
| 202 | thursday( false, true ) |
| 203 | day = "Thursday" |
| 204 | break |
| 205 | case Calendar.FRIDAY: |
| 206 | friday( false, true ) |
| 207 | day = "Friday" |
| 208 | break |
| 209 | case Calendar.SATURDAY: |
| 210 | saturday( false, true ) |
| 211 | day = "Saturday" |
| 212 | break |
| 213 | case Calendar.SUNDAY: |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 214 | sunday( false, true ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 215 | day = "Sunday" |
| 216 | break |
| 217 | } |
| 218 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 219 | |
| 220 | // function for monday. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 221 | def monday( getResult ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 222 | // add header for wiki page script. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 223 | addingHeader( "FUNC" ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 224 | // call category of basic and extra_A of FUNC tests. |
| 225 | // put M into the dictionary. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 226 | FUNC_choices += adder( "FUNC", "basic", true, "M", getResult ) |
| 227 | FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult ) |
| 228 | closingHeader( "FUNC" ) |
| 229 | addingHeader( "HA" ) |
| 230 | HA_choices += adder( "HA", "basic", true, "M", getResult ) |
| 231 | HA_choices += adder( "HA", "extra_A", true, "M", getResult ) |
| 232 | closingHeader( "HA" ) |
| 233 | addingHeader( "SCPF" ) |
| 234 | SCPF_choices += adder( "SCPF", "basic", true, "M", getResult ) |
| 235 | SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult ) |
| 236 | closingHeader( "SCPF" ) |
| 237 | addingHeader( "SR" ) |
| 238 | SR_choices += adder( "SR", "basic", true, "M", false ) |
| 239 | closingHeader( "SR" ) |
| 240 | addingHeader( "USECASE" ) |
| 241 | closingHeader( "USECASE" ) |
| 242 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 243 | |
| 244 | // If get result is false, it will not add the test result to xx_choices, but will generate the |
| 245 | // header and days |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 246 | def tuesday( getDay, getResult ){ |
| 247 | addingHeader( "FUNC" ) |
| 248 | FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult ) |
| 249 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult ) |
| 250 | closingHeader( "FUNC" ) |
| 251 | addingHeader( "HA" ) |
| 252 | HA_choices += adder( "HA", "basic", getDay, "T", getResult ) |
| 253 | HA_choices += adder( "HA", "extra_B", getDay, "T", getResult ) |
| 254 | closingHeader( "HA" ) |
| 255 | addingHeader( "SCPF" ) |
| 256 | SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult ) |
| 257 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult ) |
| 258 | closingHeader( "SCPF" ) |
| 259 | addingHeader( "SR" ) |
| 260 | SR_choices += adder( "SR", "basic", getDay, "T", false ) |
| 261 | closingHeader( "SR" ) |
| 262 | addingHeader( "USECASE" ) |
| 263 | USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult ) |
| 264 | USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult ) |
| 265 | closingHeader( "USECASE" ) |
| 266 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 267 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 268 | def wednesday( getDay, getResult ){ |
| 269 | addingHeader( "FUNC" ) |
| 270 | FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult ) |
| 271 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult ) |
| 272 | closingHeader( "FUNC" ) |
| 273 | addingHeader( "HA" ) |
| 274 | HA_choices += adder( "HA", "basic", getDay, "W", getResult ) |
| 275 | HA_choices += adder( "HA", "extra_A", getDay, "W", getResult ) |
| 276 | closingHeader( "HA" ) |
| 277 | addingHeader( "SCPF" ) |
| 278 | SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult ) |
| 279 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult ) |
| 280 | closingHeader( "SCPF" ) |
| 281 | addingHeader( "SR" ) |
| 282 | SR_choices += adder( "SR", "basic", getDay, "W", false ) |
| 283 | closingHeader( "SR" ) |
| 284 | addingHeader( "USECASE" ) |
| 285 | closingHeader( "USECASE" ) |
| 286 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 287 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 288 | def thursday( getDay, getResult ){ |
| 289 | addingHeader( "FUNC" ) |
| 290 | FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult ) |
| 291 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult ) |
| 292 | closingHeader( "FUNC" ) |
| 293 | addingHeader( "HA" ) |
| 294 | HA_choices += adder( "HA", "basic", getDay, "Th", getResult ) |
| 295 | HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult ) |
| 296 | closingHeader( "HA" ) |
| 297 | addingHeader( "SCPF" ) |
| 298 | SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult ) |
| 299 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult ) |
| 300 | closingHeader( "SCPF" ) |
| 301 | addingHeader( "SR" ) |
| 302 | SR_choices += adder( "SR", "basic", getDay, "Th", false ) |
| 303 | closingHeader( "SR" ) |
| 304 | addingHeader( "USECASE" ) |
| 305 | closingHeader( "USECASE" ) |
| 306 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 307 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 308 | def friday( getDay, getResult ){ |
| 309 | addingHeader( "FUNC" ) |
| 310 | FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult ) |
| 311 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult ) |
| 312 | closingHeader( "FUNC" ) |
| 313 | addingHeader( "HA" ) |
| 314 | HA_choices += adder( "HA", "basic", getDay, "F", getResult ) |
| 315 | HA_choices += adder( "HA", "extra_A", getDay, "F", getResult ) |
| 316 | closingHeader( "HA" ) |
| 317 | addingHeader( "SCPF" ) |
| 318 | SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult ) |
| 319 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult ) |
| 320 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult ) |
| 321 | closingHeader( "SCPF" ) |
| 322 | addingHeader( "SR" ) |
| 323 | SR_choices += adder( "SR", "basic", getDay, "F", false ) |
| 324 | SR_choices += adder( "SR", "extra_A", getDay, "F", false ) |
| 325 | closingHeader( "SR" ) |
| 326 | addingHeader( "USECASE" ) |
| 327 | closingHeader( "USECASE" ) |
| 328 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 329 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 330 | def saturday( getDay, getResult ){ |
| 331 | addingHeader( "FUNC" ) |
| 332 | FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult ) |
| 333 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult ) |
| 334 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult ) |
| 335 | closingHeader( "FUNC" ) |
| 336 | addingHeader( "HA" ) |
| 337 | HA_choices += adder( "HA", "basic", getDay, "Sa", getResult ) |
| 338 | HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult ) |
| 339 | HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult ) |
| 340 | closingHeader( "HA" ) |
| 341 | addingHeader( "SCPF" ) |
| 342 | SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult ) |
| 343 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult ) |
| 344 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult ) |
| 345 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult ) |
| 346 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult ) |
| 347 | closingHeader( "SCPF" ) |
| 348 | addingHeader( "SR" ) |
| 349 | SR_choices += adder( "SR", "basic", getDay, "Sa", false ) |
| 350 | SR_choices += adder( "SR", "extra_B", getDay, "Sa", false ) |
| 351 | closingHeader( "SR" ) |
| 352 | addingHeader( "USECASE" ) |
| 353 | USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult ) |
| 354 | closingHeader( "USECASE" ) |
| 355 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 356 | |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 357 | def sunday( getDay, getResult ){ |
| 358 | addingHeader( "FUNC" ) |
| 359 | FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult ) |
| 360 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult ) |
| 361 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult ) |
| 362 | closingHeader( "FUNC" ) |
| 363 | addingHeader( "HA" ) |
| 364 | HA_choices += adder( "HA", "basic", getDay, "S", getResult ) |
| 365 | HA_choices += adder( "HA", "extra_A", getDay, "S", getResult ) |
| 366 | HA_choices += adder( "HA", "extra_B", getDay, "S", getResult ) |
| 367 | closingHeader( "HA" ) |
| 368 | addingHeader( "SCPF" ) |
| 369 | SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult ) |
| 370 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult ) |
| 371 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult ) |
| 372 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult ) |
| 373 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult ) |
| 374 | closingHeader( "SCPF" ) |
| 375 | addingHeader( "SR" ) |
| 376 | SR_choices += adder( "SR", "basic", getDay, "S", false ) |
| 377 | closingHeader( "SR" ) |
| 378 | addingHeader( "USECASE" ) |
| 379 | USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult ) |
| 380 | closingHeader( "USECASE" ) |
| 381 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 382 | |
| 383 | // adder that will return the list of the tests. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 384 | def adder( testCat, set, dayAdding, day, getResult ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 385 | // testCat : the category of the test which will be either FUNC,HA,SR... |
| 386 | // set : the set of the test to be run which will be basic,extra_A,extra_B... |
| 387 | // dayAdding : boolean whether to add the days into the list or not |
| 388 | // day : the day you are trying to add (m,t,w,th... ) |
| 389 | // getResult : if want to get the list of the test to be run. False will return empty list. |
| 390 | // And once the list is empty, it will not be run. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 391 | def result = "" |
| 392 | for ( String test in AllTheTests[ testCat ].keySet() ){ |
| 393 | if ( AllTheTests[ testCat ][ test ][ set ] ){ |
| 394 | if ( getResult ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 395 | result += test + "," |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 396 | } |
| 397 | if ( dayAdding ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 398 | dayAdder( testCat, test, day ) |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 399 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 400 | // make HTML columns for wiki page on schedule. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 401 | makeHtmlColList( testCat, test ) |
| 402 | } |
| 403 | } |
| 404 | return result |
| 405 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 406 | |
| 407 | // Initial part of the wiki page. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 408 | def initHtmlForWiki(){ |
| 409 | wikiContents = ''' |
| 410 | <table class="wrapped confluenceTable"> |
| 411 | <colgroup> |
| 412 | <col /> |
| 413 | <col /> |
| 414 | <col /> |
| 415 | <col /> |
| 416 | <col /> |
| 417 | <col /> |
| 418 | </colgroup> |
| 419 | <tbody> |
| 420 | <tr> |
| 421 | <th colspan="1" class="confluenceTh"> |
| 422 | <br /> |
| 423 | </th> |
| 424 | <th class="confluenceTh"><p>Monday</p></th> |
| 425 | <th class="confluenceTh"><p>Tuesday</p></th> |
| 426 | <th class="confluenceTh"><p>Wednesday</p></th> |
| 427 | <th class="confluenceTh"><p>Thursday</p></th> |
| 428 | <th class="confluenceTh"><p>Friday</p></th> |
| 429 | <th class="confluenceTh"><p>Saturday</p></th> |
| 430 | <th class="confluenceTh"><p>Sunday</p></th> |
| 431 | </tr>''' |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 432 | for ( String test in testcases.keySet() ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 433 | testcases[ test ][ 'wikiContent' ] = ''' |
| 434 | <tr> |
| 435 | <th colspan="1" class="confluenceTh">''' + test + '''</th>''' |
| 436 | } |
| 437 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 438 | |
| 439 | // adding header functionality. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 440 | def addingHeader( testCategory ){ |
| 441 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
| 442 | <td class="confluenceTd"> |
| 443 | <ul>''' |
| 444 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 445 | |
| 446 | // making column list for html |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 447 | def makeHtmlColList( testCategory, testName ){ |
| 448 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 449 | <li>''' + testName + '''</li>''' |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 450 | |
| 451 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 452 | |
| 453 | // closing the header for html |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 454 | def closingHeader( testCategory ){ |
| 455 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
| 456 | </ul> |
| 457 | </td>''' |
| 458 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 459 | |
| 460 | // close the html for the wiki page. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 461 | def closeHtmlForWiki(){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 462 | for ( String test in testcases.keySet() ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 463 | wikiContents += testcases[ test ][ 'wikiContent' ] |
| 464 | wikiContents += ''' |
| 465 | </tr>''' |
| 466 | } |
| 467 | wikiContents += ''' |
| 468 | </tbody> |
| 469 | </table> |
| 470 | <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p> |
| 471 | <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p> |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 472 | <p>On <strong>Saturdays</strong>, all the other tests are built and run on the ''' + |
| 473 | funcs.branchWithPrefix( previous_version ) + ''' branch.</p> |
| 474 | <p>On <strong>Sundays</strong>, all the other tests are built and run on the ''' + |
| 475 | funcs.branchWithPrefix( before_previous_version ) + ''' branch.</p>''' |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 476 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 477 | |
| 478 | // post the result to wiki page using publish to confluence. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 479 | def postToWiki( contents ){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame^] | 480 | node( testMachine ) { |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 481 | workspace = fileRelated.jenkinsWorkspace + "all-pipeline-trigger/" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 482 | filename = "jenkinsSchedule.txt" |
| 483 | writeFile file: workspace + filename, text: contents |
| 484 | funcs.publishToConfluence( "false", "true", |
| 485 | "Automated Test Schedule", |
| 486 | workspace + filename ) |
| 487 | } |
| 488 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 489 | |
| 490 | // add the day to the "day" on the dictionary. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 491 | def dayAdder( testCat, testName, dayOfWeek ){ |
| 492 | AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + "," |
| 493 | } |