blob: f25832486528cf9ebddfa4cb9819e8d86c309e6d [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' )
Devin Lim61643762017-12-07 15:55:38 -08004funcs.initializeTrend( "VM" );
5previous_version = "1.12"
6before_previous_version = "1.11"
Devin Lim61657e42017-10-09 17:24:40 -07007AllTheTests=
8[
9 "FUNC":[
Devin Lim61643762017-12-07 15:55:38 -080010 "FUNCipv6Intent" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
11 "FUNCoptical" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
12 "FUNCflow" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
13 "FUNCnetCfg": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
14 "FUNCovsdbtest" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
15 "FUNCnetconf" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
16 "FUNCgroup" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
17 "FUNCformCluster" :[ "basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":"" ],
18 "FUNCintent" : [ "basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":"" ],
19 "FUNCintentRest" : [ "basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":"" ],
Devin Lim61657e42017-10-09 17:24:40 -070020 ],
21 "HA":[
Devin Lim61643762017-12-07 15:55:38 -080022 "HAsanity" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
23 "HAclusterRestart" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
24 "HAsingleInstanceRestart" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
25 "HAupgrade" : [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":"" ],
26 "HAupgradeRollback" : [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":true, "day":"" ],
27 "HAstopNodes" : [ "basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":"" ],
28 "HAfullNetPartition" : [ "basic":false, "extra_A":true, "extra_B":false, "new_Test":false, "day":"" ],
29 "HAswapNodes" : [ "basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":"" ],
30 "HAscaling" : [ "basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":"" ],
31 "HAkillNodes" : [ "basic":false, "extra_A":false, "extra_B":true, "new_Test":false, "day":"" ]
Devin Lim61657e42017-10-09 17:24:40 -070032 ],
33 "SCPF":[
Devin Lim61643762017-12-07 15:55:38 -080034 "SCPFswitchLat": [ "basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
35 "SCPFcbench": [ "basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
36 "SCPFportLat": [ "basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
37 "SCPFflowTp1g": [ "basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
38 "SCPFintentEventTp": [ "basic":true, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
39 "SCPFhostLat": [ "basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
40 "SCPFbatchFlowResp": [ "basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
41 "SCPFintentRerouteLat": [ "basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
42 "SCPFintentInstallWithdrawLat": [ "basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
43 "SCPFflowTp1gWithFlowObj": [ "basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
44 "SCPFintentEventTpWithFlowObj": [ "basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
45 "SCPFintentRerouteLatWithFlowObj": [ "basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
46 "SCPFscalingMaxIntentsWithFlowObj": [ "basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
47 "SCPFintentInstallWithdrawLatWithFlowObj": [ "basic":false, "extra_A":false, "extra_B":true, "extra_C":false, "extra_D":false, "new_Test":false, day:"" ],
48 "SCPFscaleTopo": [ "basic":false, "extra_A":false, "extra_B":false, "extra_C":true, "extra_D":false, "new_Test":false, day:"" ],
49 "SCPFscalingMaxIntents": [ "basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":true, "new_Test":false, day:"" ],
50 "SCPFmastershipFailoverLat": [ "basic":false, "extra_A":false, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":true, day:"" ]
Devin Lim61657e42017-10-09 17:24:40 -070051 ],
52 "USECASE":[
Devin Lim61643762017-12-07 15:55:38 -080053 "FUNCvirNetNB" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
54 "FUNCbgpls" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
55 "VPLSBasic" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
56 "USECASE_SdnipFunction": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
57 "USECASE_SdnipFunctionCluster": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
58 "PLATdockertest": [ "basic":true, "extra_A":true, "extra_B":false, "new_Test":false, "day":"" ],
59 "SRSanity": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
60 "SRSwitchFailure": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
61 "SRLinkFailure": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
62 "SROnosFailure": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
63 "SRClusterRestart": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
64 "SRDynamic": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
65 "SRHighAvailability": [ "basic":false, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
66 "VPLSfailsafe" : [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ]
67 ],
68 "SR":[
Devin Limd1fb8e92018-02-28 16:29:33 -080069 "SRBridging": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ],
70 "SRRouting": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ]
Devin Lim61657e42017-10-09 17:24:40 -070071 ]
72]
Devin Lim90803a82017-08-29 13:41:44 -070073testcases = [
Devin Lim61643762017-12-07 15:55:38 -080074 "FUNC" : [ tests : "" , nodeName : "VM" ],
75 "HA" : [ tests : "" , nodeName : "VM" ],
76 "SR" : [ tests : "", nodeName : "VM" ],
77 "SCPF" : [ tests : "" , nodeName : "BM" ],
78 "USECASE" : [ tests : "" , nodeName : "BM" ]
Devin Lim90803a82017-08-29 13:41:44 -070079]
80Prefix_organizer = [
81 "FU" : "FUNC",
82 "HA" : "HA",
83 "PL" : "USECASE",
84 "SA" : "USECASE",
85 "SC" : "SCPF",
Devin Lim61643762017-12-07 15:55:38 -080086 "SR" : "SR",
Devin Lim90803a82017-08-29 13:41:44 -070087 "US" : "USECASE",
88 "VP" : "USECASE"
89]
90
Devin Lim61643762017-12-07 15:55:38 -080091onos_b = "master"
Devin Lim0e967162017-11-03 15:59:53 -070092test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070093onos_tag = params.ONOSTag
Devin Lim61643762017-12-07 15:55:38 -080094isOldFlow = true
Devin Lim90803a82017-08-29 13:41:44 -070095// Set tests based on day of week
Devin Limd1fb8e92018-02-28 16:29:33 -080096def now = funcs.getCurrentTime()
97print now.toString()
Devin Lim61643762017-12-07 15:55:38 -080098today = now[ Calendar.DAY_OF_WEEK ]
Devin Lim90803a82017-08-29 13:41:44 -070099day = ""
Devin Lim61657e42017-10-09 17:24:40 -0700100SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -0700101USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -0700102FUNC_choices = ""
103HA_choices = ""
Devin Lim61643762017-12-07 15:55:38 -0800104SR_choices = ""
105stat_graph_generator_file = "testCategoryBuildStats.R"
106pie_graph_generator_file = "testCategoryPiePassFail.R"
107graph_saved_directory = "/var/jenkins/workspace/postjob-VM/"
Devin Lim90803a82017-08-29 13:41:44 -0700108
109manually_run = params.manual_run
110post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -0700111if( !manually_run ){
Devin Lim61643762017-12-07 15:55:38 -0800112 slackSend( color:'#03CD9F',
113 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
114 + "Starting tests on : " + now.toString()
115 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
Devin Lim61657e42017-10-09 17:24:40 -0700116 testDivider( today )
117 FUNC_choices = lastCommaRemover( FUNC_choices )
118 HA_choices = lastCommaRemover( HA_choices )
119 SCPF_choices = lastCommaRemover( SCPF_choices )
120 USECASE_choices = lastCommaRemover( USECASE_choices )
Devin Lim61643762017-12-07 15:55:38 -0800121 SR_choices = lastCommaRemover( SR_choices )
Devin Lim61657e42017-10-09 17:24:40 -0700122}
123
Devin Lim90803a82017-08-29 13:41:44 -0700124if ( manually_run ){
125 organize_tests( params.Tests )
Devin Lim61643762017-12-07 15:55:38 -0800126 onos_b = params.ONOSVersion
Devin Lim0e967162017-11-03 15:59:53 -0700127 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -0700128 println "Tests to be run manually : "
129}else{
Devin Lim61643762017-12-07 15:55:38 -0800130 testcases[ "SCPF" ][ "tests" ] = SCPF_choices
131 testcases[ "USECASE" ][ "tests" ] = USECASE_choices
132 testcases[ "FUNC" ][ "tests" ] = FUNC_choices
133 testcases[ "HA" ][ "tests" ] = HA_choices
134 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim90803a82017-08-29 13:41:44 -0700135 println "Defaulting to " + day + " tests:"
136}
137print_tests( testcases )
Devin Lim37a83792017-10-26 16:38:21 -0700138def runTest = [
139 "VM" : [:],
140 "BM" : [:]
141]
142for( String test in testcases.keySet() ){
143 println test
Devin Lim61643762017-12-07 15:55:38 -0800144 if ( testcases[ test ][ "tests" ] != "" ){
145 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 -0700146 }
147}
148def finalList = [:]
Devin Lim61643762017-12-07 15:55:38 -0800149finalList[ "VM" ] = runTestSeq( runTest[ "VM" ] )
150finalList[ "BM" ] = runTestSeq( runTest[ "BM" ] )
Devin Lim37a83792017-10-26 16:38:21 -0700151parallel finalList
Devin Lim61643762017-12-07 15:55:38 -0800152//finalList[ "BM" ].call()
153generateStatGraph()
Devin Lim90803a82017-08-29 13:41:44 -0700154
Devin Lim61657e42017-10-09 17:24:40 -0700155def testDivider( today ){
Devin Lim61643762017-12-07 15:55:38 -0800156 switch ( today ) {
Devin Lim61657e42017-10-09 17:24:40 -0700157 case Calendar.MONDAY:
158 monday( true )
159 tuesday( true, false )
160 wednesday( true, false )
161 thursday( true, false )
162 friday( true, false )
163 day = "Monday"
Devin Lim61643762017-12-07 15:55:38 -0800164 slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + printDaysForTest() )
Devin Lim61657e42017-10-09 17:24:40 -0700165 break
166 case Calendar.TUESDAY:
167 tuesday( true, true )
168 day = "Tuesday"
169 break
170 case Calendar.WEDNESDAY:
171 wednesday( true, true )
172 day = "Wednesday"
173 break
174 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700175 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700176 day = "Thursday"
Devin Lim61643762017-12-07 15:55:38 -0800177 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700178 break
179 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700180 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700181 day = "Friday"
Devin Lim61643762017-12-07 15:55:38 -0800182 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700183 break
184 case Calendar.SATURDAY:
185 saturday()
Devin Lim61643762017-12-07 15:55:38 -0800186 onos_b= previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700187 day = "Saturday"
188 break
189 case Calendar.SUNDAY:
190 sunday()
Devin Lim61643762017-12-07 15:55:38 -0800191 onos_b= before_previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700192 day = "Sunday"
Devin Lim61643762017-12-07 15:55:38 -0800193 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700194 break
195 }
196}
197def printDaysForTest(){
198 result = ""
199 for ( String test in AllTheTests.keySet() ){
200 result += test + " : \n"
201 for( String each in AllTheTests[ test ].keySet() ){
202 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
203 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
204 }
205 result += "\n"
206 }
207 return result
208}
209def lastCommaRemover( str ){
210 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
211 str = str.substring( 0,str.size() - 1 )
212 }
213 return str
214}
215def monday( getResult ){
216 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800217 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700218 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
219 HA_choices += adder( "HA", "basic", true, "M", getResult )
220 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800221 //HA_choices += adder( "HA", "new_Test", true, "M", getResult )
222 SR_choices += adder( "SR", "basic", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700223 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
224 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
225}
226def tuesday( getDay, getResult ){
227 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800228 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700229 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
230 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
231 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800232 HA_choices += adder( "HA", "new_Test", getDay, "T", getResult )
233 SR_choices += adder( "SR", "basic", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700234 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
235 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
236 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
237 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
238 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
239}
240def wednesday( getDay, getResult ){
241 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800242 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700243 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
244 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
245 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800246 //HA_choices += adder( "HA", "new_Test", getDay, "W", getResult )
247 SR_choices += adder( "SR", "basic", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700248 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
249 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
250 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
251}
252def thursday( getDay, getResult ){
253 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800254 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700255 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
256 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
257 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800258 HA_choices += adder( "HA", "new_Test", getDay, "Th", getResult )
259 SR_choices += adder( "SR", "basic", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700260 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
261 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
262}
263def friday( getDay, getResult ){
264 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800265 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700266 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
267 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
268 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800269 //HA_choices += adder( "HA", "new_Test", getDay, "F", getResult )
270 SR_choices += adder( "SR", "basic", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700271 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
272 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
273 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
274}
275def saturday(){
276 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
277 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
278 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800279 FUNC_choices += adder( "FUNC", "new_Test", true, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700280 HA_choices += adder( "HA", "basic", false, "Sa", true )
281 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
282 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800283 HA_choices += adder( "HA", "new_Test", false, "Sa", true )
284 SR_choices += adder( "SR", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700285 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
286 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
287 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
288 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
289 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
290 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
291 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700292}
293def sunday(){
294 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
295 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
296 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
297 HA_choices += adder( "HA", "basic", false, "S", true )
298 HA_choices += adder( "HA", "extra_A", false, "S", true )
299 HA_choices += adder( "HA", "extra_B", false, "S", true )
Devin Lim61643762017-12-07 15:55:38 -0800300 SR_choices += adder( "SR", "basic", false, "S", true )
Devin Lim61657e42017-10-09 17:24:40 -0700301 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
302 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
303}
304def adder( testCat, set, dayAdding, day, getResult ){
305 result = ""
306 for( String test in AllTheTests[ testCat ].keySet() ){
307 if( AllTheTests[ testCat ][ test ][ set ] ){
308 if( getResult )
309 result += test + ","
310 if( dayAdding )
311 dayAdder( testCat, test, day )
312 }
313 }
314 return result
315}
316def dayAdder( testCat, testName, dayOfWeek ){
317 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
318}
Devin Lim90803a82017-08-29 13:41:44 -0700319def runTestSeq( testList ){
320 return{
321 for ( test in testList.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800322 testList[ test ].call()
Devin Lim90803a82017-08-29 13:41:44 -0700323 }
324 }
325}
326
327def print_tests( tests ){
328 for( String test in tests.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800329 if( tests[ test ][ "tests" ] != "" ){
Devin Lim90803a82017-08-29 13:41:44 -0700330 println test + ":"
Devin Lim61643762017-12-07 15:55:38 -0800331 println tests[ test ][ "tests" ]
Devin Lim90803a82017-08-29 13:41:44 -0700332 }
333 }
334}
335def organize_tests( tests ){
Devin Lim61643762017-12-07 15:55:38 -0800336 testList = tests.tokenize( "\n;, " )
Devin Lim90803a82017-08-29 13:41:44 -0700337 for( String test in testList )
338 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
339}
Devin Lim61643762017-12-07 15:55:38 -0800340def borrow_mn( jobOn ){
341 result = ""
342 if( jobOn == "SR" ){
343 result = "~/cell_borrow.sh"
344 }
345 return result
346}
347def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
348 println jobOn + "-pipeline-" + manuallyRun ? "manually" : branch
349 wiki = branch
350 if ( branch != "master" ){
351 branch = "onos-" + branch
352 }
353 test_branch = "master"
354 node( "TestStation-" + nodeName + "s" ){
355 envSetup( branch, test_branch, onosTag, jobOn, manuallyRun )
356
357 exportEnvProperty( branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
358 }
359
360 jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
361 build job: jobToRun, propagate: false
362}
Devin Lima0e52eb2017-09-13 18:35:12 -0700363def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700364// nodeName : "BM" or "VM"
365// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
366 return{
Devin Lim61643762017-12-07 15:55:38 -0800367 if( jobOn == "SR" ){
Devin Limf5bf9b52018-02-28 18:16:21 -0800368 trigger( "1.11", tests, nodeName, jobOn, manuallyRun, onosTag )
369 trigger( "1.12", tests, nodeName, jobOn, manuallyRun, onosTag )
370 trigger( "master", tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Limd1fb8e92018-02-28 16:29:33 -0800371 // returnCell( nodeName )
Devin Lim61643762017-12-07 15:55:38 -0800372 }else{
373 trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700374 }
Devin Lim90803a82017-08-29 13:41:44 -0700375 }
376}
377
378// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700379def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800380 stage( "export Property" ){
Devin Lim90803a82017-08-29 13:41:44 -0700381 sh '''
382 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
383 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700384 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700385 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
386 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
387 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
388 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
389 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700390 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
391
Devin Lim90803a82017-08-29 13:41:44 -0700392 '''
393 }
394}
395// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700396def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim61643762017-12-07 15:55:38 -0800397 stage( "envSetup" ) {
Devin Limf5bf9b52018-02-28 18:16:21 -0800398 // after env: ''' + borrow_mn( jobOn ) + '''
Devin Lima0e52eb2017-09-13 18:35:12 -0700399 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700400 set +e
401 . ~/.bashrc
402 env
Devin Lim0e967162017-11-03 15:59:53 -0700403 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800404 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700405 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
406 }
407}
Devin Lim61643762017-12-07 15:55:38 -0800408def tagCheck( onos_tag, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700409 result = "git checkout "
Devin Lim61643762017-12-07 15:55:38 -0800410 if ( onos_tag == "" )
Devin Lim0e967162017-11-03 15:59:53 -0700411 result += onos_branch //create new local branch
412 else
413 result += onos_tag //checkout the tag
414 return result
415}
416def preSetup( onos_branch, test_branch, onos_tag, isManual ){
417 result = ""
418 if( !isManual ){
419 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700420 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700421
422 cd ~/OnosSystemTest/
423 git checkout HEAD~1 # Make sure you aren't pn a branch
424 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700425 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 -0700426 git clean -df # clean any local files
427 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700428 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700429 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700430 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700431 git branch
432 git log -1 --decorate
433
434
435 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700436 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700437
438 echo -e "\n #### check karaf version ######"
439 env |grep karaf
440
441 cd ~/onos
442 rm -rf buck-out/*
443 ~/onos/tools/build/onos-buck clean
444 git checkout HEAD~1 # Make sure you aren't pn a branch
445 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700446 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 -0700447 git clean -df # clean any local files
448 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700449 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700450 git clean -df # clean any local files
Devin Lim61643762017-12-07 15:55:38 -0800451 ''' + tagCheck( onos_tag, onos_branch ) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700452 git branch
453 git log -1 --decorate
454
455
456 echo -e "\n##### set jvm heap size to 8G #####"
457 echo ${ONOSJVMHeap}
458
Devin Lima0e52eb2017-09-13 18:35:12 -0700459 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
460 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700461
462 echo "##### Check onos-service setting..... #####"
463 cat ~/onos/tools/package/bin/onos-service
464
Devin Lim0e967162017-11-03 15:59:53 -0700465 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
466 }
467 return result
468}
Devin Limcbba0852017-11-13 10:31:32 -0800469def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700470 result = ""
Devin Lim61643762017-12-07 15:55:38 -0800471 if( jobOn == "SCPF" && ( onos_branch== "master" || onos_branch=="onos-1.12" ) )
472 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
473 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 -0700474 return result
475}
476def postSetup( onos_branch, test_branch, onos_tag, isManual ){
477 result = ""
478 if( !isManual ){
479 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700480 #mvn clean install -DskipTests
481 # Force buck update
482 rm -f ~/onos/bin/buck
483 ~/onos/tools/build/onos-buck build onos
484
Devin Lima0e52eb2017-09-13 18:35:12 -0700485 sleep 30
486 echo -e "\n##### Stop all running instances of Karaf #####"
487 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
488 sleep 30
489
Devin Lim90803a82017-08-29 13:41:44 -0700490 git branch'''
491 }
Devin Lim37a83792017-10-26 16:38:21 -0700492 return result
Devin Lim61643762017-12-07 15:55:38 -0800493}
494def returnCell( nodeName ){
495 node( "TestStation-" + nodeName + "s" ){
496 sh '''#!/bin/bash -l
497 set +e
498 . ~/.bashrc
499 env
500 ~/./return_cell.sh
501 '''
502 }
503}
504
505def generateStatGraph(){
506 if( !manually_run ){
507 testListPart = funcs.createStatsList( "FUNC", AllTheTests[ "FUNC" ], true ) +
508 funcs.createStatsList( "HA", AllTheTests[ "HA" ], true ) +
509 funcs.createStatsList( "USECASE", AllTheTests[ "USECASE" ], false )
510 pieTestList = funcs.makeTestList( AllTheTests[ "FUNC" ], true ) +
511 funcs.makeTestList( AllTheTests[ "HA" ], true ) +
512 funcs.makeTestList( AllTheTests[ "USECASE" ], false )
513 funcs.generateCategoryStatsGraph( "false", "true", stat_graph_generator_file, pie_graph_generator_file, "ALL", onos_b, testListPart, graph_saved_directory, pieTestList )
514 }
Devin Lim90803a82017-08-29 13:41:44 -0700515}