blob: e4690c3f35bc8ce1289bcba6b768254c88dd766d [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 -070022import groovy.json.*
Devin Limf5175192018-05-14 19:13:22 -070023
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070024allTests = [:]
25schedules = [:]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -080026
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070027def init(){
28 def jsonSlurper = new JsonSlurper()
29 def tests_buffer = new BufferedReader( new InputStreamReader( new FileInputStream( "tests.json" ),"UTF-8" ) )
30 def schedules_buffer = new BufferedReader( new InputStreamReader( new FileInputStream( "schedule.json" ),"UTF-8" ) )
31 allTests = jsonSlurper.parse( tests_buffer )
32 schedules = jsonSlurper.parse( schedules_buffer )
33}
Devin Limf5175192018-05-14 19:13:22 -070034
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070035def getAllTests(){
36 return allTests
37}
Devin Limf5175192018-05-14 19:13:22 -070038
Jeremy Ronquillo64eeeb12019-05-13 11:19:46 -070039def getSchedules(){
40 return schedules
41}
42
43def 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
56def 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
77def 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
88def getTestListAsString( tests ){
89 result = ""
90 for ( String key in tests.keySet() ){
91 result += test + ","
92 }
93 return result[ 0..-2 ]
94}
95
96def getTestSchedule( test ){
97 return allTests[ test ][ "schedule" ]
98}
99
100def convertScheduleKeyToDays( sch ){
101 return schedules[ sch ]
Jeremy Ronquillo14ecc172018-03-05 09:57:17 -0800102}
103
Jon Hall6af749d2018-05-29 12:59:47 -0700104return this