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