blob: 72a2c2f5d14ea0c3fa9bdc478f014f6eeee54b53 [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
Jon Hall6af749d2018-05-29 12:59:47 -0700101 // Choices will get the list of the test with Segment Routing type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700102 SR_choices += adder( "SR", "basic", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700103 SRHA_choices += adder( "SRHA", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700104 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700105 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700106 SR_choices += adder( "SR", "extra_A", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700107 SRHA_choices += adder( "SRHA", "extra_A", true )
Jon Hall6af749d2018-05-29 12:59:47 -0700108 }
109 else if ( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700110 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700111 SR_choices += adder( "SR", "extra_B", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700112 SRHA_choices += adder( "SRHA", "extra_B", true )
Devin Limbe483072018-03-24 14:37:48 -0700113 }
Devin Limf5175192018-05-14 19:13:22 -0700114 // removing last comma added at the end of the last test name.
You Wang96b98ad2018-05-25 12:14:45 -0700115 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Jon Hall2ee92f82018-06-07 13:07:33 -0700116 SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices )
117
Devin Lim431408d2018-03-23 17:51:31 -0700118}
Devin Limf5175192018-05-14 19:13:22 -0700119
120
Devin Lim431408d2018-03-23 17:51:31 -0700121if ( manually_run ){
122 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
123
124 isOldFlow = params.isOldFlow
125 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700126}
127else {
Devin Limf5175192018-05-14 19:13:22 -0700128 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700129 testcases[ "SR" ][ "tests" ] = SR_choices
Jon Hall2ee92f82018-06-07 13:07:33 -0700130 testcases[ "SRHA" ][ "tests" ] = SRHA_choices
Devin Lim431408d2018-03-23 17:51:31 -0700131 println "Defaulting to " + day + " tests:"
132}
133
Devin Limf5175192018-05-14 19:13:22 -0700134// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700135triggerFuncs.print_tests( testcases )
136
Devin Limf5175192018-05-14 19:13:22 -0700137// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700138def runTest = [
Jon Hall2ee92f82018-06-07 13:07:33 -0700139 "Fabric": [ : ],
Jon Hall6af749d2018-05-29 12:59:47 -0700140 "Fabric2": [ : ],
141 "Fabric3": [ : ],
142 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700143]
Devin Lim2edfcec2018-05-09 17:16:21 -0700144if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700145 // for manual run situation.
Jon Hall6af749d2018-05-29 12:59:47 -0700146 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700147 println test
Devin Limf5175192018-05-14 19:13:22 -0700148 // 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 -0700149 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700150 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
151 trigger_pipeline( onos_b,
152 testcases[ test ][ "tests" ],
153 testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
154 test,
155 manually_run,
156 onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700157 }
Devin Lim431408d2018-03-23 17:51:31 -0700158 }
Jon Hall6af749d2018-05-29 12:59:47 -0700159}
160else {
You Wang96b98ad2018-05-25 12:14:45 -0700161 // 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 -0700162 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
163 testcases[ "SR" ][ "tests" ],
164 testcases[ "SR" ][ "nodeName" ][ 2 ],
165 "SR",
166 manually_run, onos_tag )
167 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
168 testcases[ "SR" ][ "tests" ],
169 testcases[ "SR" ][ "nodeName" ][ 0 ],
170 "SR",
171 manually_run, onos_tag )
172 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
173 testcases[ "SR" ][ "tests" ],
174 testcases[ "SR" ][ "nodeName" ][ 1 ],
175 "SR",
176 manually_run, onos_tag )
Jon Hall2ee92f82018-06-07 13:07:33 -0700177 runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( current_version,
178 testcases[ "SRHA" ][ "tests" ],
179 testcases[ "SRHA" ][ "nodeName" ],
180 "SRHA",
181 manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700182}
Devin Lim2edfcec2018-05-09 17:16:21 -0700183
Jon Hall6af749d2018-05-29 12:59:47 -0700184def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700185
186// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700187finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700188finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
189finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700190finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700191
You Wang96b98ad2018-05-25 12:14:45 -0700192// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700193// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700194// ----> Fabric4 : current_version
195// This pipeline -----> ----> Fabric2 : previous_version
196// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700197parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700198
199// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700200/*
201if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700202 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700203 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700204 AllTheTests,
205 stat_graph_generator_file,
206 pie_graph_generator_file,
207 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700208 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700209 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700210 AllTheTests,
211 stat_graph_generator_file,
212 pie_graph_generator_file,
213 graph_saved_directory )
214 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700215 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700216 AllTheTests,
217 stat_graph_generator_file,
218 pie_graph_generator_file,
219 graph_saved_directory )
220}*/
Devin Limf5175192018-05-14 19:13:22 -0700221
222// Way to add list of the tests with specific category to the result
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700223def adder( category, day, branch, getResult ){
224 // category : test Category ( Eg. FUNC, HA, SR ... )
Devin Limf5175192018-05-14 19:13:22 -0700225 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700226 result = ""
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700227 selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
228
229 for ( String test in selectedTests.keySet() ){
230 if ( getResult ){
231 result += test + ","
Devin Lim431408d2018-03-23 17:51:31 -0700232 }
233 }
234 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700235}
Devin Limf5175192018-05-14 19:13:22 -0700236
237// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700238def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700239 switch ( branch ){
You Wang96b98ad2018-05-25 12:14:45 -0700240 case current_version: return 2
241 case previous_version: return 0
242 case before_previous_version: return 1
243 default: return 2
244 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700245}