Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | // This is a Jenkinsfile for a scripted pipeline for the SCPF tests |
| 3 | // Define sets of tests |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 4 | previous_version = "1.11" |
| 5 | before_previous_version = "1.10" |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 6 | AllTheTests= |
| 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 Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 37 | "SCPFbatchFlowResp": ["basic":false, "extra_A":true, "extra_B":false, "extra_C":false, "extra_D":false, "new_Test":false, day:""], |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 38 | "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 Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 66 | testcases = [ |
| 67 | "FUNC" : [ tests : "" , nodeName : "VM"], |
| 68 | "HA" : [ tests : "" , nodeName : "VM"], |
| 69 | "SCPF" : [ tests : "" , nodeName : "BM"], |
| 70 | "USECASE" : [ tests : "" , nodeName : "BM"] |
| 71 | ] |
| 72 | Prefix_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 Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 83 | onos_branch = "master" |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 84 | test_branch = "" |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 85 | onos_tag = params.ONOSTag |
Devin Lim | 37a8379 | 2017-10-26 16:38:21 -0700 | [diff] [blame] | 86 | isOldFlow = false |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 87 | // Set tests based on day of week |
| 88 | def now = new Date() |
| 89 | echo(now.toString()) |
| 90 | today = now[Calendar.DAY_OF_WEEK] |
| 91 | day = "" |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 92 | SCPF_choices = "" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 93 | USECASE_choices = "" |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 94 | FUNC_choices = "" |
| 95 | HA_choices = "" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 96 | |
| 97 | manually_run = params.manual_run |
| 98 | post_result = params.PostResult |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 99 | if( !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 Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 110 | if ( manually_run ){ |
| 111 | organize_tests( params.Tests ) |
| 112 | onos_branch = params.ONOSVersion |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 113 | isOldFlow = params.isOldFlow |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 114 | 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 | } |
| 122 | print_tests( testcases ) |
Devin Lim | 37a8379 | 2017-10-26 16:38:21 -0700 | [diff] [blame] | 123 | def runTest = [ |
| 124 | "VM" : [:], |
| 125 | "BM" : [:] |
| 126 | ] |
| 127 | for( 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 | } |
| 133 | def finalList = [:] |
| 134 | finalList["VM"] = runTestSeq( runTest["VM"] ) |
| 135 | finalList["BM"] = runTestSeq( runTest["BM"] ) |
| 136 | parallel finalList |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 137 | |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 138 | def 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 Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 158 | thursday( true, true ) |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 159 | day = "Thursday" |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 160 | isOldFlow = true |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 161 | break |
| 162 | case Calendar.FRIDAY: |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 163 | friday( true, true ) |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 164 | day = "Friday" |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 165 | isOldFlow = true |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 166 | break |
| 167 | case Calendar.SATURDAY: |
| 168 | saturday() |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 169 | onos_branch= previous_version |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 170 | day = "Saturday" |
| 171 | break |
| 172 | case Calendar.SUNDAY: |
| 173 | sunday() |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 174 | onos_branch= before_previous_version |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 175 | day = "Sunday" |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 176 | isOldFlow = true |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 177 | break |
| 178 | } |
| 179 | } |
| 180 | def 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 | } |
| 192 | def lastCommaRemover( str ){ |
| 193 | if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){ |
| 194 | str = str.substring( 0,str.size() - 1 ) |
| 195 | } |
| 196 | return str |
| 197 | } |
| 198 | def 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 | } |
| 206 | def 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 | } |
| 217 | def 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 | } |
| 226 | def 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 | } |
| 234 | def 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 | } |
| 243 | def 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 | } |
| 259 | def 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 | } |
| 269 | def 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 | } |
| 281 | def dayAdder( testCat, testName, dayOfWeek ){ |
| 282 | AllTheTests[ testCat ][ testName ][ "day" ] += dayOfWeek + "," |
| 283 | } |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 284 | def runTestSeq( testList ){ |
| 285 | return{ |
| 286 | for ( test in testList.keySet() ){ |
| 287 | testList[test].call() |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | def 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 | } |
| 300 | def 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 Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 305 | def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 306 | // 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 Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 315 | test_branch = onos_branch |
| 316 | if (onos_branch == previous_version) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 317 | test_branch = "master" |
| 318 | println jobOn + "_Pipeline_" + manuallyRun ? "manually" : branch |
| 319 | node("TestStation-" + nodeName + "s"){ |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 320 | envSetup(onos_branch, test_branch, onosTag, jobOn, manuallyRun ) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 321 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 322 | exportEnvProperty( onos_branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow ) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | jobToRun = jobOn + "_Pipeline_" + ( manuallyRun ? "manually" : branch ) |
| 326 | build job: jobToRun, propagate: false |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | // export Environment properties. |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 331 | def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 332 | stage("export Property"){ |
| 333 | sh ''' |
| 334 | echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property |
| 335 | echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 336 | echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 337 | 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 Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 342 | echo "isOldFlow=''' + isOldFlow +'''" >> /var/jenkins/TestONOS.property |
| 343 | |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 344 | ''' |
| 345 | } |
| 346 | } |
Devin Lim | 61657e4 | 2017-10-09 17:24:40 -0700 | [diff] [blame] | 347 | def sendToSlack( color, message ){ |
| 348 | slackSend(color:color, message: message) |
| 349 | } |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 350 | // Initialize the environment Setup for the onos and OnosSystemTest |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 351 | def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 352 | stage("envSetup") { |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 353 | sh '''#!/bin/bash -l |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 354 | set +e |
| 355 | . ~/.bashrc |
| 356 | env |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 357 | ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + ''' |
Devin Lim | cbba085 | 2017-11-13 10:31:32 -0800 | [diff] [blame] | 358 | ''' + oldFlowCheck( jobOn, onos_branch ) + ''' |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 359 | ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun ) |
| 360 | } |
| 361 | } |
| 362 | def 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 | } |
| 370 | def preSetup( onos_branch, test_branch, onos_tag, isManual ){ |
| 371 | result = "" |
| 372 | if( !isManual ){ |
| 373 | result = '''echo -e "\n##### Set TestON Branch #####" |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 374 | echo "TestON Branch is set on: ''' + test_branch + '''" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 375 | |
| 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 Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 379 | git branch -D ''' + test_branch + ''' # just incase there are local changes. This will normally result in a branch not found error |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 380 | git clean -df # clean any local files |
| 381 | git fetch --all # update all caches from remotes |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 382 | git reset --hard origin/''' + test_branch +''' # force local index to match remote branch |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 383 | git clean -df # clean any local files |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 384 | git checkout ''' + test_branch + ''' #create new local branch |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 385 | git branch |
| 386 | git log -1 --decorate |
| 387 | |
| 388 | |
| 389 | echo -e "\n##### Set ONOS Branch #####" |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 390 | echo "ONOS Branch is set on: ''' + onos_branch + '''" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 391 | |
| 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 Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 400 | git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 401 | git clean -df # clean any local files |
| 402 | git fetch --all # update all caches from remotes |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 403 | git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 404 | git clean -df # clean any local files |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 405 | ''' + tagCheck(onos_tag, onos_branch) + ''' |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 406 | git branch |
| 407 | git log -1 --decorate |
| 408 | |
| 409 | |
| 410 | echo -e "\n##### set jvm heap size to 8G #####" |
| 411 | echo ${ONOSJVMHeap} |
| 412 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 413 | inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\"" |
| 414 | sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 415 | |
| 416 | echo "##### Check onos-service setting..... #####" |
| 417 | cat ~/onos/tools/package/bin/onos-service |
| 418 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 419 | export JAVA_HOME=/usr/lib/jvm/java-8-oracle''' |
| 420 | } |
| 421 | return result |
| 422 | } |
Devin Lim | cbba085 | 2017-11-13 10:31:32 -0800 | [diff] [blame] | 423 | def oldFlowCheck( jobOn, onos_branch ){ |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 424 | result = "" |
Devin Lim | cbba085 | 2017-11-13 10:31:32 -0800 | [diff] [blame] | 425 | if( isOldFlow && jobOn == "SCPF" && onos_branch="master" ) |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 426 | 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 | } |
| 430 | def postSetup( onos_branch, test_branch, onos_tag, isManual ){ |
| 431 | result = "" |
| 432 | if( !isManual ){ |
| 433 | result = '''echo -e "\n##### build ONOS skip unit tests ######" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 434 | #mvn clean install -DskipTests |
| 435 | # Force buck update |
| 436 | rm -f ~/onos/bin/buck |
| 437 | ~/onos/tools/build/onos-buck build onos |
| 438 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 439 | 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 Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 444 | git branch''' |
| 445 | } |
Devin Lim | 37a8379 | 2017-10-26 16:38:21 -0700 | [diff] [blame] | 446 | return result |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 447 | } |