blob: b5d09bdc559884e59f71c1715e2d8deffedec68a [file] [log] [blame]
Devin Limf5175192018-05-14 19:13:22 -07001// Copyright 2017 Open Networking Foundation (ONF)
2//
3// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
4// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
5// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
6//
7// TestON is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 2 of the License, or
10// (at your option) any later version.
11//
12// TestON is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with TestON. If not, see <http://www.gnu.org/licenses/>.
19
20// This is the Jenkins script for the fabric-pipeline-trigger
21
Devin Lim431408d2018-03-23 17:51:31 -070022#!groovy
23
Devin Limf5175192018-05-14 19:13:22 -070024// init dependencies functions
Devin Limb734ea52018-05-14 14:13:05 -070025funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
26test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
27triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
28fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Devin Lim431408d2018-03-23 17:51:31 -070029
Devin Limfe9a4cb2018-05-11 17:06:21 -070030fileRelated.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"
34previous_version = "1.13"
35before_previous_version = "1.12"
Devin Limf5175192018-05-14 19:13:22 -070036
37// Function that will initialize the configuration of the Fabric.
Devin Lim431408d2018-03-23 17:51:31 -070038funcs.initializeTrend( "Fabric" );
39funcs.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
46// Having two different SR and SR1 to allow current_version and previous_version to be run on same machine.
Devin Lim431408d2018-03-23 17:51:31 -070047testcases = [
48 "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
49 "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
50 "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
Devin Lim86e40532018-04-06 12:44:06 -070051 "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
Devin Lim2edfcec2018-05-09 17:16:21 -070052 "SR1" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
Devin Lim431408d2018-03-23 17:51:31 -070053 "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
54]
Devin Limf5175192018-05-14 19:13:22 -070055
56// depends on the First two letter of the testname, it will decide which category to put test.
Devin Lim431408d2018-03-23 17:51:31 -070057Prefix_organizer = [
58 "FU" : "FUNC",
59 "HA" : "HA",
60 "PL" : "USECASE",
61 "SA" : "USECASE",
62 "SC" : "SCPF",
63 "SR" : "SR",
64 "US" : "USECASE",
65 "VP" : "USECASE"
66]
67
Devin Limf5175192018-05-14 19:13:22 -070068// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070069manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070070onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070071test_branch = ""
72onos_tag = params.ONOSTag
73isOldFlow = true
74
75// Set tests based on day of week
76def now = funcs.getCurrentTime()
77print now.toString()
78today = now[ Calendar.DAY_OF_WEEK ]
79
Devin Limf5175192018-05-14 19:13:22 -070080// if it is manually run, it will set the onos version to be what it was passed by.
81// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070082if ( manually_run ){
83 onos_b = params.ONOSVersion
84}
Devin Limf5175192018-05-14 19:13:22 -070085
86// get the list of the tests from the JenkinsTestONTests.groovy
Devin Lim431408d2018-03-23 17:51:31 -070087AllTheTests = test_lists.getAllTheTests( onos_b )
88
Devin Limf5175192018-05-14 19:13:22 -070089
Devin Lim431408d2018-03-23 17:51:31 -070090day = ""
Devin Limf5175192018-05-14 19:13:22 -070091
92// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070093SCPF_choices = ""
94USECASE_choices = ""
95FUNC_choices = ""
96HA_choices = ""
97SR_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070098
99// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -0700100stat_graph_generator_file = fileRelated.histogramMultiple
101pie_graph_generator_file = fileRelated.pieMultiple
102graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -0700103
Devin Limf5175192018-05-14 19:13:22 -0700104// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -0700105post_result = params.PostResult
106if( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700107 // If it is automated running, it will post the beginning message to the channel.
Devin Lim33fe4e72018-04-06 19:45:53 -0700108 slackSend( channel:'sr-failures', color:'#03CD9F',
Devin Lim431408d2018-03-23 17:51:31 -0700109 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
110 + "Starting tests on : " + now.toString()
111 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
112
Devin Limf5175192018-05-14 19:13:22 -0700113 // Choices will get the list of the test with Segment Rounting type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700114 SR_choices += adder( "SR", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700115 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700116 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700117 SR_choices += adder( "SR", "extra_A", true )
118 } else if( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700119 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700120 SR_choices += adder( "SR", "extra_B", true )
121 }
Devin Limf5175192018-05-14 19:13:22 -0700122 // removing last comma added at the end of the last test name.
Devin Lim431408d2018-03-23 17:51:31 -0700123 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
124}
Devin Limf5175192018-05-14 19:13:22 -0700125
126
Devin Lim431408d2018-03-23 17:51:31 -0700127if ( manually_run ){
128 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
129
130 isOldFlow = params.isOldFlow
131 println "Tests to be run manually : "
132}else{
Devin Limf5175192018-05-14 19:13:22 -0700133 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700134 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim2edfcec2018-05-09 17:16:21 -0700135 testcases[ "SR1" ][ "tests" ] = SR_choices
Devin Lim431408d2018-03-23 17:51:31 -0700136 println "Defaulting to " + day + " tests:"
137}
138
Devin Limf5175192018-05-14 19:13:22 -0700139// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700140triggerFuncs.print_tests( testcases )
141
Devin Limf5175192018-05-14 19:13:22 -0700142// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700143def runTest = [
Devin Lim86e40532018-04-06 12:44:06 -0700144 "Fabric2" : [:],
145 "Fabric3" : [:]
Devin Lim431408d2018-03-23 17:51:31 -0700146]
Devin Lim2edfcec2018-05-09 17:16:21 -0700147if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700148 // for manual run situation.
Devin Lim2edfcec2018-05-09 17:16:21 -0700149 for( String test in testcases.keySet() ){
150 println test
Devin Limf5175192018-05-14 19:13:22 -0700151 // 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 -0700152 if ( testcases[ test ][ "tests" ] != "" ){
153 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 )
154 }
Devin Lim431408d2018-03-23 17:51:31 -0700155 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700156}else{
Devin Limf5175192018-05-14 19:13:22 -0700157 // for automated situation, it will save current and previous version to Fabric2 and before_previous_version to Fabric3.
Devin Lim0c25f2f2018-05-10 15:43:09 -0700158 runTest[ "Fabric2" ][ "SR1" ] = triggerFuncs.trigger_pipeline( current_version, testcases[ "SR1" ][ "tests" ], testcases[ "SR1" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700159 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag )
160 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 -0700161}
Devin Lim2edfcec2018-05-09 17:16:21 -0700162
Devin Lim431408d2018-03-23 17:51:31 -0700163def finalList = [:]
Devin Limf5175192018-05-14 19:13:22 -0700164
165// It will run each category of test to run sequentially on each branch.
166// In our case, it will run SR1 first then SR on Fabric2 and just SR on Fabric3
Devin Lim86e40532018-04-06 12:44:06 -0700167finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
168finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
Devin Limf5175192018-05-14 19:13:22 -0700169
170// It will then run Fabric2 and Fabric3 to be run concurrently.
171// In our case,
172// ----> Fabric2 : current -> previous
173// This pipeline ----->
174// ----> Fabric3 : before_previous
Devin Lim431408d2018-03-23 17:51:31 -0700175parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700176
177// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700178/*
179if ( !manually_run ){
Devin Lim86e40532018-04-06 12:44:06 -0700180 funcs.generateStatGraph( "TestStation-Fabric2s",
181 funcs.branchWithPrefix( "master" ),
182 AllTheTests,
183 stat_graph_generator_file,
184 pie_graph_generator_file,
185 graph_saved_directory )
186 funcs.generateStatGraph( "TestStation-Fabric3s",
187 funcs.branchWithPrefix( "1.12" ),
Devin Lim431408d2018-03-23 17:51:31 -0700188 AllTheTests,
189 stat_graph_generator_file,
190 pie_graph_generator_file,
191 graph_saved_directory )
192}*/
Devin Limf5175192018-05-14 19:13:22 -0700193
194// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700195def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700196 // testCat : test Category ( Eg. FUNC, HA, SR ... )
197 // set : set of the test ( Eg. basic, extra_A ... )
198 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700199 result = ""
200 for( String test in AllTheTests[ testCat ].keySet() ){
201 if( AllTheTests[ testCat ][ test ][ set ] ){
202 if( getResult )
203 result += test + ","
204 }
205 }
206 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700207}
Devin Limf5175192018-05-14 19:13:22 -0700208
209// check which node is on.
210// 1.12 runs on Fabric3 and rest on 1.13 and master
Devin Lim2edfcec2018-05-09 17:16:21 -0700211def nodeOn( branch ){
212 return branch == "1.12" ? 1 : 0;
Devin Lim0c25f2f2018-05-10 15:43:09 -0700213}