blob: d0ce38222e28310789fff84c99c848965dde8f4a [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":[
9 "FUNCipv6Intent" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
10 "FUNCoptical" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
11 "FUNCflow" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
12 "FUNCnetCfg": ["basic":true, "extra_A":false, "extra_B":false, "day":""],
13 "FUNCovsdbtest" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
14 "FUNCnetconf" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
15 "FUNCgroup" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
16 "FUNCintent" : ["basic":false, "extra_A":true, "extra_B":false, "day":""],
17 "FUNCintentRest" : ["basic":false, "extra_A":false, "extra_B":true, "day":""]
18 ],
19 "HA":[
20 "HAsanity" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
21 "HAclusterRestart" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
22 "HAsingleInstanceRestart" : ["basic":true, "extra_A":false, "extra_B":false, "day":""],
23 "HAstopNodes" : ["basic":false, "extra_A":true, "extra_B":false, "day":""],
24 "HAfullNetPartition" : ["basic":false, "extra_A":true, "extra_B":false, "day":""],
25 "HAswapNodes" : ["basic":false, "extra_A":false, "extra_B":true, "day":""],
26 "HAscaling" : ["basic":false, "extra_A":false, "extra_B":true, "day":""],
27 "HAkillNodes" : ["basic":false, "extra_A":false, "extra_B":true, "day":""]
28 ],
29 "SCPF":[
30 "SCPFswitchLat": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
31 "SCPFcbench": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
32 "SCPFportLat": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
33 "SCPFflowTp1g": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
34 "SCPFintentEventTp": ["basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
35 "SCPFhostLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
36 // batch will be on extra_A after fixing from the ONOS side.
Devin Lim0e967162017-11-03 15:59:53 -070037 "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 -070038 "SCPFintentRerouteLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
39 "SCPFintentInstallWithdrawLat": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
40 "SCPFflowTp1gWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
41 "SCPFintentEventTpWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
42 "SCPFintentRerouteLatWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
43 "SCPFscalingMaxIntentsWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
44 "SCPFintentInstallWithdrawLatWithFlowObj": ["basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:""],
45 "SCPFscaleTopo": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":true, "extra_D":false, "new_Test":false, day:""],
46 "SCPFscalingMaxIntents": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":true, "new_Test":false, day:""],
47 "SCPFmastershipFailoverLat": ["basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":true, day:""]
48 ],
49 "USECASE":[
50 "FUNCvirNetNB" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
51 "FUNCbgpls" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
52 "VPLSBasic" : ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
53 "USECASE_SdnipFunction": ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
54 "USECASE_SdnipFunctionCluster": ["basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":""],
55 "PLATdockertest": ["basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":""],
56 "SRSanity": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
57 "SRSwitchFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
58 "SRLinkFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
59 "SROnosFailure": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
60 "SRClusterRestart": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
61 "SRDynamic": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
62 "SRHighAvailability": ["basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":""],
63 "VPLSfailsafe" : ["basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":""]
64 ]
65]
Devin Lim90803a82017-08-29 13:41:44 -070066testcases = [
67 "FUNC" : [ tests : "" , nodeName : "VM"],
68 "HA" : [ tests : "" , nodeName : "VM"],
69 "SCPF" : [ tests : "" , nodeName : "BM"],
70 "USECASE" : [ tests : "" , nodeName : "BM"]
71]
72Prefix_organizer = [
73 "FU" : "FUNC",
74 "HA" : "HA",
75 "PL" : "USECASE",
76 "SA" : "USECASE",
77 "SC" : "SCPF",
78 "SR" : "USECASE",
79 "US" : "USECASE",
80 "VP" : "USECASE"
81]
82
Devin Lima0e52eb2017-09-13 18:35:12 -070083onos_branch = "master"
Devin Lim0e967162017-11-03 15:59:53 -070084test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070085onos_tag = params.ONOSTag
Devin Lim37a83792017-10-26 16:38:21 -070086isOldFlow = false
Devin Lim90803a82017-08-29 13:41:44 -070087// Set tests based on day of week
88def now = new Date()
89echo(now.toString())
90today = now[Calendar.DAY_OF_WEEK]
91day = ""
Devin Lim61657e42017-10-09 17:24:40 -070092SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070093USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -070094FUNC_choices = ""
95HA_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070096
97manually_run = params.manual_run
98post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -070099if( !manually_run ){
100 sendToSlack( '#03CD9F', ":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
101 + "Starting tests on : " + now.toString()
102 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
103 testDivider( today )
104 FUNC_choices = lastCommaRemover( FUNC_choices )
105 HA_choices = lastCommaRemover( HA_choices )
106 SCPF_choices = lastCommaRemover( SCPF_choices )
107 USECASE_choices = lastCommaRemover( USECASE_choices )
108}
109
Devin Lim90803a82017-08-29 13:41:44 -0700110if ( manually_run ){
111 organize_tests( params.Tests )
112 onos_branch = params.ONOSVersion
Devin Lim0e967162017-11-03 15:59:53 -0700113 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -0700114 println "Tests to be run manually : "
115}else{
116 testcases["SCPF"]["tests"] = SCPF_choices
117 testcases["USECASE"]["tests"] = USECASE_choices
118 testcases["FUNC"]["tests"] = FUNC_choices
119 testcases["HA"]["tests"] = HA_choices
120 println "Defaulting to " + day + " tests:"
121}
122print_tests( testcases )
Devin Lim37a83792017-10-26 16:38:21 -0700123def runTest = [
124 "VM" : [:],
125 "BM" : [:]
126]
127for( String test in testcases.keySet() ){
128 println test
129 if (testcases[test]["tests"] != ""){
130 runTest[testcases[test]["nodeName"]][test] = trigger_pipeline( onos_branch, testcases[test]["tests"], testcases[test]["nodeName"], test, manually_run, onos_tag )
131 }
132}
133def finalList = [:]
134finalList["VM"] = runTestSeq( runTest["VM"] )
135finalList["BM"] = runTestSeq( runTest["BM"] )
136parallel finalList
Devin Lim90803a82017-08-29 13:41:44 -0700137
Devin Lim61657e42017-10-09 17:24:40 -0700138def testDivider( today ){
139 switch (today) {
140 case Calendar.MONDAY:
141 monday( true )
142 tuesday( true, false )
143 wednesday( true, false )
144 thursday( true, false )
145 friday( true, false )
146 day = "Monday"
147 sendToSlack( '#FFD988', "Tests to be run this weekdays : \n" + printDaysForTest() )
148 break
149 case Calendar.TUESDAY:
150 tuesday( true, true )
151 day = "Tuesday"
152 break
153 case Calendar.WEDNESDAY:
154 wednesday( true, true )
155 day = "Wednesday"
156 break
157 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700158 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700159 day = "Thursday"
Devin Lim0e967162017-11-03 15:59:53 -0700160 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700161 break
162 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700163 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700164 day = "Friday"
Devin Lim0e967162017-11-03 15:59:53 -0700165 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700166 break
167 case Calendar.SATURDAY:
168 saturday()
Devin Lim0e967162017-11-03 15:59:53 -0700169 onos_branch= previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700170 day = "Saturday"
171 break
172 case Calendar.SUNDAY:
173 sunday()
Devin Lim0e967162017-11-03 15:59:53 -0700174 onos_branch= before_previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700175 day = "Sunday"
Devin Lim0e967162017-11-03 15:59:53 -0700176 isOldFlow = true
Devin Lim61657e42017-10-09 17:24:40 -0700177 break
178 }
179}
180def printDaysForTest(){
181 result = ""
182 for ( String test in AllTheTests.keySet() ){
183 result += test + " : \n"
184 for( String each in AllTheTests[ test ].keySet() ){
185 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
186 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
187 }
188 result += "\n"
189 }
190 return result
191}
192def lastCommaRemover( str ){
193 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
194 str = str.substring( 0,str.size() - 1 )
195 }
196 return str
197}
198def monday( getResult ){
199 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
200 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
201 HA_choices += adder( "HA", "basic", true, "M", getResult )
202 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
203 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
204 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
205}
206def tuesday( getDay, getResult ){
207 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
208 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
209 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
210 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
211 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
212 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
213 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
214 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
215 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
216}
217def wednesday( getDay, getResult ){
218 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
219 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
220 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
221 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
222 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
223 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
224 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
225}
226def thursday( getDay, getResult ){
227 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
228 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
229 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
230 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
231 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
232 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
233}
234def friday( getDay, getResult ){
235 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
236 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
237 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
238 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
239 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
240 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
241 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
242}
243def saturday(){
244 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
245 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
246 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
247 HA_choices += adder( "HA", "basic", false, "Sa", true )
248 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
249 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
250 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
251 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
252 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
253 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
254 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
255 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
256 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
257 USECASE_choices += adder( "USECASE", "new_Test", false, "Sa", true )
258}
259def sunday(){
260 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
261 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
262 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
263 HA_choices += adder( "HA", "basic", false, "S", true )
264 HA_choices += adder( "HA", "extra_A", false, "S", true )
265 HA_choices += adder( "HA", "extra_B", false, "S", true )
266 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
267 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
268}
269def adder( testCat, set, dayAdding, day, getResult ){
270 result = ""
271 for( String test in AllTheTests[ testCat ].keySet() ){
272 if( AllTheTests[ testCat ][ test ][ set ] ){
273 if( getResult )
274 result += test + ","
275 if( dayAdding )
276 dayAdder( testCat, test, day )
277 }
278 }
279 return result
280}
281def dayAdder( testCat, testName, dayOfWeek ){
282 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
283}
Devin Lim90803a82017-08-29 13:41:44 -0700284def runTestSeq( testList ){
285 return{
286 for ( test in testList.keySet() ){
287 testList[test].call()
288 }
289 }
290}
291
292def print_tests( tests ){
293 for( String test in tests.keySet() ){
294 if( tests[test]["tests"] != "" ){
295 println test + ":"
296 println tests[test]["tests"]
297 }
298 }
299}
300def organize_tests( tests ){
301 testList = tests.tokenize("\n;, ")
302 for( String test in testList )
303 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
304}
Devin Lima0e52eb2017-09-13 18:35:12 -0700305def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700306// nodeName : "BM" or "VM"
307// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
308 return{
309 if (branch == "master"){
310 onos_branch = branch
311 }else{
312 onos_branch = "onos-" + branch
313 }
314 wiki = branch
Devin Lim0e967162017-11-03 15:59:53 -0700315 test_branch = onos_branch
316 if (onos_branch == previous_version)
Devin Lim90803a82017-08-29 13:41:44 -0700317 test_branch = "master"
318 println jobOn + "_Pipeline_" + manuallyRun ? "manually" : branch
319 node("TestStation-" + nodeName + "s"){
Devin Lim0e967162017-11-03 15:59:53 -0700320 envSetup(onos_branch, test_branch, onosTag, jobOn, manuallyRun )
Devin Lim90803a82017-08-29 13:41:44 -0700321
Devin Lim0e967162017-11-03 15:59:53 -0700322 exportEnvProperty( onos_branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
Devin Lim90803a82017-08-29 13:41:44 -0700323 }
324
325 jobToRun = jobOn + "_Pipeline_" + ( manuallyRun ? "manually" : branch )
326 build job: jobToRun, propagate: false
327 }
328}
329
330// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700331def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim90803a82017-08-29 13:41:44 -0700332 stage("export Property"){
333 sh '''
334 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
335 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700336 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700337 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
338 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
339 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
340 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
341 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700342 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
343
Devin Lim90803a82017-08-29 13:41:44 -0700344 '''
345 }
346}
Devin Lim61657e42017-10-09 17:24:40 -0700347def sendToSlack( color, message ){
348 slackSend(color:color, message: message)
349}
Devin Lim90803a82017-08-29 13:41:44 -0700350// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700351def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim90803a82017-08-29 13:41:44 -0700352 stage("envSetup") {
Devin Lima0e52eb2017-09-13 18:35:12 -0700353 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700354 set +e
355 . ~/.bashrc
356 env
Devin Lim0e967162017-11-03 15:59:53 -0700357 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800358 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700359 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
360 }
361}
362def tagCheck(onos_tag, onos_branch){
363 result = "git checkout "
364 if (onos_tag == "" )
365 result += onos_branch //create new local branch
366 else
367 result += onos_tag //checkout the tag
368 return result
369}
370def preSetup( onos_branch, test_branch, onos_tag, isManual ){
371 result = ""
372 if( !isManual ){
373 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700374 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700375
376 cd ~/OnosSystemTest/
377 git checkout HEAD~1 # Make sure you aren't pn a branch
378 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700379 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 -0700380 git clean -df # clean any local files
381 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700382 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700383 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700384 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700385 git branch
386 git log -1 --decorate
387
388
389 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700390 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700391
392 echo -e "\n #### check karaf version ######"
393 env |grep karaf
394
395 cd ~/onos
396 rm -rf buck-out/*
397 ~/onos/tools/build/onos-buck clean
398 git checkout HEAD~1 # Make sure you aren't pn a branch
399 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700400 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 -0700401 git clean -df # clean any local files
402 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700403 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700404 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700405 ''' + tagCheck(onos_tag, onos_branch) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700406 git branch
407 git log -1 --decorate
408
409
410 echo -e "\n##### set jvm heap size to 8G #####"
411 echo ${ONOSJVMHeap}
412
Devin Lima0e52eb2017-09-13 18:35:12 -0700413 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
414 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700415
416 echo "##### Check onos-service setting..... #####"
417 cat ~/onos/tools/package/bin/onos-service
418
Devin Lim0e967162017-11-03 15:59:53 -0700419 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
420 }
421 return result
422}
Devin Limcbba0852017-11-13 10:31:32 -0800423def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700424 result = ""
Devin Limcbba0852017-11-13 10:31:32 -0800425 if( isOldFlow && jobOn == "SCPF" && onos_branch="master" )
Devin Lim0e967162017-11-03 15:59:53 -0700426 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
427 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'''
428 return result
429}
430def postSetup( onos_branch, test_branch, onos_tag, isManual ){
431 result = ""
432 if( !isManual ){
433 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700434 #mvn clean install -DskipTests
435 # Force buck update
436 rm -f ~/onos/bin/buck
437 ~/onos/tools/build/onos-buck build onos
438
Devin Lima0e52eb2017-09-13 18:35:12 -0700439 sleep 30
440 echo -e "\n##### Stop all running instances of Karaf #####"
441 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
442 sleep 30
443
Devin Lim90803a82017-08-29 13:41:44 -0700444 git branch'''
445 }
Devin Lim37a83792017-10-26 16:38:21 -0700446 return result
Devin Lim90803a82017-08-29 13:41:44 -0700447}