blob: fb35bbd184b8eb0d4ec36bc2a94eac6e9ce01948 [file] [log] [blame]
Devin Lim90803a82017-08-29 13:41:44 -07001#!groovy
Devin Lim61643762017-12-07 15:55:38 -08002
3funcs = evaluate readTrusted( 'JenkinsCommonFuncs.groovy' )
4funcs.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":[
69 "SRBridging": [ "basic":true, "extra_A":false, "extra_B":false, "new_Test":false, "day":"" ]
Devin Lim61657e42017-10-09 17:24:40 -070070 ]
71]
Devin Lim90803a82017-08-29 13:41:44 -070072testcases = [
Devin Lim61643762017-12-07 15:55:38 -080073 "FUNC" : [ tests : "" , nodeName : "VM" ],
74 "HA" : [ tests : "" , nodeName : "VM" ],
75 "SR" : [ tests : "", nodeName : "VM" ],
76 "SCPF" : [ tests : "" , nodeName : "BM" ],
77 "USECASE" : [ tests : "" , nodeName : "BM" ]
Devin Lim90803a82017-08-29 13:41:44 -070078]
79Prefix_organizer = [
80 "FU" : "FUNC",
81 "HA" : "HA",
82 "PL" : "USECASE",
83 "SA" : "USECASE",
84 "SC" : "SCPF",
Devin Lim61643762017-12-07 15:55:38 -080085 "SR" : "SR",
Devin Lim90803a82017-08-29 13:41:44 -070086 "US" : "USECASE",
87 "VP" : "USECASE"
88]
89
Devin Lim61643762017-12-07 15:55:38 -080090onos_b = "master"
Devin Lim0e967162017-11-03 15:59:53 -070091test_branch = ""
Devin Lima0e52eb2017-09-13 18:35:12 -070092onos_tag = params.ONOSTag
Devin Lim61643762017-12-07 15:55:38 -080093isOldFlow = true
Devin Lim90803a82017-08-29 13:41:44 -070094// Set tests based on day of week
95def now = new Date()
Devin Lim61643762017-12-07 15:55:38 -080096echo( now.toString() )
97today = now[ Calendar.DAY_OF_WEEK ]
Devin Lim90803a82017-08-29 13:41:44 -070098day = ""
Devin Lim61657e42017-10-09 17:24:40 -070099SCPF_choices = ""
Devin Lim90803a82017-08-29 13:41:44 -0700100USECASE_choices = ""
Devin Lim61657e42017-10-09 17:24:40 -0700101FUNC_choices = ""
102HA_choices = ""
Devin Lim61643762017-12-07 15:55:38 -0800103SR_choices = ""
104stat_graph_generator_file = "testCategoryBuildStats.R"
105pie_graph_generator_file = "testCategoryPiePassFail.R"
106graph_saved_directory = "/var/jenkins/workspace/postjob-VM/"
Devin Lim90803a82017-08-29 13:41:44 -0700107
108manually_run = params.manual_run
109post_result = params.PostResult
Devin Lim61657e42017-10-09 17:24:40 -0700110if( !manually_run ){
Devin Lim61643762017-12-07 15:55:38 -0800111 slackSend( color:'#03CD9F',
112 message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
113 + "Starting tests on : " + now.toString()
114 + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )
Devin Lim61657e42017-10-09 17:24:40 -0700115 testDivider( today )
116 FUNC_choices = lastCommaRemover( FUNC_choices )
117 HA_choices = lastCommaRemover( HA_choices )
118 SCPF_choices = lastCommaRemover( SCPF_choices )
119 USECASE_choices = lastCommaRemover( USECASE_choices )
Devin Lim61643762017-12-07 15:55:38 -0800120 SR_choices = lastCommaRemover( SR_choices )
Devin Lim61657e42017-10-09 17:24:40 -0700121}
122
Devin Lim90803a82017-08-29 13:41:44 -0700123if ( manually_run ){
124 organize_tests( params.Tests )
Devin Lim61643762017-12-07 15:55:38 -0800125 onos_b = params.ONOSVersion
Devin Lim0e967162017-11-03 15:59:53 -0700126 isOldFlow = params.isOldFlow
Devin Lim90803a82017-08-29 13:41:44 -0700127 println "Tests to be run manually : "
128}else{
Devin Lim61643762017-12-07 15:55:38 -0800129 testcases[ "SCPF" ][ "tests" ] = SCPF_choices
130 testcases[ "USECASE" ][ "tests" ] = USECASE_choices
131 testcases[ "FUNC" ][ "tests" ] = FUNC_choices
132 testcases[ "HA" ][ "tests" ] = HA_choices
133 testcases[ "SR" ][ "tests" ] = SR_choices
Devin Lim90803a82017-08-29 13:41:44 -0700134 println "Defaulting to " + day + " tests:"
135}
136print_tests( testcases )
Devin Lim37a83792017-10-26 16:38:21 -0700137def runTest = [
138 "VM" : [:],
139 "BM" : [:]
140]
141for( String test in testcases.keySet() ){
142 println test
Devin Lim61643762017-12-07 15:55:38 -0800143 if ( testcases[ test ][ "tests" ] != "" ){
144 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 -0700145 }
146}
147def finalList = [:]
Devin Lim61643762017-12-07 15:55:38 -0800148finalList[ "VM" ] = runTestSeq( runTest[ "VM" ] )
149finalList[ "BM" ] = runTestSeq( runTest[ "BM" ] )
Devin Lim37a83792017-10-26 16:38:21 -0700150parallel finalList
Devin Lim61643762017-12-07 15:55:38 -0800151//finalList[ "BM" ].call()
152generateStatGraph()
Devin Lim90803a82017-08-29 13:41:44 -0700153
Devin Lim61657e42017-10-09 17:24:40 -0700154def testDivider( today ){
Devin Lim61643762017-12-07 15:55:38 -0800155 switch ( today ) {
Devin Lim61657e42017-10-09 17:24:40 -0700156 case Calendar.MONDAY:
157 monday( true )
158 tuesday( true, false )
159 wednesday( true, false )
160 thursday( true, false )
161 friday( true, false )
162 day = "Monday"
Devin Lim61643762017-12-07 15:55:38 -0800163 slackSend( color:'#FFD988', message:"Tests to be run this weekdays : \n" + printDaysForTest() )
Devin Lim61657e42017-10-09 17:24:40 -0700164 break
165 case Calendar.TUESDAY:
166 tuesday( true, true )
167 day = "Tuesday"
168 break
169 case Calendar.WEDNESDAY:
170 wednesday( true, true )
171 day = "Wednesday"
172 break
173 case Calendar.THURSDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700174 thursday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700175 day = "Thursday"
Devin Lim61643762017-12-07 15:55:38 -0800176 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700177 break
178 case Calendar.FRIDAY:
Devin Lim0e967162017-11-03 15:59:53 -0700179 friday( true, true )
Devin Lim61657e42017-10-09 17:24:40 -0700180 day = "Friday"
Devin Lim61643762017-12-07 15:55:38 -0800181 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700182 break
183 case Calendar.SATURDAY:
184 saturday()
Devin Lim61643762017-12-07 15:55:38 -0800185 onos_b= previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700186 day = "Saturday"
187 break
188 case Calendar.SUNDAY:
189 sunday()
Devin Lim61643762017-12-07 15:55:38 -0800190 onos_b= before_previous_version
Devin Lim61657e42017-10-09 17:24:40 -0700191 day = "Sunday"
Devin Lim61643762017-12-07 15:55:38 -0800192 isOldFlow = false
Devin Lim61657e42017-10-09 17:24:40 -0700193 break
194 }
195}
196def printDaysForTest(){
197 result = ""
198 for ( String test in AllTheTests.keySet() ){
199 result += test + " : \n"
200 for( String each in AllTheTests[ test ].keySet() ){
201 AllTheTests[ test ][ each ][ "day" ] = lastCommaRemover( AllTheTests[ test ][ each ][ "day" ] )
202 result += " " + each + ":[" + AllTheTests[ test ][ each ][ "day" ] + "]\n"
203 }
204 result += "\n"
205 }
206 return result
207}
208def lastCommaRemover( str ){
209 if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
210 str = str.substring( 0,str.size() - 1 )
211 }
212 return str
213}
214def monday( getResult ){
215 FUNC_choices += adder( "FUNC", "basic", true, "M", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800216 FUNC_choices += adder( "FUNC", "new_Test", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700217 FUNC_choices += adder( "FUNC", "extra_A", true, "M", getResult )
218 HA_choices += adder( "HA", "basic", true, "M", getResult )
219 HA_choices += adder( "HA", "extra_A", true, "M", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800220 //HA_choices += adder( "HA", "new_Test", true, "M", getResult )
221 SR_choices += adder( "SR", "basic", true, "M", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700222 SCPF_choices += adder( "SCPF", "basic", true, "M", getResult )
223 SCPF_choices += adder( "SCPF", "extra_B", true, "M", getResult )
224}
225def tuesday( getDay, getResult ){
226 FUNC_choices += adder( "FUNC", "basic", getDay, "T", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800227 FUNC_choices += adder( "FUNC", "new_Test", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700228 FUNC_choices += adder( "FUNC", "extra_B", getDay, "T", getResult )
229 HA_choices += adder( "HA", "basic", getDay, "T", getResult )
230 HA_choices += adder( "HA", "extra_B", getDay, "T", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800231 HA_choices += adder( "HA", "new_Test", getDay, "T", getResult )
232 SR_choices += adder( "SR", "basic", getDay, "T", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700233 SCPF_choices += adder( "SCPF", "basic", getDay, "T", getResult )
234 SCPF_choices += adder( "SCPF", "extra_C", getDay, "T", getResult )
235 USECASE_choices += adder( "USECASE", "basic", getDay, "T", getResult )
236 USECASE_choices += adder( "USECASE", "extra_A", getDay, "T", getResult )
237 USECASE_choices += adder( "USECASE", "new_Test", getDay, "T", getResult )
238}
239def wednesday( getDay, getResult ){
240 FUNC_choices += adder( "FUNC", "basic", getDay, "W", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800241 FUNC_choices += adder( "FUNC", "new_Test", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700242 FUNC_choices += adder( "FUNC", "extra_A", getDay, "W", getResult )
243 HA_choices += adder( "HA", "basic", getDay, "W", getResult )
244 HA_choices += adder( "HA", "extra_A", getDay, "W", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800245 //HA_choices += adder( "HA", "new_Test", getDay, "W", getResult )
246 SR_choices += adder( "SR", "basic", getDay, "W", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700247 SCPF_choices += adder( "SCPF", "basic", getDay, "W", getResult )
248 SCPF_choices += adder( "SCPF", "extra_A", getDay, "W", getResult )
249 SCPF_choices += adder( "SCPF", "new_Test", getDay, "W", getResult )
250}
251def thursday( getDay, getResult ){
252 FUNC_choices += adder( "FUNC", "basic", getDay, "Th", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800253 FUNC_choices += adder( "FUNC", "new_Test", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700254 FUNC_choices += adder( "FUNC", "extra_B", getDay, "Th", getResult )
255 HA_choices += adder( "HA", "basic", getDay, "Th", getResult )
256 HA_choices += adder( "HA", "extra_B", getDay, "Th", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800257 HA_choices += adder( "HA", "new_Test", getDay, "Th", getResult )
258 SR_choices += adder( "SR", "basic", getDay, "Th", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700259 SCPF_choices += adder( "SCPF", "basic", getDay, "Th", getResult )
260 SCPF_choices += adder( "SCPF", "extra_B", getDay, "Th", getResult )
261}
262def friday( getDay, getResult ){
263 FUNC_choices += adder( "FUNC", "basic", getDay, "F", getResult )
Devin Lim3ebd5e72017-11-14 10:38:00 -0800264 FUNC_choices += adder( "FUNC", "new_Test", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700265 FUNC_choices += adder( "FUNC", "extra_A", getDay, "F", getResult )
266 HA_choices += adder( "HA", "basic", getDay, "F", getResult )
267 HA_choices += adder( "HA", "extra_A", getDay, "F", getResult )
Devin Lim61643762017-12-07 15:55:38 -0800268 //HA_choices += adder( "HA", "new_Test", getDay, "F", getResult )
269 SR_choices += adder( "SR", "basic", getDay, "F", getResult )
Devin Lim61657e42017-10-09 17:24:40 -0700270 SCPF_choices += adder( "SCPF", "basic", getDay, "F", getResult )
271 SCPF_choices += adder( "SCPF", "extra_A", getDay, "F", getResult )
272 SCPF_choices += adder( "SCPF", "extra_D", getDay, "F", getResult )
273}
274def saturday(){
275 FUNC_choices += adder( "FUNC", "basic", false, "Sa", true )
276 FUNC_choices += adder( "FUNC", "extra_A", false, "Sa", true )
277 FUNC_choices += adder( "FUNC", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800278 FUNC_choices += adder( "FUNC", "new_Test", true, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700279 HA_choices += adder( "HA", "basic", false, "Sa", true )
280 HA_choices += adder( "HA", "extra_A", false, "Sa", true )
281 HA_choices += adder( "HA", "extra_B", false, "Sa", true )
Devin Lim61643762017-12-07 15:55:38 -0800282 HA_choices += adder( "HA", "new_Test", false, "Sa", true )
283 SR_choices += adder( "SR", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700284 SCPF_choices += adder( "SCPF", "basic", false, "Sa", true )
285 SCPF_choices += adder( "SCPF", "extra_A", false, "Sa", true )
286 SCPF_choices += adder( "SCPF", "extra_B", false, "Sa", true )
287 SCPF_choices += adder( "SCPF", "extra_C", false, "Sa", true )
288 SCPF_choices += adder( "SCPF", "extra_D", false, "Sa", true )
289 SCPF_choices += adder( "SCPF", "new_Test", false, "Sa", true )
290 USECASE_choices += adder( "USECASE", "basic", false, "Sa", true )
Devin Lim61657e42017-10-09 17:24:40 -0700291}
292def sunday(){
293 FUNC_choices += adder( "FUNC", "basic", false, "S", true )
294 FUNC_choices += adder( "FUNC", "extra_A", false, "S", true )
295 FUNC_choices += adder( "FUNC", "extra_B", false, "S", true )
296 HA_choices += adder( "HA", "basic", false, "S", true )
297 HA_choices += adder( "HA", "extra_A", false, "S", true )
298 HA_choices += adder( "HA", "extra_B", false, "S", true )
Devin Lim61643762017-12-07 15:55:38 -0800299 SR_choices += adder( "SR", "basic", false, "S", true )
Devin Lim61657e42017-10-09 17:24:40 -0700300 SCPF_choices += adder( "SCPF", "basic", false, "S", true )
301 USECASE_choices += adder( "USECASE", "basic", false, "S", true )
302}
303def adder( testCat, set, dayAdding, day, getResult ){
304 result = ""
305 for( String test in AllTheTests[ testCat ].keySet() ){
306 if( AllTheTests[ testCat ][ test ][ set ] ){
307 if( getResult )
308 result += test + ","
309 if( dayAdding )
310 dayAdder( testCat, test, day )
311 }
312 }
313 return result
314}
315def dayAdder( testCat, testName, dayOfWeek ){
316 AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + ","
317}
Devin Lim90803a82017-08-29 13:41:44 -0700318def runTestSeq( testList ){
319 return{
320 for ( test in testList.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800321 testList[ test ].call()
Devin Lim90803a82017-08-29 13:41:44 -0700322 }
323 }
324}
325
326def print_tests( tests ){
327 for( String test in tests.keySet() ){
Devin Lim61643762017-12-07 15:55:38 -0800328 if( tests[ test ][ "tests" ] != "" ){
Devin Lim90803a82017-08-29 13:41:44 -0700329 println test + ":"
Devin Lim61643762017-12-07 15:55:38 -0800330 println tests[ test ][ "tests" ]
Devin Lim90803a82017-08-29 13:41:44 -0700331 }
332 }
333}
334def organize_tests( tests ){
Devin Lim61643762017-12-07 15:55:38 -0800335 testList = tests.tokenize( "\n;, " )
Devin Lim90803a82017-08-29 13:41:44 -0700336 for( String test in testList )
337 testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + ","
338}
Devin Lim61643762017-12-07 15:55:38 -0800339def borrow_mn( jobOn ){
340 result = ""
341 if( jobOn == "SR" ){
342 result = "~/cell_borrow.sh"
343 }
344 return result
345}
346def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
347 println jobOn + "-pipeline-" + manuallyRun ? "manually" : branch
348 wiki = branch
349 if ( branch != "master" ){
350 branch = "onos-" + branch
351 }
352 test_branch = "master"
353 node( "TestStation-" + nodeName + "s" ){
354 envSetup( branch, test_branch, onosTag, jobOn, manuallyRun )
355
356 exportEnvProperty( branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow )
357 }
358
359 jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
360 build job: jobToRun, propagate: false
361}
Devin Lima0e52eb2017-09-13 18:35:12 -0700362def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700363// nodeName : "BM" or "VM"
364// jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
365 return{
Devin Lim61643762017-12-07 15:55:38 -0800366 if( jobOn == "SR" ){
367 trigger( "1.11", "SRBridging", nodeName, jobOn, manuallyRun, onosTag )
368 trigger( "1.12", "SRBridging", nodeName, jobOn, manuallyRun, onosTag )
369 trigger( "master", "SRBridging", nodeName, jobOn, manuallyRun, onosTag )
370 returnCell( nodeName )
371 }else{
372 trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700373 }
Devin Lim90803a82017-08-29 13:41:44 -0700374 }
375}
376
377// export Environment properties.
Devin Lim0e967162017-11-03 15:59:53 -0700378def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
Devin Lim61643762017-12-07 15:55:38 -0800379 stage( "export Property" ){
Devin Lim90803a82017-08-29 13:41:44 -0700380 sh '''
381 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
382 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700383 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700384 echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property
385 echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property
386 echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property
387 echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property
388 echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property
Devin Lim0e967162017-11-03 15:59:53 -0700389 echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property
390
Devin Lim90803a82017-08-29 13:41:44 -0700391 '''
392 }
393}
394// Initialize the environment Setup for the onos and OnosSystemTest
Devin Lim0e967162017-11-03 15:59:53 -0700395def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){
Devin Lim61643762017-12-07 15:55:38 -0800396 stage( "envSetup" ) {
Devin Lima0e52eb2017-09-13 18:35:12 -0700397 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700398 set +e
399 . ~/.bashrc
400 env
Devin Lim61643762017-12-07 15:55:38 -0800401 ''' + borrow_mn( jobOn ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700402 ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + '''
Devin Limcbba0852017-11-13 10:31:32 -0800403 ''' + oldFlowCheck( jobOn, onos_branch ) + '''
Devin Lim0e967162017-11-03 15:59:53 -0700404 ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun )
405 }
406}
Devin Lim61643762017-12-07 15:55:38 -0800407def tagCheck( onos_tag, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700408 result = "git checkout "
Devin Lim61643762017-12-07 15:55:38 -0800409 if ( onos_tag == "" )
Devin Lim0e967162017-11-03 15:59:53 -0700410 result += onos_branch //create new local branch
411 else
412 result += onos_tag //checkout the tag
413 return result
414}
415def preSetup( onos_branch, test_branch, onos_tag, isManual ){
416 result = ""
417 if( !isManual ){
418 result = '''echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700419 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700420
421 cd ~/OnosSystemTest/
422 git checkout HEAD~1 # Make sure you aren't pn a branch
423 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700424 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 -0700425 git clean -df # clean any local files
426 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700427 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700428 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700429 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700430 git branch
431 git log -1 --decorate
432
433
434 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700435 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700436
437 echo -e "\n #### check karaf version ######"
438 env |grep karaf
439
440 cd ~/onos
441 rm -rf buck-out/*
442 ~/onos/tools/build/onos-buck clean
443 git checkout HEAD~1 # Make sure you aren't pn a branch
444 git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote
Devin Lima0e52eb2017-09-13 18:35:12 -0700445 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 -0700446 git clean -df # clean any local files
447 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700448 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700449 git clean -df # clean any local files
Devin Lim61643762017-12-07 15:55:38 -0800450 ''' + tagCheck( onos_tag, onos_branch ) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700451 git branch
452 git log -1 --decorate
453
454
455 echo -e "\n##### set jvm heap size to 8G #####"
456 echo ${ONOSJVMHeap}
457
Devin Lima0e52eb2017-09-13 18:35:12 -0700458 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
459 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700460
461 echo "##### Check onos-service setting..... #####"
462 cat ~/onos/tools/package/bin/onos-service
463
Devin Lim0e967162017-11-03 15:59:53 -0700464 export JAVA_HOME=/usr/lib/jvm/java-8-oracle'''
465 }
466 return result
467}
Devin Limcbba0852017-11-13 10:31:32 -0800468def oldFlowCheck( jobOn, onos_branch ){
Devin Lim0e967162017-11-03 15:59:53 -0700469 result = ""
Devin Lim61643762017-12-07 15:55:38 -0800470 if( jobOn == "SCPF" && ( onos_branch== "master" || onos_branch=="onos-1.12" ) )
471 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
472 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 -0700473 return result
474}
475def postSetup( onos_branch, test_branch, onos_tag, isManual ){
476 result = ""
477 if( !isManual ){
478 result = '''echo -e "\n##### build ONOS skip unit tests ######"
Devin Lim90803a82017-08-29 13:41:44 -0700479 #mvn clean install -DskipTests
480 # Force buck update
481 rm -f ~/onos/bin/buck
482 ~/onos/tools/build/onos-buck build onos
483
Devin Lima0e52eb2017-09-13 18:35:12 -0700484 sleep 30
485 echo -e "\n##### Stop all running instances of Karaf #####"
486 kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}')
487 sleep 30
488
Devin Lim90803a82017-08-29 13:41:44 -0700489 git branch'''
490 }
Devin Lim37a83792017-10-26 16:38:21 -0700491 return result
Devin Lim61643762017-12-07 15:55:38 -0800492}
493def returnCell( nodeName ){
494 node( "TestStation-" + nodeName + "s" ){
495 sh '''#!/bin/bash -l
496 set +e
497 . ~/.bashrc
498 env
499 ~/./return_cell.sh
500 '''
501 }
502}
503
504def generateStatGraph(){
505 if( !manually_run ){
506 testListPart = funcs.createStatsList( "FUNC", AllTheTests[ "FUNC" ], true ) +
507 funcs.createStatsList( "HA", AllTheTests[ "HA" ], true ) +
508 funcs.createStatsList( "USECASE", AllTheTests[ "USECASE" ], false )
509 pieTestList = funcs.makeTestList( AllTheTests[ "FUNC" ], true ) +
510 funcs.makeTestList( AllTheTests[ "HA" ], true ) +
511 funcs.makeTestList( AllTheTests[ "USECASE" ], false )
512 funcs.generateCategoryStatsGraph( "false", "true", stat_graph_generator_file, pie_graph_generator_file, "ALL", onos_b, testListPart, graph_saved_directory, pieTestList )
513 }
Devin Lim90803a82017-08-29 13:41:44 -0700514}