blob: e960d70027c753dd38a3ce770a2b40e52b10bb5a [file] [log] [blame]
Devin Lim90803a82017-08-29 13:41:44 -07001#!groovy
Devin Lim61643762017-12-07 15:55:38 -08002
Devin Lim81ab48b2018-02-09 14:24:57 -08003funcs = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsCommonFuncs.groovy' )
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -08004test_lists = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsTestONTests.groovy' )
5
Devin Lim61643762017-12-07 15:55:38 -08006previous_version = "1.12"
Devin Lim3fa96a92018-03-16 11:47:58 -07007before_previous_version = "1.11"
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -08008funcs.initializeTrend( "VM" );
Devin Lime89761a2018-03-16 17:52:57 -07009wikiContents = ""
Devin Lim90803a82017-08-29 13:41:44 -070010testcases = [
Devin Lime89761a2018-03-16 17:52:57 -070011 "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
12 "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
13 "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
14 "SR" : [ tests : "", nodeName : "VM", wikiContent : "" ],
15 "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
Devin Lim90803a82017-08-29 13:41:44 -070016]
17Prefix_organizer = [
18 "FU" : "FUNC",
19 "HA" : "HA",
20 "PL" : "USECASE",
21 "SA" : "USECASE",
22 "SC" : "SCPF",
Devin Lim61643762017-12-07 15:55:38 -080023 "SR" : "SR",
Devin Lim90803a82017-08-29 13:41:44 -070024 "US" : "USECASE",
25 "VP" : "USECASE"
26]
27
Jeremy Ronquillocdd177d2018-03-09 16:55:44 -080028manually_run = params.manual_run
Devin Lim61643762017-12-07 15:55:38 -080029onos_b = "master"
Devin Lim0e967162017-11-03 15:59:53 -070030test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070031onos_tag = params.ONOSTag
Devin Lim61643762017-12-07 15:55:38 -080032isOldFlow = true
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080033
Devin Lim90803a82017-08-29 13:41:44 -070034// Set tests based on day of week
Devin Limd1fb8e92018-02-28 16:29:33 -080035def now = funcs.getCurrentTime()
36print now.toString()
Devin Lim61643762017-12-07 15:55:38 -080037today = now[ Calendar.DAY_OF_WEEK ]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080038
Jeremy Ronquillocdd177d2018-03-09 16:55:44 -080039if ( manually_run ){
40 onos_b = params.ONOSVersion
41} else {
42 if ( today == Calendar.SATURDAY ){
43 onos_b = previous_version
44 } else if( today == Calendar.SUNDAY ){
45 onos_b = before_previous_version
46 }
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080047}
48AllTheTests = test_lists.getAllTheTests( onos_b )
49
Devin Lim90803a82017-08-29 13:41:44 -070050day = ""
Devin Lim61657e42017-10-09 17:24:40 -070051SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070052USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -070053FUNC_choices = ""
54HA_choices = ""
Devin Lim61643762017-12-07 15:55:38 -080055SR_choices = ""
56stat_graph_generator_file = "testCategoryBuildStats.R"
57pie_graph_generator_file = "testCategoryPiePassFail.R"
58graph_saved_directory = "/var/jenkins/workspace/postjob-VM/"
Devin Lim90803a82017-08-29 13:41:44 -070059
Devin Lim90803a82017-08-29 13:41:44 -070060post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -070061if( !manually_run ){
Devin Lim61643762017-12-07 15:55:38 -080062 slackSend( color:'#03CD9F',
63 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
64 + "Starting tests on : " + now.toString()
65 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
Devin Lim61657e42017-10-09 17:24:40 -070066 testDivider( today )
67 FUNC_choices = lastCommaRemover( FUNC_choices )
68 HA_choices = lastCommaRemover( HA_choices )
69 SCPF_choices = lastCommaRemover( SCPF_choices )
70 USECASE_choices = lastCommaRemover( USECASE_choices )
Devin Lim61643762017-12-07 15:55:38 -080071 SR_choices = lastCommaRemover( SR_choices )
Devin Lim61657e42017-10-09 17:24:40 -070072}
73
Devin Lim90803a82017-08-29 13:41:44 -070074if ( manually_run ){
75 organize_tests( params.Tests )
Jeremy Ronquillocdd177d2018-03-09 16:55:44 -080076
Devin Lim0e967162017-11-03 15:59:53 -070077 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -070078 println "Tests to be run manually : "
79}else{
Devin Lim61643762017-12-07 15:55:38 -080080 testcases[ "SCPF" ][ "tests" ] = SCPF_choices
81 testcases[ "USECASE" ][ "tests" ] = USECASE_choices
82 testcases[ "FUNC" ][ "tests" ] = FUNC_choices
83 testcases[ "HA" ][ "tests" ] = HA_choices
84 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim90803a82017-08-29 13:41:44 -070085 println "Defaulting to " + day + " tests:"
86}
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080087
Devin Lim90803a82017-08-29 13:41:44 -070088print_tests( testcases )
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080089
Devin Lim37a83792017-10-26 16:38:21 -070090def runTest = [
91 "VM" : [:],
92 "BM" : [:]
93]
94for( String test in testcases.keySet() ){
95 println test
Devin Lim61643762017-12-07 15:55:38 -080096 if ( testcases[ test ][ "tests" ] != "" ){
97 runTest[ testcases[ test ][ "nodeName" ] ][ test ] = trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test, manually_run, onos_tag )
Devin Lim37a83792017-10-26 16:38:21 -070098 }
99}
100def finalList = [:]
Devin Lim61643762017-12-07 15:55:38 -0800101finalList[ "VM" ] = runTestSeq( runTest[ "VM" ] )
102finalList[ "BM" ] = runTestSeq( runTest[ "BM" ] )
Devin Lim37a83792017-10-26 16:38:21 -0700103parallel finalList
Devin Lim61643762017-12-07 15:55:38 -0800104//finalList[ "BM" ].call()
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800105
106if ( !manually_run ){
Jeremy Ronquillof78a6ca2018-03-12 09:20:57 -0700107 funcs.generateStatGraph( funcs.branchWithPrefix( onos_b ),
108 AllTheTests,
109 stat_graph_generator_file,
110 pie_graph_generator_file,
111 graph_saved_directory )
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800112}
Devin Lim90803a82017-08-29 13:41:44 -0700113
Devin Lim61657e42017-10-09 17:24:40 -0700114def testDivider( today ){
Devin Lim61643762017-12-07 15:55:38 -0800115 switch ( today ) {
Devin Lim61657e42017-10-09 17:24:40 -0700116 case Calendar.MONDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700117 initHtmlForWiki()
Devin Lim61657e42017-10-09 17:24:40 -0700118 monday( true )
119 tuesday( true, false )
120 wednesday( true, false )
121 thursday( true, false )
122 friday( true, false )
Devin Lime89761a2018-03-16 17:52:57 -0700123 saturday( false, false )
124 sunday( false, false )
Devin Lim61657e42017-10-09 17:24:40 -0700125 day = "Monday"
Devin Lime89761a2018-03-16 17:52:57 -0700126 closeHtmlForWiki()
127 postToWiki( wikiContents )
Devin Lim61643762017-12-07 15:55:38 -0800128 slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + printDaysForTest() )
Devin Lim61657e42017-10-09 17:24:40 -0700129 break
130 case Calendar.TUESDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700131 tuesday( false, true )
Devin Lim61657e42017-10-09 17:24:40 -0700132 day = "Tuesday"
133 break
134 case Calendar.WEDNESDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700135 wednesday( false, true )
Devin Lim61657e42017-10-09 17:24:40 -0700136 day = "Wednesday"
137 break
138 case Calendar.THURSDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700139 thursday( false, true )
Devin Lim61657e42017-10-09 17:24:40 -0700140 day = "Thursday"
141 break
142 case Calendar.FRIDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700143 friday( false, true )
Devin Lim61657e42017-10-09 17:24:40 -0700144 day = "Friday"
145 break
146 case Calendar.SATURDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700147 saturday( false, true )
Devin Lim61657e42017-10-09 17:24:40 -0700148 day = "Saturday"
149 break
150 case Calendar.SUNDAY:
Devin Lime89761a2018-03-16 17:52:57 -0700151 sunday( false , true )
Devin Lim61657e42017-10-09 17:24:40 -0700152 day = "Sunday"
Devin Lim3fa96a92018-03-16 11:47:58 -0700153 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700154 break
155 }
156}
157def printDaysForTest(){
158 result = ""
159 for ( String test in AllTheTests.keySet() ){
160 result += test + " : \n"
161 for( String each in AllTheTests[ test ].keySet() ){
162 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
163 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
164 }
165 result += "\n"
166 }
167 return result
168}
169def lastCommaRemover( str ){
170 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
171 str = str.substring( 0,str.size() - 1 )
172 }
173 return str
174}
175def monday( getResult ){
Devin Lime89761a2018-03-16 17:52:57 -0700176 addingHeader( "FUNC" )
Devin Lim61657e42017-10-09 17:24:40 -0700177 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800178 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700179 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700180 closingHeader( "FUNC" )
181 addingHeader( "HA" )
Devin Lim61657e42017-10-09 17:24:40 -0700182 HA_choices += adder( "HA", "basic", true, "M", getResult )
183 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800184 //HA_choices += adder( "HA", "new_Test", true, "M", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700185 closingHeader( "HA" )
186 addingHeader( "SCPF" )
Devin Lim61657e42017-10-09 17:24:40 -0700187 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
188 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700189 closingHeader( "SCPF" )
190 addingHeader( "SR" )
191 SR_choices += adder( "SR", "basic", true, "M", getResult )
192 closingHeader( "SR" )
193 addingHeader( "USECASE" )
194 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700195}
196def tuesday( getDay, getResult ){
Devin Lime89761a2018-03-16 17:52:57 -0700197
198 addingHeader( "FUNC" )
Devin Lim61657e42017-10-09 17:24:40 -0700199 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800200 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700201 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700202 closingHeader( "FUNC" )
203 addingHeader( "HA" )
Devin Lim61657e42017-10-09 17:24:40 -0700204 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
205 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800206 HA_choices += adder( "HA", "new_Test", getDay, "T", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700207 closingHeader( "HA" )
208 addingHeader( "SCPF" )
Devin Lim61657e42017-10-09 17:24:40 -0700209 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
210 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700211 closingHeader( "SCPF" )
212 addingHeader( "SR" )
213 SR_choices += adder( "SR", "basic", getDay, "T", getResult )
214 closingHeader( "SR" )
215 addingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700216 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
217 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700218 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700219}
220def wednesday( getDay, getResult ){
Devin Lime89761a2018-03-16 17:52:57 -0700221 addingHeader( "FUNC" )
Devin Lim61657e42017-10-09 17:24:40 -0700222 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800223 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700224 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700225 closingHeader( "FUNC" )
226 addingHeader( "HA" )
Devin Lim61657e42017-10-09 17:24:40 -0700227 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
228 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800229 //HA_choices += adder( "HA", "new_Test", getDay, "W", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700230 closingHeader( "HA" )
231 addingHeader( "SCPF" )
Devin Lim61657e42017-10-09 17:24:40 -0700232 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
233 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
234 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700235 closingHeader( "SCPF" )
236 addingHeader( "SR" )
237 SR_choices += adder( "SR", "basic", getDay, "W", getResult )
238 closingHeader( "SR" )
239 addingHeader( "USECASE" )
240 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700241}
242def thursday( getDay, getResult ){
Devin Lime89761a2018-03-16 17:52:57 -0700243 addingHeader( "FUNC" )
Devin Lim61657e42017-10-09 17:24:40 -0700244 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800245 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700246 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700247 closingHeader( "FUNC" )
248 addingHeader( "HA" )
Devin Lim61657e42017-10-09 17:24:40 -0700249 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
250 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800251 HA_choices += adder( "HA", "new_Test", getDay, "Th", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700252 closingHeader( "HA" )
253 addingHeader( "SCPF" )
Devin Lim61657e42017-10-09 17:24:40 -0700254 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
255 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700256 closingHeader( "SCPF" )
257 addingHeader( "SR" )
258 SR_choices += adder( "SR", "basic", getDay, "Th", getResult )
259 closingHeader( "SR" )
260 addingHeader( "USECASE" )
261 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700262}
263def friday( getDay, getResult ){
Devin Lime89761a2018-03-16 17:52:57 -0700264 addingHeader( "FUNC" )
Devin Lim61657e42017-10-09 17:24:40 -0700265 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800266 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700267 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700268 closingHeader( "FUNC" )
269 addingHeader( "HA" )
Devin Lim61657e42017-10-09 17:24:40 -0700270 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
271 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800272 //HA_choices += adder( "HA", "new_Test", getDay, "F", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700273 closingHeader( "HA" )
274 addingHeader( "SCPF" )
Devin Lim61657e42017-10-09 17:24:40 -0700275 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
276 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
277 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
Devin Lime89761a2018-03-16 17:52:57 -0700278 closingHeader( "SCPF" )
279 addingHeader( "SR" )
280 SR_choices += adder( "SR", "basic", getDay, "F", getResult )
281 closingHeader( "SR" )
282 addingHeader( "USECASE" )
283 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700284}
Devin Lime89761a2018-03-16 17:52:57 -0700285def saturday( getDay, getResult ){
286 addingHeader( "FUNC" )
287 FUNC_choices += adder( "FUNC", "basic", getDay, "Sa", getResult )
288 FUNC_choices += adder( "FUNC", "extra_A", getDay, "Sa", getResult )
289 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Sa", getResult )
290 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Sa", getResult )
291 closingHeader( "FUNC" )
292 addingHeader( "HA" )
293 HA_choices += adder( "HA", "basic", getDay, "Sa", getResult )
294 HA_choices += adder( "HA", "extra_A", getDay, "Sa", getResult )
295 HA_choices += adder( "HA", "extra_B", getDay, "Sa", getResult )
296 HA_choices += adder( "HA", "new_Test", getDay, "Sa", getResult )
297 closingHeader( "HA" )
298 addingHeader( "SCPF" )
299 SCPF_choices += adder( "SCPF", "basic", getDay, "Sa", getResult )
300 SCPF_choices += adder( "SCPF", "extra_A", getDay, "Sa", getResult )
301 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Sa", getResult )
302 SCPF_choices += adder( "SCPF", "extra_C", getDay, "Sa", getResult )
303 SCPF_choices += adder( "SCPF", "extra_D", getDay, "Sa", getResult )
304 SCPF_choices += adder( "SCPF", "new_Test", getDay, "Sa", getResult )
305 closingHeader( "SCPF" )
306 addingHeader( "SR" )
307 SR_choices += adder( "SR", "basic", getDay, "Sa", getResult )
308 closingHeader( "SR" )
309 addingHeader( "USECASE" )
310 USECASE_choices += adder( "USECASE", "basic", getDay, "Sa", getResult )
311 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700312}
Devin Lime89761a2018-03-16 17:52:57 -0700313def sunday( getDay, getResult ){
314 addingHeader( "FUNC" )
315 FUNC_choices += adder( "FUNC", "basic", getDay, "S", getResult )
316 FUNC_choices += adder( "FUNC", "extra_A", getDay, "S", getResult )
317 FUNC_choices += adder( "FUNC", "extra_B", getDay, "S", getResult )
318 closingHeader( "FUNC" )
319 addingHeader( "HA" )
320 HA_choices += adder( "HA", "basic", getDay, "S", getResult )
321 HA_choices += adder( "HA", "extra_A", getDay, "S", getResult )
322 HA_choices += adder( "HA", "extra_B", getDay, "S", getResult )
323 closingHeader( "HA" )
324 addingHeader( "SCPF" )
325 SCPF_choices += adder( "SCPF", "basic", getDay, "S", getResult )
326 SCPF_choices += adder( "SCPF", "extra_A", getDay, "S", getResult )
327 SCPF_choices += adder( "SCPF", "extra_B", getDay, "S", getResult )
328 SCPF_choices += adder( "SCPF", "extra_C", getDay, "S", getResult )
329 SCPF_choices += adder( "SCPF", "extra_D", getDay, "S", getResult )
330 closingHeader( "SCPF" )
331 addingHeader( "SR" )
332 SR_choices += adder( "SR", "basic", getDay, "S", getResult )
333 closingHeader( "SR" )
334 addingHeader( "USECASE" )
335 USECASE_choices += adder( "USECASE", "basic", getDay, "S", getResult )
336 closingHeader( "USECASE" )
Devin Lim61657e42017-10-09 17:24:40 -0700337}
338def adder( testCat, set, dayAdding, day, getResult ){
339 result = ""
Devin Lime89761a2018-03-16 17:52:57 -0700340 for( String test in AllTheTests[ testCat ].keySet() ){
Devin Lim61657e42017-10-09 17:24:40 -0700341 if( AllTheTests[ testCat ][ test ][ set ] ){
342 if( getResult )
343 result += test + ","
344 if( dayAdding )
345 dayAdder( testCat, test, day )
Devin Lime89761a2018-03-16 17:52:57 -0700346 makeHtmlColList( testCat, test )
Devin Lim61657e42017-10-09 17:24:40 -0700347 }
348 }
349 return result
350}
Devin Lime89761a2018-03-16 17:52:57 -0700351def initHtmlForWiki(){
352 wikiContents = '''
353 <table class="wrapped confluenceTable">
354 <colgroup>
355 <col />
356 <col />
357 <col />
358 <col />
359 <col />
360 <col />
361 </colgroup>
362 <tbody>
363 <tr>
364 <th colspan="1" class="confluenceTh">
365 <br />
366 </th>
367 <th class="confluenceTh"><p>Monday</p></th>
368 <th class="confluenceTh"><p>Tuesday</p></th>
369 <th class="confluenceTh"><p>Wednesday</p></th>
370 <th class="confluenceTh"><p>Thursday</p></th>
371 <th class="confluenceTh"><p>Friday</p></th>
372 <th class="confluenceTh"><p>Saturday</p></th>
373 <th class="confluenceTh"><p>Sunday</p></th>
374 </tr>'''
375 for( String test in testcases.keySet() ){
376 testcases[ test ][ 'wikiContent' ] = '''
377 <tr>
378 <th colspan="1" class="confluenceTh">''' + test + '''</th>'''
379 }
380}
381def addingHeader( testCategory ){
382 testcases[ testCategory ][ 'wikiContent' ] += '''
383 <td class="confluenceTd">
384 <ul>'''
385}
386def makeHtmlColList( testCategory, testName ){
387 testcases[ testCategory ][ 'wikiContent' ] += '''
388 <li>'''+ testName +'''</li>'''
389
390}
391def closingHeader( testCategory ){
392 testcases[ testCategory ][ 'wikiContent' ] += '''
393 </ul>
394 </td>'''
395}
396def closeHtmlForWiki(){
397 for( String test in testcases.keySet() ){
398 wikiContents += testcases[ test ][ 'wikiContent' ]
399 wikiContents += '''
400 </tr>'''
401 }
402 wikiContents += '''
403 </tbody>
404 </table>
405 <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every branch.</p>
406 <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p>
407 <p>On <strong>Saturdays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( previous_version ) +''' branch.</p>
408 <p>On <strong>Sundays</strong>, all the other tests are built and run on the '''+ funcs.branchWithPrefix( before_previous_version ) +''' branch.</p>'''
409}
410def postToWiki( contents ){
411 node( testMachine ){
412 workspace = "/var/jenkins/workspace/all-pipeline-trigger/"
413 filename = "jenkinsSchedule.txt"
414 writeFile file: workspace + filename, text: contents
415 funcs.publishToConfluence( "false", "true",
416 "Automated Test Schedule",
417 workspace + filename )
418 }
419}
Devin Lim61657e42017-10-09 17:24:40 -0700420def dayAdder( testCat, testName, dayOfWeek ){
421 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
422}
Devin Lim90803a82017-08-29 13:41:44 -0700423def runTestSeq( testList ){
424 return{
425 for ( test in testList.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800426 testList[ test ].call()
Devin Lim90803a82017-08-29 13:41:44 -0700427 }
428 }
429}
430
431def print_tests( tests ){
432 for( String test in tests.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800433 if( tests[ test ][ "tests" ] != "" ){
Devin Lim90803a82017-08-29 13:41:44 -0700434 println test + ":"
Devin Lim61643762017-12-07 15:55:38 -0800435 println tests[ test ][ "tests" ]
Devin Lim90803a82017-08-29 13:41:44 -0700436 }
437 }
438}
439def organize_tests( tests ){
Devin Lim61643762017-12-07 15:55:38 -0800440 testList = tests.tokenize( "\n;, " )
Devin Lim90803a82017-08-29 13:41:44 -0700441 for( String test in testList )
442 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
443}
Devin Lim61643762017-12-07 15:55:38 -0800444def borrow_mn( jobOn ){
445 result = ""
446 if( jobOn == "SR" ){
447 result = "~/cell_borrow.sh"
448 }
449 return result
450}
451def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
452 println jobOn + "-pipeline-" + manuallyRun ? "manually" : branch
453 wiki = branch
Jeremy Ronquillof78a6ca2018-03-12 09:20:57 -0700454 branch = funcs.branchWithPrefix( branch )
Devin Lim61643762017-12-07 15:55:38 -0800455 test_branch = "master"
456 node( "TestStation-" + nodeName + "s" ){
457 envSetup( branch, test_branch, onosTag, jobOn, manuallyRun )
458
459 exportEnvProperty( branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
460 }
461
462 jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
463 build job: jobToRun, propagate: false
464}
Devin Lima0e52eb2017-09-13 18:35:12 -0700465def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700466// nodeName : "BM" or "VM"
467// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
468 return{
Devin Lim61643762017-12-07 15:55:38 -0800469 if( jobOn == "SR" ){
Devin Limf5bf9b52018-02-28 18:16:21 -0800470 trigger( "1.11", tests, nodeName, jobOn, manuallyRun, onosTag )
471 trigger( "1.12", tests, nodeName, jobOn, manuallyRun, onosTag )
472 trigger( "master", tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Limd1fb8e92018-02-28 16:29:33 -0800473 // returnCell( nodeName )
Devin Lim61643762017-12-07 15:55:38 -0800474 }else{
475 trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700476 }
Devin Lim90803a82017-08-29 13:41:44 -0700477 }
478}
Devin Lim90803a82017-08-29 13:41:44 -0700479// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700480def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800481 stage( "export Property" ){
Devin Lim90803a82017-08-29 13:41:44 -0700482 sh '''
483 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
484 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700485 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700486 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
487 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
488 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
489 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
490 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700491 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
492
Devin Lim90803a82017-08-29 13:41:44 -0700493 '''
494 }
495}
496// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700497def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim61643762017-12-07 15:55:38 -0800498 stage( "envSetup" ) {
Devin Limf5bf9b52018-02-28 18:16:21 -0800499 // after env: ''' + borrow_mn( jobOn ) + '''
Devin Lima0e52eb2017-09-13 18:35:12 -0700500 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700501 set +e
502 . ~/.bashrc
503 env
Devin Lim0e967162017-11-03 15:59:53 -0700504 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800505 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700506 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
507 }
508}
Devin Lim61643762017-12-07 15:55:38 -0800509def tagCheck( onos_tag, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700510 result = "git checkout "
Devin Lim61643762017-12-07 15:55:38 -0800511 if ( onos_tag == "" )
Devin Lim0e967162017-11-03 15:59:53 -0700512 result += onos_branch //create new local branch
513 else
514 result += onos_tag //checkout the tag
515 return result
516}
517def preSetup( onos_branch, test_branch, onos_tag, isManual ){
518 result = ""
519 if( !isManual ){
520 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700521 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700522
523 cd ~/OnosSystemTest/
524 git checkout HEAD~1 # Make sure you aren't pn a branch
525 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700526 git branch -D ''' + test_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
Devin Lim90803a82017-08-29 13:41:44 -0700527 git clean -df # clean any local files
528 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700529 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700530 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700531 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700532 git branch
533 git log -1 --decorate
534
535
536 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700537 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700538
539 echo -e "\n #### check karaf version ######"
540 env |grep karaf
541
542 cd ~/onos
543 rm -rf buck-out/*
544 ~/onos/tools/build/onos-buck clean
545 git checkout HEAD~1 # Make sure you aren't pn a branch
546 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700547 git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error
Devin Lim90803a82017-08-29 13:41:44 -0700548 git clean -df # clean any local files
549 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700550 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700551 git clean -df # clean any local files
Devin Lim61643762017-12-07 15:55:38 -0800552 ''' + tagCheck( onos_tag, onos_branch ) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700553 git branch
554 git log -1 --decorate
555
556
557 echo -e "\n##### set jvm heap size to 8G #####"
558 echo ${ONOSJVMHeap}
559
Devin Lima0e52eb2017-09-13 18:35:12 -0700560 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
561 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700562
563 echo "##### Check onos-service setting..... #####"
564 cat ~/onos/tools/package/bin/onos-service
565
Devin Lim0e967162017-11-03 15:59:53 -0700566 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
567 }
568 return result
569}
Devin Limcbba0852017-11-13 10:31:32 -0800570def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700571 result = ""
Devin Lim61643762017-12-07 15:55:38 -0800572 if( jobOn == "SCPF" && ( onos_branch== "master" || onos_branch=="onos-1.12" ) )
573 result = '''sed -i -e 's/@Component(immediate = true)/@Component(enabled = false)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/''' + ( isOldFlow ? "DistributedFlowRuleStore" : "ECFlowRuleStore" ) + '''.java
574 sed -i -e 's/@Component(enabled = false)/@Component(immediate = true)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/''' + ( isOldFlow ? "ECFlowRuleStore" : "DistributedFlowRuleStore" ) + ".java"
Devin Lim0e967162017-11-03 15:59:53 -0700575 return result
576}
577def postSetup( onos_branch, test_branch, onos_tag, isManual ){
578 result = ""
579 if( !isManual ){
580 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700581 #mvn clean install -DskipTests
582 # Force buck update
583 rm -f ~/onos/bin/buck
584 ~/onos/tools/build/onos-buck build onos
585
Devin Lima0e52eb2017-09-13 18:35:12 -0700586 sleep 30
587 echo -e "\n##### Stop all running instances of Karaf #####"
588 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
589 sleep 30
590
Devin Lim90803a82017-08-29 13:41:44 -0700591 git branch'''
592 }
Devin Lim37a83792017-10-26 16:38:21 -0700593 return result
Devin Lim61643762017-12-07 15:55:38 -0800594}
595def returnCell( nodeName ){
596 node( "TestStation-" + nodeName + "s" ){
597 sh '''#!/bin/bash -l
598 set +e
599 . ~/.bashrc
600 env
601 ~/./return_cell.sh
602 '''
603 }
Devin Lim3fa96a92018-03-16 11:47:58 -0700604}