blob: 21f5ec43630306df84b0b78e3d1ff4f4a80a01a5 [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 = [
46 "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
47 "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
48 "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
You Wang96b98ad2018-05-25 12:14:45 -070049 "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3", "Fabric4" ], wikiContent : "" ],
Devin Lim431408d2018-03-23 17:51:31 -070050 "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
51]
Devin Limf5175192018-05-14 19:13:22 -070052
53// depends on the First two letter of the testname, it will decide which category to put test.
Devin Lim431408d2018-03-23 17:51:31 -070054Prefix_organizer = [
55 "FU" : "FUNC",
56 "HA" : "HA",
57 "PL" : "USECASE",
58 "SA" : "USECASE",
59 "SC" : "SCPF",
60 "SR" : "SR",
61 "US" : "USECASE",
62 "VP" : "USECASE"
63]
64
Devin Limf5175192018-05-14 19:13:22 -070065// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070066manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070067onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070068test_branch = ""
69onos_tag = params.ONOSTag
70isOldFlow = true
71
72// Set tests based on day of week
73def now = funcs.getCurrentTime()
74print now.toString()
75today = now[ Calendar.DAY_OF_WEEK ]
76
Devin Limf5175192018-05-14 19:13:22 -070077// if it is manually run, it will set the onos version to be what it was passed by.
78// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070079if ( manually_run ){
80 onos_b = params.ONOSVersion
81}
Devin Limf5175192018-05-14 19:13:22 -070082
83// get the list of the tests from the JenkinsTestONTests.groovy
Devin Lim431408d2018-03-23 17:51:31 -070084AllTheTests = test_lists.getAllTheTests( onos_b )
85
Devin Limf5175192018-05-14 19:13:22 -070086
Devin Lim431408d2018-03-23 17:51:31 -070087day = ""
Devin Limf5175192018-05-14 19:13:22 -070088
89// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070090SCPF_choices = ""
91USECASE_choices = ""
92FUNC_choices = ""
93HA_choices = ""
94SR_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070095
96// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070097stat_graph_generator_file = fileRelated.histogramMultiple
98pie_graph_generator_file = fileRelated.pieMultiple
99graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -0700100
Devin Limf5175192018-05-14 19:13:22 -0700101// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -0700102post_result = params.PostResult
103if( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700104 // If it is automated running, it will post the beginning message to the channel.
Devin Lim33fe4e72018-04-06 19:45:53 -0700105 slackSend( channel:'sr-failures', color:'#03CD9F',
Devin Lim431408d2018-03-23 17:51:31 -0700106 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
107 + "Starting tests on : " + now.toString()
108 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
109
Devin Limf5175192018-05-14 19:13:22 -0700110 // Choices will get the list of the test with Segment Rounting type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700111 SR_choices += adder( "SR", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700112 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700113 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700114 SR_choices += adder( "SR", "extra_A", true )
115 } else if( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700116 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700117 SR_choices += adder( "SR", "extra_B", true )
118 }
Devin Limf5175192018-05-14 19:13:22 -0700119 // removing last comma added at the end of the last test name.
You Wang96b98ad2018-05-25 12:14:45 -0700120 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Devin Lim431408d2018-03-23 17:51:31 -0700121}
Devin Limf5175192018-05-14 19:13:22 -0700122
123
Devin Lim431408d2018-03-23 17:51:31 -0700124if ( manually_run ){
125 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
126
127 isOldFlow = params.isOldFlow
128 println "Tests to be run manually : "
129}else{
Devin Limf5175192018-05-14 19:13:22 -0700130 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700131 testcases[ "SR" ][ "tests" ] = SR_choices
132 println "Defaulting to " + day + " tests:"
133}
134
Devin Limf5175192018-05-14 19:13:22 -0700135// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700136triggerFuncs.print_tests( testcases )
137
Devin Limf5175192018-05-14 19:13:22 -0700138// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700139def runTest = [
Devin Lim86e40532018-04-06 12:44:06 -0700140 "Fabric2" : [:],
You Wang96b98ad2018-05-25 12:14:45 -0700141 "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.
Devin Lim2edfcec2018-05-09 17:16:21 -0700146 for( String test in testcases.keySet() ){
147 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" ] != "" ){
150 runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ], test, manually_run, onos_tag )
151 }
Devin Lim431408d2018-03-23 17:51:31 -0700152 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700153}else{
You Wang96b98ad2018-05-25 12:14:45 -0700154 // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3.
155 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 2 ], "SR", manually_run, onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700156 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag )
157 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 1 ], "SR", manually_run, onos_tag )
Devin Lim431408d2018-03-23 17:51:31 -0700158}
Devin Lim2edfcec2018-05-09 17:16:21 -0700159
Devin Lim431408d2018-03-23 17:51:31 -0700160def finalList = [:]
Devin Limf5175192018-05-14 19:13:22 -0700161
162// It will run each category of test to run sequentially on each branch.
Devin Lim86e40532018-04-06 12:44:06 -0700163finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
164finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700165finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700166
You Wang96b98ad2018-05-25 12:14:45 -0700167// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700168// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700169// ----> Fabric4 : current_version
170// This pipeline -----> ----> Fabric2 : previous_version
171// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700172parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700173
174// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700175/*
176if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700177 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700178 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700179 AllTheTests,
180 stat_graph_generator_file,
181 pie_graph_generator_file,
182 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700183 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700184 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700185 AllTheTests,
186 stat_graph_generator_file,
187 pie_graph_generator_file,
188 graph_saved_directory )
189 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700190 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700191 AllTheTests,
192 stat_graph_generator_file,
193 pie_graph_generator_file,
194 graph_saved_directory )
195}*/
Devin Limf5175192018-05-14 19:13:22 -0700196
197// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700198def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700199 // testCat : test Category ( Eg. FUNC, HA, SR ... )
200 // set : set of the test ( Eg. basic, extra_A ... )
201 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700202 result = ""
203 for( String test in AllTheTests[ testCat ].keySet() ){
204 if( AllTheTests[ testCat ][ test ][ set ] ){
205 if( getResult )
206 result += test + ","
207 }
208 }
209 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700210}
Devin Limf5175192018-05-14 19:13:22 -0700211
212// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700213def nodeOn( branch ){
You Wang96b98ad2018-05-25 12:14:45 -0700214 switch( branch ) {
215 case current_version: return 2
216 case previous_version: return 0
217 case before_previous_version: return 1
218 default: return 2
219 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700220}