Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 1 | // Copyright 2017 Open Networking Foundation (ONF) |
| 2 | // |
| 3 | // Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 4 | // the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 5 | // or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 6 | // |
| 7 | // TestON is free software: you can redistribute it and/or modify |
| 8 | // it under the terms of the GNU General Public License as published by |
| 9 | // the Free Software Foundation, either version 2 of the License, or |
| 10 | // (at your option) any later version. |
| 11 | // |
| 12 | // TestON is distributed in the hope that it will be useful, |
| 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | // GNU General Public License for more details. |
| 16 | // |
| 17 | // You should have received a copy of the GNU General Public License |
| 18 | // along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | // This is the Jenkins script for the fabric-pipeline-trigger |
| 21 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 22 | #!groovy |
| 23 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 24 | // init dependencies functions |
Devin Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 25 | funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' ) |
| 26 | test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
| 27 | triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' ) |
| 28 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 29 | |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 30 | fileRelated.init() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 31 | |
| 32 | // set the versions of the onos. |
You Wang | 9af1648 | 2018-05-02 13:45:28 -0700 | [diff] [blame] | 33 | current_version = "master" |
| 34 | previous_version = "1.13" |
| 35 | before_previous_version = "1.12" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 36 | |
| 37 | // Function that will initialize the configuration of the Fabric. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 38 | funcs.initializeTrend( "Fabric" ); |
| 39 | funcs.initialize( "Fabric" ) |
| 40 | triggerFuncs.init( funcs ) |
| 41 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 42 | // Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule |
| 43 | // It will only be used by the VM_BMJenkinsTrigger not in here. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 44 | wikiContents = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 45 | |
| 46 | // Having two different SR and SR1 to allow current_version and previous_version to be run on same machine. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 47 | testcases = [ |
| 48 | "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 49 | "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 50 | "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ], |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 51 | "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ], |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 52 | "SR1" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ], |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 53 | "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ] |
| 54 | ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 55 | |
| 56 | // depends on the First two letter of the testname, it will decide which category to put test. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 57 | Prefix_organizer = [ |
| 58 | "FU" : "FUNC", |
| 59 | "HA" : "HA", |
| 60 | "PL" : "USECASE", |
| 61 | "SA" : "USECASE", |
| 62 | "SC" : "SCPF", |
| 63 | "SR" : "SR", |
| 64 | "US" : "USECASE", |
| 65 | "VP" : "USECASE" |
| 66 | ] |
| 67 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 68 | // set some variables from the parameter |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 69 | manually_run = params.manual_run |
Devin Lim | b6f92de | 2018-04-13 18:27:33 -0700 | [diff] [blame] | 70 | onos_b = current_version |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 71 | test_branch = "" |
| 72 | onos_tag = params.ONOSTag |
| 73 | isOldFlow = true |
| 74 | |
| 75 | // Set tests based on day of week |
| 76 | def now = funcs.getCurrentTime() |
| 77 | print now.toString() |
| 78 | today = now[ Calendar.DAY_OF_WEEK ] |
| 79 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 80 | // if it is manually run, it will set the onos version to be what it was passed by. |
| 81 | // Currently, SR-pipeline-manually is not supported due to the special way of it is executed. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 82 | if ( manually_run ){ |
| 83 | onos_b = params.ONOSVersion |
| 84 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 85 | |
| 86 | // get the list of the tests from the JenkinsTestONTests.groovy |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 87 | AllTheTests = test_lists.getAllTheTests( onos_b ) |
| 88 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 89 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 90 | day = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 91 | |
| 92 | // list of the test on each test category will be run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 93 | SCPF_choices = "" |
| 94 | USECASE_choices = "" |
| 95 | FUNC_choices = "" |
| 96 | HA_choices = "" |
| 97 | SR_choices = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 98 | |
| 99 | // initialize the graph generating files. |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 100 | stat_graph_generator_file = fileRelated.histogramMultiple |
| 101 | pie_graph_generator_file = fileRelated.pieMultiple |
| 102 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/" |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 103 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 104 | // get the post_result. This will be affected only for the manual runs. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 105 | post_result = params.PostResult |
| 106 | if( !manually_run ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 107 | // If it is automated running, it will post the beginning message to the channel. |
Devin Lim | 33fe4e7 | 2018-04-06 19:45:53 -0700 | [diff] [blame] | 108 | slackSend( channel:'sr-failures', color:'#03CD9F', |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 109 | message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n" |
| 110 | + "Starting tests on : " + now.toString() |
| 111 | + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" ) |
| 112 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 113 | // Choices will get the list of the test with Segment Rounting type tests. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 114 | SR_choices += adder( "SR", "basic", true ) |
Devin Lim | be48307 | 2018-03-24 14:37:48 -0700 | [diff] [blame] | 115 | if ( today == Calendar.FRIDAY ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 116 | // if today is Friday, it will also test tests with extra_A category |
Devin Lim | be48307 | 2018-03-24 14:37:48 -0700 | [diff] [blame] | 117 | SR_choices += adder( "SR", "extra_A", true ) |
| 118 | } else if( today == Calendar.SATURDAY ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 119 | // if today is Saturday, it will add the test with extra_B category |
Devin Lim | be48307 | 2018-03-24 14:37:48 -0700 | [diff] [blame] | 120 | SR_choices += adder( "SR", "extra_B", true ) |
| 121 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 122 | // removing last comma added at the end of the last test name. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 123 | SR_choices = triggerFuncs.lastCommaRemover( SR_choices ) |
| 124 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 125 | |
| 126 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 127 | if ( manually_run ){ |
| 128 | testcases = triggerFuncs.organize_tests( params.Tests, testcases ) |
| 129 | |
| 130 | isOldFlow = params.isOldFlow |
| 131 | println "Tests to be run manually : " |
| 132 | }else{ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 133 | // set the list of the tests to run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 134 | testcases[ "SR" ][ "tests" ] = SR_choices |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 135 | testcases[ "SR1" ][ "tests" ] = SR_choices |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 136 | println "Defaulting to " + day + " tests:" |
| 137 | } |
| 138 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 139 | // print out the list of the test to run on Jenkins |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 140 | triggerFuncs.print_tests( testcases ) |
| 141 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 142 | // This will hold the block of code to be run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 143 | def runTest = [ |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 144 | "Fabric2" : [:], |
| 145 | "Fabric3" : [:] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 146 | ] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 147 | if ( manually_run ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 148 | // for manual run situation. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 149 | for( String test in testcases.keySet() ){ |
| 150 | println test |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 151 | // Unless the list of the tests on the test category is empty, it will save the block of code to run in dictionary. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 152 | if ( testcases[ test ][ "tests" ] != "" ){ |
| 153 | runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ], test, manually_run, onos_tag ) |
| 154 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 155 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 156 | }else{ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 157 | // for automated situation, it will save current and previous version to Fabric2 and before_previous_version to Fabric3. |
Devin Lim | 0c25f2f | 2018-05-10 15:43:09 -0700 | [diff] [blame] | 158 | runTest[ "Fabric2" ][ "SR1" ] = triggerFuncs.trigger_pipeline( current_version, testcases[ "SR1" ][ "tests" ], testcases[ "SR1" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 159 | runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag ) |
| 160 | runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 1 ], "SR", manually_run, onos_tag ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 161 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 162 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 163 | def finalList = [:] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 164 | |
| 165 | // It will run each category of test to run sequentially on each branch. |
| 166 | // In our case, it will run SR1 first then SR on Fabric2 and just SR on Fabric3 |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 167 | finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] ) |
| 168 | finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 169 | |
| 170 | // It will then run Fabric2 and Fabric3 to be run concurrently. |
| 171 | // In our case, |
| 172 | // ----> Fabric2 : current -> previous |
| 173 | // This pipeline -----> |
| 174 | // ----> Fabric3 : before_previous |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 175 | parallel finalList |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 176 | |
| 177 | // Way we are generating pie graphs. not supported in SegmentRouting yet. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 178 | /* |
| 179 | if ( !manually_run ){ |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 180 | funcs.generateStatGraph( "TestStation-Fabric2s", |
| 181 | funcs.branchWithPrefix( "master" ), |
| 182 | AllTheTests, |
| 183 | stat_graph_generator_file, |
| 184 | pie_graph_generator_file, |
| 185 | graph_saved_directory ) |
| 186 | funcs.generateStatGraph( "TestStation-Fabric3s", |
| 187 | funcs.branchWithPrefix( "1.12" ), |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 188 | AllTheTests, |
| 189 | stat_graph_generator_file, |
| 190 | pie_graph_generator_file, |
| 191 | graph_saved_directory ) |
| 192 | }*/ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 193 | |
| 194 | // Way to add list of the tests with specific category to the result |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 195 | def adder( testCat, set, getResult ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 196 | // testCat : test Category ( Eg. FUNC, HA, SR ... ) |
| 197 | // set : set of the test ( Eg. basic, extra_A ... ) |
| 198 | // if getResult == true, it will add the result. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 199 | result = "" |
| 200 | for( String test in AllTheTests[ testCat ].keySet() ){ |
| 201 | if( AllTheTests[ testCat ][ test ][ set ] ){ |
| 202 | if( getResult ) |
| 203 | result += test + "," |
| 204 | } |
| 205 | } |
| 206 | return result |
Devin Lim | b6f92de | 2018-04-13 18:27:33 -0700 | [diff] [blame] | 207 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame^] | 208 | |
| 209 | // check which node is on. |
| 210 | // 1.12 runs on Fabric3 and rest on 1.13 and master |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 211 | def nodeOn( branch ){ |
| 212 | return branch == "1.12" ? 1 : 0; |
Devin Lim | 0c25f2f | 2018-05-10 15:43:09 -0700 | [diff] [blame] | 213 | } |