blob: 6ee93289570d5cbbaeeb4fabaeddf6ea2500e4ac [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
37 supportBranch1 = test_list.convertBranchCodeToBranch( "onos-1.x" )
38 supportBranch2 = test_list.convertBranchCodeToBranch( "onos-2.x" )
39
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)
132// Example: if support branch is onos-1.x, then adds 1 asterisks, if onos-2.x, then adds 2 asterisks
133def 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 ){
140 if ( branch.substring( 0, 1 ) != "m" ){
141 asteriskCount += branch.substring( 0, 1 ) as Integer
142 }
143 }
144
145 for ( i = 0; i < asteriskCount; i++ ){
146 asterisks += '''*'''
147 }
148 return asterisks
149}
150
151def endTable(){
152 return '''
153 </tbody>
154 </table>'''
155}
156
157def debugPrintHTML(){
158 echo "wikiContents:\n" + wikiContents
159}
160
161def addBranchDescription(){
162 branchDescription = ""
163
164 branchDescription += '''
165 <p>* test runs on the <b>''' + supportBranch1 + '''</b> branch.</p>
166 <p>** test runs on the <b>''' + supportBranch2 + '''</b> branch.</p>
Jeremy Ronquillofdc739c2019-06-26 14:22:36 -0700167 <p>*** test runs on the <b>''' + supportBranch1 + ''', ''' + supportBranch2 + ''', and master branches''' + '''</b>.</p>
Jeremy Ronquillo644284b2019-06-17 11:20:02 -0700168 <p>Otherwise, test runs on the <b>''' + '''master''' + '''</b> branch.</p>'''
169
170
171 return branchDescription
172}
173
174def publishToConfluence( pageName, contents ){
175 // publish HTML script to wiki confluence
176
177 publishConfluence siteName: 'wiki.onosproject.org', pageName: pageName, spaceName: 'ONOS',
178 attachArchivedArtifacts: true, buildIfUnstable: true,
179 editorList: [ confluenceWritePage( confluenceText( contents ) ) ]
180
181}