blob: d54231a00bb020dcf2a18b07798e1cb641219ae7 [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
32// set the versions of the onos.
You Wang9af16482018-05-02 13:45:28 -070033current_version = "master"
You Wang8f12d7d2018-11-09 13:47:23 -080034previous_version = "1.15"
You Wangf043d0a2019-04-22 16:30:40 -070035before_previous_version = "2.1"
Devin Limf5175192018-05-14 19:13:22 -070036
37// Function that will initialize the configuration of the Fabric.
You Wang96b98ad2018-05-25 12:14:45 -070038funcs.initializeTrend( "Fabric" )
Devin Lim431408d2018-03-23 17:51:31 -070039funcs.initialize( "Fabric" )
40triggerFuncs.init( funcs )
41
Devin Limf5175192018-05-14 19:13:22 -070042// Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule
43// It will only be used by the VM_BMJenkinsTrigger not in here.
Devin Lim431408d2018-03-23 17:51:31 -070044wikiContents = ""
Devin Limf5175192018-05-14 19:13:22 -070045
Devin Lim431408d2018-03-23 17:51:31 -070046testcases = [
Jon Hall6af749d2018-05-29 12:59:47 -070047 "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ],
48 "HA": [ tests: "", nodeName: "VM", wikiContent: "" ],
49 "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ],
50 "SR": [ tests: "", nodeName: [ "Fabric2", "Fabric3", "Fabric4" ], wikiContent: "" ],
Jon Hall2ee92f82018-06-07 13:07:33 -070051 "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
Jon Hall6af749d2018-05-29 12:59:47 -070052 "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
Devin Lim431408d2018-03-23 17:51:31 -070053]
54
Devin Limf5175192018-05-14 19:13:22 -070055// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070056manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070057onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070058test_branch = ""
59onos_tag = params.ONOSTag
60isOldFlow = true
61
62// Set tests based on day of week
63def now = funcs.getCurrentTime()
64print now.toString()
65today = now[ Calendar.DAY_OF_WEEK ]
66
Devin Limf5175192018-05-14 19:13:22 -070067// if it is manually run, it will set the onos version to be what it was passed by.
68// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070069if ( manually_run ){
70 onos_b = params.ONOSVersion
71}
Devin Limf5175192018-05-14 19:13:22 -070072
73// get the list of the tests from the JenkinsTestONTests.groovy
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070074// AllTheTests = test_list.getAllTests()
Devin Lim431408d2018-03-23 17:51:31 -070075
Devin Limf5175192018-05-14 19:13:22 -070076
Devin Lim431408d2018-03-23 17:51:31 -070077day = ""
Devin Limf5175192018-05-14 19:13:22 -070078
79// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070080SCPF_choices = ""
81USECASE_choices = ""
82FUNC_choices = ""
83HA_choices = ""
84SR_choices = ""
You Wang38ad08f2018-06-10 15:55:48 -070085SRHA_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070086
87// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070088stat_graph_generator_file = fileRelated.histogramMultiple
89pie_graph_generator_file = fileRelated.pieMultiple
90graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070091
Devin Limf5175192018-05-14 19:13:22 -070092// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070093post_result = params.PostResult
Jon Hall6af749d2018-05-29 12:59:47 -070094if ( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -070095 // If it is automated running, it will post the beginning message to the channel.
Jon Hall6af749d2018-05-29 12:59:47 -070096 slackSend( channel: 'sr-failures', color: '#03CD9F',
97 message: ":sparkles:" * 16 + "\n" +
98 "Starting tests on : " + now.toString() +
99 "\n" + ":sparkles:" * 16 )
Devin Lim431408d2018-03-23 17:51:31 -0700100
Jeremy Ronquillofdf65582019-05-21 21:07:05 -0700101 dayMap = [ ( Calendar.MONDAY ) : "mon",
102 ( Calendar.TUESDAY ) : "tue",
103 ( Calendar.WEDNESDAY ) : "wed",
104 ( Calendar.THURSDAY ) : "thu",
105 ( Calendar.FRIDAY ) : "fri",
106 ( Calendar.SATURDAY ) : "sat",
107 ( Calendar.SUNDAY ) : "sun" ]
108
109 SR_choices += adder( "SR", dayMap[ today ], true )
110 SRHA_choices += adder( "SRHA", dayMap[ today ], true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700111
Devin Lim431408d2018-03-23 17:51:31 -0700112}
Devin Limf5175192018-05-14 19:13:22 -0700113
114
Devin Lim431408d2018-03-23 17:51:31 -0700115if ( manually_run ){
116 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
117
118 isOldFlow = params.isOldFlow
119 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700120}
121else {
Devin Limf5175192018-05-14 19:13:22 -0700122 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700123 testcases[ "SR" ][ "tests" ] = SR_choices
Jon Hall2ee92f82018-06-07 13:07:33 -0700124 testcases[ "SRHA" ][ "tests" ] = SRHA_choices
Devin Lim431408d2018-03-23 17:51:31 -0700125 println "Defaulting to " + day + " tests:"
126}
127
Devin Limf5175192018-05-14 19:13:22 -0700128// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700129triggerFuncs.print_tests( testcases )
130
Devin Limf5175192018-05-14 19:13:22 -0700131// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700132def runTest = [
Jon Hall2ee92f82018-06-07 13:07:33 -0700133 "Fabric": [ : ],
Jon Hall6af749d2018-05-29 12:59:47 -0700134 "Fabric2": [ : ],
135 "Fabric3": [ : ],
136 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700137]
Devin Lim2edfcec2018-05-09 17:16:21 -0700138if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700139 // for manual run situation.
Jon Hall6af749d2018-05-29 12:59:47 -0700140 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700141 println test
Devin Limf5175192018-05-14 19:13:22 -0700142 // Unless the list of the tests on the test category is empty, it will save the block of code to run in dictionary.
Devin Lim2edfcec2018-05-09 17:16:21 -0700143 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700144 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
145 trigger_pipeline( onos_b,
146 testcases[ test ][ "tests" ],
147 testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
148 test,
149 manually_run,
150 onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700151 }
Devin Lim431408d2018-03-23 17:51:31 -0700152 }
Jon Hall6af749d2018-05-29 12:59:47 -0700153}
154else {
You Wang96b98ad2018-05-25 12:14:45 -0700155 // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3.
Jon Hall6af749d2018-05-29 12:59:47 -0700156 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
157 testcases[ "SR" ][ "tests" ],
158 testcases[ "SR" ][ "nodeName" ][ 2 ],
159 "SR",
160 manually_run, onos_tag )
161 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
162 testcases[ "SR" ][ "tests" ],
163 testcases[ "SR" ][ "nodeName" ][ 0 ],
164 "SR",
165 manually_run, onos_tag )
166 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
167 testcases[ "SR" ][ "tests" ],
168 testcases[ "SR" ][ "nodeName" ][ 1 ],
169 "SR",
170 manually_run, onos_tag )
Jon Hall2ee92f82018-06-07 13:07:33 -0700171 runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( current_version,
172 testcases[ "SRHA" ][ "tests" ],
173 testcases[ "SRHA" ][ "nodeName" ],
174 "SRHA",
175 manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700176}
Devin Lim2edfcec2018-05-09 17:16:21 -0700177
Jon Hall6af749d2018-05-29 12:59:47 -0700178def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700179
180// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700181finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700182finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
183finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700184finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700185
You Wang96b98ad2018-05-25 12:14:45 -0700186// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700187// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700188// ----> Fabric4 : current_version
189// This pipeline -----> ----> Fabric2 : previous_version
190// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700191parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700192
193// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700194/*
195if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700196 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700197 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700198 AllTheTests,
199 stat_graph_generator_file,
200 pie_graph_generator_file,
201 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700202 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700203 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700204 AllTheTests,
205 stat_graph_generator_file,
206 pie_graph_generator_file,
207 graph_saved_directory )
208 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700209 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700210 AllTheTests,
211 stat_graph_generator_file,
212 pie_graph_generator_file,
213 graph_saved_directory )
214}*/
Devin Limf5175192018-05-14 19:13:22 -0700215
216// Way to add list of the tests with specific category to the result
Jeremy Ronquillofdf65582019-05-21 21:07:05 -0700217def adder( category, day, getResult ){
218 // category : the category of the test which will be either FUNC,HA,SR...
219 // day : the day you are trying to add (m,t,w,th... )
220 // getResult : if want to get the list of the test to be run. False will return empty list.
221 // And once the list is empty, it will not be run.
222 def result = ""
223 selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, onos_b ) )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700224
225 for ( String test in selectedTests.keySet() ){
226 if ( getResult ){
227 result += test + ","
Devin Lim431408d2018-03-23 17:51:31 -0700228 }
229 }
230 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700231}
Devin Limf5175192018-05-14 19:13:22 -0700232
233// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700234def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700235 switch ( branch ){
You Wang96b98ad2018-05-25 12:14:45 -0700236 case current_version: return 2
237 case previous_version: return 0
238 case before_previous_version: return 1
239 default: return 2
240 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700241}