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