blob: 9ca9bbc4f8c595bae1883472cd867e700c615982 [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"
7before_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
Devin Lim61643762017-12-07 15:55:38 -080028onos_b = "master"
Devin Lim0e967162017-11-03 15:59:53 -070029test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070030onos_tag = params.ONOSTag
Devin Lim61643762017-12-07 15:55:38 -080031isOldFlow = true
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080032
Devin Lim90803a82017-08-29 13:41:44 -070033// Set tests based on day of week
Devin Limd1fb8e92018-02-28 16:29:33 -080034def now = funcs.getCurrentTime()
35print now.toString()
Devin Lim61643762017-12-07 15:55:38 -080036today = now[ Calendar.DAY_OF_WEEK ]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080037
38if( today == Calendar.SATURDAY ){
39 onos_b = previous_version
40} else if( today == Calendar.SUNDAY ){
41 onos_b = before_previous_version
42}
43AllTheTests = test_lists.getAllTheTests( onos_b )
44
Devin Lim90803a82017-08-29 13:41:44 -070045day = ""
Devin Lim61657e42017-10-09 17:24:40 -070046SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -070047USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -070048FUNC_choices = ""
49HA_choices = ""
Devin Lim61643762017-12-07 15:55:38 -080050SR_choices = ""
51stat_graph_generator_file = "testCategoryBuildStats.R"
52pie_graph_generator_file = "testCategoryPiePassFail.R"
53graph_saved_directory = "/var/jenkins/workspace/postjob-VM/"
Devin Lim90803a82017-08-29 13:41:44 -070054
55manually_run = params.manual_run
56post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -070057if( !manually_run ){
Devin Lim61643762017-12-07 15:55:38 -080058 slackSend( color:'#03CD9F',
59 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
60 + "Starting tests on : " + now.toString()
61 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
Devin Lim61657e42017-10-09 17:24:40 -070062 testDivider( today )
63 FUNC_choices = lastCommaRemover( FUNC_choices )
64 HA_choices = lastCommaRemover( HA_choices )
65 SCPF_choices = lastCommaRemover( SCPF_choices )
66 USECASE_choices = lastCommaRemover( USECASE_choices )
Devin Lim61643762017-12-07 15:55:38 -080067 SR_choices = lastCommaRemover( SR_choices )
Devin Lim61657e42017-10-09 17:24:40 -070068}
69
Devin Lim90803a82017-08-29 13:41:44 -070070if ( manually_run ){
71 organize_tests( params.Tests )
Devin Lim61643762017-12-07 15:55:38 -080072 onos_b = params.ONOSVersion
Devin Lim0e967162017-11-03 15:59:53 -070073 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -070074 println "Tests to be run manually : "
75}else{
Devin Lim61643762017-12-07 15:55:38 -080076 testcases[ "SCPF" ][ "tests" ] = SCPF_choices
77 testcases[ "USECASE" ][ "tests" ] = USECASE_choices
78 testcases[ "FUNC" ][ "tests" ] = FUNC_choices
79 testcases[ "HA" ][ "tests" ] = HA_choices
80 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim90803a82017-08-29 13:41:44 -070081 println "Defaulting to " + day + " tests:"
82}
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080083
Devin Lim90803a82017-08-29 13:41:44 -070084print_tests( testcases )
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080085
Devin Lim37a83792017-10-26 16:38:21 -070086def runTest = [
87 "VM" : [:],
88 "BM" : [:]
89]
90for( String test in testcases.keySet() ){
91 println test
Devin Lim61643762017-12-07 15:55:38 -080092 if ( testcases[ test ][ "tests" ] != "" ){
93 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 -070094 }
95}
96def finalList = [:]
Devin Lim61643762017-12-07 15:55:38 -080097finalList[ "VM" ] = runTestSeq( runTest[ "VM" ] )
98finalList[ "BM" ] = runTestSeq( runTest[ "BM" ] )
Devin Lim37a83792017-10-26 16:38:21 -070099parallel finalList
Devin Lim61643762017-12-07 15:55:38 -0800100//finalList[ "BM" ].call()
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800101
102if ( !manually_run ){
103 funcs.generateStatGraph( onos_b, AllTheTests, stat_graph_generator_file, pie_graph_generator_file, graph_saved_directory )
104}
Devin Lim90803a82017-08-29 13:41:44 -0700105
Devin Lim61657e42017-10-09 17:24:40 -0700106def testDivider( today ){
Devin Lim61643762017-12-07 15:55:38 -0800107 switch ( today ) {
Devin Lim61657e42017-10-09 17:24:40 -0700108 case Calendar.MONDAY:
109 monday( true )
110 tuesday( true, false )
111 wednesday( true, false )
112 thursday( true, false )
113 friday( true, false )
114 day = "Monday"
Devin Lim61643762017-12-07 15:55:38 -0800115 slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + printDaysForTest() )
Devin Lim61657e42017-10-09 17:24:40 -0700116 break
117 case Calendar.TUESDAY:
118 tuesday( true, true )
119 day = "Tuesday"
120 break
121 case Calendar.WEDNESDAY:
122 wednesday( true, true )
123 day = "Wednesday"
124 break
125 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700126 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700127 day = "Thursday"
Devin Lim61643762017-12-07 15:55:38 -0800128 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700129 break
130 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700131 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700132 day = "Friday"
Devin Lim61643762017-12-07 15:55:38 -0800133 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700134 break
135 case Calendar.SATURDAY:
136 saturday()
Devin Lim61657e42017-10-09 17:24:40 -0700137 day = "Saturday"
138 break
139 case Calendar.SUNDAY:
140 sunday()
Devin Lim61657e42017-10-09 17:24:40 -0700141 day = "Sunday"
Devin Lim61643762017-12-07 15:55:38 -0800142 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700143 break
144 }
145}
146def printDaysForTest(){
147 result = ""
148 for ( String test in AllTheTests.keySet() ){
149 result += test + " : \n"
150 for( String each in AllTheTests[ test ].keySet() ){
151 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
152 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
153 }
154 result += "\n"
155 }
156 return result
157}
158def lastCommaRemover( str ){
159 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
160 str = str.substring( 0,str.size() - 1 )
161 }
162 return str
163}
164def monday( getResult ){
165 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800166 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700167 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
168 HA_choices += adder( "HA", "basic", true, "M", getResult )
169 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800170 //HA_choices += adder( "HA", "new_Test", true, "M", getResult )
171 SR_choices += adder( "SR", "basic", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700172 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
173 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
174}
175def tuesday( getDay, getResult ){
176 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800177 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700178 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
179 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
180 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800181 HA_choices += adder( "HA", "new_Test", getDay, "T", getResult )
182 SR_choices += adder( "SR", "basic", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700183 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
184 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
185 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
186 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
187 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
188}
189def wednesday( getDay, getResult ){
190 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800191 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700192 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
193 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
194 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800195 //HA_choices += adder( "HA", "new_Test", getDay, "W", getResult )
196 SR_choices += adder( "SR", "basic", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700197 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
198 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
199 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
200}
201def thursday( getDay, getResult ){
202 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800203 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700204 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
205 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
206 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800207 HA_choices += adder( "HA", "new_Test", getDay, "Th", getResult )
208 SR_choices += adder( "SR", "basic", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700209 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
210 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
211}
212def friday( getDay, getResult ){
213 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800214 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700215 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
216 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
217 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800218 //HA_choices += adder( "HA", "new_Test", getDay, "F", getResult )
219 SR_choices += adder( "SR", "basic", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700220 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
221 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
222 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
223}
224def saturday(){
225 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
226 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
227 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800228 FUNC_choices += adder( "FUNC", "new_Test", true, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700229 HA_choices += adder( "HA", "basic", false, "Sa", true )
230 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
231 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800232 HA_choices += adder( "HA", "new_Test", false, "Sa", true )
233 SR_choices += adder( "SR", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700234 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
235 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
236 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
237 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
238 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
239 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
240 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700241}
242def sunday(){
243 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
244 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
245 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
246 HA_choices += adder( "HA", "basic", false, "S", true )
247 HA_choices += adder( "HA", "extra_A", false, "S", true )
248 HA_choices += adder( "HA", "extra_B", false, "S", true )
Devin Lim61643762017-12-07 15:55:38 -0800249 SR_choices += adder( "SR", "basic", false, "S", true )
Devin Lim61657e42017-10-09 17:24:40 -0700250 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
251 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
252}
253def adder( testCat, set, dayAdding, day, getResult ){
254 result = ""
255 for( String test in AllTheTests[ testCat ].keySet() ){
256 if( AllTheTests[ testCat ][ test ][ set ] ){
257 if( getResult )
258 result += test + ","
259 if( dayAdding )
260 dayAdder( testCat, test, day )
261 }
262 }
263 return result
264}
265def dayAdder( testCat, testName, dayOfWeek ){
266 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
267}
Devin Lim90803a82017-08-29 13:41:44 -0700268def runTestSeq( testList ){
269 return{
270 for ( test in testList.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800271 testList[ test ].call()
Devin Lim90803a82017-08-29 13:41:44 -0700272 }
273 }
274}
275
276def print_tests( tests ){
277 for( String test in tests.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800278 if( tests[ test ][ "tests" ] != "" ){
Devin Lim90803a82017-08-29 13:41:44 -0700279 println test + ":"
Devin Lim61643762017-12-07 15:55:38 -0800280 println tests[ test ][ "tests" ]
Devin Lim90803a82017-08-29 13:41:44 -0700281 }
282 }
283}
284def organize_tests( tests ){
Devin Lim61643762017-12-07 15:55:38 -0800285 testList = tests.tokenize( "\n;, " )
Devin Lim90803a82017-08-29 13:41:44 -0700286 for( String test in testList )
287 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
288}
Devin Lim61643762017-12-07 15:55:38 -0800289def borrow_mn( jobOn ){
290 result = ""
291 if( jobOn == "SR" ){
292 result = "~/cell_borrow.sh"
293 }
294 return result
295}
296def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
297 println jobOn + "-pipeline-" + manuallyRun ? "manually" : branch
298 wiki = branch
299 if ( branch != "master" ){
300 branch = "onos-" + branch
301 }
302 test_branch = "master"
303 node( "TestStation-" + nodeName + "s" ){
304 envSetup( branch, test_branch, onosTag, jobOn, manuallyRun )
305
306 exportEnvProperty( branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
307 }
308
309 jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
310 build job: jobToRun, propagate: false
311}
Devin Lima0e52eb2017-09-13 18:35:12 -0700312def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700313// nodeName : "BM" or "VM"
314// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
315 return{
Devin Lim61643762017-12-07 15:55:38 -0800316 if( jobOn == "SR" ){
Devin Limf5bf9b52018-02-28 18:16:21 -0800317 trigger( "1.11", tests, nodeName, jobOn, manuallyRun, onosTag )
318 trigger( "1.12", tests, nodeName, jobOn, manuallyRun, onosTag )
319 trigger( "master", tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Limd1fb8e92018-02-28 16:29:33 -0800320 // returnCell( nodeName )
Devin Lim61643762017-12-07 15:55:38 -0800321 }else{
322 trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700323 }
Devin Lim90803a82017-08-29 13:41:44 -0700324 }
325}
326
327// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700328def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800329 stage( "export Property" ){
Devin Lim90803a82017-08-29 13:41:44 -0700330 sh '''
331 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
332 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700333 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700334 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
335 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
336 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
337 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
338 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700339 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
340
Devin Lim90803a82017-08-29 13:41:44 -0700341 '''
342 }
343}
344// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700345def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim61643762017-12-07 15:55:38 -0800346 stage( "envSetup" ) {
Devin Limf5bf9b52018-02-28 18:16:21 -0800347 // after env: ''' + borrow_mn( jobOn ) + '''
Devin Lima0e52eb2017-09-13 18:35:12 -0700348 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700349 set +e
350 . ~/.bashrc
351 env
Devin Lim0e967162017-11-03 15:59:53 -0700352 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800353 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700354 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
355 }
356}
Devin Lim61643762017-12-07 15:55:38 -0800357def tagCheck( onos_tag, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700358 result = "git checkout "
Devin Lim61643762017-12-07 15:55:38 -0800359 if ( onos_tag == "" )
Devin Lim0e967162017-11-03 15:59:53 -0700360 result += onos_branch //create new local branch
361 else
362 result += onos_tag //checkout the tag
363 return result
364}
365def preSetup( onos_branch, test_branch, onos_tag, isManual ){
366 result = ""
367 if( !isManual ){
368 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700369 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700370
371 cd ~/OnosSystemTest/
372 git checkout HEAD~1 # Make sure you aren't pn a branch
373 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700374 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 -0700375 git clean -df # clean any local files
376 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700377 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700378 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700379 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700380 git branch
381 git log -1 --decorate
382
383
384 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700385 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700386
387 echo -e "\n #### check karaf version ######"
388 env |grep karaf
389
390 cd ~/onos
391 rm -rf buck-out/*
392 ~/onos/tools/build/onos-buck clean
393 git checkout HEAD~1 # Make sure you aren't pn a branch
394 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700395 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 -0700396 git clean -df # clean any local files
397 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700398 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700399 git clean -df # clean any local files
Devin Lim61643762017-12-07 15:55:38 -0800400 ''' + tagCheck( onos_tag, onos_branch ) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700401 git branch
402 git log -1 --decorate
403
404
405 echo -e "\n##### set jvm heap size to 8G #####"
406 echo ${ONOSJVMHeap}
407
Devin Lima0e52eb2017-09-13 18:35:12 -0700408 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
409 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700410
411 echo "##### Check onos-service setting..... #####"
412 cat ~/onos/tools/package/bin/onos-service
413
Devin Lim0e967162017-11-03 15:59:53 -0700414 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
415 }
416 return result
417}
Devin Limcbba0852017-11-13 10:31:32 -0800418def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700419 result = ""
Devin Lim61643762017-12-07 15:55:38 -0800420 if( jobOn == "SCPF" && ( onos_branch== "master" || onos_branch=="onos-1.12" ) )
421 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
422 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 -0700423 return result
424}
425def postSetup( onos_branch, test_branch, onos_tag, isManual ){
426 result = ""
427 if( !isManual ){
428 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700429 #mvn clean install -DskipTests
430 # Force buck update
431 rm -f ~/onos/bin/buck
432 ~/onos/tools/build/onos-buck build onos
433
Devin Lima0e52eb2017-09-13 18:35:12 -0700434 sleep 30
435 echo -e "\n##### Stop all running instances of Karaf #####"
436 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
437 sleep 30
438
Devin Lim90803a82017-08-29 13:41:44 -0700439 git branch'''
440 }
Devin Lim37a83792017-10-26 16:38:21 -0700441 return result
Devin Lim61643762017-12-07 15:55:38 -0800442}
443def returnCell( nodeName ){
444 node( "TestStation-" + nodeName + "s" ){
445 sh '''#!/bin/bash -l
446 set +e
447 . ~/.bashrc
448 env
449 ~/./return_cell.sh
450 '''
451 }
Devin Lim90803a82017-08-29 13:41:44 -0700452}