blob: 4c9c8228fcc39ad4d95c7c6d50418c9dfdbeb4e9 [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' )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070025test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
Devin Limb734ea52018-05-14 14:13:05 -070026triggerFuncs = 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()
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070030test_list.init()
Devin Limf5175192018-05-14 19:13:22 -070031
Devin Limf5175192018-05-14 19:13:22 -070032// Function that will initialize the configuration of the Fabric.
You Wang96b98ad2018-05-25 12:14:45 -070033funcs.initializeTrend( "Fabric" )
Devin Lim431408d2018-03-23 17:51:31 -070034funcs.initialize( "Fabric" )
35triggerFuncs.init( funcs )
36
Devin Limf5175192018-05-14 19:13:22 -070037// Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule
38// It will only be used by the VM_BMJenkinsTrigger not in here.
Devin Lim431408d2018-03-23 17:51:31 -070039wikiContents = ""
Devin Limf5175192018-05-14 19:13:22 -070040
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070041all_testcases = [:]
Devin Lim431408d2018-03-23 17:51:31 -070042
Devin Limf5175192018-05-14 19:13:22 -070043// set some variables from the parameter
Devin Lim431408d2018-03-23 17:51:31 -070044manually_run = params.manual_run
Devin Lim431408d2018-03-23 17:51:31 -070045onos_tag = params.ONOSTag
46isOldFlow = true
47
48// Set tests based on day of week
49def now = funcs.getCurrentTime()
50print now.toString()
51today = now[ Calendar.DAY_OF_WEEK ]
52
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070053dayMap = [ ( Calendar.MONDAY ) : "mon",
54 ( Calendar.TUESDAY ) : "tue",
55 ( Calendar.WEDNESDAY ) : "wed",
56 ( Calendar.THURSDAY ) : "thu",
57 ( Calendar.FRIDAY ) : "fri",
58 ( Calendar.SATURDAY ) : "sat",
59 ( Calendar.SUNDAY ) : "sun" ]
60fullDayMap = [ ( Calendar.MONDAY ) : "Monday",
61 ( Calendar.TUESDAY ) : "Tuesday",
62 ( Calendar.WEDNESDAY ) : "Wednesday",
63 ( Calendar.THURSDAY ) : "Thursday",
64 ( Calendar.FRIDAY ) : "Friday",
65 ( Calendar.SATURDAY ) : "Saturday",
66 ( Calendar.SUNDAY ) : "Sunday" ]
67
68
Devin Limf5175192018-05-14 19:13:22 -070069// if it is manually run, it will set the onos version to be what it was passed by.
70// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
Devin Lim431408d2018-03-23 17:51:31 -070071if ( manually_run ){
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070072 onos_branches = params.branches.tokenize( "\n;, " )
73} else {
74 onos_branches = test_list.getBranchesFromDay( today )
Devin Lim431408d2018-03-23 17:51:31 -070075}
Devin Limf5175192018-05-14 19:13:22 -070076
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070077testcases_template = [
78 "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ],
79 "HA": [ tests: "", nodeName: "VM", wikiContent: "" ],
80 "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ],
81 "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
82 "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
83 "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
84]
Devin Lim431408d2018-03-23 17:51:31 -070085
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070086for ( String b in onos_branches ){
87 all_testcases.put( b, testcases_template )
88}
Devin Limf5175192018-05-14 19:13:22 -070089
Devin Lim431408d2018-03-23 17:51:31 -070090day = ""
Devin Limf5175192018-05-14 19:13:22 -070091
Devin Limf5175192018-05-14 19:13:22 -070092// initialize the graph generating files.
Devin Limfe9a4cb2018-05-11 17:06:21 -070093stat_graph_generator_file = fileRelated.histogramMultiple
94pie_graph_generator_file = fileRelated.pieMultiple
95graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"
Devin Lim431408d2018-03-23 17:51:31 -070096
Devin Limf5175192018-05-14 19:13:22 -070097// get the post_result. This will be affected only for the manual runs.
Devin Lim431408d2018-03-23 17:51:31 -070098post_result = params.PostResult
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -070099
100if ( manually_run ){
101 for ( String b in onos_branches ){
102 all_testcases[ b ] = triggerFuncs.organize_tests( params.Tests, all_testcases[ b ] )
103 }
104 isOldFlow = params.isOldFlow
105 println "Tests to be run manually : "
106} else {
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700107 for ( String b in onos_branches ){
108 // set the list of the tests to run.
109 all_testcases[ b ][ "SR" ][ "tests" ] += adder( "SR", dayMap[ today ], true, b )
110 all_testcases[ b ][ "SRHA" ][ "tests" ] += adder( "SRHA", dayMap[ today ], true, b )
111 }
Devin Lim431408d2018-03-23 17:51:31 -0700112 println "Defaulting to " + day + " tests:"
113}
114
Devin Limf5175192018-05-14 19:13:22 -0700115// print out the list of the test to run on Jenkins
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700116for ( String b in onos_branches ){
117 triggerFuncs.print_tests( all_testcases[ b ] )
118}
Devin Lim431408d2018-03-23 17:51:31 -0700119
Devin Limf5175192018-05-14 19:13:22 -0700120// This will hold the block of code to be run.
Devin Lim431408d2018-03-23 17:51:31 -0700121def runTest = [
Jeremy Ronquillo96e2bd32019-05-28 15:40:18 -0700122
Devin Lim431408d2018-03-23 17:51:31 -0700123]
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700124for ( String b in onos_branches ){
125 if ( manually_run ){
126 // for manual run situation.
127 for ( String test in all_testcases[ b ].keySet() ){
128 println test
129 // Unless the list of the tests on the test category is empty, it will save the block of code to run in dictionary.
130 if ( all_testcases[ b ][ test ][ "tests" ] != "" ){
131 runTest[ all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( b ) ] ][ test ] = triggerFuncs.
132 trigger_pipeline( b,
133 all_testcases[ b ][ test ][ "tests" ],
134 all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( b ) ],
135 test,
136 manually_run,
137 onos_tag )
138 }
Devin Lim2edfcec2018-05-09 17:16:21 -0700139 }
Devin Lim431408d2018-03-23 17:51:31 -0700140 }
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700141 else {
142 // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3.
143 runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( "master",
144 all_testcases[ b ][ "SR" ][ "tests" ],
145 all_testcases[ b ][ "SR" ][ "nodeName" ][ 2 ],
146 "SR",
147 manually_run, onos_tag )
148 runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-2.x" ),
149 all_testcases[ b ][ "SR" ][ "tests" ],
150 all_testcases[ b ][ "SR" ][ "nodeName" ][ 0 ],
151 "SR",
152 manually_run, onos_tag )
153 runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-1.x" ),
154 all_testcases[ b ][ "SR" ][ "tests" ],
155 all_testcases[ b ][ "SR" ][ "nodeName" ][ 1 ],
156 "SR",
157 manually_run, onos_tag )
158 runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( "master",
159 all_testcases[ b ][ "SRHA" ][ "tests" ],
160 all_testcases[ b ][ "SRHA" ][ "nodeName" ],
161 "SRHA",
162 manually_run, onos_tag )
163 }
Devin Lim431408d2018-03-23 17:51:31 -0700164}
Devin Lim2edfcec2018-05-09 17:16:21 -0700165
Jon Hall6af749d2018-05-29 12:59:47 -0700166def finalList = [ : ]
Devin Limf5175192018-05-14 19:13:22 -0700167
168// It will run each category of test to run sequentially on each branch.
Jon Hall2ee92f82018-06-07 13:07:33 -0700169finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
Devin Lim86e40532018-04-06 12:44:06 -0700170finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
171finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
You Wang96b98ad2018-05-25 12:14:45 -0700172finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )
Devin Limf5175192018-05-14 19:13:22 -0700173
You Wang96b98ad2018-05-25 12:14:45 -0700174// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
Devin Limf5175192018-05-14 19:13:22 -0700175// In our case,
You Wang96b98ad2018-05-25 12:14:45 -0700176// ----> Fabric4 : current_version
177// This pipeline -----> ----> Fabric2 : previous_version
178// ----> Fabric3 : before_previous_version
Devin Lim431408d2018-03-23 17:51:31 -0700179parallel finalList
Devin Limf5175192018-05-14 19:13:22 -0700180
181// Way we are generating pie graphs. not supported in SegmentRouting yet.
Devin Lim431408d2018-03-23 17:51:31 -0700182/*
183if ( !manually_run ){
You Wang96b98ad2018-05-25 12:14:45 -0700184 funcs.generateStatGraph( "TestStation-Fabric4s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700185 funcs.branchWithPrefix( current_version ),
You Wang96b98ad2018-05-25 12:14:45 -0700186 AllTheTests,
187 stat_graph_generator_file,
188 pie_graph_generator_file,
189 graph_saved_directory )
Devin Lim86e40532018-04-06 12:44:06 -0700190 funcs.generateStatGraph( "TestStation-Fabric2s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700191 funcs.branchWithPrefix( previous_version ),
Devin Lim86e40532018-04-06 12:44:06 -0700192 AllTheTests,
193 stat_graph_generator_file,
194 pie_graph_generator_file,
195 graph_saved_directory )
196 funcs.generateStatGraph( "TestStation-Fabric3s",
Devin Limc8ecd6c2018-05-25 13:27:22 -0700197 funcs.branchWithPrefix( before_previous_version ),
Devin Lim431408d2018-03-23 17:51:31 -0700198 AllTheTests,
199 stat_graph_generator_file,
200 pie_graph_generator_file,
201 graph_saved_directory )
202}*/
Devin Limf5175192018-05-14 19:13:22 -0700203
204// Way to add list of the tests with specific category to the result
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700205def adder( category, day, getResult, branch ){
Jeremy Ronquillofdf65582019-05-21 21:07:05 -0700206 // category : the category of the test which will be either FUNC,HA,SR...
207 // day : the day you are trying to add (m,t,w,th... )
208 // getResult : if want to get the list of the test to be run. False will return empty list.
209 // And once the list is empty, it will not be run.
210 def result = ""
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700211 selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -0700212
213 for ( String test in selectedTests.keySet() ){
214 if ( getResult ){
215 result += test + ","
Devin Lim431408d2018-03-23 17:51:31 -0700216 }
217 }
218 return result
Devin Limb6f92de2018-04-13 18:27:33 -0700219}
Devin Limf5175192018-05-14 19:13:22 -0700220
221// check which node is on.
Devin Lim2edfcec2018-05-09 17:16:21 -0700222def nodeOn( branch ){
Jon Hall6af749d2018-05-29 12:59:47 -0700223 switch ( branch ){
Jeremy Ronquilloa37920b2019-05-23 14:34:25 -0700224 case "master": return 2
225 case convertBranchCodeToBranch( "onos-2.x" ): return 0
226 case convertBranchCodeToBranch( "onos-1.x" ): return 1
227 default: return 3
You Wang96b98ad2018-05-25 12:14:45 -0700228 }
Devin Lim0c25f2f2018-05-10 15:43:09 -0700229}