blob: 139c72e27fc3a81652f5b361c189bb5cef29fd48 [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"
You Wang5cf67da2018-08-20 15:06:46 -070034before_previous_version = "1.14"
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 = ""
You Wang38ad08f2018-06-10 15:55:48 -070084SRHA_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070085
86// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070087stat_graph_generator_file = fileRelated.histogramMultiple
88pie_graph_generator_file = fileRelated.pieMultiple
89graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070090
Devin Limf5175192018-05-14 19:13:22 -070091// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070092post_result = params.PostResult
Jon Hall6af749d2018-05-29 12:59:47 -070093if ( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -070094 // If it is automated running, it will post the beginning message to the channel.
Jon Hall6af749d2018-05-29 12:59:47 -070095 slackSend( channel: 'sr-failures', color: '#03CD9F',
96 message: ":sparkles:" * 16 + "\n" +
97 "Starting tests on : " + now.toString() +
98 "\n" + ":sparkles:" * 16 )
Devin Lim431408d2018-03-23 17:51:31 -070099
Jon Hall6af749d2018-05-29 12:59:47 -0700100 // Choices will get the list of the test with Segment Routing type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700101 SR_choices += adder( "SR", "basic", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700102 SRHA_choices += adder( "SRHA", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700103 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700104 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700105 SR_choices += adder( "SR", "extra_A", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700106 SRHA_choices += adder( "SRHA", "extra_A", true )
Jon Hall6af749d2018-05-29 12:59:47 -0700107 }
108 else if ( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700109 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700110 SR_choices += adder( "SR", "extra_B", true )
Jon Hall2ee92f82018-06-07 13:07:33 -0700111 SRHA_choices += adder( "SRHA", "extra_B", true )
Devin Limbe483072018-03-24 14:37:48 -0700112 }
Devin Limf5175192018-05-14 19:13:22 -0700113 // removing last comma added at the end of the last test name.
You Wang96b98ad2018-05-25 12:14:45 -0700114 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Jon Hall2ee92f82018-06-07 13:07:33 -0700115 SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices )
116
Devin Lim431408d2018-03-23 17:51:31 -0700117}
Devin Limf5175192018-05-14 19:13:22 -0700118
119
Devin Lim431408d2018-03-23 17:51:31 -0700120if ( manually_run ){
121 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
122
123 isOldFlow = params.isOldFlow
124 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700125}
126else {
Devin Limf5175192018-05-14 19:13:22 -0700127 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700128 testcases[ "SR" ][ "tests" ] = SR_choices
Jon Hall2ee92f82018-06-07 13:07:33 -0700129 testcases[ "SRHA" ][ "tests" ] = SRHA_choices
Devin Lim431408d2018-03-23 17:51:31 -0700130 println "Defaulting to " + day + " tests:"
131}
132
Devin Limf5175192018-05-14 19:13:22 -0700133// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700134triggerFuncs.print_tests( testcases )
135
Devin Limf5175192018-05-14 19:13:22 -0700136// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700137def runTest = [
Jon Hall2ee92f82018-06-07 13:07:33 -0700138 "Fabric": [ : ],
Jon Hall6af749d2018-05-29 12:59:47 -0700139 "Fabric2": [ : ],
140 "Fabric3": [ : ],
141 "Fabric4": [ : ]
Devin Lim431408d2018-03-23 17:51:31 -0700142]
Devin Lim2edfcec2018-05-09 17:16:21 -0700143if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700144 // for manual run situation.
Jon Hall6af749d2018-05-29 12:59:47 -0700145 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700146 println test
Devin Limf5175192018-05-14 19:13:22 -0700147 // 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 -0700148 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700149 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
150 trigger_pipeline( onos_b,
151 testcases[ test ][ "tests" ],
152 testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
153 test,
154 manually_run,
155 onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700156 }
Devin Lim431408d2018-03-23 17:51:31 -0700157 }
Jon Hall6af749d2018-05-29 12:59:47 -0700158}
159else {
You Wang96b98ad2018-05-25 12:14:45 -0700160 // 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 -0700161 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
162 testcases[ "SR" ][ "tests" ],
163 testcases[ "SR" ][ "nodeName" ][ 2 ],
164 "SR",
165 manually_run, onos_tag )
166 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
167 testcases[ "SR" ][ "tests" ],
168 testcases[ "SR" ][ "nodeName" ][ 0 ],
169 "SR",
170 manually_run, onos_tag )
171 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
172 testcases[ "SR" ][ "tests" ],
173 testcases[ "SR" ][ "nodeName" ][ 1 ],
174 "SR",
175 manually_run, onos_tag )
Jon Hall2ee92f82018-06-07 13:07:33 -0700176 runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( current_version,
177 testcases[ "SRHA" ][ "tests" ],
178 testcases[ "SRHA" ][ "nodeName" ],
179 "SRHA",
180 manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700181}
Devin Lim2edfcec2018-05-09 17:16:21 -0700182
Jon Hall6af749d2018-05-29 12:59:47 -0700183def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700184
185// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700186finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700187finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
188finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700189finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700190
You Wang96b98ad2018-05-25 12:14:45 -0700191// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700192// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700193// ----> Fabric4 : current_version
194// This pipeline -----> ----> Fabric2 : previous_version
195// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700196parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700197
198// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700199/*
200if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700201 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700202 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700203 AllTheTests,
204 stat_graph_generator_file,
205 pie_graph_generator_file,
206 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700207 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700208 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700209 AllTheTests,
210 stat_graph_generator_file,
211 pie_graph_generator_file,
212 graph_saved_directory )
213 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700214 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700215 AllTheTests,
216 stat_graph_generator_file,
217 pie_graph_generator_file,
218 graph_saved_directory )
219}*/
Devin Limf5175192018-05-14 19:13:22 -0700220
221// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700222def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700223 // testCat : test Category ( Eg. FUNC, HA, SR ... )
224 // set : set of the test ( Eg. basic, extra_A ... )
225 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700226 result = ""
Jon Hall6af749d2018-05-29 12:59:47 -0700227 for ( String test in AllTheTests[ testCat ].keySet() ){
228 if ( AllTheTests[ testCat ][ test ][ set ] ){
229 if ( getResult ){
Devin Lim431408d2018-03-23 17:51:31 -0700230 result += test + ","
Jon Hall6af749d2018-05-29 12:59:47 -0700231 }
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}