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