Devin Lim | e1346f4 | 2018-05-15 15:41:36 -0700 | [diff] [blame] | 1 | #!groovy |
| 2 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 3 | // Copyright 2019 Open Networking Foundation (ONF) |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 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 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 22 | allTests = [:] |
| 23 | schedules = [:] |
Jeremy Ronquillo | 14ecc17 | 2018-03-05 09:57:17 -0800 | [diff] [blame] | 24 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 25 | def init(){ |
Jeremy Ronquillo | bc631c1 | 2019-05-21 15:29:04 -0700 | [diff] [blame] | 26 | def tests_buffer = readTrusted( "TestON/JenkinsFile/dependencies/tests.json" ) |
| 27 | def schedules_buffer = readTrusted( "TestON/JenkinsFile/dependencies/schedule.json" ) |
Jeremy Ronquillo | 266b92e | 2019-05-21 15:45:20 -0700 | [diff] [blame] | 28 | allTests = readJSON text: tests_buffer |
| 29 | schedules = readJSON text: schedules_buffer |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 30 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 31 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 32 | def getAllTests(){ |
| 33 | return allTests |
| 34 | } |
Devin Lim | f517519 | 2018-05-14 19:13:22 -0700 | [diff] [blame] | 35 | |
Jeremy Ronquillo | 64eeeb1 | 2019-05-13 11:19:46 -0700 | [diff] [blame] | 36 | def getSchedules(){ |
| 37 | return schedules |
| 38 | } |
| 39 | |
| 40 | def getTestsFromCategory( category, tests=[:] ){ |
| 41 | result = [:] |
| 42 | if ( tests == [:] ){ |
| 43 | tests = allTests |
| 44 | } |
| 45 | for ( String key in tests.keySet() ){ |
| 46 | if ( tests[ key ][ "category" ] == category ){ |
| 47 | result.put( key, tests[ key ] ) |
| 48 | } |
| 49 | } |
| 50 | return result |
| 51 | } |
| 52 | |
| 53 | def getTestsFromDay( day, branch, tests=[:] ){ |
| 54 | result = [:] |
| 55 | if ( tests == [:] ){ |
| 56 | tests = allTests |
| 57 | } |
| 58 | validSchedules = [] |
| 59 | for ( String key in schedules.keySet() ){ |
| 60 | if ( schedules[ key ].contains( day ) ){ |
| 61 | validSchedules += key |
| 62 | } |
| 63 | } |
| 64 | echo validSchedules.toString() |
| 65 | for ( String key in tests.keySet() ){ |
| 66 | schedule = tests[ key ][ "schedule" ][ branch ] |
| 67 | if ( validSchedules.contains( schedule ) ){ |
| 68 | result.put( key, tests[ key ] ) |
| 69 | } |
| 70 | } |
| 71 | return result |
| 72 | } |
| 73 | |
| 74 | def getTestsFromNodeLabel( nodeLabel, tests=[:] ){ |
| 75 | if ( tests == [:] ){ |
| 76 | tests = allTests |
| 77 | } |
| 78 | for ( String key in tests.keySet() ){ |
| 79 | if ( tests[ key ][ "nodeLabel" ] == nodeLabel ){ |
| 80 | result.put( key, tests[ key ] ) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | def getTestListAsString( tests ){ |
| 86 | result = "" |
| 87 | for ( String key in tests.keySet() ){ |
| 88 | result += test + "," |
| 89 | } |
| 90 | return result[ 0..-2 ] |
| 91 | } |
| 92 | |
| 93 | def getTestSchedule( test ){ |
| 94 | return allTests[ test ][ "schedule" ] |
| 95 | } |
| 96 | |
| 97 | def convertScheduleKeyToDays( sch ){ |
| 98 | return schedules[ sch ] |
Jeremy Ronquillo | 14ecc17 | 2018-03-05 09:57:17 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Jon Hall | 6af749d | 2018-05-29 12:59:47 -0700 | [diff] [blame] | 101 | return this |