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