blob: 8a140ef224eed639a07f160b394dc4ef7e631e52 [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 Ronquillo3c2f10d2019-06-10 16:54:46 -070039simulateDay = null
40day = null
Jeremy Ronquillo4fd82442019-05-21 20:56:58 -070041
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070042dayMap = [:]
43fullDayMap = [:]
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070044all_testcases = [:]
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070045runTest = [:]
46selectedTests = [:]
47graphPaths = [:]
Devin Lim2edfcec2018-05-09 17:16:21 -070048
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070049main()
Devin Limf5175192018-05-14 19:13:22 -070050
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070051def main() {
52 init()
53 runTests()
54 generateGraphs()
55}
56
57// **************
58// Initialization
59// **************
60
61// initialize file scope vars
62def init(){
63 // get the name of the job.
64 jobName = env.JOB_NAME
65
66 // set the versions of the onos
67 fileRelated.init()
68 test_list.init()
69 readParams()
70
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -070071 funcs.initializeTrend( "Fabric" )
72 funcs.initialize( "Fabric" )
73
74 funcs.initializeTrend( "VM" )
75
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070076 triggerFuncs.init( funcs )
77
78 // list of the tests to be run will be saved in each choices.
79 day = ""
80
81 initDates()
82 onos_branches = getONOSBranches()
83 selectedTests = getONOSTests()
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -070084
Jeremy Ronquillod98c2a12019-06-07 15:13:29 -070085 initGraphPaths()
86
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -070087 echo "selectedTests: " + selectedTests
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -070088 echo "onos_branches: " + onos_branches
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -070089}
90
91def readParams(){
92 // get post result from the params for manually run.
93 post_result = params.PostResult
94 manually_run = params.manual_run
95 onos_tag = params.ONOSTag
96 branchesParam = params.branches
97 isOldFlow = params.isOldFlow
98 testsParam = params.Tests
99 isFabric = params.isFabric
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700100 simulateDay = params.simulate_day
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700101}
Devin Lim2edfcec2018-05-09 17:16:21 -0700102
103// Set tests based on day of week
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700104def initDates(){
105 echo "-> initDates()"
106 now = funcs.getCurrentTime()
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700107 dayMap = [ ( Calendar.MONDAY ) : "mon",
108 ( Calendar.TUESDAY ) : "tue",
109 ( Calendar.WEDNESDAY ) : "wed",
110 ( Calendar.THURSDAY ) : "thu",
111 ( Calendar.FRIDAY ) : "fri",
112 ( Calendar.SATURDAY ) : "sat",
113 ( Calendar.SUNDAY ) : "sun" ]
114 fullDayMap = [ ( Calendar.MONDAY ) : "Monday",
115 ( Calendar.TUESDAY ) : "Tuesday",
116 ( Calendar.WEDNESDAY ) : "Wednesday",
117 ( Calendar.THURSDAY ) : "Thursday",
118 ( Calendar.FRIDAY ) : "Friday",
119 ( Calendar.SATURDAY ) : "Saturday",
120 ( Calendar.SUNDAY ) : "Sunday" ]
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700121 if ( simulateDay == "" ){
122 today = now[ Calendar.DAY_OF_WEEK ]
123 day = dayMap[ today ]
124 print now.toString()
125 } else {
126 day = simulateDay
127 }
Jon Hall6af749d2018-05-29 12:59:47 -0700128}
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700129
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700130// gets ONOS branches from params or string parameter
131def getONOSBranches(){
132 echo "-> getONOSBranches()"
133 if ( manually_run ){
134 return branchesParam.tokenize( "\n;, " )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700135 } else {
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700136 return test_list.getBranchesFromDay( day )
Devin Lim2edfcec2018-05-09 17:16:21 -0700137 }
138}
Devin Limf5175192018-05-14 19:13:22 -0700139
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700140def getONOSTests(){
141 echo "-> getONOSTests()"
142 if ( manually_run ){
143 return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) )
144 } else {
Jeremy Ronquillo3c2f10d2019-06-10 16:54:46 -0700145
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700146 return test_list.getTestsFromDay( day )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700147 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700148}
Devin Limf5175192018-05-14 19:13:22 -0700149
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700150// init paths for the files and directories.
151def initGraphPaths(){
Jeremy Ronquillod98c2a12019-06-07 15:13:29 -0700152 graphPaths.put( "histogramMultiple", fileRelated.histogramMultiple )
153 graphPaths.put( "pieMultiple", fileRelated.pieMultiple )
154 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700155}
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700156
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700157// **********************
158// Determine Tests to Run
159// **********************
160
161def printTestsToRun( runList ){
162 if ( manually_run ){
163 println "Tests to be run manually:"
164 } else {
165 if ( isFabric ){
166 postToSlackSR()
Devin Lim2edfcec2018-05-09 17:16:21 -0700167 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700168 if ( today == Calendar.MONDAY ){
169 postToSlackTestsToRun()
170 }
171 println "Defaulting to " + day + " tests:"
Devin Lim2edfcec2018-05-09 17:16:21 -0700172 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700173 for ( list in runList ){
174 // triggerFuncs.print_tests( all_testcases[ b ] )
175 echo "" + list
176 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700177}
Devin Limf5175192018-05-14 19:13:22 -0700178
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700179def postToSlackSR(){
180 // If it is automated running, it will post the beginning message to the channel.
181 slackSend( channel: 'sr-failures', color: '#03CD9F',
182 message: ":sparkles:" * 16 + "\n" +
183 "Starting tests on : " + now.toString() +
184 "\n" + ":sparkles:" * 16 )
185}
186
187def postToSlackTestsToRun(){
188 slackSend( color: '#FFD988',
189 message: "Tests to be run this weekdays : \n" +
190 triggerFuncs.printDaysForTest() )
191}
192
193// *********
194// Run Tests
195// *********
196
197def generateRunList(){
198 runList = [:]
199 for ( branch in onos_branches ){
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -0700200 runBranch = []
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700201 nodeLabels = test_list.getAllNodeLabels( branch, selectedTests )
202 for ( nodeLabel in nodeLabels ){
203 selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests )
204 selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests )
205 for ( category in selectedNodeLabelCategories ){
Jeremy Ronquilloa5aa7c12019-06-04 10:26:36 -0700206 selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests )
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700207 exeTestList = test_list.getTestListAsString( selectedNodeLabelCategoryTests )
Jeremy Ronquillof3b173d2019-06-07 14:53:25 -0700208 runList.put( branch + "-" + nodeLabel + "-" + category, triggerFuncs.trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) )
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700209 }
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700210 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700211 }
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700212 return runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700213}
Devin Limf5175192018-05-14 19:13:22 -0700214
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700215def runTests(){
216 runList = generateRunList()
217 printTestsToRun( runList )
218 parallel runList
Devin Lim2edfcec2018-05-09 17:16:21 -0700219}
Devin Limf5175192018-05-14 19:13:22 -0700220
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700221// ***************
222// Generate Graphs
223// ***************
Devin Lim2edfcec2018-05-09 17:16:21 -0700224
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700225def generateGraphs(){
226 // If it is automated running, it will generate the stats graph on VM.
227 if ( !manually_run ){
228 for ( String b in onos_branches ){
229 funcs.generateStatGraph( "TestStation-VMs",
230 funcs.branchWithPrefix( b ),
231 graphPaths[ "histogramMultiple" ],
232 graphPaths[ "pieMultiple" ],
233 graphPaths[ "saveDirectory" ] )
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700234 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700235 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700236}