blob: 372efc6e1d5b73f867f8c69706e39f597a5b7666 [file] [log] [blame]
Devin Lime1346f42018-05-15 15:41:36 -07001#!groovy
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -07002// Copyright 2019 Open Networking Foundation (ONF)
Devin Limf5175192018-05-14 19:13:22 -07003//
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
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070021// This is the Jenkins script for master-trigger
Devin Limf5175192018-05-14 19:13:22 -070022
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 Ronquillo3c2f10d2019-06-10 16:54:46 -070039simulateDay = null
Jeremy Ronquillo4fd82442019-05-21 20:56:58 -070040
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070041dayMap = [:]
42fullDayMap = [:]
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070043all_testcases = [:]
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070044runTest = [:]
45selectedTests = [:]
46graphPaths = [:]
Devin Lim2edfcec2018-05-09 17:16:21 -070047
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070048main()
Devin Limf5175192018-05-14 19:13:22 -070049
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070050def main() {
51 init()
52 runTests()
53 generateGraphs()
54}
55
56// **************
57// Initialization
58// **************
59
60// initialize file scope vars
61def init(){
62 // get the name of the job.
63 jobName = env.JOB_NAME
64
65 // set the versions of the onos
66 fileRelated.init()
67 test_list.init()
68 readParams()
69
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070070 // list of the tests to be run will be saved in each choices.
71 day = ""
72
73 initDates()
74 onos_branches = getONOSBranches()
75 selectedTests = getONOSTests()
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -070076
Jeremy Ronquillod98c2a12019-06-07 15:13:29 -070077 initGraphPaths()
78
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -070079 echo "selectedTests: " + selectedTests
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -070080 echo "onos_branches: " + onos_branches
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070081}
82
83def readParams(){
84 // get post result from the params for manually run.
85 post_result = params.PostResult
86 manually_run = params.manual_run
87 onos_tag = params.ONOSTag
88 branchesParam = params.branches
89 isOldFlow = params.isOldFlow
90 testsParam = params.Tests
91 isFabric = params.isFabric
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -070092 simulateDay = params.simulate_day
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070093}
Devin Lim2edfcec2018-05-09 17:16:21 -070094
95// Set tests based on day of week
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070096def initDates(){
97 echo "-> initDates()"
98 now = funcs.getCurrentTime()
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070099 dayMap = [ ( Calendar.MONDAY ) : "mon",
100 ( Calendar.TUESDAY ) : "tue",
101 ( Calendar.WEDNESDAY ) : "wed",
102 ( Calendar.THURSDAY ) : "thu",
103 ( Calendar.FRIDAY ) : "fri",
104 ( Calendar.SATURDAY ) : "sat",
105 ( Calendar.SUNDAY ) : "sun" ]
106 fullDayMap = [ ( Calendar.MONDAY ) : "Monday",
107 ( Calendar.TUESDAY ) : "Tuesday",
108 ( Calendar.WEDNESDAY ) : "Wednesday",
109 ( Calendar.THURSDAY ) : "Thursday",
110 ( Calendar.FRIDAY ) : "Friday",
111 ( Calendar.SATURDAY ) : "Saturday",
112 ( Calendar.SUNDAY ) : "Sunday" ]
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700113 if ( simulateDay == "" ){
114 today = now[ Calendar.DAY_OF_WEEK ]
115 day = dayMap[ today ]
116 print now.toString()
117 } else {
118 day = simulateDay
119 }
Jon Hall6af749d2018-05-29 12:59:47 -0700120}
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700121
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700122// gets ONOS branches from params or string parameter
123def getONOSBranches(){
124 echo "-> getONOSBranches()"
125 if ( manually_run ){
126 return branchesParam.tokenize( "\n;, " )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700127 } else {
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700128 return test_list.getBranchesFromDay( day )
Devin Lim2edfcec2018-05-09 17:16:21 -0700129 }
130}
Devin Limf5175192018-05-14 19:13:22 -0700131
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700132def getONOSTests(){
133 echo "-> getONOSTests()"
134 if ( manually_run ){
135 return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) )
136 } else {
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700137
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700138 return test_list.getTestsFromDay( day )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700139 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700140}
Devin Limf5175192018-05-14 19:13:22 -0700141
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700142// init paths for the files and directories.
143def initGraphPaths(){
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700144 graphPaths.put( "histogramMultiple", fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ] )
145 graphPaths.put( "pieMultiple", fileRelated.rScriptPaths[ "scripts" ][ "pieMultiple" ] )
146 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "VM" ] )
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700147}
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700148
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700149// **********************
150// Determine Tests to Run
151// **********************
152
153def printTestsToRun( runList ){
154 if ( manually_run ){
155 println "Tests to be run manually:"
156 } else {
157 if ( isFabric ){
158 postToSlackSR()
Devin Lim2edfcec2018-05-09 17:16:21 -0700159 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700160 if ( today == Calendar.MONDAY ){
161 postToSlackTestsToRun()
162 }
163 println "Defaulting to " + day + " tests:"
Devin Lim2edfcec2018-05-09 17:16:21 -0700164 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700165 for ( list in runList ){
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700166 echo "" + list
167 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700168}
Devin Limf5175192018-05-14 19:13:22 -0700169
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700170def postToSlackSR(){
171 // If it is automated running, it will post the beginning message to the channel.
172 slackSend( channel: 'sr-failures', color: '#03CD9F',
173 message: ":sparkles:" * 16 + "\n" +
174 "Starting tests on : " + now.toString() +
175 "\n" + ":sparkles:" * 16 )
176}
177
178def postToSlackTestsToRun(){
179 slackSend( color: '#FFD988',
180 message: "Tests to be run this weekdays : \n" +
181 triggerFuncs.printDaysForTest() )
182}
183
184// *********
185// Run Tests
186// *********
187
188def generateRunList(){
189 runList = [:]
Jeremy Ronquilloedb663b2019-06-26 14:09:38 -0700190 validSchedules = test_list.getValidSchedules( day )
191 echo "validSchedules: " + validSchedules
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700192 for ( branch in onos_branches ){
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -0700193 runBranch = []
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700194 nodeLabels = test_list.getAllNodeLabels( branch, selectedTests )
195 for ( nodeLabel in nodeLabels ){
196 selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests )
197 selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests )
198 for ( category in selectedNodeLabelCategories ){
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -0700199 selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests )
Jeremy Ronquilloedb663b2019-06-26 14:09:38 -0700200
201 filteredList = [:]
202 for ( key in selectedNodeLabelCategoryTests.keySet() ){
203 for ( sch in selectedNodeLabelCategoryTests[ key ][ "schedules" ] ){
Jeremy Ronquillobd26bdb2019-07-08 16:15:45 -0700204 if ( validSchedules.contains( sch[ "day" ] ) && sch[ "branch" ] == test_list.convertBranchToBranchCode( branch ) || manually_run ){
Jeremy Ronquilloedb663b2019-06-26 14:09:38 -0700205 filteredList.put( key, selectedNodeLabelCategoryTests[ key ] )
206 break
207 }
208 }
209 }
210
211 echo "=========================================="
212 echo "BRANCH: " + branch
213 echo "CATEGORY: " + category
214 echo "TESTS: " + filteredList
215 if ( filteredList != [:] ){
216 exeTestList = test_list.getTestListAsString( filteredList )
217 runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) )
218 }
219
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700220 }
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700221 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700222 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700223 return runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700224}
Devin Limf5175192018-05-14 19:13:22 -0700225
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700226def runTests(){
227 runList = generateRunList()
228 printTestsToRun( runList )
229 parallel runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700230}
Devin Limf5175192018-05-14 19:13:22 -0700231
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700232// ***************
233// Generate Graphs
234// ***************
Devin Lim2edfcec2018-05-09 17:16:21 -0700235
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700236def generateGraphs(){
237 // If it is automated running, it will generate the stats graph on VM.
238 if ( !manually_run ){
239 for ( String b in onos_branches ){
240 funcs.generateStatGraph( "TestStation-VMs",
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700241 test_list.addPrefixToBranch( b ),
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700242 graphPaths[ "histogramMultiple" ],
243 graphPaths[ "pieMultiple" ],
244 graphPaths[ "saveDirectory" ] )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700245 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700246 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700247}