blob: 28d81de701b05648e47da509e636a2c93f3f38cc [file] [log] [blame]
Devin Lime1346f42018-05-15 15:41:36 -07001#!groovy
2
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -07003// Copyright 2019 Open Networking Foundation (ONF)
Devin Limf5175192018-05-14 19:13:22 -07004//
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 Ronquillo64eeeb12019-05-13 11:19:46 -070022allTests = [:]
23schedules = [:]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080024
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070025def init(){
Jeremy Ronquillobc631c12019-05-21 15:29:04 -070026 def tests_buffer = readTrusted( "TestON/JenkinsFile/dependencies/tests.json" )
27 def schedules_buffer = readTrusted( "TestON/JenkinsFile/dependencies/schedule.json" )
Jeremy Ronquillo266b92e2019-05-21 15:45:20 -070028 allTests = readJSON text: tests_buffer
29 schedules = readJSON text: schedules_buffer
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070030}
Devin Limf5175192018-05-14 19:13:22 -070031
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070032def getAllTests(){
33 return allTests
34}
Devin Limf5175192018-05-14 19:13:22 -070035
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070036def getSchedules(){
37 return schedules
38}
39
40def 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
53def 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
74def 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
85def getTestListAsString( tests ){
86 result = ""
87 for ( String key in tests.keySet() ){
88 result += test + ","
89 }
90 return result[ 0..-2 ]
91}
92
93def getTestSchedule( test ){
94 return allTests[ test ][ "schedule" ]
95}
96
97def convertScheduleKeyToDays( sch ){
98 return schedules[ sch ]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080099}
100
Jon Hall6af749d2018-05-29 12:59:47 -0700101return this