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' ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 25 | test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
Devin Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 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() |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 30 | test_list.init() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 31 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 32 | // Function that will initialize the configuration of the Fabric. |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 33 | funcs.initializeTrend( "Fabric" ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 34 | funcs.initialize( "Fabric" ) |
| 35 | triggerFuncs.init( funcs ) |
| 36 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 37 | // Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule |
| 38 | // It will only be used by the VM_BMJenkinsTrigger not in here. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 39 | wikiContents = "" |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 40 | |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 41 | all_testcases = [:] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 42 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 43 | // set some variables from the parameter |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 44 | manually_run = params.manual_run |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 45 | onos_tag = params.ONOSTag |
| 46 | isOldFlow = true |
| 47 | |
| 48 | // Set tests based on day of week |
| 49 | def now = funcs.getCurrentTime() |
| 50 | print now.toString() |
| 51 | today = now[ Calendar.DAY_OF_WEEK ] |
| 52 | |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 53 | dayMap = [ ( Calendar.MONDAY ) : "mon", |
| 54 | ( Calendar.TUESDAY ) : "tue", |
| 55 | ( Calendar.WEDNESDAY ) : "wed", |
| 56 | ( Calendar.THURSDAY ) : "thu", |
| 57 | ( Calendar.FRIDAY ) : "fri", |
| 58 | ( Calendar.SATURDAY ) : "sat", |
| 59 | ( Calendar.SUNDAY ) : "sun" ] |
| 60 | fullDayMap = [ ( Calendar.MONDAY ) : "Monday", |
| 61 | ( Calendar.TUESDAY ) : "Tuesday", |
| 62 | ( Calendar.WEDNESDAY ) : "Wednesday", |
| 63 | ( Calendar.THURSDAY ) : "Thursday", |
| 64 | ( Calendar.FRIDAY ) : "Friday", |
| 65 | ( Calendar.SATURDAY ) : "Saturday", |
| 66 | ( Calendar.SUNDAY ) : "Sunday" ] |
| 67 | |
| 68 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 69 | // if it is manually run, it will set the onos version to be what it was passed by. |
| 70 | // 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] | 71 | if ( manually_run ){ |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 72 | onos_branches = params.branches.tokenize( "\n;, " ) |
| 73 | } else { |
| 74 | onos_branches = test_list.getBranchesFromDay( today ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 75 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 76 | |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 77 | testcases_template = [ |
| 78 | "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| 79 | "HA": [ tests: "", nodeName: "VM", wikiContent: "" ], |
| 80 | "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ], |
| 81 | "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ], |
| 82 | "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ], |
| 83 | "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ] |
| 84 | ] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 85 | |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 86 | for ( String b in onos_branches ){ |
| 87 | all_testcases.put( b, testcases_template ) |
| 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 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 92 | // initialize the graph generating files. |
Devin Lim | fe9a4cb | 2018-05-11 17:06:21 -0700 | [diff] [blame] | 93 | stat_graph_generator_file = fileRelated.histogramMultiple |
| 94 | pie_graph_generator_file = fileRelated.pieMultiple |
| 95 | graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/" |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 96 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 97 | // 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] | 98 | post_result = params.PostResult |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 99 | |
| 100 | if ( manually_run ){ |
| 101 | for ( String b in onos_branches ){ |
| 102 | all_testcases[ b ] = triggerFuncs.organize_tests( params.Tests, all_testcases[ b ] ) |
| 103 | } |
| 104 | isOldFlow = params.isOldFlow |
| 105 | println "Tests to be run manually : " |
| 106 | } else { |
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. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 108 | slackSend( channel: 'sr-failures', color: '#03CD9F', |
| 109 | message: ":sparkles:" * 16 + "\n" + |
| 110 | "Starting tests on : " + now.toString() + |
| 111 | "\n" + ":sparkles:" * 16 ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 112 | |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 113 | for ( String b in onos_branches ){ |
| 114 | // set the list of the tests to run. |
| 115 | all_testcases[ b ][ "SR" ][ "tests" ] += adder( "SR", dayMap[ today ], true, b ) |
| 116 | all_testcases[ b ][ "SRHA" ][ "tests" ] += adder( "SRHA", dayMap[ today ], true, b ) |
| 117 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 118 | println "Defaulting to " + day + " tests:" |
| 119 | } |
| 120 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 121 | // print out the list of the test to run on Jenkins |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 122 | for ( String b in onos_branches ){ |
| 123 | triggerFuncs.print_tests( all_testcases[ b ] ) |
| 124 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 125 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 126 | // This will hold the block of code to be run. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 127 | def runTest = [ |
Jon Hall | 2ee92f8 | 2018-06-07 13:07:33 -0700 | [diff] [blame] | 128 | "Fabric": [ : ], |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 129 | "Fabric2": [ : ], |
| 130 | "Fabric3": [ : ], |
| 131 | "Fabric4": [ : ] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 132 | ] |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 133 | for ( String b in onos_branches ){ |
| 134 | if ( manually_run ){ |
| 135 | // for manual run situation. |
| 136 | for ( String test in all_testcases[ b ].keySet() ){ |
| 137 | println test |
| 138 | // Unless the list of the tests on the test category is empty, it will save the block of code to run in dictionary. |
| 139 | if ( all_testcases[ b ][ test ][ "tests" ] != "" ){ |
| 140 | runTest[ all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( b ) ] ][ test ] = triggerFuncs. |
| 141 | trigger_pipeline( b, |
| 142 | all_testcases[ b ][ test ][ "tests" ], |
| 143 | all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( b ) ], |
| 144 | test, |
| 145 | manually_run, |
| 146 | onos_tag ) |
| 147 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 148 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 149 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 150 | else { |
| 151 | // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3. |
| 152 | runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( "master", |
| 153 | all_testcases[ b ][ "SR" ][ "tests" ], |
| 154 | all_testcases[ b ][ "SR" ][ "nodeName" ][ 2 ], |
| 155 | "SR", |
| 156 | manually_run, onos_tag ) |
| 157 | runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-2.x" ), |
| 158 | all_testcases[ b ][ "SR" ][ "tests" ], |
| 159 | all_testcases[ b ][ "SR" ][ "nodeName" ][ 0 ], |
| 160 | "SR", |
| 161 | manually_run, onos_tag ) |
| 162 | runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-1.x" ), |
| 163 | all_testcases[ b ][ "SR" ][ "tests" ], |
| 164 | all_testcases[ b ][ "SR" ][ "nodeName" ][ 1 ], |
| 165 | "SR", |
| 166 | manually_run, onos_tag ) |
| 167 | runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( "master", |
| 168 | all_testcases[ b ][ "SRHA" ][ "tests" ], |
| 169 | all_testcases[ b ][ "SRHA" ][ "nodeName" ], |
| 170 | "SRHA", |
| 171 | manually_run, onos_tag ) |
| 172 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 173 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 174 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 175 | def finalList = [ : ] |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 176 | |
| 177 | // 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] | 178 | finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] ) |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 179 | finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] ) |
| 180 | finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] ) |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 181 | finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] ) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 182 | |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 183 | // It will then run Fabric2, Fabric3 and Fabric4 concurrently. |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 184 | // In our case, |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 185 | // ----> Fabric4 : current_version |
| 186 | // This pipeline -----> ----> Fabric2 : previous_version |
| 187 | // ----> Fabric3 : before_previous_version |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 188 | parallel finalList |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 189 | |
| 190 | // Way we are generating pie graphs. not supported in SegmentRouting yet. |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 191 | /* |
| 192 | if ( !manually_run ){ |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 193 | funcs.generateStatGraph( "TestStation-Fabric4s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame] | 194 | funcs.branchWithPrefix( current_version ), |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 195 | AllTheTests, |
| 196 | stat_graph_generator_file, |
| 197 | pie_graph_generator_file, |
| 198 | graph_saved_directory ) |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 199 | funcs.generateStatGraph( "TestStation-Fabric2s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame] | 200 | funcs.branchWithPrefix( previous_version ), |
Devin Lim | 86e4053 | 2018-04-06 12:44:06 -0700 | [diff] [blame] | 201 | AllTheTests, |
| 202 | stat_graph_generator_file, |
| 203 | pie_graph_generator_file, |
| 204 | graph_saved_directory ) |
| 205 | funcs.generateStatGraph( "TestStation-Fabric3s", |
Devin Lim | c8ecd6c | 2018-05-25 13:27:22 -0700 | [diff] [blame] | 206 | funcs.branchWithPrefix( before_previous_version ), |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 207 | AllTheTests, |
| 208 | stat_graph_generator_file, |
| 209 | pie_graph_generator_file, |
| 210 | graph_saved_directory ) |
| 211 | }*/ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 212 | |
| 213 | // Way to add list of the tests with specific category to the result |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 214 | def adder( category, day, getResult, branch ){ |
Jeremy Ronquillo | fdf6558 | 2019-05-21 21:07:05 -0700 | [diff] [blame] | 215 | // category : the category of the test which will be either FUNC,HA,SR... |
| 216 | // day : the day you are trying to add (m,t,w,th... ) |
| 217 | // getResult : if want to get the list of the test to be run. False will return empty list. |
| 218 | // And once the list is empty, it will not be run. |
| 219 | def result = "" |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 220 | selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 221 | |
| 222 | for ( String test in selectedTests.keySet() ){ |
| 223 | if ( getResult ){ |
| 224 | result += test + "," |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | return result |
Devin Lim | b6f92de | 2018-04-13 18:27:33 -0700 | [diff] [blame] | 228 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 229 | |
| 230 | // check which node is on. |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 231 | def nodeOn( branch ){ |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 232 | switch ( branch ){ |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame^] | 233 | case "master": return 2 |
| 234 | case convertBranchCodeToBranch( "onos-2.x" ): return 0 |
| 235 | case convertBranchCodeToBranch( "onos-1.x" ): return 1 |
| 236 | default: return 3 |
You Wang | 96b98ad | 2018-05-25 12:14:45 -0700 | [diff] [blame] | 237 | } |
Devin Lim | 0c25f2f | 2018-05-10 15:43:09 -0700 | [diff] [blame] | 238 | } |