blob: 6b1da7ba8610ed33db398ba6f8d4b0ca2d377dc0 [file] [log] [blame]
Devin Lim90803a82017-08-29 13:41:44 -07001#!groovy
2// This is a Jenkinsfile for a scripted pipeline for the SCPF tests
3// Define sets of tests
Devin Lim0e967162017-11-03 15:59:53 -07004previous_version = "1.11"
5before_previous_version = "1.10"
Devin Lim61657e42017-10-09 17:24:40 -07006AllTheTests=
7[
8 "FUNC":[
Devin Lim3ebd5e72017-11-14 10:38:00 -08009 "FUNCipv6Intent" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
10 "FUNCoptical" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
11 "FUNCflow" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
12 "FUNCnetCfg": ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
13 "FUNCovsdbtest" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
14 "FUNCnetconf" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
15 "FUNCgroup" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
16 "FUNCformCluster" :["basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":""],
17 "FUNCintent" : ["basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":""],
18 "FUNCintentRest" : ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
Devin Lim61657e42017-10-09 17:24:40 -070019 ],
20 "HA":[
21 "HAsanity" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
22 "HAclusterRestart" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
23 "HAsingleInstanceRestart" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
24 "HAstopNodes" : ["basic":false, "extra_A":true, "extra_B":false, "day":""],
25 "HAfullNetPartition" : ["basic":false, "extra_A":true, "extra_B":false, "day":""],
26 "HAswapNodes" : ["basic":false, "extra_A":false, "extra_B":true, "day":""],
27 "HAscaling" : ["basic":false, "extra_A":false, "extra_B":true, "day":""],
28 "HAkillNodes" : ["basic":false, "extra_A":false, "extra_B":true, "day":""]
29 ],
30 "SCPF":[
31 "SCPFswitchLat": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
32 "SCPFcbench": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
33 "SCPFportLat": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
34 "SCPFflowTp1g": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
35 "SCPFintentEventTp": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
36 "SCPFhostLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
37 // batch will be on extra_A after fixing from the ONOS side.
Devin Lim0e967162017-11-03 15:59:53 -070038 "SCPFbatchFlowResp": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
Devin Lim61657e42017-10-09 17:24:40 -070039 "SCPFintentRerouteLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
40 "SCPFintentInstallWithdrawLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
41 "SCPFflowTp1gWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
42 "SCPFintentEventTpWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
43 "SCPFintentRerouteLatWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
44 "SCPFscalingMaxIntentsWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
45 "SCPFintentInstallWithdrawLatWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
46 "SCPFscaleTopo": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":true, "extra_D":false, "new_Test":false, day:""],
47 "SCPFscalingMaxIntents": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":true, "new_Test":false, day:""],
48 "SCPFmastershipFailoverLat": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":true, day:""]
49 ],
50 "USECASE":[
51 "FUNCvirNetNB" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
52 "FUNCbgpls" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
53 "VPLSBasic" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
54 "USECASE_SdnipFunction": ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
55 "USECASE_SdnipFunctionCluster": ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
56 "PLATdockertest": ["basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":""],
57 "SRSanity": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
58 "SRSwitchFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
59 "SRLinkFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
60 "SROnosFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
61 "SRClusterRestart": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
62 "SRDynamic": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
63 "SRHighAvailability": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
64 "VPLSfailsafe" : ["basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":""]
65 ]
66]
Devin Lim90803a82017-08-29 13:41:44 -070067testcases = [
68 "FUNC" : [ tests : "" , nodeName : "VM"],
69 "HA" : [ tests : "" , nodeName : "VM"],
70 "SCPF" : [ tests : "" , nodeName : "BM"],
71 "USECASE" : [ tests : "" , nodeName : "BM"]
72]
73Prefix_organizer = [
74 "FU" : "FUNC",
75 "HA" : "HA",
76 "PL" : "USECASE",
77 "SA" : "USECASE",
78 "SC" : "SCPF",
79 "SR" : "USECASE",
80 "US" : "USECASE",
81 "VP" : "USECASE"
82]
83
Devin Lima0e52eb2017-09-13 18:35:12 -070084onos_branch = "master"
Devin Lim0e967162017-11-03 15:59:53 -070085test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070086onos_tag = params.ONOSTag
Devin Lim37a83792017-10-26 16:38:21 -070087isOldFlow = false
Devin Lim90803a82017-08-29 13:41:44 -070088// Set tests based on day of week
89def now = new Date()
90echo(now.toString())
91today = now[Calendar.DAY_OF_WEEK]
92day = ""
Devin Lim61657e42017-10-09 17:24:40 -070093SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070094USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -070095FUNC_choices = ""
96HA_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070097
98manually_run = params.manual_run
99post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -0700100if( !manually_run ){
101 sendToSlack( '#03CD9F', ":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
102 + "Starting tests on : " + now.toString()
103 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
104 testDivider( today )
105 FUNC_choices = lastCommaRemover( FUNC_choices )
106 HA_choices = lastCommaRemover( HA_choices )
107 SCPF_choices = lastCommaRemover( SCPF_choices )
108 USECASE_choices = lastCommaRemover( USECASE_choices )
109}
110
Devin Lim90803a82017-08-29 13:41:44 -0700111if ( manually_run ){
112 organize_tests( params.Tests )
113 onos_branch = params.ONOSVersion
Devin Lim0e967162017-11-03 15:59:53 -0700114 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -0700115 println "Tests to be run manually : "
116}else{
117 testcases["SCPF"]["tests"] = SCPF_choices
118 testcases["USECASE"]["tests"] = USECASE_choices
119 testcases["FUNC"]["tests"] = FUNC_choices
120 testcases["HA"]["tests"] = HA_choices
121 println "Defaulting to " + day + " tests:"
122}
123print_tests( testcases )
Devin Lim37a83792017-10-26 16:38:21 -0700124def runTest = [
125 "VM" : [:],
126 "BM" : [:]
127]
128for( String test in testcases.keySet() ){
129 println test
130 if (testcases[test]["tests"] != ""){
131 runTest[testcases[test]["nodeName"]][test] = trigger_pipeline( onos_branch, testcases[test]["tests"], testcases[test]["nodeName"], test, manually_run, onos_tag )
132 }
133}
134def finalList = [:]
135finalList["VM"] = runTestSeq( runTest["VM"] )
136finalList["BM"] = runTestSeq( runTest["BM"] )
137parallel finalList
Devin Lim90803a82017-08-29 13:41:44 -0700138
Devin Lim61657e42017-10-09 17:24:40 -0700139def testDivider( today ){
140 switch (today) {
141 case Calendar.MONDAY:
142 monday( true )
143 tuesday( true, false )
144 wednesday( true, false )
145 thursday( true, false )
146 friday( true, false )
147 day = "Monday"
148 sendToSlack( '#FFD988', "Tests to be run this weekdays : \n" + printDaysForTest() )
149 break
150 case Calendar.TUESDAY:
151 tuesday( true, true )
152 day = "Tuesday"
153 break
154 case Calendar.WEDNESDAY:
155 wednesday( true, true )
156 day = "Wednesday"
157 break
158 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700159 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700160 day = "Thursday"
Devin Lim0e967162017-11-03 15:59:53 -0700161 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700162 break
163 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700164 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700165 day = "Friday"
Devin Lim0e967162017-11-03 15:59:53 -0700166 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700167 break
168 case Calendar.SATURDAY:
169 saturday()
Devin Lim0e967162017-11-03 15:59:53 -0700170 onos_branch= previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700171 day = "Saturday"
172 break
173 case Calendar.SUNDAY:
174 sunday()
Devin Lim0e967162017-11-03 15:59:53 -0700175 onos_branch= before_previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700176 day = "Sunday"
Devin Lim0e967162017-11-03 15:59:53 -0700177 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700178 break
179 }
180}
181def printDaysForTest(){
182 result = ""
183 for ( String test in AllTheTests.keySet() ){
184 result += test + " : \n"
185 for( String each in AllTheTests[ test ].keySet() ){
186 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
187 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
188 }
189 result += "\n"
190 }
191 return result
192}
193def lastCommaRemover( str ){
194 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
195 str = str.substring( 0,str.size() - 1 )
196 }
197 return str
198}
199def monday( getResult ){
200 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800201 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700202 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
203 HA_choices += adder( "HA", "basic", true, "M", getResult )
204 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
205 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
206 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
207}
208def tuesday( getDay, getResult ){
209 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800210 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700211 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
212 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
213 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
214 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
215 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
216 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
217 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
218 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
219}
220def wednesday( getDay, getResult ){
221 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800222 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700223 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
224 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
225 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
226 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
227 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
228 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
229}
230def thursday( getDay, getResult ){
231 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800232 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700233 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
234 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
235 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
236 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
237 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
238}
239def friday( getDay, getResult ){
240 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800241 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700242 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
243 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
244 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
245 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
246 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
247 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
248}
249def saturday(){
250 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
251 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
252 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
253 HA_choices += adder( "HA", "basic", false, "Sa", true )
254 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
255 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
256 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
257 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
258 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
259 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
260 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
261 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
262 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
263 USECASE_choices += adder( "USECASE", "new_Test", false, "Sa", true )
264}
265def sunday(){
266 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
267 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
268 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
269 HA_choices += adder( "HA", "basic", false, "S", true )
270 HA_choices += adder( "HA", "extra_A", false, "S", true )
271 HA_choices += adder( "HA", "extra_B", false, "S", true )
272 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
273 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
274}
275def adder( testCat, set, dayAdding, day, getResult ){
276 result = ""
277 for( String test in AllTheTests[ testCat ].keySet() ){
278 if( AllTheTests[ testCat ][ test ][ set ] ){
279 if( getResult )
280 result += test + ","
281 if( dayAdding )
282 dayAdder( testCat, test, day )
283 }
284 }
285 return result
286}
287def dayAdder( testCat, testName, dayOfWeek ){
288 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
289}
Devin Lim90803a82017-08-29 13:41:44 -0700290def runTestSeq( testList ){
291 return{
292 for ( test in testList.keySet() ){
293 testList[test].call()
294 }
295 }
296}
297
298def print_tests( tests ){
299 for( String test in tests.keySet() ){
300 if( tests[test]["tests"] != "" ){
301 println test + ":"
302 println tests[test]["tests"]
303 }
304 }
305}
306def organize_tests( tests ){
307 testList = tests.tokenize("\n;, ")
308 for( String test in testList )
309 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
310}
Devin Lima0e52eb2017-09-13 18:35:12 -0700311def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700312// nodeName : "BM" or "VM"
313// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
314 return{
315 if (branch == "master"){
316 onos_branch = branch
317 }else{
318 onos_branch = "onos-" + branch
319 }
320 wiki = branch
Devin Lim0e967162017-11-03 15:59:53 -0700321 test_branch = onos_branch
322 if (onos_branch == previous_version)
Devin Lim90803a82017-08-29 13:41:44 -0700323 test_branch = "master"
324 println jobOn + "_Pipeline_" + manuallyRun ? "manually" : branch
325 node("TestStation-" + nodeName + "s"){
Devin Lim0e967162017-11-03 15:59:53 -0700326 envSetup(onos_branch, test_branch, onosTag, jobOn, manuallyRun )
Devin Lim90803a82017-08-29 13:41:44 -0700327
Devin Lim0e967162017-11-03 15:59:53 -0700328 exportEnvProperty( onos_branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
Devin Lim90803a82017-08-29 13:41:44 -0700329 }
330
331 jobToRun = jobOn + "_Pipeline_" + ( manuallyRun ? "manually" : branch )
332 build job: jobToRun, propagate: false
333 }
334}
335
336// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700337def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim90803a82017-08-29 13:41:44 -0700338 stage("export Property"){
339 sh '''
340 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
341 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700342 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700343 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
344 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
345 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
346 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
347 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700348 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
349
Devin Lim90803a82017-08-29 13:41:44 -0700350 '''
351 }
352}
Devin Lim61657e42017-10-09 17:24:40 -0700353def sendToSlack( color, message ){
354 slackSend(color:color, message: message)
355}
Devin Lim90803a82017-08-29 13:41:44 -0700356// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700357def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim90803a82017-08-29 13:41:44 -0700358 stage("envSetup") {
Devin Lima0e52eb2017-09-13 18:35:12 -0700359 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700360 set +e
361 . ~/.bashrc
362 env
Devin Lim0e967162017-11-03 15:59:53 -0700363 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800364 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700365 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
366 }
367}
368def tagCheck(onos_tag, onos_branch){
369 result = "git checkout "
370 if (onos_tag == "" )
371 result += onos_branch //create new local branch
372 else
373 result += onos_tag //checkout the tag
374 return result
375}
376def preSetup( onos_branch, test_branch, onos_tag, isManual ){
377 result = ""
378 if( !isManual ){
379 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700380 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700381
382 cd ~/OnosSystemTest/
383 git checkout HEAD~1 # Make sure you aren't pn a branch
384 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700385 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 -0700386 git clean -df # clean any local files
387 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700388 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700389 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700390 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700391 git branch
392 git log -1 --decorate
393
394
395 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700396 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700397
398 echo -e "\n #### check karaf version ######"
399 env |grep karaf
400
401 cd ~/onos
402 rm -rf buck-out/*
403 ~/onos/tools/build/onos-buck clean
404 git checkout HEAD~1 # Make sure you aren't pn a branch
405 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700406 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 -0700407 git clean -df # clean any local files
408 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700409 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700410 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700411 ''' + tagCheck(onos_tag, onos_branch) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700412 git branch
413 git log -1 --decorate
414
415
416 echo -e "\n##### set jvm heap size to 8G #####"
417 echo ${ONOSJVMHeap}
418
Devin Lima0e52eb2017-09-13 18:35:12 -0700419 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
420 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700421
422 echo "##### Check onos-service setting..... #####"
423 cat ~/onos/tools/package/bin/onos-service
424
Devin Lim0e967162017-11-03 15:59:53 -0700425 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
426 }
427 return result
428}
Devin Limcbba0852017-11-13 10:31:32 -0800429def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700430 result = ""
Devin Lim3ebd5e72017-11-14 10:38:00 -0800431 if( isOldFlow && jobOn == "SCPF" && onos_branch== "master" )
Devin Lim0e967162017-11-03 15:59:53 -0700432 result = '''sed -i -e 's/@Component(immediate = true)/@Component(enabled = false)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
433 sed -i -e 's/@Component(enabled = false)/@Component(immediate = true)/g' ~/onos/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java'''
434 return result
435}
436def postSetup( onos_branch, test_branch, onos_tag, isManual ){
437 result = ""
438 if( !isManual ){
439 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700440 #mvn clean install -DskipTests
441 # Force buck update
442 rm -f ~/onos/bin/buck
443 ~/onos/tools/build/onos-buck build onos
444
Devin Lima0e52eb2017-09-13 18:35:12 -0700445 sleep 30
446 echo -e "\n##### Stop all running instances of Karaf #####"
447 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
448 sleep 30
449
Devin Lim90803a82017-08-29 13:41:44 -0700450 git branch'''
451 }
Devin Lim37a83792017-10-26 16:38:21 -0700452 return result
Devin Lim90803a82017-08-29 13:41:44 -0700453}