blob: b958d17ae4b8d59a713fdf9be4e4b0800b59e437 [file] [log] [blame]
Devin Lime1346f42018-05-15 15:41:36 -07001#!groovy
Devin Limf5175192018-05-14 19:13:22 -07002// 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 Limf5175192018-05-14 19:13:22 -070023// init dependencies functions
Devin Limb734ea52018-05-14 14:13:05 -070024funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070025test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
Devin Limb734ea52018-05-14 14:13:05 -070026triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
27fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Devin Lim431408d2018-03-23 17:51:31 -070028
Devin Limfe9a4cb2018-05-11 17:06:21 -070029fileRelated.init()
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070030test_list.init()
Devin Limf5175192018-05-14 19:13:22 -070031
Devin Limf5175192018-05-14 19:13:22 -070032// Function that will initialize the configuration of the Fabric.
You Wang96b98ad2018-05-25 12:14:45 -070033funcs.initializeTrend( "Fabric" )
Devin Lim431408d2018-03-23 17:51:31 -070034funcs.initialize( "Fabric" )
35triggerFuncs.init( funcs )
36
Devin Limf5175192018-05-14 19:13:22 -070037// 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 Lim431408d2018-03-23 17:51:31 -070039wikiContents = ""
Devin Limf5175192018-05-14 19:13:22 -070040
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070041all_testcases = [:]
Devin Lim431408d2018-03-23 17:51:31 -070042
Devin Limf5175192018-05-14 19:13:22 -070043// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070044manually_run = params.manual_run
Devin Lim431408d2018-03-23 17:51:31 -070045onos_tag = params.ONOSTag
46isOldFlow = true
47
48// Set tests based on day of week
49def now = funcs.getCurrentTime()
50print now.toString()
51today = now[ Calendar.DAY_OF_WEEK ]
52
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070053dayMap = [ ( 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" ]
60fullDayMap = [ ( 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 Limf5175192018-05-14 19:13:22 -070069// 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 Lim431408d2018-03-23 17:51:31 -070071if ( manually_run ){
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070072 onos_branches = params.branches.tokenize( "\n;, " )
73} else {
74 onos_branches = test_list.getBranchesFromDay( today )
Devin Lim431408d2018-03-23 17:51:31 -070075}
Devin Limf5175192018-05-14 19:13:22 -070076
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070077testcases_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 Lim431408d2018-03-23 17:51:31 -070085
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070086for ( String b in onos_branches ){
87 all_testcases.put( b, testcases_template )
88}
Devin Limf5175192018-05-14 19:13:22 -070089
Devin Lim431408d2018-03-23 17:51:31 -070090day = ""
Devin Limf5175192018-05-14 19:13:22 -070091
Devin Limf5175192018-05-14 19:13:22 -070092// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070093stat_graph_generator_file = fileRelated.histogramMultiple
94pie_graph_generator_file = fileRelated.pieMultiple
95graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070096
Devin Limf5175192018-05-14 19:13:22 -070097// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070098post_result = params.PostResult
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070099
100if ( 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 Limf5175192018-05-14 19:13:22 -0700107 // If it is automated running, it will post the beginning message to the channel.
Jon Hall6af749d2018-05-29 12:59:47 -0700108 slackSend( channel: 'sr-failures', color: '#03CD9F',
109 message: ":sparkles:" * 16 + "\n" +
110 "Starting tests on : " + now.toString() +
111 "\n" + ":sparkles:" * 16 )
Devin Lim431408d2018-03-23 17:51:31 -0700112
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700113 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 Lim431408d2018-03-23 17:51:31 -0700118 println "Defaulting to " + day + " tests:"
119}
120
Devin Limf5175192018-05-14 19:13:22 -0700121// print out the list of the test to run on Jenkins
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700122for ( String b in onos_branches ){
123 triggerFuncs.print_tests( all_testcases[ b ] )
124}
Devin Lim431408d2018-03-23 17:51:31 -0700125
Devin Limf5175192018-05-14 19:13:22 -0700126// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700127def runTest = [
Jon Hall2ee92f82018-06-07 13:07:33 -0700128 "Fabric": [ : ],
Jon Hall6af749d2018-05-29 12:59:47 -0700129 "Fabric2": [ : ],
130 "Fabric3": [ : ],
131 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700132]
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700133for ( 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 Lim2edfcec2018-05-09 17:16:21 -0700148 }
Devin Lim431408d2018-03-23 17:51:31 -0700149 }
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700150 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 Lim431408d2018-03-23 17:51:31 -0700173}
Devin Lim2edfcec2018-05-09 17:16:21 -0700174
Jon Hall6af749d2018-05-29 12:59:47 -0700175def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700176
177// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700178finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700179finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
180finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700181finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700182
You Wang96b98ad2018-05-25 12:14:45 -0700183// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700184// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700185// ----> Fabric4 : current_version
186// This pipeline -----> ----> Fabric2 : previous_version
187// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700188parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700189
190// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700191/*
192if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700193 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700194 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700195 AllTheTests,
196 stat_graph_generator_file,
197 pie_graph_generator_file,
198 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700199 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700200 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700201 AllTheTests,
202 stat_graph_generator_file,
203 pie_graph_generator_file,
204 graph_saved_directory )
205 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700206 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700207 AllTheTests,
208 stat_graph_generator_file,
209 pie_graph_generator_file,
210 graph_saved_directory )
211}*/
Devin Limf5175192018-05-14 19:13:22 -0700212
213// Way to add list of the tests with specific category to the result
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700214def adder( category, day, getResult, branch ){
Jeremy Ronquillofdf65582019-05-21 21:07:05 -0700215 // 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 Ronquilloa37920b2019-05-23 14:34:25 -0700220 selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700221
222 for ( String test in selectedTests.keySet() ){
223 if ( getResult ){
224 result += test + ","
Devin Lim431408d2018-03-23 17:51:31 -0700225 }
226 }
227 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700228}
Devin Limf5175192018-05-14 19:13:22 -0700229
230// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700231def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700232 switch ( branch ){
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700233 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 Wang96b98ad2018-05-25 12:14:45 -0700237 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700238}