blob: 7a7fabc034790831acedb2d76bc86cc0bb2a7e8d [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 vm-pipeline-trigger or bm-pipeline-trigger
22
Devin Limf5175192018-05-14 19:13:22 -070023// set the functions of the dependencies.
Devin Limb734ea52018-05-14 14:13:05 -070024funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
Devin Limb734ea52018-05-14 14:13:05 -070025triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
26fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070027test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
Devin Lim2edfcec2018-05-09 17:16:21 -070028
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070029onos_tag = null
30manually_run = null
31now = null
32today = null
33onos_branches = null
34day = null
35post_result = null
36branchesParam = null
37isFabric = null
38testsParam = null
Jeremy Ronquillo4fd82442019-05-21 20:56:58 -070039
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070040dayMap = [:]
41fullDayMap = [:]
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070042all_testcases = [:]
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070043runTest = [:]
44selectedTests = [:]
45graphPaths = [:]
Devin Lim2edfcec2018-05-09 17:16:21 -070046
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070047main()
Devin Limf5175192018-05-14 19:13:22 -070048
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070049def main() {
50 init()
51 runTests()
52 generateGraphs()
53}
54
55// **************
56// Initialization
57// **************
58
59// initialize file scope vars
60def init(){
61 // get the name of the job.
62 jobName = env.JOB_NAME
63
64 // set the versions of the onos
65 fileRelated.init()
66 test_list.init()
67 readParams()
68
69 if ( isFabric ){
70 funcs.initializeTrend( "Fabric" )
71 funcs.initialize( "Fabric" )
72 } else {
73 funcs.initializeTrend( "VM" );
74 }
75 triggerFuncs.init( funcs )
76
77 // list of the tests to be run will be saved in each choices.
78 day = ""
79
80 initDates()
81 onos_branches = getONOSBranches()
82 selectedTests = getONOSTests()
83}
84
85def readParams(){
86 // get post result from the params for manually run.
87 post_result = params.PostResult
88 manually_run = params.manual_run
89 onos_tag = params.ONOSTag
90 branchesParam = params.branches
91 isOldFlow = params.isOldFlow
92 testsParam = params.Tests
93 isFabric = params.isFabric
94}
Devin Lim2edfcec2018-05-09 17:16:21 -070095
96// Set tests based on day of week
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070097def initDates(){
98 echo "-> initDates()"
99 now = funcs.getCurrentTime()
100 today = now[ Calendar.DAY_OF_WEEK ]
101 dayMap = [ ( Calendar.MONDAY ) : "mon",
102 ( Calendar.TUESDAY ) : "tue",
103 ( Calendar.WEDNESDAY ) : "wed",
104 ( Calendar.THURSDAY ) : "thu",
105 ( Calendar.FRIDAY ) : "fri",
106 ( Calendar.SATURDAY ) : "sat",
107 ( Calendar.SUNDAY ) : "sun" ]
108 fullDayMap = [ ( Calendar.MONDAY ) : "Monday",
109 ( Calendar.TUESDAY ) : "Tuesday",
110 ( Calendar.WEDNESDAY ) : "Wednesday",
111 ( Calendar.THURSDAY ) : "Thursday",
112 ( Calendar.FRIDAY ) : "Friday",
113 ( Calendar.SATURDAY ) : "Saturday",
114 ( Calendar.SUNDAY ) : "Sunday" ]
115 print now.toString()
Jon Hall6af749d2018-05-29 12:59:47 -0700116}
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700117
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700118// gets ONOS branches from params or string parameter
119def getONOSBranches(){
120 echo "-> getONOSBranches()"
121 if ( manually_run ){
122 return branchesParam.tokenize( "\n;, " )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700123 } else {
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700124 return test_list.getBranchesFromDay( dayMap[ today ] )
Devin Lim2edfcec2018-05-09 17:16:21 -0700125 }
126}
Devin Limf5175192018-05-14 19:13:22 -0700127
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700128def getONOSTests(){
129 echo "-> getONOSTests()"
130 if ( manually_run ){
131 return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) )
132 } else {
133 day = dayMap[ today ]
134 return test_list.getTestsFromDay( day )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700135 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700136}
Devin Limf5175192018-05-14 19:13:22 -0700137
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700138// init paths for the files and directories.
139def initGraphPaths(){
140 graphPaths[ "histogramMultiple" ] = fileRelated.histogramMultiple
141 graphPaths[ "pieMultiple" ] = fileRelated.pieMultiple
142 graphPaths[ "saveDirectory" ] = fileRelated.jenkinsWorkspace + "postjob-VM/"
143}
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700144
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700145// **********************
146// Determine Tests to Run
147// **********************
148
149def printTestsToRun( runList ){
150 if ( manually_run ){
151 println "Tests to be run manually:"
152 } else {
153 if ( isFabric ){
154 postToSlackSR()
Devin Lim2edfcec2018-05-09 17:16:21 -0700155 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700156 if ( today == Calendar.MONDAY ){
157 postToSlackTestsToRun()
158 }
159 println "Defaulting to " + day + " tests:"
Devin Lim2edfcec2018-05-09 17:16:21 -0700160 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700161 for ( list in runList ){
162 // triggerFuncs.print_tests( all_testcases[ b ] )
163 echo "" + list
164 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700165}
Devin Limf5175192018-05-14 19:13:22 -0700166
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700167def postToSlackSR(){
168 // If it is automated running, it will post the beginning message to the channel.
169 slackSend( channel: 'sr-failures', color: '#03CD9F',
170 message: ":sparkles:" * 16 + "\n" +
171 "Starting tests on : " + now.toString() +
172 "\n" + ":sparkles:" * 16 )
173}
174
175def postToSlackTestsToRun(){
176 slackSend( color: '#FFD988',
177 message: "Tests to be run this weekdays : \n" +
178 triggerFuncs.printDaysForTest() )
179}
180
181// *********
182// Run Tests
183// *********
184
185def generateRunList(){
186 runList = [:]
187 for ( branch in onos_branches ){
188 nodeLabels = test_list.getAllNodeLabels( branch, selectedTests )
189 for ( nodeLabel in nodeLabels ){
190 selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests )
191 selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests )
192 for ( category in selectedNodeLabelCategories ){
193 selectedNodeLabelCategoryTests = getTestsFromCategory( category, selectedNodeLabelTests )
194 exeTestList = test_list.getTestListAsString( selectedNodeLabelCategoryTests )
195 runList.put( nodeLabel, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) )
196 }
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700197 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700198 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700199 return runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700200}
Devin Limf5175192018-05-14 19:13:22 -0700201
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700202def runTests(){
203 runList = generateRunList()
204 printTestsToRun( runList )
205 parallel runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700206}
Devin Limf5175192018-05-14 19:13:22 -0700207
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700208// ***************
209// Generate Graphs
210// ***************
Devin Lim2edfcec2018-05-09 17:16:21 -0700211
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700212def generateGraphs(){
213 // If it is automated running, it will generate the stats graph on VM.
214 if ( !manually_run ){
215 for ( String b in onos_branches ){
216 funcs.generateStatGraph( "TestStation-VMs",
217 funcs.branchWithPrefix( b ),
218 graphPaths[ "histogramMultiple" ],
219 graphPaths[ "pieMultiple" ],
220 graphPaths[ "saveDirectory" ] )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700221 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700222 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700223}