blob: c20db0cfe1362de77eb39c5d98b8fe97cde79b8f [file] [log] [blame]
Devin Lim90803a82017-08-29 13:41:44 -07001#!groovy
2// This is a Jenkinsfile for a scripted pipeline for the SCPF tests
3// Define sets of tests
4SCPF_Basic = "SCPFswitchLat,SCPFportLat,SCPFintentInstallWithdrawLat,SCPFintentEventTp,SCPFflowTp1g,SCPFcbench,SCPFbatchFlowResp"
5SCPF_ExtraSetA = "SCPFintentRerouteLat,SCPFscalingMaxIntents,SCPFhostLat,SCPFscaleTopo,SCPFmastershipFailoverLat"
6SCPF_NEW_TEST = "SCPFmastershipFailoverLat"
7SCPF_ExtraSetB = "SCPFintentInstallWithdrawLatWithFlowObj,SCPFintentEventTpWithFlowObj,SCPFintentRerouteLatWithFlowObj,SCPFscalingMaxIntentsWithFlowObj,SCPFflowTp1gWithFlowObj"
8FUNC_Basic = "FUNCipv6Intent,FUNCoptical,FUNCflow,FUNCnetCfg,FUNCovsdbtest,FUNCnetconf"
9FUNC_ExtraSetA = "FUNCgroup,FUNCintent"
10FUNC_ExtraSetB = "FUNCintentRest"
11HA_Basic = "HAsanity,HAsingleInstanceRestart,HAclusterRestart"
12HA_ExtraSetA = "HAstopNodes,HAfullNetPartition"
13HA_ExtraSetB = "HAkillNodes,HAswapNodes,HAscaling"
14USECASE_Basic = "FUNCvirNetNB,FUNCbgpls,VPLSBasic,PLATdockertest,SRSanity,SRSwitchFailure,SRLinkFailure,SROnosFailure,SRClusterRestart,SRDynamic,SRHA,USECASE_SdnipFunction,USECASE_SdnipFunctionCluster"
15USECASE_NEW_TEST = "VPLSfailsafe"
16testcases = [
17 "FUNC" : [ tests : "" , nodeName : "VM"],
18 "HA" : [ tests : "" , nodeName : "VM"],
19 "SCPF" : [ tests : "" , nodeName : "BM"],
20 "USECASE" : [ tests : "" , nodeName : "BM"]
21]
22Prefix_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 Lima0e52eb2017-09-13 18:35:12 -070033onos_branch = "master"
34onos_tag = params.ONOSTag
Devin Lim90803a82017-08-29 13:41:44 -070035// Set tests based on day of week
36def now = new Date()
37echo(now.toString())
38today = now[Calendar.DAY_OF_WEEK]
39day = ""
40SCPF_choices = SCPF_Basic
41USECASE_choices = ""
42FUNC_choices = FUNC_Basic
43HA_choices = HA_Basic
44
45switch (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 Lima0e52eb2017-09-13 18:35:12 -070089 onos_branch= "1.11"
Devin Lim90803a82017-08-29 13:41:44 -070090 day = "Sunday"
91 break
92}
93
94manually_run = params.manual_run
95post_result = params.PostResult
96if ( 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}
108print_tests( testcases )
109
110def runTest = [
111 "VM" : [:],
112 "BM" : [:]
113]
114for( String test in testcases.keySet() ){
115 println test
116 if (testcases[test]["tests"] != ""){
Devin Lima0e52eb2017-09-13 18:35:12 -0700117 runTest[testcases[test]["nodeName"]][test] = trigger_pipeline( onos_branch, testcases[test]["tests"], testcases[test]["nodeName"], test, manually_run, onos_tag )
Devin Lim90803a82017-08-29 13:41:44 -0700118 }
119}
120def finalList = [:]
121finalList["VM"] = runTestSeq( runTest["VM"] )
122finalList["BM"] = runTestSeq( runTest["BM"] )
123parallel finalList
124
125def runTestSeq( testList ){
126 return{
127 for ( test in testList.keySet() ){
128 testList[test].call()
129 }
130 }
131}
132
133def 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}
141def 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 Lima0e52eb2017-09-13 18:35:12 -0700146def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700147// 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 Lima0e52eb2017-09-13 18:35:12 -0700163 envSetup(onos_branch, test_branch, onosTag)
Devin Lim90803a82017-08-29 13:41:44 -0700164
Devin Lima0e52eb2017-09-13 18:35:12 -0700165 exportEnvProperty( onos_branch, test_branch, wiki, tests, post_result, manuallyRun, onosTag )
Devin Lim90803a82017-08-29 13:41:44 -0700166 }
167
168 jobToRun = jobOn + "_Pipeline_" + ( manuallyRun ? "manually" : branch )
169 build job: jobToRun, propagate: false
170 }
171}
172
173// export Environment properties.
Devin Lima0e52eb2017-09-13 18:35:12 -0700174def exportEnvProperty( onos_branch, test_branch, wiki, tests, postResult, manually_run, onosTag ){
Devin Lim90803a82017-08-29 13:41:44 -0700175 stage("export Property"){
176 sh '''
177 echo "ONOSBranch=''' + onos_branch +'''" > /var/jenkins/TestONOS.property
178 echo "TestONBranch=''' + test_branch +'''" >> /var/jenkins/TestONOS.property
Devin Lima0e52eb2017-09-13 18:35:12 -0700179 echo "ONOSTag='''+ onosTag +'''" >> /var/jenkins/TestONOS.property
Devin Lim90803a82017-08-29 13:41:44 -0700180 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 Lima0e52eb2017-09-13 18:35:12 -0700189def envSetup( onos_branch, test_branch, onos_tag ){
Devin Lim90803a82017-08-29 13:41:44 -0700190 stage("envSetup") {
Devin Lima0e52eb2017-09-13 18:35:12 -0700191 sh '''#!/bin/bash -l
Devin Lim90803a82017-08-29 13:41:44 -0700192 set +e
193 . ~/.bashrc
194 env
195
196 echo -e "\n##### Set TestON Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700197 echo "TestON Branch is set on: ''' + test_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700198
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 Lima0e52eb2017-09-13 18:35:12 -0700202 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 -0700203 git clean -df # clean any local files
204 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700205 git reset --hard origin/''' + test_branch +''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700206 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700207 git checkout ''' + test_branch + ''' #create new local branch
Devin Lim90803a82017-08-29 13:41:44 -0700208 git branch
209 git log -1 --decorate
210
211
212 echo -e "\n##### Set ONOS Branch #####"
Devin Lima0e52eb2017-09-13 18:35:12 -0700213 echo "ONOS Branch is set on: ''' + onos_branch + '''"
Devin Lim90803a82017-08-29 13:41:44 -0700214
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 Lima0e52eb2017-09-13 18:35:12 -0700223 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 -0700224 git clean -df # clean any local files
225 git fetch --all # update all caches from remotes
Devin Lima0e52eb2017-09-13 18:35:12 -0700226 git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch
Devin Lim90803a82017-08-29 13:41:44 -0700227 git clean -df # clean any local files
Devin Lima0e52eb2017-09-13 18:35:12 -0700228 ''' + tagCheck(onos_tag, onos_branch) + '''
Devin Lim90803a82017-08-29 13:41:44 -0700229 git branch
230 git log -1 --decorate
231
232
233 echo -e "\n##### set jvm heap size to 8G #####"
234 echo ${ONOSJVMHeap}
235
Devin Lima0e52eb2017-09-13 18:35:12 -0700236 inserted_line="export JAVA_OPTS=\"\${ONOSJVMHeap}\""
237 sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service
Devin Lim90803a82017-08-29 13:41:44 -0700238
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 Lima0e52eb2017-09-13 18:35:12 -0700250 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 Lim90803a82017-08-29 13:41:44 -0700255 git branch'''
256 }
Devin Lima0e52eb2017-09-13 18:35:12 -0700257}
258def 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 Lim90803a82017-08-29 13:41:44 -0700265}