blob: 349324bb20afaeb942d69d4e99baede92a374989 [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' )
25test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
26triggerFuncs = 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()
Devin Limf5175192018-05-14 19:13:22 -070030
31// set the versions of the onos.
You Wang9af16482018-05-02 13:45:28 -070032current_version = "master"
33previous_version = "1.13"
34before_previous_version = "1.12"
Devin Limf5175192018-05-14 19:13:22 -070035
36// Function that will initialize the configuration of the Fabric.
You Wang96b98ad2018-05-25 12:14:45 -070037funcs.initializeTrend( "Fabric" )
Devin Lim431408d2018-03-23 17:51:31 -070038funcs.initialize( "Fabric" )
39triggerFuncs.init( funcs )
40
Devin Limf5175192018-05-14 19:13:22 -070041// 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 Lim431408d2018-03-23 17:51:31 -070043wikiContents = ""
Devin Limf5175192018-05-14 19:13:22 -070044
Devin Lim431408d2018-03-23 17:51:31 -070045testcases = [
Jon Hall6af749d2018-05-29 12:59:47 -070046 "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 Hall2ee92f82018-06-07 13:07:33 -070050 "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
Jon Hall6af749d2018-05-29 12:59:47 -070051 "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
Devin Lim431408d2018-03-23 17:51:31 -070052]
53
Devin Limf5175192018-05-14 19:13:22 -070054// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070055manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070056onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070057test_branch = ""
58onos_tag = params.ONOSTag
59isOldFlow = true
60
61// Set tests based on day of week
62def now = funcs.getCurrentTime()
63print now.toString()
64today = now[ Calendar.DAY_OF_WEEK ]
65
Devin Limf5175192018-05-14 19:13:22 -070066// 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 Lim431408d2018-03-23 17:51:31 -070068if ( manually_run ){
69 onos_b = params.ONOSVersion
70}
Devin Limf5175192018-05-14 19:13:22 -070071
72// get the list of the tests from the JenkinsTestONTests.groovy
Devin Lim431408d2018-03-23 17:51:31 -070073AllTheTests = test_lists.getAllTheTests( onos_b )
74
Devin Limf5175192018-05-14 19:13:22 -070075
Devin Lim431408d2018-03-23 17:51:31 -070076day = ""
Devin Limf5175192018-05-14 19:13:22 -070077
78// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070079SCPF_choices = ""
80USECASE_choices = ""
81FUNC_choices = ""
82HA_choices = ""
83SR_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070084
85// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070086stat_graph_generator_file = fileRelated.histogramMultiple
87pie_graph_generator_file = fileRelated.pieMultiple
88graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070089
Devin Limf5175192018-05-14 19:13:22 -070090// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070091post_result = params.PostResult
Jon Hall6af749d2018-05-29 12:59:47 -070092if ( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -070093 // If it is automated running, it will post the beginning message to the channel.
Jon Hall6af749d2018-05-29 12:59:47 -070094 slackSend( channel: 'sr-failures', color: '#03CD9F',
95 message: ":sparkles:" * 16 + "\n" +
96 "Starting tests on : " + now.toString() +
97 "\n" + ":sparkles:" * 16 )
Devin Lim431408d2018-03-23 17:51:31 -070098
Jon Hall6af749d2018-05-29 12:59:47 -070099 // Choices will get the list of the test with Segment Routing type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700100 SR_choices += adder( "SR", "basic", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700101 SRHA_choices += adder( "SRHA", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700102 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700103 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700104 SR_choices += adder( "SR", "extra_A", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700105 SRHA_choices += adder( "SRHA", "extra_A", true )
Jon Hall6af749d2018-05-29 12:59:47 -0700106 }
107 else if ( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700108 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700109 SR_choices += adder( "SR", "extra_B", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700110 SRHA_choices += adder( "SRHA", "extra_B", true )
Devin Limbe483072018-03-24 14:37:48 -0700111 }
Devin Limf5175192018-05-14 19:13:22 -0700112 // removing last comma added at the end of the last test name.
You Wang96b98ad2018-05-25 12:14:45 -0700113 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Jon Hall2ee92f82018-06-07 13:07:33 -0700114 SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices )
115
Devin Lim431408d2018-03-23 17:51:31 -0700116}
Devin Limf5175192018-05-14 19:13:22 -0700117
118
Devin Lim431408d2018-03-23 17:51:31 -0700119if ( manually_run ){
120 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
121
122 isOldFlow = params.isOldFlow
123 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700124}
125else {
Devin Limf5175192018-05-14 19:13:22 -0700126 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700127 testcases[ "SR" ][ "tests" ] = SR_choices
Jon Hall2ee92f82018-06-07 13:07:33 -0700128 testcases[ "SRHA" ][ "tests" ] = SRHA_choices
Devin Lim431408d2018-03-23 17:51:31 -0700129 println "Defaulting to " + day + " tests:"
130}
131
Devin Limf5175192018-05-14 19:13:22 -0700132// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700133triggerFuncs.print_tests( testcases )
134
Devin Limf5175192018-05-14 19:13:22 -0700135// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700136def runTest = [
Jon Hall2ee92f82018-06-07 13:07:33 -0700137 "Fabric": [ : ],
Jon Hall6af749d2018-05-29 12:59:47 -0700138 "Fabric2": [ : ],
139 "Fabric3": [ : ],
140 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700141]
Devin Lim2edfcec2018-05-09 17:16:21 -0700142if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700143 // for manual run situation.
Jon Hall6af749d2018-05-29 12:59:47 -0700144 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700145 println test
Devin Limf5175192018-05-14 19:13:22 -0700146 // 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 -0700147 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700148 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
149 trigger_pipeline( onos_b,
150 testcases[ test ][ "tests" ],
151 testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
152 test,
153 manually_run,
154 onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700155 }
Devin Lim431408d2018-03-23 17:51:31 -0700156 }
Jon Hall6af749d2018-05-29 12:59:47 -0700157}
158else {
You Wang96b98ad2018-05-25 12:14:45 -0700159 // 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 -0700160 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
161 testcases[ "SR" ][ "tests" ],
162 testcases[ "SR" ][ "nodeName" ][ 2 ],
163 "SR",
164 manually_run, onos_tag )
165 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
166 testcases[ "SR" ][ "tests" ],
167 testcases[ "SR" ][ "nodeName" ][ 0 ],
168 "SR",
169 manually_run, onos_tag )
170 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
171 testcases[ "SR" ][ "tests" ],
172 testcases[ "SR" ][ "nodeName" ][ 1 ],
173 "SR",
174 manually_run, onos_tag )
Jon Hall2ee92f82018-06-07 13:07:33 -0700175 runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( current_version,
176 testcases[ "SRHA" ][ "tests" ],
177 testcases[ "SRHA" ][ "nodeName" ],
178 "SRHA",
179 manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700180}
Devin Lim2edfcec2018-05-09 17:16:21 -0700181
Jon Hall6af749d2018-05-29 12:59:47 -0700182def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700183
184// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700185finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700186finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
187finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700188finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700189
You Wang96b98ad2018-05-25 12:14:45 -0700190// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700191// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700192// ----> Fabric4 : current_version
193// This pipeline -----> ----> Fabric2 : previous_version
194// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700195parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700196
197// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700198/*
199if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700200 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700201 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700202 AllTheTests,
203 stat_graph_generator_file,
204 pie_graph_generator_file,
205 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700206 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700207 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700208 AllTheTests,
209 stat_graph_generator_file,
210 pie_graph_generator_file,
211 graph_saved_directory )
212 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700213 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700214 AllTheTests,
215 stat_graph_generator_file,
216 pie_graph_generator_file,
217 graph_saved_directory )
218}*/
Devin Limf5175192018-05-14 19:13:22 -0700219
220// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700221def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700222 // testCat : test Category ( Eg. FUNC, HA, SR ... )
223 // set : set of the test ( Eg. basic, extra_A ... )
224 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700225 result = ""
Jon Hall6af749d2018-05-29 12:59:47 -0700226 for ( String test in AllTheTests[ testCat ].keySet() ){
227 if ( AllTheTests[ testCat ][ test ][ set ] ){
228 if ( getResult ){
Devin Lim431408d2018-03-23 17:51:31 -0700229 result += test + ","
Jon Hall6af749d2018-05-29 12:59:47 -0700230 }
Devin Lim431408d2018-03-23 17:51:31 -0700231 }
232 }
233 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700234}
Devin Limf5175192018-05-14 19:13:22 -0700235
236// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700237def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700238 switch ( branch ){
You Wang96b98ad2018-05-25 12:14:45 -0700239 case current_version: return 2
240 case previous_version: return 0
241 case before_previous_version: return 1
242 default: return 2
243 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700244}