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 the fabric-pipeline-trigger |
| 22 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 23 | // init dependencies functions |
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 | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 28 | |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 29 | fileRelated.init() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 30 | |
| 31 | // set the versions of the onos. |
You Wang | 9af1648 | 2018-05-02 13:45:28 -0700 | [diff] [blame] | 32 | current_version = "master" |
| 33 | previous_version = "1.13" |
| 34 | before_previous_version = "1.12" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 35 | |
| 36 | // Function that will initialize the configuration of the Fabric. |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 37 | funcs.initializeTrend( "Fabric" ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 38 | funcs.initialize( "Fabric" ) |
| 39 | triggerFuncs.init( funcs ) |
| 40 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 41 | // Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule |
| 42 | // It will only be used by the VM_BMJenkinsTrigger not in here. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 43 | wikiContents = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 44 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 45 | testcases = [ |
| 46 | "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 47 | "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ], |
| 48 | "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ], |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 49 | "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3", "Fabric4" ], wikiContent : "" ], |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 50 | "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ] |
| 51 | ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 52 | |
| 53 | // 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] | 54 | Prefix_organizer = [ |
| 55 | "FU" : "FUNC", |
| 56 | "HA" : "HA", |
| 57 | "PL" : "USECASE", |
| 58 | "SA" : "USECASE", |
| 59 | "SC" : "SCPF", |
| 60 | "SR" : "SR", |
| 61 | "US" : "USECASE", |
| 62 | "VP" : "USECASE" |
| 63 | ] |
| 64 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 65 | // set some variables from the parameter |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 66 | manually_run = params.manual_run |
Devin Lim | b6f92de | 2018-04-13 18:27:33 -0700 | [diff] [blame] | 67 | onos_b = current_version |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 68 | test_branch = "" |
| 69 | onos_tag = params.ONOSTag |
| 70 | isOldFlow = true |
| 71 | |
| 72 | // Set tests based on day of week |
| 73 | def now = funcs.getCurrentTime() |
| 74 | print now.toString() |
| 75 | today = now[ Calendar.DAY_OF_WEEK ] |
| 76 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 77 | // if it is manually run, it will set the onos version to be what it was passed by. |
| 78 | // 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] | 79 | if ( manually_run ){ |
| 80 | onos_b = params.ONOSVersion |
| 81 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 82 | |
| 83 | // get the list of the tests from the JenkinsTestONTests.groovy |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 84 | AllTheTests = test_lists.getAllTheTests( onos_b ) |
| 85 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 86 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 87 | day = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 88 | |
| 89 | // list of the test on each test category will be run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 90 | SCPF_choices = "" |
| 91 | USECASE_choices = "" |
| 92 | FUNC_choices = "" |
| 93 | HA_choices = "" |
| 94 | SR_choices = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 95 | |
| 96 | // initialize the graph generating files. |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 97 | stat_graph_generator_file = fileRelated.histogramMultiple |
| 98 | pie_graph_generator_file = fileRelated.pieMultiple |
| 99 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/" |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 100 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 101 | // 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] | 102 | post_result = params.PostResult |
| 103 | if( !manually_run ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 104 | // 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] | 105 | slackSend( channel:'sr-failures', color:'#03CD9F', |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 106 | message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n" |
| 107 | + "Starting tests on : " + now.toString() |
| 108 | + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" ) |
| 109 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 110 | // 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] | 111 | SR_choices += adder( "SR", "basic", true ) |
Devin Lim | be48307 | 2018-03-24 14:37:48 -0700 | [diff] [blame] | 112 | if ( today == Calendar.FRIDAY ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 113 | // 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] | 114 | SR_choices += adder( "SR", "extra_A", true ) |
| 115 | } else if( today == Calendar.SATURDAY ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 116 | // 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] | 117 | SR_choices += adder( "SR", "extra_B", true ) |
| 118 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 119 | // removing last comma added at the end of the last test name. |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 120 | SR_choices = triggerFuncs.lastCommaRemover( SR_choices ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 121 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 122 | |
| 123 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 124 | if ( manually_run ){ |
| 125 | testcases = triggerFuncs.organize_tests( params.Tests, testcases ) |
| 126 | |
| 127 | isOldFlow = params.isOldFlow |
| 128 | println "Tests to be run manually : " |
| 129 | }else{ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 130 | // set the list of the tests to run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 131 | testcases[ "SR" ][ "tests" ] = SR_choices |
| 132 | println "Defaulting to " + day + " tests:" |
| 133 | } |
| 134 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 135 | // print out the list of the test to run on Jenkins |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 136 | triggerFuncs.print_tests( testcases ) |
| 137 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 138 | // This will hold the block of code to be run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 139 | def runTest = [ |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 140 | "Fabric2" : [:], |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 141 | "Fabric3" : [:], |
| 142 | "Fabric4" : [:] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 143 | ] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 144 | if ( manually_run ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 145 | // for manual run situation. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 146 | for( String test in testcases.keySet() ){ |
| 147 | println test |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 148 | // 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] | 149 | if ( testcases[ test ][ "tests" ] != "" ){ |
| 150 | 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 ) |
| 151 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 152 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 153 | }else{ |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 154 | // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3. |
| 155 | runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 2 ], "SR", manually_run, onos_tag ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 156 | runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag ) |
| 157 | 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] | 158 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 159 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 160 | def finalList = [:] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 161 | |
| 162 | // It will run each category of test to run sequentially on each branch. |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 163 | finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] ) |
| 164 | finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] ) |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 165 | finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 166 | |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 167 | // It will then run Fabric2, Fabric3 and Fabric4 concurrently. |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 168 | // In our case, |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 169 | // ----> Fabric4 : current_version |
| 170 | // This pipeline -----> ----> Fabric2 : previous_version |
| 171 | // ----> Fabric3 : before_previous_version |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 172 | parallel finalList |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 173 | |
| 174 | // Way we are generating pie graphs. not supported in SegmentRouting yet. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 175 | /* |
| 176 | if ( !manually_run ){ |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 177 | funcs.generateStatGraph( "TestStation-Fabric4s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame^] | 178 | funcs.branchWithPrefix( current_version ), |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 179 | AllTheTests, |
| 180 | stat_graph_generator_file, |
| 181 | pie_graph_generator_file, |
| 182 | graph_saved_directory ) |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 183 | funcs.generateStatGraph( "TestStation-Fabric2s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame^] | 184 | funcs.branchWithPrefix( previous_version ), |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 185 | AllTheTests, |
| 186 | stat_graph_generator_file, |
| 187 | pie_graph_generator_file, |
| 188 | graph_saved_directory ) |
| 189 | funcs.generateStatGraph( "TestStation-Fabric3s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame^] | 190 | funcs.branchWithPrefix( before_previous_version ), |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 191 | AllTheTests, |
| 192 | stat_graph_generator_file, |
| 193 | pie_graph_generator_file, |
| 194 | graph_saved_directory ) |
| 195 | }*/ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 196 | |
| 197 | // 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] | 198 | def adder( testCat, set, getResult ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 199 | // testCat : test Category ( Eg. FUNC, HA, SR ... ) |
| 200 | // set : set of the test ( Eg. basic, extra_A ... ) |
| 201 | // if getResult == true, it will add the result. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 202 | result = "" |
| 203 | for( String test in AllTheTests[ testCat ].keySet() ){ |
| 204 | if( AllTheTests[ testCat ][ test ][ set ] ){ |
| 205 | if( getResult ) |
| 206 | result += test + "," |
| 207 | } |
| 208 | } |
| 209 | return result |
Devin Lim | b6f92de | 2018-04-13 18:27:33 -0700 | [diff] [blame] | 210 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 211 | |
| 212 | // check which node is on. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 213 | def nodeOn( branch ){ |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 214 | switch( branch ) { |
| 215 | case current_version: return 2 |
| 216 | case previous_version: return 0 |
| 217 | case before_previous_version: return 1 |
| 218 | default: return 2 |
| 219 | } |
Devin Lim | 0c25f2f | 2018-05-10 15:43:09 -0700 | [diff] [blame] | 220 | } |