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