Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 3 | // Copyright 2017 Open Networking Foundation (ONF) |
| 4 | // |
| 5 | // Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 6 | // the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 7 | // or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 8 | // |
| 9 | // TestON is free software: you can redistribute it and/or modify |
| 10 | // it under the terms of the GNU General Public License as published by |
| 11 | // the Free Software Foundation, either version 2 of the License, or |
| 12 | // (at your option) any later version. |
| 13 | // |
| 14 | // TestON is distributed in the hope that it will be useful, |
| 15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | // GNU General Public License for more details. |
| 18 | // |
| 19 | // You should have received a copy of the GNU General Public License |
| 20 | // along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | // This is the dependency Jenkins script. |
| 23 | // This will provide the portion that will set up the environment of the machine |
| 24 | // and trigger the corresponding jobs. |
| 25 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 26 | test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
| 27 | test_list.init() |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 28 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 29 | def init( commonFuncs ){ |
| 30 | funcs = commonFuncs |
| 31 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 32 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 33 | def printDaysForTest(){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 34 | // Print the days for what test has. |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 35 | AllTheTests = test_list.getAllTests() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 36 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 37 | result = "" |
| 38 | for ( String test in AllTheTests.keySet() ){ |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 39 | result += test + ": [" |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 40 | test_schedule = AllTheTests[ test ][ "schedules" ] |
| 41 | for ( String sch_dict in test_schedule ){ |
| 42 | for ( String day in test_list.convertScheduleKeyToDays( sch_dict[ "branch" ] ) ){ |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 43 | result += day + " " |
| 44 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 45 | } |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 46 | result += "]\n" |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 47 | } |
| 48 | return result |
| 49 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 50 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 51 | def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 52 | // triggering function that will setup the environment and determine which pipeline to trigger |
| 53 | |
You Wang | 49461a8 | 2018-08-02 13:15:30 -0700 | [diff] [blame] | 54 | println "Job name: " + jobOn + "-pipeline-" + ( manuallyRun ? "manually" : branch ) |
Devin Lim | 6c77b7c | 2018-04-06 19:36:56 -0700 | [diff] [blame] | 55 | def wiki = branch |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 56 | def onos_branch = test_list.addPrefixToBranch( branch ) |
| 57 | def test_branch = test_list.addPrefixToBranch( branch ) |
You Wang | 49461a8 | 2018-08-02 13:15:30 -0700 | [diff] [blame] | 58 | println "onos_branch with prefix: " + onos_branch |
| 59 | println "test_branch with prefix: " + test_branch |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 60 | node( "TestStation-" + nodeName + "s" ) { |
You Wang | 7952750 | 2018-08-02 12:18:20 -0700 | [diff] [blame] | 61 | envSetup( onos_branch, test_branch, onosTag, jobOn, manuallyRun ) |
Jeremy Ronquillo | 259d71f | 2019-06-07 14:38:46 -0700 | [diff] [blame] | 62 | exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 66 | build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ], [ $class: 'StringParameterValue', name: 'Branch', value: branch ] ] |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 67 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 68 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 69 | def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 70 | // nodeName : "BM" or "VM" |
| 71 | // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA" |
| 72 | // this will return the function by wrapping them up with return{} to prevent them to be |
| 73 | // executed once this function is called to assign to specific variable. |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 74 | return { |
Devin Lim | 5b22fbb | 2018-04-06 15:30:45 -0700 | [diff] [blame] | 75 | trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 76 | } |
| 77 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 78 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 79 | // export Environment properties. |
Jeremy Ronquillo | 259d71f | 2019-06-07 14:38:46 -0700 | [diff] [blame] | 80 | def exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 81 | // export environment properties to the machine. |
| 82 | |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 83 | filePath = "/var/jenkins/TestONOS-" + jobOn + "-" + onos_branch + ".property" |
Jeremy Ronquillo | 259d71f | 2019-06-07 14:38:46 -0700 | [diff] [blame] | 84 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 85 | stage( "export Property" ) { |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 86 | sh ''' |
Jeremy Ronquillo | 259d71f | 2019-06-07 14:38:46 -0700 | [diff] [blame] | 87 | echo "ONOSBranch=''' + onos_branch + '''" > ''' + filePath + ''' |
| 88 | echo "TestONBranch=''' + test_branch + '''" >> ''' + filePath + ''' |
| 89 | echo "ONOSTag=''' + onosTag + '''" >> ''' + filePath + ''' |
| 90 | echo "WikiPrefix=''' + wiki + '''" >> ''' + filePath + ''' |
| 91 | echo "ONOSJAVAOPTS=''' + env.ONOSJAVAOPTS + '''" >> ''' + filePath + ''' |
| 92 | echo "Tests=''' + tests + '''" >> ''' + filePath + ''' |
| 93 | echo "postResult=''' + postResult + '''" >> ''' + filePath + ''' |
| 94 | echo "manualRun=''' + manually_run + '''" >> ''' + filePath + ''' |
| 95 | echo "isOldFlow=''' + isOldFlow + '''" >> ''' + filePath + ''' |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 96 | ''' |
| 97 | } |
| 98 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 99 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 100 | // Initialize the environment Setup for the onos and OnosSystemTest |
| 101 | def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 102 | // to setup the environment using the bash script |
You Wang | 49461a8 | 2018-08-02 13:15:30 -0700 | [diff] [blame] | 103 | println "onos_branch is set to " + onos_branch |
| 104 | println "test_branch is set to " + test_branch |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 105 | stage( "envSetup" ) { |
| 106 | // after env: ''' + borrow_mn( jobOn ) + ''' |
| 107 | sh '''#!/bin/bash -l |
| 108 | set +e |
| 109 | . ~/.bashrc |
| 110 | env |
| 111 | ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ) + ''' |
| 112 | ''' + oldFlowCheck( jobOn, onos_branch ) + ''' |
| 113 | ''' + postSetup( onos_branch, test_branch, onos_tag, manuallyRun ) |
Devin Lim | 90b6a59 | 2018-05-09 13:20:33 -0700 | [diff] [blame] | 114 | generateKey() |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 115 | } |
| 116 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 117 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 118 | def tagCheck( onos_tag, onos_branch ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 119 | // check the tag for onos if it is not empty |
| 120 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 121 | result = "git checkout " |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 122 | if ( onos_tag == "" ){ |
| 123 | //create new local branch |
| 124 | result += onos_branch |
| 125 | } |
| 126 | else { |
| 127 | //checkout the tag |
| 128 | result += onos_tag |
| 129 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 130 | return result |
| 131 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 132 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 133 | def preSetup( onos_branch, test_branch, onos_tag, isManual ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 134 | // pre setup part which will clean up and checkout to corresponding branch. |
| 135 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 136 | result = "" |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 137 | if ( !isManual ){ |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 138 | result = '''echo -e "\n##### Set TestON Branch #####" |
| 139 | echo "TestON Branch is set on: ''' + test_branch + '''" |
| 140 | cd ~/OnosSystemTest/ |
| 141 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 142 | git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 143 | git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 144 | git clean -df # clean any local files |
| 145 | git fetch --all # update all caches from remotes |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 146 | git reset --hard origin/''' + test_branch + ''' # force local index to match remote branch |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 147 | git clean -df # clean any local files |
| 148 | git checkout ''' + test_branch + ''' #create new local branch |
| 149 | git branch |
| 150 | git log -1 --decorate |
| 151 | echo -e "\n##### Set ONOS Branch #####" |
| 152 | echo "ONOS Branch is set on: ''' + onos_branch + '''" |
| 153 | echo -e "\n #### check karaf version ######" |
| 154 | env |grep karaf |
| 155 | cd ~/onos |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 156 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 157 | git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote |
| 158 | git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error |
| 159 | git clean -df # clean any local files |
| 160 | git fetch --all # update all caches from remotes |
| 161 | git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch |
| 162 | git clean -df # clean any local files |
Jon Hall | 5b05626 | 2018-09-25 11:44:41 -0700 | [diff] [blame] | 163 | rm -rf buck-out |
| 164 | rm -rf bazel-* |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 165 | ''' + tagCheck( onos_tag, onos_branch ) + ''' |
| 166 | git branch |
| 167 | git log -1 --decorate |
| 168 | echo -e "\n##### set jvm heap size to 8G #####" |
You Wang | 8e4f4c0 | 2019-01-03 10:49:46 -0800 | [diff] [blame] | 169 | echo ${ONOSJAVAOPTS} |
| 170 | inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\"" |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 171 | sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service |
| 172 | echo "##### Check onos-service setting..... #####" |
| 173 | cat ~/onos/tools/package/bin/onos-service |
| 174 | export JAVA_HOME=/usr/lib/jvm/java-8-oracle''' |
| 175 | } |
| 176 | return result |
| 177 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 178 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 179 | def oldFlowCheck( jobOn, onos_branch ){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 180 | // part that will check if it is oldFlow. If so, it will switch to use old flow. Only affected with SCPF. |
| 181 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 182 | result = "" |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 183 | if ( jobOn == "SCPF" && ( onos_branch == "master" || onos_branch == "onos-1.12" ) ) |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 184 | 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 |
| 185 | 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" |
| 186 | return result |
| 187 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 188 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 189 | def postSetup( onos_branch, test_branch, onos_tag, isManual ){ |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 190 | // setup that will build ONOS |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 191 | |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 192 | result = "" |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 193 | if ( !isManual ){ |
Jeremy Ronquillo | 352048b | 2019-06-20 10:47:47 -0700 | [diff] [blame] | 194 | result = '''echo -e "Installing bazel" |
| 195 | cd ~ |
| 196 | rm -rf ci-management |
| 197 | git clone https://gerrit.onosproject.org/ci-management |
| 198 | cd ci-management/jjb/onos/ |
| 199 | export GERRIT_BRANCH="''' + onos_branch + '''" |
| 200 | chmod +x install-bazel.sh |
| 201 | ./install-bazel.sh |
| 202 | bazel --version |
| 203 | |
| 204 | echo -e "\n##### build ONOS skip unit tests ######" |
Jon Hall | 3e6edb3 | 2018-08-21 16:20:30 -0700 | [diff] [blame] | 205 | cd ~/onos |
| 206 | . tools/dev/bash_profile |
| 207 | op |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 208 | sleep 30 |
| 209 | echo -e "\n##### Stop all running instances of Karaf #####" |
| 210 | kill $(ps -efw | grep karaf | grep -v grep | awk '{print $2}') |
| 211 | sleep 30 |
Devin Lim | 2d7371a | 2018-05-08 18:02:05 -0700 | [diff] [blame] | 212 | git branch |
Devin Lim | 2d7371a | 2018-05-08 18:02:05 -0700 | [diff] [blame] | 213 | ''' |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 214 | } |
| 215 | return result |
| 216 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 217 | |
Devin Lim | 90b6a59 | 2018-05-09 13:20:33 -0700 | [diff] [blame] | 218 | def generateKey(){ |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 219 | // generate cluster-key of the onos |
| 220 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 221 | try { |
Devin Lim | 018203a | 2018-05-09 11:33:20 -0700 | [diff] [blame] | 222 | sh ''' |
| 223 | #!/bin/bash -l |
| 224 | set +e |
| 225 | . ~/.bashrc |
| 226 | env |
Devin Lim | 90b6a59 | 2018-05-09 13:20:33 -0700 | [diff] [blame] | 227 | onos-push-bits-through-proxy |
| 228 | onos-gen-cluster-key -f |
Devin Lim | 018203a | 2018-05-09 11:33:20 -0700 | [diff] [blame] | 229 | ''' |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 230 | } catch ( all ){ |
| 231 | } |
Devin Lim | 018203a | 2018-05-09 11:33:20 -0700 | [diff] [blame] | 232 | } |
Devin Lim | 431408d | 2018-03-23 17:51:31 -0700 | [diff] [blame] | 233 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 234 | return this |