blob: 5ba40558cba0e3a457ade02b094e6eb404aab545 [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' )
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 Lim2edfcec2018-05-09 17:16:21 -070028
Devin Limf5175192018-05-14 19:13:22 -070029// set the versions of the onos
Devin Limfe9a4cb2018-05-11 17:06:21 -070030fileRelated.init()
You Wang7ca7dc72018-09-05 10:56:24 -070031current_version = "master"
32previous_version = "1.14"
33before_previous_version = "1.13"
Devin Limf5175192018-05-14 19:13:22 -070034
35// init trend graphs to be on VM.
Devin Lim2edfcec2018-05-09 17:16:21 -070036funcs.initializeTrend( "VM" );
37triggerFuncs.init( funcs )
Devin Limf5175192018-05-14 19:13:22 -070038
39// contents for page https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule
40// which will demonstrates the list of the scheduled tests on the days.
Devin Lim2edfcec2018-05-09 17:16:21 -070041wikiContents = ""
Devin Limf5175192018-05-14 19:13:22 -070042
43// default FUNC,HA to be VM, SCPF,USECASE to be BM.
44// SR will not be used in here.
Devin Lim2edfcec2018-05-09 17:16:21 -070045testcases = [
Jon Hall6af749d2018-05-29 12:59:47 -070046 "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ],
47 "HA": [ tests: "", nodeName: "VM", wikiContent: "" ],
48 "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ],
49 "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
Jon Hall2ee92f82018-06-07 13:07:33 -070050 "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
Jon Hall6af749d2018-05-29 12:59:47 -070051 "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
Devin Lim2edfcec2018-05-09 17:16:21 -070052]
53
Devin Limf5175192018-05-14 19:13:22 -070054// read the parameters from the Jenkins
Devin Lim2edfcec2018-05-09 17:16:21 -070055manually_run = params.manual_run
Devin Limf5175192018-05-14 19:13:22 -070056
57// set default onos_b to be current_version.
Devin Lim2edfcec2018-05-09 17:16:21 -070058onos_b = current_version
59test_branch = ""
60onos_tag = params.ONOSTag
61isOldFlow = true
62
63// Set tests based on day of week
64def now = funcs.getCurrentTime()
65print now.toString()
66today = now[ Calendar.DAY_OF_WEEK ]
67
Devin Limf5175192018-05-14 19:13:22 -070068// get branch from parameter if it is manually running
Devin Lim2edfcec2018-05-09 17:16:21 -070069if ( manually_run ){
70 onos_b = params.ONOSVersion
Jon Hall6af749d2018-05-29 12:59:47 -070071}
72else {
Devin Limf5175192018-05-14 19:13:22 -070073 // otherwise, the version would be different over the weekend.
74 // If today is weekdays, it will be default to current_version.
Devin Lim2edfcec2018-05-09 17:16:21 -070075 if ( today == Calendar.SATURDAY ){
76 onos_b = previous_version
Jon Hall6af749d2018-05-29 12:59:47 -070077 }
78 else if ( today == Calendar.SUNDAY ){
Devin Lim2edfcec2018-05-09 17:16:21 -070079 onos_b = before_previous_version
80 }
81}
Devin Limf5175192018-05-14 19:13:22 -070082
83// Get all the list of the tests from the JenkinsTestONTests.groovy
Devin Lim2edfcec2018-05-09 17:16:21 -070084AllTheTests = test_lists.getAllTheTests( onos_b )
85
Devin Limf5175192018-05-14 19:13:22 -070086// list of the tests to be run will be saved in each choices.
Devin Lim2edfcec2018-05-09 17:16:21 -070087day = ""
88SCPF_choices = ""
89USECASE_choices = ""
90FUNC_choices = ""
91HA_choices = ""
92SR_choices = ""
Jon Hall2ee92f82018-06-07 13:07:33 -070093SRHA_choices = ""
Devin Limf5175192018-05-14 19:13:22 -070094
95// init some paths for the files and directories.
Devin Limfe9a4cb2018-05-11 17:06:21 -070096stat_graph_generator_file = fileRelated.histogramMultiple
97pie_graph_generator_file = fileRelated.pieMultiple
98graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/"
Devin Lim2edfcec2018-05-09 17:16:21 -070099
Devin Limf5175192018-05-14 19:13:22 -0700100// get post result from the params for manually run.
Devin Lim2edfcec2018-05-09 17:16:21 -0700101post_result = params.PostResult
Devin Limf5175192018-05-14 19:13:22 -0700102
103// if automatically run, it will remove the comma at the end after dividing the tests.
Jon Hall6af749d2018-05-29 12:59:47 -0700104if ( !manually_run ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700105 testDivider( today )
Jon Hall6af749d2018-05-29 12:59:47 -0700106 FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices )
107 HA_choices = triggerFuncs.lastCommaRemover( HA_choices )
108 SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices )
109 USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices )
110 SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
Jon Hall2ee92f82018-06-07 13:07:33 -0700111 SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices )
Devin Lim2edfcec2018-05-09 17:16:21 -0700112}
113
Devin Limf5175192018-05-14 19:13:22 -0700114
Devin Lim2edfcec2018-05-09 17:16:21 -0700115if ( manually_run ){
116 testcases = triggerFuncs.organize_tests( params.Tests, testcases )
117
118 isOldFlow = params.isOldFlow
119 println "Tests to be run manually : "
Jon Hall6af749d2018-05-29 12:59:47 -0700120}
121else {
Devin Lim2edfcec2018-05-09 17:16:21 -0700122 testcases[ "SCPF" ][ "tests" ] = SCPF_choices
123 testcases[ "USECASE" ][ "tests" ] = USECASE_choices
124 testcases[ "FUNC" ][ "tests" ] = FUNC_choices
125 testcases[ "HA" ][ "tests" ] = HA_choices
126 testcases[ "SR" ][ "tests" ] = SR_choices
Jon Hall2ee92f82018-06-07 13:07:33 -0700127 testcases[ "SRHA" ][ "tests" ] = SRHA_choices
Devin Lim2edfcec2018-05-09 17:16:21 -0700128 println "Defaulting to " + day + " tests:"
129}
130
131triggerFuncs.print_tests( testcases )
132
133def runTest = [
Jon Hall6af749d2018-05-29 12:59:47 -0700134 "VM": [ : ],
135 "BM": [ : ]
Devin Lim2edfcec2018-05-09 17:16:21 -0700136]
Devin Limf5175192018-05-14 19:13:22 -0700137
138// set the test running function into the dictionary.
Jon Hall6af749d2018-05-29 12:59:47 -0700139for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700140 println test
141 if ( testcases[ test ][ "tests" ] != "" ){
Jon Hall6af749d2018-05-29 12:59:47 -0700142 runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs.
143 trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test,
144 manually_run, onos_tag )
Devin Lim2edfcec2018-05-09 17:16:21 -0700145 }
146}
Jon Hall6af749d2018-05-29 12:59:47 -0700147def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700148
149// get the name of the job.
Devin Limb91bf792018-05-10 15:09:52 -0700150jobName = env.JOB_NAME
Devin Limf5175192018-05-14 19:13:22 -0700151
152// first set the list of the functions to be run.
Devin Lim2edfcec2018-05-09 17:16:21 -0700153finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] )
154finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] )
Devin Limf5175192018-05-14 19:13:22 -0700155
156// if first two character of the job name is vm, only call VM.
157// else, only on BM
Jon Hall6af749d2018-05-29 12:59:47 -0700158if ( jobName.take( 2 ) == "vm" ){
Devin Limb91bf792018-05-10 15:09:52 -0700159 finalList[ "VM" ].call()
Jon Hall6af749d2018-05-29 12:59:47 -0700160}
161else {
Devin Limb91bf792018-05-10 15:09:52 -0700162 finalList[ "BM" ].call()
Jon Hall6af749d2018-05-29 12:59:47 -0700163}
Devin Lim2edfcec2018-05-09 17:16:21 -0700164
Devin Limf5175192018-05-14 19:13:22 -0700165// If it is automated running, it will generate the stats graph on VM.
Devin Lim2edfcec2018-05-09 17:16:21 -0700166if ( !manually_run ){
167 funcs.generateStatGraph( "TestStation-VMs",
168 funcs.branchWithPrefix( onos_b ),
169 AllTheTests,
170 stat_graph_generator_file,
171 pie_graph_generator_file,
172 graph_saved_directory )
173}
174
Devin Limf5175192018-05-14 19:13:22 -0700175// function that will divide tests depends on which day it is.
Devin Lim2edfcec2018-05-09 17:16:21 -0700176def testDivider( today ){
Jon Hall6af749d2018-05-29 12:59:47 -0700177 switch ( today ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700178 case Calendar.MONDAY:
Devin Limf5175192018-05-14 19:13:22 -0700179 // THe reason Monday calls all the days is because we want to post the test schedules on the wiki
180 // and slack channel every monday.
181 // It will only generate the list of the test for monday.
Devin Lim2edfcec2018-05-09 17:16:21 -0700182 initHtmlForWiki()
183 monday( true )
184 tuesday( true, false )
185 wednesday( true, false )
186 thursday( true, false )
187 friday( true, false )
188 saturday( false, false )
189 sunday( false, false )
190 day = "Monday"
191 closeHtmlForWiki()
192 postToWiki( wikiContents )
Jon Hall6af749d2018-05-29 12:59:47 -0700193 slackSend( color: '#FFD988',
194 message: "Tests to be run this weekdays : \n" +
195 triggerFuncs.printDaysForTest( AllTheTests ) )
Devin Lim2edfcec2018-05-09 17:16:21 -0700196 break
197 case Calendar.TUESDAY:
198 tuesday( false, true )
199 day = "Tuesday"
200 break
201 case Calendar.WEDNESDAY:
202 wednesday( false, true )
203 day = "Wednesday"
204 break
205 case Calendar.THURSDAY:
206 thursday( false, true )
207 day = "Thursday"
208 break
209 case Calendar.FRIDAY:
210 friday( false, true )
211 day = "Friday"
212 break
213 case Calendar.SATURDAY:
214 saturday( false, true )
215 day = "Saturday"
216 break
217 case Calendar.SUNDAY:
Jon Hall6af749d2018-05-29 12:59:47 -0700218 sunday( false, true )
Devin Lim2edfcec2018-05-09 17:16:21 -0700219 day = "Sunday"
220 break
221 }
222}
Devin Limf5175192018-05-14 19:13:22 -0700223
224// function for monday.
Devin Lim2edfcec2018-05-09 17:16:21 -0700225def monday( getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700226 // add header for wiki page script.
Devin Lim2edfcec2018-05-09 17:16:21 -0700227 addingHeader( "FUNC" )
Devin Limf5175192018-05-14 19:13:22 -0700228 // call category of basic and extra_A of FUNC tests.
229 // put M into the dictionary.
Devin Lim2edfcec2018-05-09 17:16:21 -0700230 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
231 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
232 closingHeader( "FUNC" )
233 addingHeader( "HA" )
234 HA_choices += adder( "HA", "basic", true, "M", getResult )
235 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
236 closingHeader( "HA" )
237 addingHeader( "SCPF" )
238 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
239 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
240 closingHeader( "SCPF" )
241 addingHeader( "SR" )
242 SR_choices += adder( "SR", "basic", true, "M", false )
243 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700244 addingHeader( "SRHA" )
245 SRHA_choices += adder( "SRHA", "basic", true, "M", false )
246 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700247 addingHeader( "USECASE" )
248 closingHeader( "USECASE" )
249}
Devin Limf5175192018-05-14 19:13:22 -0700250
251// If get result is false, it will not add the test result to xx_choices, but will generate the
252// header and days
Devin Lim2edfcec2018-05-09 17:16:21 -0700253def tuesday( getDay, getResult ){
254 addingHeader( "FUNC" )
255 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
256 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
257 closingHeader( "FUNC" )
258 addingHeader( "HA" )
259 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
260 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
261 closingHeader( "HA" )
262 addingHeader( "SCPF" )
263 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
264 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
265 closingHeader( "SCPF" )
266 addingHeader( "SR" )
267 SR_choices += adder( "SR", "basic", getDay, "T", false )
268 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700269 addingHeader( "SRHA" )
270 SRHA_choices += adder( "SRHA", "basic", getDay, "T", false )
271 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700272 addingHeader( "USECASE" )
273 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
274 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
275 closingHeader( "USECASE" )
276}
Jon Hall6af749d2018-05-29 12:59:47 -0700277
Devin Lim2edfcec2018-05-09 17:16:21 -0700278def wednesday( getDay, getResult ){
279 addingHeader( "FUNC" )
280 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
281 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
282 closingHeader( "FUNC" )
283 addingHeader( "HA" )
284 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
285 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
286 closingHeader( "HA" )
287 addingHeader( "SCPF" )
288 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
289 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
290 closingHeader( "SCPF" )
291 addingHeader( "SR" )
292 SR_choices += adder( "SR", "basic", getDay, "W", false )
293 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700294 addingHeader( "SRHA" )
295 SRHA_choices += adder( "SRHA", "basic", getDay, "W", false )
296 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700297 addingHeader( "USECASE" )
298 closingHeader( "USECASE" )
299}
Jon Hall6af749d2018-05-29 12:59:47 -0700300
Devin Lim2edfcec2018-05-09 17:16:21 -0700301def thursday( getDay, getResult ){
302 addingHeader( "FUNC" )
303 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
304 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
305 closingHeader( "FUNC" )
306 addingHeader( "HA" )
307 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
308 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
309 closingHeader( "HA" )
310 addingHeader( "SCPF" )
311 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
312 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
313 closingHeader( "SCPF" )
314 addingHeader( "SR" )
315 SR_choices += adder( "SR", "basic", getDay, "Th", false )
316 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700317 addingHeader( "SRHA" )
318 SRHA_choices += adder( "SRHA", "basic", getDay, "Th", false )
319 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700320 addingHeader( "USECASE" )
321 closingHeader( "USECASE" )
322}
Jon Hall6af749d2018-05-29 12:59:47 -0700323
Devin Lim2edfcec2018-05-09 17:16:21 -0700324def friday( getDay, getResult ){
325 addingHeader( "FUNC" )
326 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
327 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
328 closingHeader( "FUNC" )
329 addingHeader( "HA" )
330 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
331 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
332 closingHeader( "HA" )
333 addingHeader( "SCPF" )
334 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
335 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
336 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
337 closingHeader( "SCPF" )
338 addingHeader( "SR" )
339 SR_choices += adder( "SR", "basic", getDay, "F", false )
340 SR_choices += adder( "SR", "extra_A", getDay, "F", false )
341 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700342 addingHeader( "SRHA" )
343 SRHA_choices += adder( "SRHA", "basic", getDay, "F", false )
344 SRHA_choices += adder( "SRHA", "extra_A", getDay, "F", false )
345 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700346 addingHeader( "USECASE" )
347 closingHeader( "USECASE" )
348}
Jon Hall6af749d2018-05-29 12:59:47 -0700349
Devin Lim2edfcec2018-05-09 17:16:21 -0700350def saturday( getDay, getResult ){
351 addingHeader( "FUNC" )
352 FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult )
353 FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult )
354 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult )
355 closingHeader( "FUNC" )
356 addingHeader( "HA" )
357 HA_choices += adder( "HA", "basic", getDay, "Sa", getResult )
358 HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult )
359 HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult )
360 closingHeader( "HA" )
361 addingHeader( "SCPF" )
362 SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult )
363 SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult )
364 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult )
365 SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult )
366 SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult )
367 closingHeader( "SCPF" )
368 addingHeader( "SR" )
369 SR_choices += adder( "SR", "basic", getDay, "Sa", false )
370 SR_choices += adder( "SR", "extra_B", getDay, "Sa", false )
371 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700372 addingHeader( "SRHA" )
373 SRHA_choices += adder( "SRHA", "basic", getDay, "Sa", false )
374 SRHA_choices += adder( "SRHA", "extra_B", getDay, "Sa", false )
375 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700376 addingHeader( "USECASE" )
377 USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult )
378 closingHeader( "USECASE" )
379}
Jon Hall6af749d2018-05-29 12:59:47 -0700380
Devin Lim2edfcec2018-05-09 17:16:21 -0700381def sunday( getDay, getResult ){
382 addingHeader( "FUNC" )
383 FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult )
384 FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult )
385 FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult )
386 closingHeader( "FUNC" )
387 addingHeader( "HA" )
388 HA_choices += adder( "HA", "basic", getDay, "S", getResult )
389 HA_choices += adder( "HA", "extra_A", getDay, "S", getResult )
390 HA_choices += adder( "HA", "extra_B", getDay, "S", getResult )
391 closingHeader( "HA" )
392 addingHeader( "SCPF" )
393 SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult )
394 SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult )
395 SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult )
396 SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult )
397 SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult )
398 closingHeader( "SCPF" )
399 addingHeader( "SR" )
400 SR_choices += adder( "SR", "basic", getDay, "S", false )
401 closingHeader( "SR" )
Jon Hall2ee92f82018-06-07 13:07:33 -0700402 addingHeader( "SRHA" )
403 SRHA_choices += adder( "SRHA", "basic", getDay, "S", false )
404 closingHeader( "SRHA" )
Devin Lim2edfcec2018-05-09 17:16:21 -0700405 addingHeader( "USECASE" )
406 USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult )
407 closingHeader( "USECASE" )
408}
Devin Limf5175192018-05-14 19:13:22 -0700409
410// adder that will return the list of the tests.
Devin Lim2edfcec2018-05-09 17:16:21 -0700411def adder( testCat, set, dayAdding, day, getResult ){
Devin Limf5175192018-05-14 19:13:22 -0700412 // testCat : the category of the test which will be either FUNC,HA,SR...
413 // set : the set of the test to be run which will be basic,extra_A,extra_B...
414 // dayAdding : boolean whether to add the days into the list or not
415 // day : the day you are trying to add (m,t,w,th... )
416 // getResult : if want to get the list of the test to be run. False will return empty list.
417 // And once the list is empty, it will not be run.
Jon Hall6af749d2018-05-29 12:59:47 -0700418 def result = ""
419 for ( String test in AllTheTests[ testCat ].keySet() ){
420 if ( AllTheTests[ testCat ][ test ][ set ] ){
421 if ( getResult ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700422 result += test + ","
Jon Hall6af749d2018-05-29 12:59:47 -0700423 }
424 if ( dayAdding ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700425 dayAdder( testCat, test, day )
Jon Hall6af749d2018-05-29 12:59:47 -0700426 }
Devin Limf5175192018-05-14 19:13:22 -0700427 // make HTML columns for wiki page on schedule.
Devin Lim2edfcec2018-05-09 17:16:21 -0700428 makeHtmlColList( testCat, test )
429 }
430 }
431 return result
432}
Devin Limf5175192018-05-14 19:13:22 -0700433
434// Initial part of the wiki page.
Devin Lim2edfcec2018-05-09 17:16:21 -0700435def initHtmlForWiki(){
436 wikiContents = '''
437 <table class="wrapped confluenceTable">
438 <colgroup>
439 <col />
440 <col />
441 <col />
442 <col />
443 <col />
444 <col />
445 </colgroup>
446 <tbody>
447 <tr>
448 <th colspan="1" class="confluenceTh">
449 <br />
450 </th>
451 <th class="confluenceTh"><p>Monday</p></th>
452 <th class="confluenceTh"><p>Tuesday</p></th>
453 <th class="confluenceTh"><p>Wednesday</p></th>
454 <th class="confluenceTh"><p>Thursday</p></th>
455 <th class="confluenceTh"><p>Friday</p></th>
456 <th class="confluenceTh"><p>Saturday</p></th>
457 <th class="confluenceTh"><p>Sunday</p></th>
458 </tr>'''
Jon Hall6af749d2018-05-29 12:59:47 -0700459 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700460 testcases[ test ][ 'wikiContent' ] = '''
461 <tr>
462 <th colspan="1" class="confluenceTh">''' + test + '''</th>'''
463 }
464}
Devin Limf5175192018-05-14 19:13:22 -0700465
466// adding header functionality.
Devin Lim2edfcec2018-05-09 17:16:21 -0700467def addingHeader( testCategory ){
468 testcases[ testCategory ][ 'wikiContent' ] += '''
469 <td class="confluenceTd">
470 <ul>'''
471}
Devin Limf5175192018-05-14 19:13:22 -0700472
473// making column list for html
Devin Lim2edfcec2018-05-09 17:16:21 -0700474def makeHtmlColList( testCategory, testName ){
475 testcases[ testCategory ][ 'wikiContent' ] += '''
Jon Hall6af749d2018-05-29 12:59:47 -0700476 <li>''' + testName + '''</li>'''
Devin Lim2edfcec2018-05-09 17:16:21 -0700477
478}
Devin Limf5175192018-05-14 19:13:22 -0700479
480// closing the header for html
Devin Lim2edfcec2018-05-09 17:16:21 -0700481def closingHeader( testCategory ){
482 testcases[ testCategory ][ 'wikiContent' ] += '''
483 </ul>
484 </td>'''
485}
Devin Limf5175192018-05-14 19:13:22 -0700486
487// close the html for the wiki page.
Devin Lim2edfcec2018-05-09 17:16:21 -0700488def closeHtmlForWiki(){
Jon Hall6af749d2018-05-29 12:59:47 -0700489 for ( String test in testcases.keySet() ){
Devin Lim2edfcec2018-05-09 17:16:21 -0700490 wikiContents += testcases[ test ][ 'wikiContent' ]
491 wikiContents += '''
492 </tr>'''
493 }
494 wikiContents += '''
495 </tbody>
496 </table>
497 <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p>
498 <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p>
Jon Hall6af749d2018-05-29 12:59:47 -0700499 <p>On <strong>Saturdays</strong>, all the other tests are built and run on the ''' +
500 funcs.branchWithPrefix( previous_version ) + ''' branch.</p>
501 <p>On <strong>Sundays</strong>, all the other tests are built and run on the ''' +
502 funcs.branchWithPrefix( before_previous_version ) + ''' branch.</p>'''
Devin Lim2edfcec2018-05-09 17:16:21 -0700503}
Devin Limf5175192018-05-14 19:13:22 -0700504
505// post the result to wiki page using publish to confluence.
Devin Lim2edfcec2018-05-09 17:16:21 -0700506def postToWiki( contents ){
Jon Hall6af749d2018-05-29 12:59:47 -0700507 node( testMachine ) {
Devin Limfe9a4cb2018-05-11 17:06:21 -0700508 workspace = fileRelated.jenkinsWorkspace + "all-pipeline-trigger/"
Devin Lim2edfcec2018-05-09 17:16:21 -0700509 filename = "jenkinsSchedule.txt"
510 writeFile file: workspace + filename, text: contents
511 funcs.publishToConfluence( "false", "true",
512 "Automated Test Schedule",
513 workspace + filename )
514 }
515}
Devin Limf5175192018-05-14 19:13:22 -0700516
517// add the day to the "day" on the dictionary.
Devin Lim2edfcec2018-05-09 17:16:21 -0700518def dayAdder( testCat, testName, dayOfWeek ){
519 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
520}