blob: 6507fc10e889c191a1664f7a5b063e0b8ef06413 [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.
Devin Lim431408d2018-03-23 17:51:31 -070037funcs.initializeTrend( "Fabric" );
38funcs.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
45// 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 -070046testcases = [
47 "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
48 "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
49 "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
Devin Lim86e40532018-04-06 12:44:06 -070050 "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
Devin Lim2edfcec2018-05-09 17:16:21 -070051 "SR1" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
Devin Lim431408d2018-03-23 17:51:31 -070052 "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
53]
Devin Limf5175192018-05-14 19:13:22 -070054
55// depends on the First two letter of the testname, it will decide which category to put test.
Devin Lim431408d2018-03-23 17:51:31 -070056Prefix_organizer = [
57 "FU" : "FUNC",
58 "HA" : "HA",
59 "PL" : "USECASE",
60 "SA" : "USECASE",
61 "SC" : "SCPF",
62 "SR" : "SR",
63 "US" : "USECASE",
64 "VP" : "USECASE"
65]
66
Devin Limf5175192018-05-14 19:13:22 -070067// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070068manually_run = params.manual_run
Devin Limb6f92de2018-04-13 18:27:33 -070069onos_b = current_version
Devin Lim431408d2018-03-23 17:51:31 -070070test_branch = ""
71onos_tag = params.ONOSTag
72isOldFlow = true
73
74// Set tests based on day of week
75def now = funcs.getCurrentTime()
76print now.toString()
77today = now[ Calendar.DAY_OF_WEEK ]
78
Devin Limf5175192018-05-14 19:13:22 -070079// if it is manually run, it will set the onos version to be what it was passed by.
80// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070081if ( manually_run ){
82 onos_b = params.ONOSVersion
83}
Devin Limf5175192018-05-14 19:13:22 -070084
85// get the list of the tests from the JenkinsTestONTests.groovy
Devin Lim431408d2018-03-23 17:51:31 -070086AllTheTests = test_lists.getAllTheTests( onos_b )
87
Devin Limf5175192018-05-14 19:13:22 -070088
Devin Lim431408d2018-03-23 17:51:31 -070089day = ""
Devin Limf5175192018-05-14 19:13:22 -070090
91// list of the test on each test category will be run.
Devin Lim431408d2018-03-23 17:51:31 -070092SCPF_choices = ""
93USECASE_choices = ""
94FUNC_choices = ""
95HA_choices = ""
96SR_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070097
98// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070099stat_graph_generator_file = fileRelated.histogramMultiple
100pie_graph_generator_file = fileRelated.pieMultiple
101graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -0700102
Devin Limf5175192018-05-14 19:13:22 -0700103// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -0700104post_result = params.PostResult
105if( !manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700106 // If it is automated running, it will post the beginning message to the channel.
Devin Lim33fe4e72018-04-06 19:45:53 -0700107 slackSend( channel:'sr-failures', color:'#03CD9F',
Devin Lim431408d2018-03-23 17:51:31 -0700108 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
109 + "Starting tests on : " + now.toString()
110 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
111
Devin Limf5175192018-05-14 19:13:22 -0700112 // Choices will get the list of the test with Segment Rounting type tests.
Devin Lim431408d2018-03-23 17:51:31 -0700113 SR_choices += adder( "SR", "basic", true )
Devin Limbe483072018-03-24 14:37:48 -0700114 if ( today == Calendar.FRIDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700115 // if today is Friday, it will also test tests with extra_A category
Devin Limbe483072018-03-24 14:37:48 -0700116 SR_choices += adder( "SR", "extra_A", true )
117 } else if( today == Calendar.SATURDAY ){
Devin Limf5175192018-05-14 19:13:22 -0700118 // if today is Saturday, it will add the test with extra_B category
Devin Limbe483072018-03-24 14:37:48 -0700119 SR_choices += adder( "SR", "extra_B", true )
120 }
Devin Limf5175192018-05-14 19:13:22 -0700121 // removing last comma added at the end of the last test name.
Devin Lim431408d2018-03-23 17:51:31 -0700122 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
123}
Devin Limf5175192018-05-14 19:13:22 -0700124
125
Devin Lim431408d2018-03-23 17:51:31 -0700126if ( manually_run ){
127 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
128
129 isOldFlow = params.isOldFlow
130 println "Tests to be run manually : "
131}else{
Devin Limf5175192018-05-14 19:13:22 -0700132 // set the list of the tests to run.
Devin Lim431408d2018-03-23 17:51:31 -0700133 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim2edfcec2018-05-09 17:16:21 -0700134 testcases[ "SR1" ][ "tests" ] = SR_choices
Devin Lim431408d2018-03-23 17:51:31 -0700135 println "Defaulting to " + day + " tests:"
136}
137
Devin Limf5175192018-05-14 19:13:22 -0700138// print out the list of the test to run on Jenkins
Devin Lim431408d2018-03-23 17:51:31 -0700139triggerFuncs.print_tests( testcases )
140
Devin Limf5175192018-05-14 19:13:22 -0700141// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700142def runTest = [
Devin Lim86e40532018-04-06 12:44:06 -0700143 "Fabric2" : [:],
144 "Fabric3" : [:]
Devin Lim431408d2018-03-23 17:51:31 -0700145]
Devin Lim2edfcec2018-05-09 17:16:21 -0700146if ( manually_run ){
Devin Limf5175192018-05-14 19:13:22 -0700147 // for manual run situation.
Devin Lim2edfcec2018-05-09 17:16:21 -0700148 for( String test in testcases.keySet() ){
149 println test
Devin Limf5175192018-05-14 19:13:22 -0700150 // 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 -0700151 if ( testcases[ test ][ "tests" ] != "" ){
152 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 )
153 }
Devin Lim431408d2018-03-23 17:51:31 -0700154 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700155}else{
Devin Limf5175192018-05-14 19:13:22 -0700156 // 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 -0700157 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 -0700158 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ "SR" ][ "tests" ], testcases[ "SR" ][ "nodeName" ][ 0 ], "SR", manually_run, onos_tag )
159 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 -0700160}
Devin Lim2edfcec2018-05-09 17:16:21 -0700161
Devin Lim431408d2018-03-23 17:51:31 -0700162def finalList = [:]
Devin Limf5175192018-05-14 19:13:22 -0700163
164// It will run each category of test to run sequentially on each branch.
165// In our case, it will run SR1 first then SR on Fabric2 and just SR on Fabric3
Devin Lim86e40532018-04-06 12:44:06 -0700166finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
167finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
Devin Limf5175192018-05-14 19:13:22 -0700168
169// It will then run Fabric2 and Fabric3 to be run concurrently.
170// In our case,
171// ----> Fabric2 : current -> previous
172// This pipeline ----->
173// ----> Fabric3 : before_previous
Devin Lim431408d2018-03-23 17:51:31 -0700174parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700175
176// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700177/*
178if ( !manually_run ){
Devin Lim86e40532018-04-06 12:44:06 -0700179 funcs.generateStatGraph( "TestStation-Fabric2s",
180 funcs.branchWithPrefix( "master" ),
181 AllTheTests,
182 stat_graph_generator_file,
183 pie_graph_generator_file,
184 graph_saved_directory )
185 funcs.generateStatGraph( "TestStation-Fabric3s",
186 funcs.branchWithPrefix( "1.12" ),
Devin Lim431408d2018-03-23 17:51:31 -0700187 AllTheTests,
188 stat_graph_generator_file,
189 pie_graph_generator_file,
190 graph_saved_directory )
191}*/
Devin Limf5175192018-05-14 19:13:22 -0700192
193// Way to add list of the tests with specific category to the result
Devin Lim431408d2018-03-23 17:51:31 -0700194def adder( testCat, set, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700195 // testCat : test Category ( Eg. FUNC, HA, SR ... )
196 // set : set of the test ( Eg. basic, extra_A ... )
197 // if getResult == true, it will add the result.
Devin Lim431408d2018-03-23 17:51:31 -0700198 result = ""
199 for( String test in AllTheTests[ testCat ].keySet() ){
200 if( AllTheTests[ testCat ][ test ][ set ] ){
201 if( getResult )
202 result += test + ","
203 }
204 }
205 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700206}
Devin Limf5175192018-05-14 19:13:22 -0700207
208// check which node is on.
209// 1.12 runs on Fabric3 and rest on 1.13 and master
Devin Lim2edfcec2018-05-09 17:16:21 -0700210def nodeOn( branch ){
211 return branch == "1.12" ? 1 : 0;
Devin Lim0c25f2f2018-05-10 15:43:09 -0700212}