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 |
| 4 | SCPF_Basic = "SCPFswitchLat,SCPFportLat,SCPFintentInstallWithdrawLat,SCPFintentEventTp,SCPFflowTp1g,SCPFcbench,SCPFbatchFlowResp" |
| 5 | SCPF_ExtraSetA = "SCPFintentRerouteLat,SCPFscalingMaxIntents,SCPFhostLat,SCPFscaleTopo,SCPFmastershipFailoverLat" |
| 6 | SCPF_NEW_TEST = "SCPFmastershipFailoverLat" |
| 7 | SCPF_ExtraSetB = "SCPFintentInstallWithdrawLatWithFlowObj,SCPFintentEventTpWithFlowObj,SCPFintentRerouteLatWithFlowObj,SCPFscalingMaxIntentsWithFlowObj,SCPFflowTp1gWithFlowObj" |
| 8 | FUNC_Basic = "FUNCipv6Intent,FUNCoptical,FUNCflow,FUNCnetCfg,FUNCovsdbtest,FUNCnetconf" |
| 9 | FUNC_ExtraSetA = "FUNCgroup,FUNCintent" |
| 10 | FUNC_ExtraSetB = "FUNCintentRest" |
| 11 | HA_Basic = "HAsanity,HAsingleInstanceRestart,HAclusterRestart" |
| 12 | HA_ExtraSetA = "HAstopNodes,HAfullNetPartition" |
| 13 | HA_ExtraSetB = "HAkillNodes,HAswapNodes,HAscaling" |
| 14 | USECASE_Basic = "FUNCvirNetNB,FUNCbgpls,VPLSBasic,PLATdockertest,SRSanity,SRSwitchFailure,SRLinkFailure,SROnosFailure,SRClusterRestart,SRDynamic,SRHA,USECASE_SdnipFunction,USECASE_SdnipFunctionCluster" |
| 15 | USECASE_NEW_TEST = "VPLSfailsafe" |
| 16 | testcases = [ |
| 17 | "FUNC" : [ tests : "" , nodeName : "VM"], |
| 18 | "HA" : [ tests : "" , nodeName : "VM"], |
| 19 | "SCPF" : [ tests : "" , nodeName : "BM"], |
| 20 | "USECASE" : [ tests : "" , nodeName : "BM"] |
| 21 | ] |
| 22 | Prefix_organizer = [ |
| 23 | "FU" : "FUNC", |
| 24 | "HA" : "HA", |
| 25 | "PL" : "USECASE", |
| 26 | "SA" : "USECASE", |
| 27 | "SC" : "SCPF", |
| 28 | "SR" : "USECASE", |
| 29 | "US" : "USECASE", |
| 30 | "VP" : "USECASE" |
| 31 | ] |
| 32 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 33 | onos_branch = "master" |
| 34 | onos_tag = params.ONOSTag |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 35 | // Set tests based on day of week |
| 36 | def now = new Date() |
| 37 | echo(now.toString()) |
| 38 | today = now[Calendar.DAY_OF_WEEK] |
| 39 | day = "" |
| 40 | SCPF_choices = SCPF_Basic |
| 41 | USECASE_choices = "" |
| 42 | FUNC_choices = FUNC_Basic |
| 43 | HA_choices = HA_Basic |
| 44 | |
| 45 | switch (today) { |
| 46 | case Calendar.MONDAY: |
| 47 | SCPF_choices += "," + SCPF_ExtraSetB |
| 48 | FUNC_choices += "," + FUNC_ExtraSetA |
| 49 | HA_choices += "," + HA_ExtraSetA |
| 50 | day = "Monday" |
| 51 | break |
| 52 | case Calendar.TUESDAY: |
| 53 | day = "Tuesday" |
| 54 | USECASE_choices = USECASE_Basic + "," + USECASE_NEW_TEST |
| 55 | FUNC_choices += "," + FUNC_ExtraSetB |
| 56 | HA_choices += "," + HA_ExtraSetB |
| 57 | break |
| 58 | case Calendar.WEDNESDAY: |
| 59 | SCPF_choices += "," + SCPF_ExtraSetA + "," + SCPF_NEW_TEST |
| 60 | FUNC_choices += "," + FUNC_ExtraSetA |
| 61 | HA_choices += "," + HA_ExtraSetA |
| 62 | day = "Wednesday" |
| 63 | break |
| 64 | case Calendar.THURSDAY: |
| 65 | SCPF_choices += "," + SCPF_ExtraSetB |
| 66 | FUNC_choices += "," + FUNC_ExtraSetB |
| 67 | HA_choices += "," + HA_ExtraSetB |
| 68 | day = "Thursday" |
| 69 | break |
| 70 | case Calendar.FRIDAY: |
| 71 | SCPF_choices += "," + SCPF_ExtraSetA + "," + SCPF_NEW_TEST + "," + SCPF_ExtraSetB |
| 72 | FUNC_choices += "," + FUNC_ExtraSetA |
| 73 | HA_choices += "," + HA_ExtraSetA |
| 74 | day = "Friday" |
| 75 | break |
| 76 | case Calendar.SATURDAY: |
| 77 | SCPF_choices += "," + SCPF_ExtraSetA + "," + SCPF_ExtraSetB |
| 78 | USECASE_choices = USECASE_Basic |
| 79 | FUNC_choices += "," + FUNC_ExtraSetA + "," + FUNC_ExtraSetB |
| 80 | HA_choices += "," + HA_ExtraSetA + "," + HA_ExtraSetB |
| 81 | onos_branch= "1.10" |
| 82 | day = "Saturday" |
| 83 | break |
| 84 | case Calendar.SUNDAY: |
| 85 | SCPF_choices += "," + SCPF_ExtraSetA + "," + SCPF_NEW_TEST + "," + SCPF_ExtraSetB |
| 86 | USECASE_choices = USECASE_Basic + "," + USECASE_NEW_TEST |
| 87 | FUNC_choices += "," + FUNC_ExtraSetA + "," + FUNC_ExtraSetB |
| 88 | HA_choices += "," + HA_ExtraSetA + "," + HA_ExtraSetB |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 89 | onos_branch= "1.11" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 90 | day = "Sunday" |
| 91 | break |
| 92 | } |
| 93 | |
| 94 | manually_run = params.manual_run |
| 95 | post_result = params.PostResult |
| 96 | if ( manually_run ){ |
| 97 | organize_tests( params.Tests ) |
| 98 | onos_branch = params.ONOSVersion |
| 99 | test_branch = params.TestONBranch |
| 100 | println "Tests to be run manually : " |
| 101 | }else{ |
| 102 | testcases["SCPF"]["tests"] = SCPF_choices |
| 103 | testcases["USECASE"]["tests"] = USECASE_choices |
| 104 | testcases["FUNC"]["tests"] = FUNC_choices |
| 105 | testcases["HA"]["tests"] = HA_choices |
| 106 | println "Defaulting to " + day + " tests:" |
| 107 | } |
| 108 | print_tests( testcases ) |
| 109 | |
| 110 | def runTest = [ |
| 111 | "VM" : [:], |
| 112 | "BM" : [:] |
| 113 | ] |
| 114 | for( String test in testcases.keySet() ){ |
| 115 | println test |
| 116 | if (testcases[test]["tests"] != ""){ |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 117 | runTest[testcases[test]["nodeName"]][test] = trigger_pipeline( onos_branch, testcases[test]["tests"], testcases[test]["nodeName"], test, manually_run, onos_tag ) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | def finalList = [:] |
| 121 | finalList["VM"] = runTestSeq( runTest["VM"] ) |
| 122 | finalList["BM"] = runTestSeq( runTest["BM"] ) |
| 123 | parallel finalList |
| 124 | |
| 125 | def runTestSeq( testList ){ |
| 126 | return{ |
| 127 | for ( test in testList.keySet() ){ |
| 128 | testList[test].call() |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | def print_tests( tests ){ |
| 134 | for( String test in tests.keySet() ){ |
| 135 | if( tests[test]["tests"] != "" ){ |
| 136 | println test + ":" |
| 137 | println tests[test]["tests"] |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | def organize_tests( tests ){ |
| 142 | testList = tests.tokenize("\n;, ") |
| 143 | for( String test in testList ) |
| 144 | testcases [ Prefix_organizer[ ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ? "US" : ( test[ 0 ] + test[ 1 ] ) ) ] ][ "tests" ] += test + "," |
| 145 | } |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 146 | def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 147 | // nodeName : "BM" or "VM" |
| 148 | // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA" |
| 149 | return{ |
| 150 | if (branch == "master"){ |
| 151 | onos_branch = branch |
| 152 | }else{ |
| 153 | onos_branch = "onos-" + branch |
| 154 | } |
| 155 | wiki = branch |
| 156 | if ( !manuallyRun ) |
| 157 | test_branch = onos_branch |
| 158 | if (onos_branch == "onos-1.11") |
| 159 | test_branch = "master" |
| 160 | println jobOn + "_Pipeline_" + manuallyRun ? "manually" : branch |
| 161 | node("TestStation-" + nodeName + "s"){ |
| 162 | if (!manuallyRun) |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 163 | envSetup(onos_branch, test_branch, onosTag) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 164 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 165 | exportEnvProperty( onos_branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag ) |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | jobToRun = jobOn + "_Pipeline_" + ( manuallyRun ? "manually" : branch ) |
| 169 | build job: jobToRun, propagate: false |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | // export Environment properties. |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 174 | def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 175 | stage("export Property"){ |
| 176 | sh ''' |
| 177 | echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property |
| 178 | echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 179 | echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 180 | echo "WikiPrefix=''' + wiki +'''" >> /var/jenkins/TestONOS.property |
| 181 | echo "ONOSJVMHeap='''+ env.ONOSJVMHeap +'''" >> /var/jenkins/TestONOS.property |
| 182 | echo "Tests=''' + tests +'''" >> /var/jenkins/TestONOS.property |
| 183 | echo "postResult=''' + postResult +'''" >> /var/jenkins/TestONOS.property |
| 184 | echo "manualRun=''' + manually_run +'''" >> /var/jenkins/TestONOS.property |
| 185 | ''' |
| 186 | } |
| 187 | } |
| 188 | // Initialize the environment Setup for the onos and OnosSystemTest |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 189 | def envSetup( onos_branch, test_branch, onos_tag ){ |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 190 | stage("envSetup") { |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 191 | sh '''#!/bin/bash -l |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 192 | set +e |
| 193 | . ~/.bashrc |
| 194 | env |
| 195 | |
| 196 | echo -e "\n##### Set TestON Branch #####" |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 197 | echo "TestON Branch is set on: ''' + test_branch + '''" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 198 | |
| 199 | cd ~/OnosSystemTest/ |
| 200 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 201 | 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] | 202 | 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] | 203 | git clean -df # clean any local files |
| 204 | git fetch --all # update all caches from remotes |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 205 | 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] | 206 | git clean -df # clean any local files |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 207 | git checkout ''' + test_branch + ''' #create new local branch |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 208 | git branch |
| 209 | git log -1 --decorate |
| 210 | |
| 211 | |
| 212 | echo -e "\n##### Set ONOS Branch #####" |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 213 | echo "ONOS Branch is set on: ''' + onos_branch + '''" |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 214 | |
| 215 | echo -e "\n #### check karaf version ######" |
| 216 | env |grep karaf |
| 217 | |
| 218 | cd ~/onos |
| 219 | rm -rf buck-out/* |
| 220 | ~/onos/tools/build/onos-buck clean |
| 221 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 222 | 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] | 223 | 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] | 224 | git clean -df # clean any local files |
| 225 | git fetch --all # update all caches from remotes |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 226 | 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] | 227 | git clean -df # clean any local files |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 228 | ''' + tagCheck(onos_tag, onos_branch) + ''' |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 229 | git branch |
| 230 | git log -1 --decorate |
| 231 | |
| 232 | |
| 233 | echo -e "\n##### set jvm heap size to 8G #####" |
| 234 | echo ${ONOSJVMHeap} |
| 235 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 236 | inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\"" |
| 237 | 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] | 238 | |
| 239 | echo "##### Check onos-service setting..... #####" |
| 240 | cat ~/onos/tools/package/bin/onos-service |
| 241 | |
| 242 | export JAVA_HOME=/usr/lib/jvm/java-8-oracle |
| 243 | |
| 244 | echo -e "\n##### build ONOS skip unit tests ######" |
| 245 | #mvn clean install -DskipTests |
| 246 | # Force buck update |
| 247 | rm -f ~/onos/bin/buck |
| 248 | ~/onos/tools/build/onos-buck build onos |
| 249 | |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 250 | sleep 30 |
| 251 | echo -e "\n##### Stop all running instances of Karaf #####" |
| 252 | kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}') |
| 253 | sleep 30 |
| 254 | |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 255 | git branch''' |
| 256 | } |
Devin Lim | a0e52eb | 2017-09-13 18:35:12 -0700 | [diff] [blame] | 257 | } |
| 258 | def tagCheck(onos_tag, onos_branch){ |
| 259 | result = "git checkout " |
| 260 | if (onos_tag == "" ) |
| 261 | result += onos_branch //create new local branch |
| 262 | else |
| 263 | result += onos_tag //checkout the tag |
| 264 | return result |
Devin Lim | 90803a8 | 2017-08-29 13:41:44 -0700 | [diff] [blame] | 265 | } |