blob: b17a8b6544b7ddb693dd060243d672642aa23720 [file] [log] [blame]
Jeremy Ronquillo644284b2019-06-17 11:20:02 -07001#!groovy
2// Copyright 2019 Open Networking Foundation (ONF)
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
21// This script generates the test list on the wiki.
22test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
23
24wikiContents = ""
25testHTMLtableContents = ""
26runningNode = "TestStation-BMs"
27supportBranch1 = null
28supportBranch2 = null
29
30testCategoryContents = [:]
31
32main()
33
34def main(){
35 test_list.init()
36
Jeremy Ronquillof5482c92020-12-09 16:30:49 -080037 supportBranch1 = test_list.convertBranchCodeToBranch( "onos-LTS1" )
38 supportBranch2 = test_list.convertBranchCodeToBranch( "onos-LTS2" )
Jeremy Ronquillo644284b2019-06-17 11:20:02 -070039
40 initHtmlForWiki()
41 initTestCategoryContents()
42 wikiContents += contentsToHTML()
43 wikiContents += endTable()
44 wikiContents += addBranchDescription()
45
46 debugPrintHTML()
47
48 node ( runningNode ) {
49 publishToConfluence( "Automated Test Schedule", wikiContents )
50 }
51}
52
53// Initial part of the wiki page.
54def initHtmlForWiki(){
55 wikiContents = '''
56 <table class="wrapped confluenceTable">
57 <colgroup>
58 <col />
59 <col />
60 <col />
61 <col />
62 <col />
63 <col />
64 </colgroup>
65 <tbody>
66 <tr>
67 <th colspan="1" class="confluenceTh">
68 <br />
69 </th>
70 <th class="confluenceTh"><p>Monday</p></th>
71 <th class="confluenceTh"><p>Tuesday</p></th>
72 <th class="confluenceTh"><p>Wednesday</p></th>
73 <th class="confluenceTh"><p>Thursday</p></th>
74 <th class="confluenceTh"><p>Friday</p></th>
75 <th class="confluenceTh"><p>Saturday</p></th>
76 <th class="confluenceTh"><p>Sunday</p></th>
77 </tr>'''
78}
79
80def initTestCategoryContents(){
81 allCategories = test_list.getAllTestCategories()
82
83 for ( category in allCategories ){
84 testsFromCategory = test_list.getTestsFromCategory( category )
85
86 dayOfWeekDict = [ "mon" : null,
87 "tue" : null,
88 "wed" : null,
89 "thu" : null,
90 "fri" : null,
91 "sat" : null,
92 "sun" : null ]
93
94 for ( day in dayOfWeekDict.keySet() ){
95 testsFromDay = test_list.getTestsFromDay( day, testsFromCategory )
96 dayOfWeekDict[ day ] = testsFromDay
97 }
98
99 testCategoryContents.put( category, dayOfWeekDict )
100 }
101}
102
103def contentsToHTML(){
104 testHTMLtableContents = ""
105 for ( category in testCategoryContents.keySet() ){
106 categoryTableCells = ""
107 categoryTableCells += '''
108 <tr>
109 <th colspan="1" class="confluenceTh">''' + category + '''</th>'''
110 for ( day in testCategoryContents[ category ].keySet() ){
111 categoryTableCells += '''
112 <td class="confluenceTd">
113 <ul>'''
114 for ( test in testCategoryContents[ category ][ day ].keySet() ){
115 testName = test
116 categoryTableCells += '''
117 <li>''' + test + addAsterisks( category, day, test ) + '''</li>'''
118 }
119 categoryTableCells += '''
120 </ul>
121 </td>'''
122 }
123 categoryTableCells += '''
124 </tr>'''
125
126 testHTMLtableContents += categoryTableCells
127 }
128 return testHTMLtableContents
129}
130
131// adds asterisks based on the support branch number (hack)
Jeremy Ronquillof5482c92020-12-09 16:30:49 -0800132// Example: if support branch is onos-LTS1, then adds 1 asterisks, if ONOS-LTS2, then adds 2 asterisks
Jeremy Ronquillo644284b2019-06-17 11:20:02 -0700133def addAsterisks( category, day, test ){
134 asterisks = ""
135 tempDict = [ test : testCategoryContents[ category ][ day ][ test ] ]
136 testBranches = test_list.getBranchesFromDay( day, tempDict )
137 asteriskCount = 0
138
139 for ( branch in testBranches ){
Jeremy Ronquillof5482c92020-12-09 16:30:49 -0800140 branch_code = test_list.convertBranchToBranchCode( branch )
141 if ( branch_code == "onos-LTS1" ) {
142 asteriskCount += 1
143 } else if ( branch_code == "onos-LTS2" ) {
144 asteriskCount += 2
Jeremy Ronquillo644284b2019-06-17 11:20:02 -0700145 }
146 }
147
148 for ( i = 0; i < asteriskCount; i++ ){
149 asterisks += '''*'''
150 }
151 return asterisks
152}
153
154def endTable(){
155 return '''
156 </tbody>
157 </table>'''
158}
159
160def debugPrintHTML(){
161 echo "wikiContents:\n" + wikiContents
162}
163
164def addBranchDescription(){
165 branchDescription = ""
166
167 branchDescription += '''
168 <p>* test runs on the <b>''' + supportBranch1 + '''</b> branch.</p>
169 <p>** test runs on the <b>''' + supportBranch2 + '''</b> branch.</p>
Jeremy Ronquillofdc739c2019-06-26 14:22:36 -0700170 <p>*** test runs on the <b>''' + supportBranch1 + ''', ''' + supportBranch2 + ''', and master branches''' + '''</b>.</p>
Jeremy Ronquillo644284b2019-06-17 11:20:02 -0700171 <p>Otherwise, test runs on the <b>''' + '''master''' + '''</b> branch.</p>'''
172
173
174 return branchDescription
175}
176
177def publishToConfluence( pageName, contents ){
178 // publish HTML script to wiki confluence
179
180 publishConfluence siteName: 'wiki.onosproject.org', pageName: pageName, spaceName: 'ONOS',
181 attachArchivedArtifacts: true, buildIfUnstable: true,
182 editorList: [ confluenceWritePage( confluenceText( contents ) ) ]
183
184}