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