Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | |
| 3 | funcs = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsCommonFuncs.groovy' ) |
| 4 | test_lists = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsTestONTests.groovy' ) |
| 5 | triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/TriggerFuncs.groovy' ) |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 6 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsPathAndFiles.groovy' ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 7 | |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 8 | fileRelated.init() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 9 | current_version = "master" |
| 10 | previous_version = "1.13" |
| 11 | before_previous_version = "1.12" |
| 12 | funcs.initializeTrend( "VM" ); |
| 13 | triggerFuncs.init( funcs ) |
| 14 | wikiContents = "" |
| 15 | testcases = [ |
| 16 | "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 17 | "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 18 | "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ], |
| 19 | "SR" : [ tests : "", nodeName : "Fabric", wikiContent : "" ], |
| 20 | "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ] |
| 21 | ] |
| 22 | Prefix_organizer = [ |
| 23 | "FU" : "FUNC", |
| 24 | "HA" : "HA", |
| 25 | "PL" : "USECASE", |
| 26 | "SA" : "USECASE", |
| 27 | "SC" : "SCPF", |
| 28 | "SR" : "SR", |
| 29 | "US" : "USECASE", |
| 30 | "VP" : "USECASE" |
| 31 | ] |
| 32 | |
| 33 | manually_run = params.manual_run |
| 34 | onos_b = current_version |
| 35 | test_branch = "" |
| 36 | onos_tag = params.ONOSTag |
| 37 | isOldFlow = true |
| 38 | |
| 39 | // Set tests based on day of week |
| 40 | def now = funcs.getCurrentTime() |
| 41 | print now.toString() |
| 42 | today = now[ Calendar.DAY_OF_WEEK ] |
| 43 | |
| 44 | if ( manually_run ){ |
| 45 | onos_b = params.ONOSVersion |
| 46 | } else { |
| 47 | if ( today == Calendar.SATURDAY ){ |
| 48 | onos_b = previous_version |
| 49 | } else if( today == Calendar.SUNDAY ){ |
| 50 | onos_b = before_previous_version |
| 51 | } |
| 52 | } |
| 53 | AllTheTests = test_lists.getAllTheTests( onos_b ) |
| 54 | |
| 55 | day = "" |
| 56 | SCPF_choices = "" |
| 57 | USECASE_choices = "" |
| 58 | FUNC_choices = "" |
| 59 | HA_choices = "" |
| 60 | SR_choices = "" |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 61 | stat_graph_generator_file = fileRelated.histogramMultiple |
| 62 | pie_graph_generator_file = fileRelated.pieMultiple |
| 63 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 64 | |
| 65 | post_result = params.PostResult |
| 66 | if( !manually_run ){ |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 67 | testDivider( today ) |
| 68 | FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices ) |
| 69 | HA_choices = triggerFuncs.lastCommaRemover( HA_choices ) |
| 70 | SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices ) |
| 71 | USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices ) |
| 72 | SR_choices = triggerFuncs.lastCommaRemover( SR_choices ) |
| 73 | } |
| 74 | |
| 75 | if ( manually_run ){ |
| 76 | testcases = triggerFuncs.organize_tests( params.Tests, testcases ) |
| 77 | |
| 78 | isOldFlow = params.isOldFlow |
| 79 | println "Tests to be run manually : " |
| 80 | }else{ |
| 81 | testcases[ "SCPF" ][ "tests" ] = SCPF_choices |
| 82 | testcases[ "USECASE" ][ "tests" ] = USECASE_choices |
| 83 | testcases[ "FUNC" ][ "tests" ] = FUNC_choices |
| 84 | testcases[ "HA" ][ "tests" ] = HA_choices |
| 85 | testcases[ "SR" ][ "tests" ] = SR_choices |
| 86 | println "Defaulting to " + day + " tests:" |
| 87 | } |
| 88 | |
| 89 | triggerFuncs.print_tests( testcases ) |
| 90 | |
| 91 | def runTest = [ |
| 92 | "VM" : [:], |
| 93 | "BM" : [:] |
| 94 | ] |
| 95 | for( String test in testcases.keySet() ){ |
| 96 | println test |
| 97 | if ( testcases[ test ][ "tests" ] != "" ){ |
| 98 | runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs.trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test, manually_run, onos_tag ) |
| 99 | } |
| 100 | } |
| 101 | def finalList = [:] |
Devin Lim | b91bf79 | 2018-05-10 15:09:52 -0700 | [diff] [blame] | 102 | jobName = env.JOB_NAME |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 103 | finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] ) |
| 104 | finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] ) |
Devin Lim | b91bf79 | 2018-05-10 15:09:52 -0700 | [diff] [blame] | 105 | //parallel finalList |
| 106 | if( jobName.take( 2 ) == "vm" ) |
| 107 | finalList[ "VM" ].call() |
| 108 | else |
| 109 | finalList[ "BM" ].call() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 110 | |
| 111 | if ( !manually_run ){ |
| 112 | funcs.generateStatGraph( "TestStation-VMs", |
| 113 | funcs.branchWithPrefix( onos_b ), |
| 114 | AllTheTests, |
| 115 | stat_graph_generator_file, |
| 116 | pie_graph_generator_file, |
| 117 | graph_saved_directory ) |
| 118 | } |
| 119 | |
| 120 | def testDivider( today ){ |
| 121 | switch ( today ) { |
| 122 | case Calendar.MONDAY: |
| 123 | initHtmlForWiki() |
| 124 | monday( true ) |
| 125 | tuesday( true, false ) |
| 126 | wednesday( true, false ) |
| 127 | thursday( true, false ) |
| 128 | friday( true, false ) |
| 129 | saturday( false, false ) |
| 130 | sunday( false, false ) |
| 131 | day = "Monday" |
| 132 | closeHtmlForWiki() |
| 133 | postToWiki( wikiContents ) |
| 134 | slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + triggerFuncs.printDaysForTest( AllTheTests ) ) |
| 135 | break |
| 136 | case Calendar.TUESDAY: |
| 137 | tuesday( false, true ) |
| 138 | day = "Tuesday" |
| 139 | break |
| 140 | case Calendar.WEDNESDAY: |
| 141 | wednesday( false, true ) |
| 142 | day = "Wednesday" |
| 143 | break |
| 144 | case Calendar.THURSDAY: |
| 145 | thursday( false, true ) |
| 146 | day = "Thursday" |
| 147 | break |
| 148 | case Calendar.FRIDAY: |
| 149 | friday( false, true ) |
| 150 | day = "Friday" |
| 151 | break |
| 152 | case Calendar.SATURDAY: |
| 153 | saturday( false, true ) |
| 154 | day = "Saturday" |
| 155 | break |
| 156 | case Calendar.SUNDAY: |
| 157 | sunday( false , true ) |
| 158 | day = "Sunday" |
| 159 | break |
| 160 | } |
| 161 | } |
| 162 | def monday( getResult ){ |
| 163 | addingHeader( "FUNC" ) |
| 164 | FUNC_choices += adder( "FUNC", "basic", true, "M", getResult ) |
| 165 | FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult ) |
| 166 | closingHeader( "FUNC" ) |
| 167 | addingHeader( "HA" ) |
| 168 | HA_choices += adder( "HA", "basic", true, "M", getResult ) |
| 169 | HA_choices += adder( "HA", "extra_A", true, "M", getResult ) |
| 170 | closingHeader( "HA" ) |
| 171 | addingHeader( "SCPF" ) |
| 172 | SCPF_choices += adder( "SCPF", "basic", true, "M", getResult ) |
| 173 | SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult ) |
| 174 | closingHeader( "SCPF" ) |
| 175 | addingHeader( "SR" ) |
| 176 | SR_choices += adder( "SR", "basic", true, "M", false ) |
| 177 | closingHeader( "SR" ) |
| 178 | addingHeader( "USECASE" ) |
| 179 | closingHeader( "USECASE" ) |
| 180 | } |
| 181 | def tuesday( getDay, getResult ){ |
| 182 | addingHeader( "FUNC" ) |
| 183 | FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult ) |
| 184 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult ) |
| 185 | closingHeader( "FUNC" ) |
| 186 | addingHeader( "HA" ) |
| 187 | HA_choices += adder( "HA", "basic", getDay, "T", getResult ) |
| 188 | HA_choices += adder( "HA", "extra_B", getDay, "T", getResult ) |
| 189 | closingHeader( "HA" ) |
| 190 | addingHeader( "SCPF" ) |
| 191 | SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult ) |
| 192 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult ) |
| 193 | closingHeader( "SCPF" ) |
| 194 | addingHeader( "SR" ) |
| 195 | SR_choices += adder( "SR", "basic", getDay, "T", false ) |
| 196 | closingHeader( "SR" ) |
| 197 | addingHeader( "USECASE" ) |
| 198 | USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult ) |
| 199 | USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult ) |
| 200 | closingHeader( "USECASE" ) |
| 201 | } |
| 202 | def wednesday( getDay, getResult ){ |
| 203 | addingHeader( "FUNC" ) |
| 204 | FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult ) |
| 205 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult ) |
| 206 | closingHeader( "FUNC" ) |
| 207 | addingHeader( "HA" ) |
| 208 | HA_choices += adder( "HA", "basic", getDay, "W", getResult ) |
| 209 | HA_choices += adder( "HA", "extra_A", getDay, "W", getResult ) |
| 210 | closingHeader( "HA" ) |
| 211 | addingHeader( "SCPF" ) |
| 212 | SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult ) |
| 213 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult ) |
| 214 | closingHeader( "SCPF" ) |
| 215 | addingHeader( "SR" ) |
| 216 | SR_choices += adder( "SR", "basic", getDay, "W", false ) |
| 217 | closingHeader( "SR" ) |
| 218 | addingHeader( "USECASE" ) |
| 219 | closingHeader( "USECASE" ) |
| 220 | } |
| 221 | def thursday( getDay, getResult ){ |
| 222 | addingHeader( "FUNC" ) |
| 223 | FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult ) |
| 224 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult ) |
| 225 | closingHeader( "FUNC" ) |
| 226 | addingHeader( "HA" ) |
| 227 | HA_choices += adder( "HA", "basic", getDay, "Th", getResult ) |
| 228 | HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult ) |
| 229 | closingHeader( "HA" ) |
| 230 | addingHeader( "SCPF" ) |
| 231 | SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult ) |
| 232 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult ) |
| 233 | closingHeader( "SCPF" ) |
| 234 | addingHeader( "SR" ) |
| 235 | SR_choices += adder( "SR", "basic", getDay, "Th", false ) |
| 236 | closingHeader( "SR" ) |
| 237 | addingHeader( "USECASE" ) |
| 238 | closingHeader( "USECASE" ) |
| 239 | } |
| 240 | def friday( getDay, getResult ){ |
| 241 | addingHeader( "FUNC" ) |
| 242 | FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult ) |
| 243 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult ) |
| 244 | closingHeader( "FUNC" ) |
| 245 | addingHeader( "HA" ) |
| 246 | HA_choices += adder( "HA", "basic", getDay, "F", getResult ) |
| 247 | HA_choices += adder( "HA", "extra_A", getDay, "F", getResult ) |
| 248 | closingHeader( "HA" ) |
| 249 | addingHeader( "SCPF" ) |
| 250 | SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult ) |
| 251 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult ) |
| 252 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult ) |
| 253 | closingHeader( "SCPF" ) |
| 254 | addingHeader( "SR" ) |
| 255 | SR_choices += adder( "SR", "basic", getDay, "F", false ) |
| 256 | SR_choices += adder( "SR", "extra_A", getDay, "F", false ) |
| 257 | closingHeader( "SR" ) |
| 258 | addingHeader( "USECASE" ) |
| 259 | closingHeader( "USECASE" ) |
| 260 | } |
| 261 | def saturday( getDay, getResult ){ |
| 262 | addingHeader( "FUNC" ) |
| 263 | FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult ) |
| 264 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult ) |
| 265 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult ) |
| 266 | closingHeader( "FUNC" ) |
| 267 | addingHeader( "HA" ) |
| 268 | HA_choices += adder( "HA", "basic", getDay, "Sa", getResult ) |
| 269 | HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult ) |
| 270 | HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult ) |
| 271 | closingHeader( "HA" ) |
| 272 | addingHeader( "SCPF" ) |
| 273 | SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult ) |
| 274 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult ) |
| 275 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult ) |
| 276 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult ) |
| 277 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult ) |
| 278 | closingHeader( "SCPF" ) |
| 279 | addingHeader( "SR" ) |
| 280 | SR_choices += adder( "SR", "basic", getDay, "Sa", false ) |
| 281 | SR_choices += adder( "SR", "extra_B", getDay, "Sa", false ) |
| 282 | closingHeader( "SR" ) |
| 283 | addingHeader( "USECASE" ) |
| 284 | USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult ) |
| 285 | closingHeader( "USECASE" ) |
| 286 | } |
| 287 | def sunday( getDay, getResult ){ |
| 288 | addingHeader( "FUNC" ) |
| 289 | FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult ) |
| 290 | FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult ) |
| 291 | FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult ) |
| 292 | closingHeader( "FUNC" ) |
| 293 | addingHeader( "HA" ) |
| 294 | HA_choices += adder( "HA", "basic", getDay, "S", getResult ) |
| 295 | HA_choices += adder( "HA", "extra_A", getDay, "S", getResult ) |
| 296 | HA_choices += adder( "HA", "extra_B", getDay, "S", getResult ) |
| 297 | closingHeader( "HA" ) |
| 298 | addingHeader( "SCPF" ) |
| 299 | SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult ) |
| 300 | SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult ) |
| 301 | SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult ) |
| 302 | SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult ) |
| 303 | SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult ) |
| 304 | closingHeader( "SCPF" ) |
| 305 | addingHeader( "SR" ) |
| 306 | SR_choices += adder( "SR", "basic", getDay, "S", false ) |
| 307 | closingHeader( "SR" ) |
| 308 | addingHeader( "USECASE" ) |
| 309 | USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult ) |
| 310 | closingHeader( "USECASE" ) |
| 311 | } |
| 312 | def adder( testCat, set, dayAdding, day, getResult ){ |
| 313 | result = "" |
| 314 | for( String test in AllTheTests[ testCat ].keySet() ){ |
| 315 | if( AllTheTests[ testCat ][ test ][ set ] ){ |
| 316 | if( getResult ) |
| 317 | result += test + "," |
| 318 | if( dayAdding ) |
| 319 | dayAdder( testCat, test, day ) |
| 320 | makeHtmlColList( testCat, test ) |
| 321 | } |
| 322 | } |
| 323 | return result |
| 324 | } |
| 325 | def initHtmlForWiki(){ |
| 326 | wikiContents = ''' |
| 327 | <table class="wrapped confluenceTable"> |
| 328 | <colgroup> |
| 329 | <col /> |
| 330 | <col /> |
| 331 | <col /> |
| 332 | <col /> |
| 333 | <col /> |
| 334 | <col /> |
| 335 | </colgroup> |
| 336 | <tbody> |
| 337 | <tr> |
| 338 | <th colspan="1" class="confluenceTh"> |
| 339 | <br /> |
| 340 | </th> |
| 341 | <th class="confluenceTh"><p>Monday</p></th> |
| 342 | <th class="confluenceTh"><p>Tuesday</p></th> |
| 343 | <th class="confluenceTh"><p>Wednesday</p></th> |
| 344 | <th class="confluenceTh"><p>Thursday</p></th> |
| 345 | <th class="confluenceTh"><p>Friday</p></th> |
| 346 | <th class="confluenceTh"><p>Saturday</p></th> |
| 347 | <th class="confluenceTh"><p>Sunday</p></th> |
| 348 | </tr>''' |
| 349 | for( String test in testcases.keySet() ){ |
| 350 | testcases[ test ][ 'wikiContent' ] = ''' |
| 351 | <tr> |
| 352 | <th colspan="1" class="confluenceTh">''' + test + '''</th>''' |
| 353 | } |
| 354 | } |
| 355 | def addingHeader( testCategory ){ |
| 356 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
| 357 | <td class="confluenceTd"> |
| 358 | <ul>''' |
| 359 | } |
| 360 | def makeHtmlColList( testCategory, testName ){ |
| 361 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
| 362 | <li>'''+ testName +'''</li>''' |
| 363 | |
| 364 | } |
| 365 | def closingHeader( testCategory ){ |
| 366 | testcases[ testCategory ][ 'wikiContent' ] += ''' |
| 367 | </ul> |
| 368 | </td>''' |
| 369 | } |
| 370 | def closeHtmlForWiki(){ |
| 371 | for( String test in testcases.keySet() ){ |
| 372 | wikiContents += testcases[ test ][ 'wikiContent' ] |
| 373 | wikiContents += ''' |
| 374 | </tr>''' |
| 375 | } |
| 376 | wikiContents += ''' |
| 377 | </tbody> |
| 378 | </table> |
| 379 | <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p> |
| 380 | <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p> |
| 381 | <p>On <strong>Saturdays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( previous_version ) +''' branch.</p> |
| 382 | <p>On <strong>Sundays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( before_previous_version ) +''' branch.</p>''' |
| 383 | } |
| 384 | def postToWiki( contents ){ |
| 385 | node( testMachine ){ |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame^] | 386 | workspace = fileRelated.jenkinsWorkspace + "all-pipeline-trigger/" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 387 | filename = "jenkinsSchedule.txt" |
| 388 | writeFile file: workspace + filename, text: contents |
| 389 | funcs.publishToConfluence( "false", "true", |
| 390 | "Automated Test Schedule", |
| 391 | workspace + filename ) |
| 392 | } |
| 393 | } |
| 394 | def dayAdder( testCat, testName, dayOfWeek ){ |
| 395 | AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + "," |
| 396 | } |