Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 2 | // Copyright 2019 Open Networking Foundation (ONF) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 3 | // |
| 4 | // Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | // the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | // or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | // |
| 8 | // TestON is free software: you can redistribute it and/or modify |
| 9 | // it under the terms of the GNU General Public License as published by |
| 10 | // the Free Software Foundation, either version 2 of the License, or |
| 11 | // (at your option) any later version. |
| 12 | // |
| 13 | // TestON is distributed in the hope that it will be useful, |
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | // GNU General Public License for more details. |
| 17 | // |
| 18 | // You should have received a copy of the GNU General Public License |
| 19 | // along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 21 | // This is the Jenkins script for master-trigger |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 22 | |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 23 | import groovy.time.TimeCategory |
| 24 | import groovy.time.TimeDuration |
| 25 | |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 26 | // set the functions of the dependencies. |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 27 | graphs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy' ) |
Devin Lim | b734ea5 | 2018-05-14 14:13:05 -0700 | [diff] [blame] | 28 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 29 | test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 30 | |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 31 | INITIALIZATION_TIMEOUT_MINUTES = 10 // timeout init() function if it takes too long. |
| 32 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 33 | onos_tag = null |
| 34 | manually_run = null |
| 35 | now = null |
| 36 | today = null |
| 37 | onos_branches = null |
| 38 | day = null |
| 39 | post_result = null |
| 40 | branchesParam = null |
| 41 | isFabric = null |
| 42 | testsParam = null |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 43 | simulateDay = null |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 44 | pipelineTimeOut = null |
Jeremy Ronquillo | 4fd8244 | 2019-05-21 20:56:58 -0700 | [diff] [blame] | 45 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 46 | dayMap = [:] |
| 47 | fullDayMap = [:] |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 48 | all_testcases = [:] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 49 | runTest = [:] |
| 50 | selectedTests = [:] |
| 51 | graphPaths = [:] |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 52 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 53 | main() |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 54 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 55 | def main() { |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 56 | timeout( time: INITIALIZATION_TIMEOUT_MINUTES, unit: "MINUTES" ){ |
| 57 | init() |
| 58 | } |
Jeremy Ronquillo | 194e2a7 | 2019-08-09 12:36:09 -0700 | [diff] [blame] | 59 | if ( selectedTests == [:] && manually_run ){ |
| 60 | echo "No valid tests provided. Check if the provided test(s) is/are in test.json, and try again.\n\nProvided Tests:\n" + testsParam |
| 61 | throw new Exception( "No valid tests provided. Check if the provided test(s) is/are in test.json, and try again." ) |
| 62 | } |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 63 | timeout( time: pipelineTimeOut, unit: "MINUTES" ){ |
| 64 | runTests() |
| 65 | generateGraphs() |
| 66 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | // ************** |
| 70 | // Initialization |
| 71 | // ************** |
| 72 | |
| 73 | // initialize file scope vars |
| 74 | def init(){ |
| 75 | // get the name of the job. |
| 76 | jobName = env.JOB_NAME |
| 77 | |
| 78 | // set the versions of the onos |
| 79 | fileRelated.init() |
| 80 | test_list.init() |
| 81 | readParams() |
| 82 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 83 | // list of the tests to be run will be saved in each choices. |
| 84 | day = "" |
| 85 | |
| 86 | initDates() |
| 87 | onos_branches = getONOSBranches() |
| 88 | selectedTests = getONOSTests() |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 89 | |
Jeremy Ronquillo | d98c2a1 | 2019-06-07 15:13:29 -0700 | [diff] [blame] | 90 | initGraphPaths() |
| 91 | |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 92 | echo "selectedTests: " + selectedTests |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 93 | echo "onos_branches: " + onos_branches |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | def readParams(){ |
| 97 | // get post result from the params for manually run. |
| 98 | post_result = params.PostResult |
| 99 | manually_run = params.manual_run |
| 100 | onos_tag = params.ONOSTag |
| 101 | branchesParam = params.branches |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 102 | isOldFlow = true // hardcoding to true since we are always using oldFlow. |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 103 | testsParam = params.Tests |
| 104 | isFabric = params.isFabric |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 105 | simulateDay = params.simulate_day |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 106 | pipelineTimeOut = params.TimeOut.toInteger() |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 107 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 108 | |
| 109 | // Set tests based on day of week |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 110 | def initDates(){ |
| 111 | echo "-> initDates()" |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 112 | now = getCurrentTime() |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 113 | dayMap = [ ( Calendar.MONDAY ) : "mon", |
| 114 | ( Calendar.TUESDAY ) : "tue", |
| 115 | ( Calendar.WEDNESDAY ) : "wed", |
| 116 | ( Calendar.THURSDAY ) : "thu", |
| 117 | ( Calendar.FRIDAY ) : "fri", |
| 118 | ( Calendar.SATURDAY ) : "sat", |
| 119 | ( Calendar.SUNDAY ) : "sun" ] |
| 120 | fullDayMap = [ ( Calendar.MONDAY ) : "Monday", |
| 121 | ( Calendar.TUESDAY ) : "Tuesday", |
| 122 | ( Calendar.WEDNESDAY ) : "Wednesday", |
| 123 | ( Calendar.THURSDAY ) : "Thursday", |
| 124 | ( Calendar.FRIDAY ) : "Friday", |
| 125 | ( Calendar.SATURDAY ) : "Saturday", |
| 126 | ( Calendar.SUNDAY ) : "Sunday" ] |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 127 | if ( simulateDay == "" ){ |
| 128 | today = now[ Calendar.DAY_OF_WEEK ] |
| 129 | day = dayMap[ today ] |
| 130 | print now.toString() |
| 131 | } else { |
| 132 | day = simulateDay |
| 133 | } |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 134 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 135 | |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 136 | def getCurrentTime(){ |
| 137 | // get time of the PST zone. |
| 138 | |
| 139 | TimeZone.setDefault( TimeZone.getTimeZone( 'PST' ) ) |
| 140 | return new Date() |
| 141 | } |
| 142 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 143 | // gets ONOS branches from params or string parameter |
| 144 | def getONOSBranches(){ |
| 145 | echo "-> getONOSBranches()" |
| 146 | if ( manually_run ){ |
| 147 | return branchesParam.tokenize( "\n;, " ) |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 148 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 149 | return test_list.getBranchesFromDay( day ) |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 150 | } |
| 151 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 152 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 153 | def getONOSTests(){ |
| 154 | echo "-> getONOSTests()" |
| 155 | if ( manually_run ){ |
| 156 | return test_list.getTestsFromStringList( testsParam.tokenize( "\n;, " ) ) |
| 157 | } else { |
Jeremy Ronquillo | 3c2f10d | 2019-06-10 16:54:46 -0700 | [diff] [blame] | 158 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 159 | return test_list.getTestsFromDay( day ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 160 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 161 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 162 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 163 | // init paths for the files and directories. |
| 164 | def initGraphPaths(){ |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 165 | graphPaths.put( "histogramMultiple", fileRelated.rScriptPaths[ "scripts" ][ "histogramMultiple" ] ) |
| 166 | graphPaths.put( "pieMultiple", fileRelated.rScriptPaths[ "scripts" ][ "pieMultiple" ] ) |
| 167 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "VM" ] ) |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 168 | } |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 169 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 170 | // ********************** |
| 171 | // Determine Tests to Run |
| 172 | // ********************** |
| 173 | |
| 174 | def printTestsToRun( runList ){ |
| 175 | if ( manually_run ){ |
| 176 | println "Tests to be run manually:" |
| 177 | } else { |
| 178 | if ( isFabric ){ |
| 179 | postToSlackSR() |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 180 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 181 | if ( today == Calendar.MONDAY ){ |
| 182 | postToSlackTestsToRun() |
| 183 | } |
| 184 | println "Defaulting to " + day + " tests:" |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 185 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 186 | for ( list in runList ){ |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 187 | echo "" + list |
| 188 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 189 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 190 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 191 | def postToSlackSR(){ |
| 192 | // If it is automated running, it will post the beginning message to the channel. |
| 193 | slackSend( channel: 'sr-failures', color: '#03CD9F', |
| 194 | message: ":sparkles:" * 16 + "\n" + |
| 195 | "Starting tests on : " + now.toString() + |
| 196 | "\n" + ":sparkles:" * 16 ) |
| 197 | } |
| 198 | |
| 199 | def postToSlackTestsToRun(){ |
| 200 | slackSend( color: '#FFD988', |
| 201 | message: "Tests to be run this weekdays : \n" + |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 202 | printDaysForTest() ) |
| 203 | } |
| 204 | |
| 205 | def printDaysForTest(){ |
| 206 | // Print the days for what test has. |
| 207 | AllTheTests = test_list.getAllTests() |
| 208 | |
| 209 | result = "" |
| 210 | for ( String test in AllTheTests.keySet() ){ |
| 211 | result += test + ": [" |
| 212 | test_schedule = AllTheTests[ test ][ "schedules" ] |
| 213 | for ( String sch_dict in test_schedule ){ |
| 214 | for ( String day in test_list.convertScheduleKeyToDays( sch_dict[ "branch" ] ) ){ |
| 215 | result += day + " " |
| 216 | } |
| 217 | } |
| 218 | result += "]\n" |
| 219 | } |
| 220 | return result |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | // ********* |
| 224 | // Run Tests |
| 225 | // ********* |
| 226 | |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 227 | def tagCheck( onos_tag, onos_branch ){ |
| 228 | // check the tag for onos if it is not empty |
| 229 | |
| 230 | result = "git checkout " |
| 231 | if ( onos_tag == "" ){ |
| 232 | //create new local branch |
| 233 | result += onos_branch |
| 234 | } |
| 235 | else { |
| 236 | //checkout the tag |
| 237 | result += onos_tag |
| 238 | } |
| 239 | return result |
| 240 | } |
| 241 | |
| 242 | def preSetup( onos_branch, test_branch, onos_tag, isManual ){ |
| 243 | // pre setup part which will clean up and checkout to corresponding branch. |
| 244 | |
| 245 | result = "" |
| 246 | if ( !isManual ){ |
| 247 | result = '''echo -e "\n##### Set TestON Branch #####" |
| 248 | echo "TestON Branch is set on: ''' + test_branch + '''" |
| 249 | cd ~/OnosSystemTest/ |
| 250 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 251 | git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote |
| 252 | git branch -D ''' + test_branch + ''' # just in case there are local changes. This will normally result in a branch not found error |
| 253 | git clean -df # clean any local files |
| 254 | git fetch --all # update all caches from remotes |
| 255 | git reset --hard origin/''' + test_branch + ''' # force local index to match remote branch |
| 256 | git clean -df # clean any local files |
| 257 | git checkout ''' + test_branch + ''' #create new local branch |
| 258 | git branch |
| 259 | git log -1 --decorate |
| 260 | echo -e "\n##### Set ONOS Branch #####" |
| 261 | echo "ONOS Branch is set on: ''' + onos_branch + '''" |
| 262 | echo -e "\n #### check karaf version ######" |
| 263 | env |grep karaf |
| 264 | cd ~/onos |
| 265 | git checkout HEAD~1 # Make sure you aren't pn a branch |
| 266 | git branch | grep -v "detached from" | xargs git branch -d # delete all local branches merged with remote |
| 267 | git branch -D ''' + onos_branch + ''' # just incase there are local changes. This will normally result in a branch not found error |
| 268 | git clean -df # clean any local files |
| 269 | git fetch --all # update all caches from remotes |
| 270 | git reset --hard origin/''' + onos_branch + ''' # force local index to match remote branch |
| 271 | git clean -df # clean any local files |
| 272 | rm -rf buck-out |
| 273 | rm -rf bazel-* |
| 274 | ''' + tagCheck( onos_tag, onos_branch ) + ''' |
| 275 | git branch |
| 276 | git log -1 --decorate |
| 277 | echo -e "\n##### set jvm heap size to 8G #####" |
| 278 | echo ${ONOSJAVAOPTS} |
| 279 | inserted_line="export JAVA_OPTS=\"\${ONOSJAVAOPTS}\"" |
| 280 | sed -i "s/bash/bash\\n$inserted_line/" ~/onos/tools/package/bin/onos-service |
| 281 | echo "##### Check onos-service setting..... #####" |
| 282 | cat ~/onos/tools/package/bin/onos-service |
| 283 | export JAVA_HOME=/usr/lib/jvm/java-8-oracle''' |
| 284 | } else { |
| 285 | result = '''echo "Since this is a manual run, we'll use the current ONOS and TestON branch:" |
| 286 | echo "ONOS branch:" |
| 287 | cd ~/OnosSystemTest/ |
| 288 | git branch |
| 289 | echo "TestON branch:" |
| 290 | cd ~/TestON/ |
| 291 | git branch''' |
| 292 | } |
| 293 | return result |
| 294 | } |
| 295 | |
| 296 | def postSetup( onos_branch, test_branch, onos_tag, isManual ){ |
| 297 | // setup that will build ONOS |
| 298 | |
| 299 | result = "" |
| 300 | if ( !isManual ){ |
| 301 | result = '''echo -e "Installing bazel" |
| 302 | cd ~ |
| 303 | rm -rf ci-management |
| 304 | git clone https://gerrit.onosproject.org/ci-management |
| 305 | cd ci-management/jjb/onos/ |
| 306 | export GERRIT_BRANCH="''' + onos_branch + '''" |
| 307 | chmod +x install-bazel.sh |
| 308 | ./install-bazel.sh |
| 309 | ''' |
| 310 | } else { |
| 311 | result = '''echo -e "Since this is a manual run, we will not install Bazel."''' |
| 312 | } |
| 313 | return result |
| 314 | } |
| 315 | |
| 316 | def generateKey(){ |
| 317 | // generate cluster-key of the onos |
| 318 | |
| 319 | try { |
| 320 | sh script: ''' |
| 321 | #!/bin/bash -l |
| 322 | set +e |
| 323 | . ~/.bashrc |
| 324 | env |
| 325 | onos-push-bits-through-proxy |
| 326 | onos-gen-cluster-key -f |
| 327 | ''', label: "Generate Cluster Key", returnStdout: false |
| 328 | } catch ( all ){ |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Initialize the environment Setup for the onos and OnosSystemTest |
| 333 | def envSetup( onos_branch, test_branch, onos_tag, jobOn, manuallyRun, nodeLabel ){ |
| 334 | // to setup the environment using the bash script |
| 335 | stage( "Environment Setup: " + onos_branch + "-" + nodeLabel + "-" + jobOn ) { |
| 336 | // after env: ''' + borrow_mn( jobOn ) + ''' |
| 337 | sh script: '''#!/bin/bash -l |
| 338 | set +e |
| 339 | . ~/.bashrc |
| 340 | env |
| 341 | ''' + preSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Repo Setup", returnStdout: false |
| 342 | sh script: postSetup( onos_branch, test_branch, onos_tag, manuallyRun ), label: "Install Bazel", returnStdout: false |
| 343 | generateKey() |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | // export Environment properties. |
| 348 | def exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, postResult, manually_run, onosTag, isOldFlow, nodeLabel ){ |
| 349 | // export environment properties to the machine. |
| 350 | |
| 351 | filePath = "/var/jenkins/TestONOS-" + jobOn + "-" + onos_branch + ".property" |
| 352 | |
| 353 | stage( "Property Export: " + onos_branch + "-" + nodeLabel + "-" + jobOn ) { |
| 354 | sh script: ''' |
| 355 | echo "ONOSBranch=''' + onos_branch + '''" > ''' + filePath + ''' |
| 356 | echo "TestONBranch=''' + test_branch + '''" >> ''' + filePath + ''' |
| 357 | echo "ONOSTag=''' + onosTag + '''" >> ''' + filePath + ''' |
| 358 | echo "WikiPrefix=''' + wiki + '''" >> ''' + filePath + ''' |
| 359 | echo "ONOSJAVAOPTS=''' + env.ONOSJAVAOPTS + '''" >> ''' + filePath + ''' |
| 360 | echo "Tests=''' + tests + '''" >> ''' + filePath + ''' |
| 361 | echo "postResult=''' + postResult + '''" >> ''' + filePath + ''' |
| 362 | echo "manualRun=''' + manually_run + '''" >> ''' + filePath + ''' |
| 363 | echo "isOldFlow=''' + isOldFlow + '''" >> ''' + filePath + ''' |
| 364 | ''', label: "Exporting Property File: " + filePath |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | def trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){ |
| 369 | // triggering function that will setup the environment and determine which pipeline to trigger |
| 370 | |
| 371 | println "Job name: " + jobOn + "-pipeline-" + ( manuallyRun ? "manually" : branch ) |
| 372 | def wiki = branch |
| 373 | def onos_branch = test_list.addPrefixToBranch( branch ) |
| 374 | def test_branch = test_list.addPrefixToBranch( branch ) |
| 375 | assignedNode = null |
| 376 | node( label: nodeLabel ) { |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 377 | envSetup( onos_branch, test_branch, onosTag, jobOn, manuallyRun, nodeLabel ) |
| 378 | exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow, nodeLabel ) |
| 379 | assignedNode = env.NODE_NAME |
| 380 | } |
| 381 | |
| 382 | jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki ) |
| 383 | build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ], |
| 384 | [ $class: 'StringParameterValue', name: 'Branch', value: branch ], |
| 385 | [ $class: 'StringParameterValue', name: 'TestStation', value: assignedNode ], |
Jeremy Ronquillo | 6da78cf | 2019-07-29 11:47:19 -0700 | [diff] [blame] | 386 | [ $class: 'StringParameterValue', name: 'NodeLabel', value: nodeLabel ], |
| 387 | [ $class: 'StringParameterValue', name: 'TimeOut', value: pipelineTimeOut.toString() ] ] |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | def trigger_pipeline( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){ |
| 391 | // nodeLabel : nodeLabel from tests.json |
| 392 | // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA" |
| 393 | // this will return the function by wrapping them up with return{} to prevent them to be |
| 394 | // executed once this function is called to assign to specific variable. |
| 395 | return { |
| 396 | trigger( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ) |
| 397 | } |
| 398 | } |
| 399 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 400 | def generateRunList(){ |
| 401 | runList = [:] |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 402 | validSchedules = test_list.getValidSchedules( day ) |
| 403 | echo "validSchedules: " + validSchedules |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 404 | for ( branch in onos_branches ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 405 | runBranch = [] |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 406 | nodeLabels = test_list.getAllNodeLabels( branch, selectedTests ) |
| 407 | for ( nodeLabel in nodeLabels ){ |
| 408 | selectedNodeLabelTests = test_list.getTestsFromNodeLabel( nodeLabel, branch, selectedTests ) |
| 409 | selectedNodeLabelCategories = test_list.getAllTestCategories( selectedNodeLabelTests ) |
| 410 | for ( category in selectedNodeLabelCategories ){ |
Jeremy Ronquillo | a5aa7c1 | 2019-06-04 10:26:36 -0700 | [diff] [blame] | 411 | selectedNodeLabelCategoryTests = test_list.getTestsFromCategory( category, selectedNodeLabelTests ) |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 412 | |
| 413 | filteredList = [:] |
| 414 | for ( key in selectedNodeLabelCategoryTests.keySet() ){ |
| 415 | for ( sch in selectedNodeLabelCategoryTests[ key ][ "schedules" ] ){ |
Jeremy Ronquillo | bd26bdb | 2019-07-08 16:15:45 -0700 | [diff] [blame] | 416 | if ( validSchedules.contains( sch[ "day" ] ) && sch[ "branch" ] == test_list.convertBranchToBranchCode( branch ) || manually_run ){ |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 417 | filteredList.put( key, selectedNodeLabelCategoryTests[ key ] ) |
| 418 | break |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | echo "==========================================" |
| 424 | echo "BRANCH: " + branch |
| 425 | echo "CATEGORY: " + category |
| 426 | echo "TESTS: " + filteredList |
| 427 | if ( filteredList != [:] ){ |
| 428 | exeTestList = test_list.getTestListAsString( filteredList ) |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 429 | runList.put( branch + "-" + nodeLabel + "-" + category, trigger_pipeline( branch, exeTestList, nodeLabel, category, manually_run, onos_tag ) ) |
Jeremy Ronquillo | edb663b | 2019-06-26 14:09:38 -0700 | [diff] [blame] | 430 | } |
| 431 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 432 | } |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 433 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 434 | } |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 435 | return runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 436 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 437 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 438 | def runTests(){ |
| 439 | runList = generateRunList() |
| 440 | printTestsToRun( runList ) |
| 441 | parallel runList |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 442 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 443 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 444 | // *************** |
| 445 | // Generate Graphs |
| 446 | // *************** |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 447 | |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 448 | def generateGraphs(){ |
| 449 | // If it is automated running, it will generate the stats graph on VM. |
| 450 | if ( !manually_run ){ |
| 451 | for ( String b in onos_branches ){ |
Jeremy Ronquillo | 336110a | 2019-07-11 14:20:40 -0700 | [diff] [blame] | 452 | graphs.generateStatGraph( "TestStation-VMs", |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 453 | test_list.addPrefixToBranch( b ), |
Jeremy Ronquillo | 96e2bd3 | 2019-05-28 15:40:18 -0700 | [diff] [blame] | 454 | graphPaths[ "histogramMultiple" ], |
| 455 | graphPaths[ "pieMultiple" ], |
Jeremy Ronquillo | cfec28a | 2019-08-08 11:29:04 -0700 | [diff] [blame] | 456 | graphPaths[ "saveDirectory" ], |
| 457 | "VM" ) |
Jeremy Ronquillo | a37920b | 2019-05-23 14:34:25 -0700 | [diff] [blame] | 458 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 459 | } |
Devin Lim | 2edfcec | 2018-05-09 17:16:21 -0700 | [diff] [blame] | 460 | } |