blob: 04695f758dcf726b75fa4288472ed2c75fe0c7f9 [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: "" ],
50 "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
Devin Lim431408d2018-03-23 17:51:31 -070051]
52
Devin Limf5175192018-05-14 19:13:22 -070053// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070054manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070055onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070056test_branch = ""
57onos_tag = params.ONOSTag
58isOldFlow = true
59
60// Set tests based on day of week
61def now = funcs.getCurrentTime()
62print now.toString()
63today = now[ Calendar.DAY_OF_WEEK ]
64
Devin Limf5175192018-05-14 19:13:22 -070065// if it is manually run, it will set the onos version to be what it was passed by.
66// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070067if ( manually_run ){
68 onos_b = params.ONOSVersion
69}
Devin Limf5175192018-05-14 19:13:22 -070070
71// get the list of the tests from the JenkinsTestONTests.groovy
Devin Lim431408d2018-03-23 17:51:31 -070072AllTheTests = test_lists.getAllTheTests( onos_b )
73
Devin Limf5175192018-05-14 19:13:22 -070074
Devin Lim431408d2018-03-23 17:51:31 -070075day = ""
Devin Limf5175192018-05-14 19:13:22 -070076
77// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070078SCPF_choices = ""
79USECASE_choices = ""
80FUNC_choices = ""
81HA_choices = ""
82SR_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070083
84// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070085stat_graph_generator_file = fileRelated.histogramMultiple
86pie_graph_generator_file = fileRelated.pieMultiple
87graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070088
Devin Limf5175192018-05-14 19:13:22 -070089// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070090post_result = params.PostResult
Jon Hall6af749d2018-05-29 12:59:47 -070091if ( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -070092 // If it is automated running, it will post the beginning message to the channel.
Jon Hall6af749d2018-05-29 12:59:47 -070093 slackSend( channel: 'sr-failures', color: '#03CD9F',
94 message: ":sparkles:" * 16 + "\n" +
95 "Starting tests on : " + now.toString() +
96 "\n" + ":sparkles:" * 16 )
Devin Lim431408d2018-03-23 17:51:31 -070097
Jon Hall6af749d2018-05-29 12:59:47 -070098 // Choices will get the list of the test with Segment Routing type tests.
Devin Lim431408d2018-03-23 17:51:31 -070099 SR_choices += adder( "SR", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700100 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700101 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700102 SR_choices += adder( "SR", "extra_A", true )
Jon Hall6af749d2018-05-29 12:59:47 -0700103 }
104 else if ( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700105 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700106 SR_choices += adder( "SR", "extra_B", true )
107 }
Devin Limf5175192018-05-14 19:13:22 -0700108 // removing last comma added at the end of the last test name.
You Wang96b98ad2018-05-25 12:14:45 -0700109 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Devin Lim431408d2018-03-23 17:51:31 -0700110}
Devin Limf5175192018-05-14 19:13:22 -0700111
112
Devin Lim431408d2018-03-23 17:51:31 -0700113if ( manually_run ){
114 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
115
116 isOldFlow = params.isOldFlow
117 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700118}
119else {
Devin Limf5175192018-05-14 19:13:22 -0700120 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700121 testcases[ "SR" ][ "tests" ] = SR_choices
122 println "Defaulting to " + day + " tests:"
123}
124
Devin Limf5175192018-05-14 19:13:22 -0700125// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700126triggerFuncs.print_tests( testcases )
127
Devin Limf5175192018-05-14 19:13:22 -0700128// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700129def runTest = [
Jon Hall6af749d2018-05-29 12:59:47 -0700130 "Fabric2": [ : ],
131 "Fabric3": [ : ],
132 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700133]
Devin Lim2edfcec2018-05-09 17:16:21 -0700134if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700135 // for manual run situation.
Jon Hall6af749d2018-05-29 12:59:47 -0700136 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700137 println test
Devin Limf5175192018-05-14 19:13:22 -0700138 // 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 -0700139 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700140 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
141 trigger_pipeline( onos_b,
142 testcases[ test ][ "tests" ],
143 testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
144 test,
145 manually_run,
146 onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700147 }
Devin Lim431408d2018-03-23 17:51:31 -0700148 }
Jon Hall6af749d2018-05-29 12:59:47 -0700149}
150else {
You Wang96b98ad2018-05-25 12:14:45 -0700151 // 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 -0700152 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
153 testcases[ "SR" ][ "tests" ],
154 testcases[ "SR" ][ "nodeName" ][ 2 ],
155 "SR",
156 manually_run, onos_tag )
157 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
158 testcases[ "SR" ][ "tests" ],
159 testcases[ "SR" ][ "nodeName" ][ 0 ],
160 "SR",
161 manually_run, onos_tag )
162 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
163 testcases[ "SR" ][ "tests" ],
164 testcases[ "SR" ][ "nodeName" ][ 1 ],
165 "SR",
166 manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700167}
Devin Lim2edfcec2018-05-09 17:16:21 -0700168
Jon Hall6af749d2018-05-29 12:59:47 -0700169def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700170
171// It will run each category of test to run sequentially on each branch.
Devin Lim86e40532018-04-06 12:44:06 -0700172finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
173finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700174finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700175
You Wang96b98ad2018-05-25 12:14:45 -0700176// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700177// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700178// ----> Fabric4 : current_version
179// This pipeline -----> ----> Fabric2 : previous_version
180// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700181parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700182
183// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700184/*
185if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700186 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700187 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700188 AllTheTests,
189 stat_graph_generator_file,
190 pie_graph_generator_file,
191 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700192 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700193 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700194 AllTheTests,
195 stat_graph_generator_file,
196 pie_graph_generator_file,
197 graph_saved_directory )
198 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700199 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700200 AllTheTests,
201 stat_graph_generator_file,
202 pie_graph_generator_file,
203 graph_saved_directory )
204}*/
Devin Limf5175192018-05-14 19:13:22 -0700205
206// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700207def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700208 // testCat : test Category ( Eg. FUNC, HA, SR ... )
209 // set : set of the test ( Eg. basic, extra_A ... )
210 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700211 result = ""
Jon Hall6af749d2018-05-29 12:59:47 -0700212 for ( String test in AllTheTests[ testCat ].keySet() ){
213 if ( AllTheTests[ testCat ][ test ][ set ] ){
214 if ( getResult ){
Devin Lim431408d2018-03-23 17:51:31 -0700215 result += test + ","
Jon Hall6af749d2018-05-29 12:59:47 -0700216 }
Devin Lim431408d2018-03-23 17:51:31 -0700217 }
218 }
219 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700220}
Devin Limf5175192018-05-14 19:13:22 -0700221
222// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700223def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700224 switch ( branch ){
You Wang96b98ad2018-05-25 12:14:45 -0700225 case current_version: return 2
226 case previous_version: return 0
227 case before_previous_version: return 1
228 default: return 2
229 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700230}