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