blob: c624984203f14e1e28d1682298de460be07a6bd2 [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" );
9
Devin Lim90803a82017-08-29 13:41:44 -070010testcases = [
Devin Lim61643762017-12-07 15:55:38 -080011 "FUNC" : [ tests : "" , nodeName : "VM" ],
12 "HA" : [ tests : "" , nodeName : "VM" ],
13 "SR" : [ tests : "", nodeName : "VM" ],
14 "SCPF" : [ tests : "" , nodeName : "BM" ],
15 "USECASE" : [ tests : "" , nodeName : "BM" ]
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:
117 monday( true )
118 tuesday( true, false )
119 wednesday( true, false )
120 thursday( true, false )
121 friday( true, false )
122 day = "Monday"
Devin Lim61643762017-12-07 15:55:38 -0800123 slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + printDaysForTest() )
Devin Lim61657e42017-10-09 17:24:40 -0700124 break
125 case Calendar.TUESDAY:
126 tuesday( true, true )
127 day = "Tuesday"
128 break
129 case Calendar.WEDNESDAY:
130 wednesday( true, true )
131 day = "Wednesday"
132 break
133 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700134 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700135 day = "Thursday"
Devin Lim61643762017-12-07 15:55:38 -0800136 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700137 break
138 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700139 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700140 day = "Friday"
Devin Lim61643762017-12-07 15:55:38 -0800141 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700142 break
143 case Calendar.SATURDAY:
144 saturday()
Devin Lim61657e42017-10-09 17:24:40 -0700145 day = "Saturday"
146 break
147 case Calendar.SUNDAY:
148 sunday()
Devin Lim61657e42017-10-09 17:24:40 -0700149 day = "Sunday"
Devin Lim3fa96a92018-03-16 11:47:58 -0700150 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700151 break
152 }
153}
154def printDaysForTest(){
155 result = ""
156 for ( String test in AllTheTests.keySet() ){
157 result += test + " : \n"
158 for( String each in AllTheTests[ test ].keySet() ){
159 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
160 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
161 }
162 result += "\n"
163 }
164 return result
165}
166def lastCommaRemover( str ){
167 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
168 str = str.substring( 0,str.size() - 1 )
169 }
170 return str
171}
172def monday( getResult ){
173 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800174 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700175 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
176 HA_choices += adder( "HA", "basic", true, "M", getResult )
177 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800178 //HA_choices += adder( "HA", "new_Test", true, "M", getResult )
179 SR_choices += adder( "SR", "basic", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700180 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
181 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
182}
183def tuesday( getDay, getResult ){
184 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800185 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700186 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
187 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
188 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800189 HA_choices += adder( "HA", "new_Test", getDay, "T", getResult )
190 SR_choices += adder( "SR", "basic", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700191 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
192 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
193 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
194 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
195 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
196}
197def wednesday( getDay, getResult ){
198 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800199 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700200 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
201 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
202 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800203 //HA_choices += adder( "HA", "new_Test", getDay, "W", getResult )
204 SR_choices += adder( "SR", "basic", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700205 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
206 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
207 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
208}
209def thursday( getDay, getResult ){
210 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800211 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700212 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
213 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
214 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800215 HA_choices += adder( "HA", "new_Test", getDay, "Th", getResult )
216 SR_choices += adder( "SR", "basic", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700217 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
218 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
219}
220def friday( getDay, getResult ){
221 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800222 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700223 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
224 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
225 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800226 //HA_choices += adder( "HA", "new_Test", getDay, "F", getResult )
227 SR_choices += adder( "SR", "basic", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700228 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
229 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
230 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
231}
232def saturday(){
233 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
234 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
235 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800236 FUNC_choices += adder( "FUNC", "new_Test", true, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700237 HA_choices += adder( "HA", "basic", false, "Sa", true )
238 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
239 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800240 HA_choices += adder( "HA", "new_Test", false, "Sa", true )
241 SR_choices += adder( "SR", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700242 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
243 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
244 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
245 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
246 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
247 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
248 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700249}
250def sunday(){
251 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
252 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
253 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
254 HA_choices += adder( "HA", "basic", false, "S", true )
255 HA_choices += adder( "HA", "extra_A", false, "S", true )
256 HA_choices += adder( "HA", "extra_B", false, "S", true )
Devin Lim61643762017-12-07 15:55:38 -0800257 SR_choices += adder( "SR", "basic", false, "S", true )
Devin Lim61657e42017-10-09 17:24:40 -0700258 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
Devin Lim7220c502018-03-12 11:43:06 -0700259 SCPF_choices += adder( "SCPF", "extra_A", false, "S", true )
Devin Lim3fa96a92018-03-16 11:47:58 -0700260 SCPF_choices += adder( "SCPF", "extra_B", false, "S", true )
261 SCPF_choices += adder( "SCPF", "extra_C", false, "S", true )
262 SCPF_choices += adder( "SCPF", "extra_D", false, "S", true )
Devin Lim61657e42017-10-09 17:24:40 -0700263 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
264}
265def adder( testCat, set, dayAdding, day, getResult ){
266 result = ""
267 for( String test in AllTheTests[ testCat ].keySet() ){
268 if( AllTheTests[ testCat ][ test ][ set ] ){
269 if( getResult )
270 result += test + ","
271 if( dayAdding )
272 dayAdder( testCat, test, day )
273 }
274 }
275 return result
276}
277def dayAdder( testCat, testName, dayOfWeek ){
278 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
279}
Devin Lim90803a82017-08-29 13:41:44 -0700280def runTestSeq( testList ){
281 return{
282 for ( test in testList.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800283 testList[ test ].call()
Devin Lim90803a82017-08-29 13:41:44 -0700284 }
285 }
286}
287
288def print_tests( tests ){
289 for( String test in tests.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800290 if( tests[ test ][ "tests" ] != "" ){
Devin Lim90803a82017-08-29 13:41:44 -0700291 println test + ":"
Devin Lim61643762017-12-07 15:55:38 -0800292 println tests[ test ][ "tests" ]
Devin Lim90803a82017-08-29 13:41:44 -0700293 }
294 }
295}
296def organize_tests( tests ){
Devin Lim61643762017-12-07 15:55:38 -0800297 testList = tests.tokenize( "\n;, " )
Devin Lim90803a82017-08-29 13:41:44 -0700298 for( String test in testList )
299 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
300}
Devin Lim61643762017-12-07 15:55:38 -0800301def borrow_mn( jobOn ){
302 result = ""
303 if( jobOn == "SR" ){
304 result = "~/cell_borrow.sh"
305 }
306 return result
307}
308def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
309 println jobOn + "-pipeline-" + manuallyRun ? "manually" : branch
310 wiki = branch
Jeremy Ronquillof78a6ca2018-03-12 09:20:57 -0700311 branch = funcs.branchWithPrefix( branch )
Devin Lim61643762017-12-07 15:55:38 -0800312 test_branch = "master"
313 node( "TestStation-" + nodeName + "s" ){
314 envSetup( branch, test_branch, onosTag, jobOn, manuallyRun )
315
316 exportEnvProperty( branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
317 }
318
319 jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
320 build job: jobToRun, propagate: false
321}
Devin Lima0e52eb2017-09-13 18:35:12 -0700322def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700323// nodeName : "BM" or "VM"
324// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
325 return{
Devin Lim61643762017-12-07 15:55:38 -0800326 if( jobOn == "SR" ){
Devin Limf5bf9b52018-02-28 18:16:21 -0800327 trigger( "1.11", tests, nodeName, jobOn, manuallyRun, onosTag )
328 trigger( "1.12", tests, nodeName, jobOn, manuallyRun, onosTag )
329 trigger( "master", tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Limd1fb8e92018-02-28 16:29:33 -0800330 // returnCell( nodeName )
Devin Lim61643762017-12-07 15:55:38 -0800331 }else{
332 trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700333 }
Devin Lim90803a82017-08-29 13:41:44 -0700334 }
335}
336
337// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700338def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800339 stage( "export Property" ){
Devin Lim90803a82017-08-29 13:41:44 -0700340 sh '''
341 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
342 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700343 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700344 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
345 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
346 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
347 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
348 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700349 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
350
Devin Lim90803a82017-08-29 13:41:44 -0700351 '''
352 }
353}
354// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700355def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim61643762017-12-07 15:55:38 -0800356 stage( "envSetup" ) {
Devin Limf5bf9b52018-02-28 18:16:21 -0800357 // after env: ''' + borrow_mn( jobOn ) + '''
Devin Lima0e52eb2017-09-13 18:35:12 -0700358 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700359 set +e
360 . ~/.bashrc
361 env
Devin Lim0e967162017-11-03 15:59:53 -0700362 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800363 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700364 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
365 }
366}
Devin Lim61643762017-12-07 15:55:38 -0800367def tagCheck( onos_tag, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700368 result = "git checkout "
Devin Lim61643762017-12-07 15:55:38 -0800369 if ( onos_tag == "" )
Devin Lim0e967162017-11-03 15:59:53 -0700370 result += onos_branch //create new local branch
371 else
372 result += onos_tag //checkout the tag
373 return result
374}
375def preSetup( onos_branch, test_branch, onos_tag, isManual ){
376 result = ""
377 if( !isManual ){
378 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700379 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700380
381 cd ~/OnosSystemTest/
382 git checkout HEAD~1 # Make sure you aren't pn a branch
383 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700384 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 -0700385 git clean -df # clean any local files
386 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700387 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700388 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700389 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700390 git branch
391 git log -1 --decorate
392
393
394 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700395 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700396
397 echo -e "\n #### check karaf version ######"
398 env |grep karaf
399
400 cd ~/onos
401 rm -rf buck-out/*
402 ~/onos/tools/build/onos-buck clean
403 git checkout HEAD~1 # Make sure you aren't pn a branch
404 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700405 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 -0700406 git clean -df # clean any local files
407 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700408 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700409 git clean -df # clean any local files
Devin Lim61643762017-12-07 15:55:38 -0800410 ''' + tagCheck( onos_tag, onos_branch ) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700411 git branch
412 git log -1 --decorate
413
414
415 echo -e "\n##### set jvm heap size to 8G #####"
416 echo ${ONOSJVMHeap}
417
Devin Lima0e52eb2017-09-13 18:35:12 -0700418 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
419 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700420
421 echo "##### Check onos-service setting..... #####"
422 cat ~/onos/tools/package/bin/onos-service
423
Devin Lim0e967162017-11-03 15:59:53 -0700424 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
425 }
426 return result
427}
Devin Limcbba0852017-11-13 10:31:32 -0800428def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700429 result = ""
Devin Lim61643762017-12-07 15:55:38 -0800430 if( jobOn == "SCPF" && ( onos_branch== "master" || onos_branch=="onos-1.12" ) )
431 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
432 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 -0700433 return result
434}
435def postSetup( onos_branch, test_branch, onos_tag, isManual ){
436 result = ""
437 if( !isManual ){
438 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700439 #mvn clean install -DskipTests
440 # Force buck update
441 rm -f ~/onos/bin/buck
442 ~/onos/tools/build/onos-buck build onos
443
Devin Lima0e52eb2017-09-13 18:35:12 -0700444 sleep 30
445 echo -e "\n##### Stop all running instances of Karaf #####"
446 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
447 sleep 30
448
Devin Lim90803a82017-08-29 13:41:44 -0700449 git branch'''
450 }
Devin Lim37a83792017-10-26 16:38:21 -0700451 return result
Devin Lim61643762017-12-07 15:55:38 -0800452}
453def returnCell( nodeName ){
454 node( "TestStation-" + nodeName + "s" ){
455 sh '''#!/bin/bash -l
456 set +e
457 . ~/.bashrc
458 env
459 ~/./return_cell.sh
460 '''
461 }
Devin Lim3fa96a92018-03-16 11:47:58 -0700462}