| #!groovy |
| // Copyright 2017 Open Networking Foundation (ONF) |
| // |
| // Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| // the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| // or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| // |
| // TestON is free software: you can redistribute it and/or modify |
| // it under the terms of the GNU General Public License as published by |
| // the Free Software Foundation, either version 2 of the License, or |
| // (at your option) any later version. |
| // |
| // TestON is distributed in the hope that it will be useful, |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| // GNU General Public License for more details. |
| // |
| // You should have received a copy of the GNU General Public License |
| // along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| |
| // This is the Jenkins script for vm-pipeline-trigger or bm-pipeline-trigger |
| |
| // set the functions of the dependencies. |
| funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' ) |
| test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
| triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' ) |
| fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
| |
| // set the versions of the onos |
| fileRelated.init() |
| current_version = "master" |
| previous_version = "1.15" |
| before_previous_version = "2.1" |
| |
| // init trend graphs to be on VM. |
| funcs.initializeTrend( "VM" ); |
| triggerFuncs.init( funcs ) |
| |
| // contents for page https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule |
| // which will demonstrates the list of the scheduled tests on the days. |
| wikiContents = "" |
| |
| // default FUNC,HA to be VM, SCPF,USECASE to be BM. |
| // SR will not be used in here. |
| testcases = [ |
| "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| "HA": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ], |
| "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ], |
| "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ], |
| "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ] |
| ] |
| |
| // read the parameters from the Jenkins |
| manually_run = params.manual_run |
| |
| // set default onos_b to be current_version. |
| onos_b = current_version |
| test_branch = "" |
| onos_tag = params.ONOSTag |
| isOldFlow = true |
| |
| // Set tests based on day of week |
| def now = funcs.getCurrentTime() |
| print now.toString() |
| today = now[ Calendar.DAY_OF_WEEK ] |
| |
| // get branch from parameter if it is manually running |
| if ( manually_run ){ |
| onos_b = params.ONOSVersion |
| } |
| else { |
| // otherwise, the version would be different over the weekend. |
| // If today is weekdays, it will be default to current_version. |
| if ( today == Calendar.SATURDAY ){ |
| onos_b = previous_version |
| } |
| else if ( today == Calendar.SUNDAY ){ |
| onos_b = before_previous_version |
| } |
| } |
| |
| // Get all the list of the tests from the JenkinsTestONTests.groovy |
| AllTheTests = test_lists.getAllTheTests( onos_b ) |
| |
| // list of the tests to be run will be saved in each choices. |
| day = "" |
| SCPF_choices = "" |
| USECASE_choices = "" |
| FUNC_choices = "" |
| HA_choices = "" |
| SR_choices = "" |
| SRHA_choices = "" |
| |
| // init some paths for the files and directories. |
| stat_graph_generator_file = fileRelated.histogramMultiple |
| pie_graph_generator_file = fileRelated.pieMultiple |
| graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/" |
| |
| // get post result from the params for manually run. |
| post_result = params.PostResult |
| |
| // if automatically run, it will remove the comma at the end after dividing the tests. |
| if ( !manually_run ){ |
| testDivider( today ) |
| FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices ) |
| HA_choices = triggerFuncs.lastCommaRemover( HA_choices ) |
| SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices ) |
| USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices ) |
| SR_choices = triggerFuncs.lastCommaRemover( SR_choices ) |
| SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices ) |
| } |
| |
| |
| if ( manually_run ){ |
| testcases = triggerFuncs.organize_tests( params.Tests, testcases ) |
| |
| isOldFlow = params.isOldFlow |
| println "Tests to be run manually : " |
| } |
| else { |
| testcases[ "SCPF" ][ "tests" ] = SCPF_choices |
| testcases[ "USECASE" ][ "tests" ] = USECASE_choices |
| testcases[ "FUNC" ][ "tests" ] = FUNC_choices |
| testcases[ "HA" ][ "tests" ] = HA_choices |
| testcases[ "SR" ][ "tests" ] = SR_choices |
| testcases[ "SRHA" ][ "tests" ] = SRHA_choices |
| println "Defaulting to " + day + " tests:" |
| } |
| |
| triggerFuncs.print_tests( testcases ) |
| |
| def runTest = [ |
| "VM": [ : ], |
| "BM": [ : ] |
| ] |
| |
| // set the test running function into the dictionary. |
| for ( String test in testcases.keySet() ){ |
| println test |
| if ( testcases[ test ][ "tests" ] != "" ){ |
| runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs. |
| trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test, |
| manually_run, onos_tag ) |
| } |
| } |
| def finalList = [ : ] |
| |
| // get the name of the job. |
| jobName = env.JOB_NAME |
| |
| // first set the list of the functions to be run. |
| finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] ) |
| finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] ) |
| |
| // if first two character of the job name is vm, only call VM. |
| // else, only on BM |
| if ( jobName.take( 2 ) == "vm" ){ |
| finalList[ "VM" ].call() |
| } |
| else { |
| finalList[ "BM" ].call() |
| } |
| |
| // If it is automated running, it will generate the stats graph on VM. |
| if ( !manually_run ){ |
| funcs.generateStatGraph( "TestStation-VMs", |
| funcs.branchWithPrefix( onos_b ), |
| AllTheTests, |
| stat_graph_generator_file, |
| pie_graph_generator_file, |
| graph_saved_directory ) |
| } |
| |
| // function that will divide tests depends on which day it is. |
| def testDivider( today ){ |
| switch ( today ){ |
| case Calendar.MONDAY: |
| // THe reason Monday calls all the days is because we want to post the test schedules on the wiki |
| // and slack channel every monday. |
| // It will only generate the list of the test for monday. |
| initHtmlForWiki() |
| monday( true ) |
| tuesday( true, false ) |
| wednesday( true, false ) |
| thursday( true, false ) |
| friday( true, false ) |
| saturday( false, false ) |
| sunday( false, false ) |
| day = "Monday" |
| closeHtmlForWiki() |
| postToWiki( wikiContents ) |
| slackSend( color: '#FFD988', |
| message: "Tests to be run this weekdays : \n" + |
| triggerFuncs.printDaysForTest( AllTheTests ) ) |
| break |
| case Calendar.TUESDAY: |
| tuesday( false, true ) |
| day = "Tuesday" |
| break |
| case Calendar.WEDNESDAY: |
| wednesday( false, true ) |
| day = "Wednesday" |
| break |
| case Calendar.THURSDAY: |
| thursday( false, true ) |
| day = "Thursday" |
| break |
| case Calendar.FRIDAY: |
| friday( false, true ) |
| day = "Friday" |
| break |
| case Calendar.SATURDAY: |
| saturday( false, true ) |
| day = "Saturday" |
| break |
| case Calendar.SUNDAY: |
| sunday( false, true ) |
| day = "Sunday" |
| break |
| } |
| } |
| |
| // function for monday. |
| def monday( getResult ){ |
| // add header for wiki page script. |
| addingHeader( "FUNC" ) |
| // call category of basic and extra_A of FUNC tests. |
| // put M into the dictionary. |
| FUNC_choices += adder( "FUNC", "basic", true, "M", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", true, "M", getResult ) |
| HA_choices += adder( "HA", "extra_A", true, "M", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", true, "M", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", true, "M", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", true, "M", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| closingHeader( "USECASE" ) |
| } |
| |
| // If get result is false, it will not add the test result to xx_choices, but will generate the |
| // header and days |
| def tuesday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "T", getResult ) |
| HA_choices += adder( "HA", "extra_B", getDay, "T", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "T", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "T", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult ) |
| USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult ) |
| closingHeader( "USECASE" ) |
| } |
| |
| def wednesday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "W", getResult ) |
| HA_choices += adder( "HA", "extra_A", getDay, "W", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "W", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "W", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| closingHeader( "USECASE" ) |
| } |
| |
| def thursday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "Th", getResult ) |
| HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "Th", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "Th", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| closingHeader( "USECASE" ) |
| } |
| |
| def friday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "F", getResult ) |
| HA_choices += adder( "HA", "extra_A", getDay, "F", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "F", false ) |
| SR_choices += adder( "SR", "extra_A", getDay, "F", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "F", false ) |
| SRHA_choices += adder( "SRHA", "extra_A", getDay, "F", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| closingHeader( "USECASE" ) |
| } |
| |
| def saturday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "Sa", getResult ) |
| HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult ) |
| HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "Sa", false ) |
| SR_choices += adder( "SR", "extra_B", getDay, "Sa", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "Sa", false ) |
| SRHA_choices += adder( "SRHA", "extra_B", getDay, "Sa", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult ) |
| closingHeader( "USECASE" ) |
| } |
| |
| def sunday( getDay, getResult ){ |
| addingHeader( "FUNC" ) |
| FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult ) |
| FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult ) |
| closingHeader( "FUNC" ) |
| addingHeader( "HA" ) |
| HA_choices += adder( "HA", "basic", getDay, "S", getResult ) |
| HA_choices += adder( "HA", "extra_A", getDay, "S", getResult ) |
| HA_choices += adder( "HA", "extra_B", getDay, "S", getResult ) |
| closingHeader( "HA" ) |
| addingHeader( "SCPF" ) |
| SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult ) |
| SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult ) |
| closingHeader( "SCPF" ) |
| addingHeader( "SR" ) |
| SR_choices += adder( "SR", "basic", getDay, "S", false ) |
| closingHeader( "SR" ) |
| addingHeader( "SRHA" ) |
| SRHA_choices += adder( "SRHA", "basic", getDay, "S", false ) |
| closingHeader( "SRHA" ) |
| addingHeader( "USECASE" ) |
| USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult ) |
| closingHeader( "USECASE" ) |
| } |
| |
| // adder that will return the list of the tests. |
| def adder( testCat, set, dayAdding, day, getResult ){ |
| // testCat : the category of the test which will be either FUNC,HA,SR... |
| // set : the set of the test to be run which will be basic,extra_A,extra_B... |
| // dayAdding : boolean whether to add the days into the list or not |
| // day : the day you are trying to add (m,t,w,th... ) |
| // getResult : if want to get the list of the test to be run. False will return empty list. |
| // And once the list is empty, it will not be run. |
| def result = "" |
| for ( String test in AllTheTests[ testCat ].keySet() ){ |
| if ( AllTheTests[ testCat ][ test ][ set ] ){ |
| if ( getResult ){ |
| result += test + "," |
| } |
| if ( dayAdding ){ |
| dayAdder( testCat, test, day ) |
| } |
| // make HTML columns for wiki page on schedule. |
| makeHtmlColList( testCat, test ) |
| } |
| } |
| return result |
| } |
| |
| // Initial part of the wiki page. |
| def initHtmlForWiki(){ |
| wikiContents = ''' |
| <table class="wrapped confluenceTable"> |
| <colgroup> |
| <col /> |
| <col /> |
| <col /> |
| <col /> |
| <col /> |
| <col /> |
| </colgroup> |
| <tbody> |
| <tr> |
| <th colspan="1" class="confluenceTh"> |
| <br /> |
| </th> |
| <th class="confluenceTh"><p>Monday</p></th> |
| <th class="confluenceTh"><p>Tuesday</p></th> |
| <th class="confluenceTh"><p>Wednesday</p></th> |
| <th class="confluenceTh"><p>Thursday</p></th> |
| <th class="confluenceTh"><p>Friday</p></th> |
| <th class="confluenceTh"><p>Saturday</p></th> |
| <th class="confluenceTh"><p>Sunday</p></th> |
| </tr>''' |
| for ( String test in testcases.keySet() ){ |
| testcases[ test ][ 'wikiContent' ] = ''' |
| <tr> |
| <th colspan="1" class="confluenceTh">''' + test + '''</th>''' |
| } |
| } |
| |
| // adding header functionality. |
| def addingHeader( testCategory ){ |
| testcases[ testCategory ][ 'wikiContent' ] += ''' |
| <td class="confluenceTd"> |
| <ul>''' |
| } |
| |
| // making column list for html |
| def makeHtmlColList( testCategory, testName ){ |
| testcases[ testCategory ][ 'wikiContent' ] += ''' |
| <li>''' + testName + '''</li>''' |
| |
| } |
| |
| // closing the header for html |
| def closingHeader( testCategory ){ |
| testcases[ testCategory ][ 'wikiContent' ] += ''' |
| </ul> |
| </td>''' |
| } |
| |
| // close the html for the wiki page. |
| def closeHtmlForWiki(){ |
| for ( String test in testcases.keySet() ){ |
| wikiContents += testcases[ test ][ 'wikiContent' ] |
| wikiContents += ''' |
| </tr>''' |
| } |
| wikiContents += ''' |
| </tbody> |
| </table> |
| <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p> |
| <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p> |
| <p>On <strong>Saturdays</strong>, all the other tests are built and run on the ''' + |
| funcs.branchWithPrefix( previous_version ) + ''' branch.</p> |
| <p>On <strong>Sundays</strong>, all the other tests are built and run on the ''' + |
| funcs.branchWithPrefix( before_previous_version ) + ''' branch.</p>''' |
| } |
| |
| // post the result to wiki page using publish to confluence. |
| def postToWiki( contents ){ |
| node( testMachine ) { |
| workspace = fileRelated.jenkinsWorkspace + "all-pipeline-trigger/" |
| filename = "jenkinsSchedule.txt" |
| writeFile file: workspace + filename, text: contents |
| funcs.publishToConfluence( "false", "true", |
| "Automated Test Schedule", |
| workspace + filename ) |
| } |
| } |
| |
| // add the day to the "day" on the dictionary. |
| def dayAdder( testCat, testName, dayOfWeek ){ |
| AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + "," |
| } |