blob: d90151c93b5c927d492adbbdb1b11ef7e387a880 [file] [log] [blame]
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -07001#!groovy
2// Copyright 2017 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
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070021import groovy.time.TimeCategory
22import groovy.time.TimeDuration
23
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070024// read the dependency files
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070025graphs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsGraphs.groovy' )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070026test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
27fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
28SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
29
30category = null
31prop = null
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070032testsToRunStrList = null
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070033branch = null
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070034branchWithPrefix = null
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070035start = null
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070036nodeLabel = null
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070037testStation = null
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070038testsOverride = null
39isGraphOnly = false
40isSCPF = false
Jeremy Ronquillo6da78cf2019-07-29 11:47:19 -070041pipelineTimeout = null
42
Jon Hallf29368d2020-07-31 12:23:56 -070043testsToRun = [:]
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070044testsFromList = [:]
45graphPaths = [:]
46pipeline = [:]
47
48main()
49
50def main(){
Jeremy Ronquillo892c1732019-07-29 15:22:57 -070051 pipelineTimeout = params.TimeOut.toInteger() // integer minutes until the entire pipeline times out. Usually passed from upstream master-trigger job.
Jeremy Ronquillo6da78cf2019-07-29 11:47:19 -070052 timeout( time: pipelineTimeout, unit: "MINUTES" ){
Jeremy Ronquillo892c1732019-07-29 15:22:57 -070053 init()
Jeremy Ronquillo6da78cf2019-07-29 11:47:19 -070054 runTests()
55 generateGraphs()
56 sendToSlack()
57 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070058}
59
60def init(){
61 fileRelated.init()
62 test_list.init()
63 readParams()
64
Jeremy Ronquillob8aac442019-07-31 13:28:01 -070065 if ( branch == "manually" ){
66 echo '''Warning: entered branch was: "manually". Defaulting to master branch.'''
67 branch = "master"
68 branchWithPrefix = test_list.addPrefixToBranch( branch )
69 }
70
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070071 if ( category == "SCPF" ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070072 isSCPF = true
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070073 SCPFfuncs.init()
Jeremy Ronquillo442ce4d2019-07-26 16:35:11 -070074 graphs.initialize( SCPFfuncs );
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070075 prop = getProperties()
76 isOldFlow = ( prop[ "isOldFlow" ] == "true" )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070077 SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070078 } else {
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070079 isSCPF = false
80 graphs.initialize()
81 prop = getProperties()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070082 }
83
Jeremy Ronquillob8aac442019-07-31 13:28:01 -070084 // get the list of the tests from category
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070085 testsFromList = test_list.getTestsFromCategory( category )
86
87 initGraphPaths()
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070088 tokenizeTokens = "\n;, "
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070089
Jeremy Ronquillo336110a2019-07-11 14:20:40 -070090 if ( testsOverride == "" || testsOverride == null ){
91 testsToRunStrList = prop[ "Tests" ].tokenize( tokenizeTokens )
92 } else {
93 testsToRunStrList = testsOverride.tokenize( tokenizeTokens )
94 }
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070095 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070096}
97
98def readParams(){
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070099 category = params.Category // "FUNC", "HA", "USECASE", etc.
100 branch = params.Branch // "1.15", "2.1", "master", etc.
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700101 branchWithPrefix = test_list.addPrefixToBranch( branch )
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -0700102 testStation = params.TestStation // "TestStation-BMs", etc.
Jeremy Ronquillof5482c92020-12-09 16:30:49 -0800103 nodeLabel = params.NodeLabel // "BM", "VM", "Fabric-LTS1", etc.
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700104 testsOverride = params.TestsOverride // "FUNCflow, FUNCintent, [...]", overrides property file
105 isGraphOnly = params.OnlyRefreshGraphs // true or false
106}
107
108def getProperties(){
109 // get the properties of the test by reading the TestONOS.property
110
111 filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
112
113 node( testStation ) {
114 return readProperties( file: filePath )
115 }
116}
117
118def getCurrentTime(){
119 // get time of the PST zone.
120
121 TimeZone.setDefault( TimeZone.getTimeZone( 'PST' ) )
122 return new Date()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700123}
124
125def initGraphPaths(){
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700126 graphPaths.put( "trendIndividual", fileRelated.rScriptPaths[ "scripts" ][ "trendIndividual" ] )
Jon Hall4dc60b12020-12-15 16:46:06 -0800127 if ( category == "SR" || category == "SR-StratumBMv2" ){
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700128 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "base" ] + "postjob-" + ( testStation - "TestStation-" - "s" ) + "/" )
Jon Hall4dc60b12020-12-15 16:46:06 -0800129 } else if ( category == "SR-Tofino" ){
130 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "QA-POD" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700131 } else if ( category == "SRHA" ) {
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700132 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "Fabric" ] )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700133 } else if ( category == "SCPF" || category == "USECASE" ){
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700134 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "BM" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700135 } else {
Jeremy Ronquillo1e5d7f22019-07-17 14:18:42 -0700136 graphPaths.put( "saveDirectory", fileRelated.workspaces[ "VM" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700137 }
138}
139
140def runTests(){
141 // run the test sequentially and save the function into the dictionary.
Jon Halld4f33e12020-07-29 14:50:34 -0700142 for ( String JenkinsLabel : testsFromList.keySet() ){
143 toBeRun = testsToRun.keySet().contains( JenkinsLabel )
144 stepName = ( toBeRun ? "" : "Not " ) + "Running $JenkinsLabel"
145
Jon Hallf29368d2020-07-31 12:23:56 -0700146 TestONTest = ( toBeRun && testsToRun[ JenkinsLabel ].keySet().contains( "test" ) ) ? testsToRun[ JenkinsLabel ][ "test" ] : JenkinsLabel
Jon Halld4f33e12020-07-29 14:50:34 -0700147
148 pipeline[ stepName ] = runTest( JenkinsLabel,
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700149 toBeRun,
150 prop,
Jon Halld4f33e12020-07-29 14:50:34 -0700151 TestONTest,
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700152 isGraphOnly,
153 testsToRun,
154 graphPaths[ "trendIndividual" ],
155 graphPaths[ "saveDirectory" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700156 }
157
158 // get the start time of the test.
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700159 start = getCurrentTime()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700160
161 // run the tests sequentially.
Jon Halld4f33e12020-07-29 14:50:34 -0700162 for ( JenkinsLabel in pipeline.keySet() ){
163 pipeline[ JenkinsLabel ].call()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700164 }
165}
166
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700167def initTest(){
168 return '''#!/bin/bash -l
169 set -i # interactive
170 set +e
171 shopt -s expand_aliases # expand alias in non-interactive mode
172 export PYTHONUNBUFFERED=1
173 ifconfig
174 echo "ONOS Branch is: $ONOSBranch"
175 echo "TestON Branch is: $TestONBranch"
176 echo "Test date: "
177 date
178 cd ~
179 export PATH=$PATH:onos/tools/test/bin
180 timeout 240 stc shutdown | head -100
181 timeout 240 stc teardown | head -100
182 timeout 240 stc shutdown | head -100
183 cd ~/OnosSystemTest/TestON/bin
184 git log | head
185 ./cleanup.sh -f || true
186 '''
187}
188
Jeremy Ronquillo5ceda072019-08-12 12:56:43 -0700189def configureJavaVersion(){
190 java_1_8_branches = [ "1.15" ]
191 return '''#!/bin/bash -l
192 ''' + ( java_1_8_branches.contains( branch ) ? '''SET_JAVA_VER=java-8-oracle''' : '''SET_JAVA_VER=java-1.11.0-openjdk-amd64''' ) +
193 '''
194 CELL_COUNT=$( env | egrep "OC[1-9]+" | wc -l )
195 for i in $(seq 1 $CELL_COUNT)
196 do
197 CELL_TO_SET=$( env | egrep "OC$i" | cut -c5- )
198 echo "Setting java to $SET_JAVA_VER on $CELL_TO_SET"
199 eval ssh $CELL_TO_SET 'sudo update-java-alternatives -s $SET_JAVA_VER'
200 done
201 '''
202}
203
Jon Halld4f33e12020-07-29 14:50:34 -0700204def runTestCli_py( testName, testArguments ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700205 // Bash script that will run the test.
Jon Halld4f33e12020-07-29 14:50:34 -0700206 // testName : name of the test in TestON
207 // testArguments : Arguments to be passed to the test framework
Jeremy Ronquillo31a3eb32019-08-02 13:30:37 -0700208
209 command = '''cd ~/OnosSystemTest/TestON/bin
Jon Halld4f33e12020-07-29 14:50:34 -0700210 ./cli.py run ''' + testName + ''' --params GRAPH/nodeCluster=''' + graphs.getPostjobType( nodeLabel ) + ''' ''' + testArguments
Jeremy Ronquillo31a3eb32019-08-02 13:30:37 -0700211 echo command
212
213 return command
214
215
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700216}
217
218def concludeRunTest(){
Jon Halld4f33e12020-07-29 14:50:34 -0700219 // TODO: Add cleanup for if we use docker containers
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700220 return '''cd ~/OnosSystemTest/TestON/bin
221 ./cleanup.sh -f || true
222 # cleanup config changes
223 cd ~/onos/tools/package/config
224 git clean -df'''
225}
226
227def copyLogs(){
228 // bash script to copy the logs and other necessary element for SR tests.
229
230 result = ""
Jon Hallc68e2162020-07-29 10:50:09 -0700231 if ( category == "SR" || category == "SR-StratumBMv2" || category == "SR-Tofino" ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700232 result = '''
233 sudo rm /var/jenkins/workspace/SR-log-${WikiPrefix}/*
234 sudo cp *karaf.log.* /var/jenkins/workspace/SR-log-${WikiPrefix}/
235 sudo cp *Flows* /var/jenkins/workspace/SR-log-${WikiPrefix}/
236 sudo cp *Groups* /var/jenkins/workspace/SR-log-${WikiPrefix}/
237 sudo cp *.tar.gz /var/jenkins/workspace/SR-log-${WikiPrefix}/
238 sudo cp t3-* /var/jenkins/workspace/SR-log-${WikiPrefix}/
239 '''
240 }
241 return result
242}
243
Jon Halld4f33e12020-07-29 14:50:34 -0700244def cleanAndCopyFiles( JenkinsLabel ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700245 // clean up some files that were in the folder and copy the new files from the log
Jon Halld4f33e12020-07-29 14:50:34 -0700246 // JenkinsLabel : name of the test in Jenkins
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700247
248 return '''#!/bin/bash -i
249 set +e
250 echo "ONOS Branch is: ${ONOSBranch}"
251 echo "TestON Branch is: ${TestONBranch}"
Jon Halld4f33e12020-07-29 14:50:34 -0700252 echo "Job name is: "''' + JenkinsLabel + '''
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700253 echo "Workspace is: ${WORKSPACE}/"
254 echo "Wiki page to post is: ${WikiPrefix}-"
255 # remove any leftover files from previous tests
256 sudo rm ${WORKSPACE}/*Wiki.txt
257 sudo rm ${WORKSPACE}/*Summary.txt
258 sudo rm ${WORKSPACE}/*Result.txt
259 sudo rm ${WORKSPACE}/*Alarm.txt || true
260 sudo rm ${WORKSPACE}/*.csv
261 #copy files to workspace
262 cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
263 ''' + copyLogs() + '''
264 sudo cp *.txt ${WORKSPACE}/
265 sudo cp *.csv ${WORKSPACE}/
266 cd ${WORKSPACE}/
267 for i in *.csv
268 do mv "$i" "$WikiPrefix"-"$i"
269 done
270 ls -al
271 cd '''
272}
273
Jon Halld4f33e12020-07-29 14:50:34 -0700274def fetchLogs( JenkinsLabel ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700275 // fetch the logs of onos from onos nodes to onos System Test logs
Jon Halld4f33e12020-07-29 14:50:34 -0700276 // JenkinsLabel : name of the test in Jenkins
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700277
278 return '''#!/bin/bash
279 set +e
280 cd ~/OnosSystemTest/TestON/logs
Jon Halld4f33e12020-07-29 14:50:34 -0700281 echo "TestON test name is: "''' + JenkinsLabel + '''
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700282 TestONlogDir=$(ls -t | grep ${TEST_NAME}_ |head -1)
283 echo "########################################################################################"
284 echo "##### copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}"
285 echo "########################################################################################"
286 cd $TestONlogDir
287 if [ $? -eq 1 ]
288 then
289 echo "Job name does not match any test suite name to move log!"
290 else
291 pwd
292 for i in $OC{1..7}; do onos-fetch-logs $i || echo log does not exist for onos $i; done
293 for i in $OC{1..7}; do atomix-fetch-logs $i || echo log does not exist for atomix $i; done
294 fi
295 cd'''
296}
297
298def publishToConfluence( isManualRun, isPostResult, wikiLink, file ){
299 // publish HTML script to wiki confluence
300 // isManualRun : string "true" "false"
301 // isPostResult : string "true" "false"
302 // wikiLink : link of the wiki page to publish
303 // file : name of the file to be published
304
Jeremy Ronquillo31a3eb32019-08-02 13:30:37 -0700305 if ( graphs.isPostingResult( isManualRun, isPostResult ) ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700306 publishConfluence siteName: 'wiki.onosproject.org', pageName: wikiLink, spaceName: 'ONOS',
307 attachArchivedArtifacts: true, buildIfUnstable: true,
308 editorList: [ confluenceWritePage( confluenceFile( file ) ) ]
309 }
310}
311
Jon Halld4f33e12020-07-29 14:50:34 -0700312def postLogs( prefix ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700313 // posting logs of the onos jobs specifically SR tests
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700314 // prefix : branch prefix ( master, 2.1, 1.15 ... )
315
316 resultURL = ""
Jon Hallc68e2162020-07-29 10:50:09 -0700317 if ( category == "SR" || category == "SR-StratumBMv2" || category == "SR-Tofino" ){
Jon Hall77018912020-12-11 18:54:01 -0800318 if ( category == "SR-Tofino" ){
319 prefix = "Tofino"
320 }
321 node( params.assignedNode ) {
322 def post = build job: "SR-log-" + prefix, propagate: false
323 resultURL = post.getAbsoluteUrl()
324 }
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700325 }
326 return resultURL
327}
328
Jon Halld4f33e12020-07-29 14:50:34 -0700329def analyzeResult( prop, workSpace, TestONTest, JenkinsLabel, resultURL, wikiLink, isSCPF ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700330 // analyzing the result of the test and send to slack if any abnormal result is logged.
331 // prop : property dictionary
332 // workSpace : workSpace where the result file is saved
Jon Halld4f33e12020-07-29 14:50:34 -0700333 // TestONTest : TestON name of the test
334 // JenkinsLabel : Jenkins name of the test. Example: SCPFflowTPFobj
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700335 // resultURL : url for the logs for SR tests. Will not be posted if it is empty
336 // wikiLink : link of the wiki page where the result was posted
337 // isSCPF : Check if it is SCPF. If so, it won't post the wiki link.
338
339 node( testStation ) {
Jon Halld4f33e12020-07-29 14:50:34 -0700340 def alarmFile = workSpace + "/" + TestONTest + "Alarm.txt"
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700341 if ( fileExists( alarmFile ) ) {
342 def alarmContents = readFile( alarmFile )
343 slackSend( channel: "#jenkins-related",
344 color: "FF0000",
Jon Halld4f33e12020-07-29 14:50:34 -0700345 message: "[" + prop[ "ONOSBranch" ] + "] " + JenkinsLabel + " : triggered alarms:\n" +
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700346 alarmContents + "\n" +
347 "[TestON log] : \n" +
348 "https://jenkins.onosproject.org/blue/organizations/jenkins/${ env.JOB_NAME }/detail/${ env.JOB_NAME }/${ env.BUILD_NUMBER }/pipeline" +
349 ( isSCPF ? "" : ( "\n[Result on Wiki] : \n" +
350 "https://wiki.onosproject.org/display/ONOS/" +
351 wikiLink.replaceAll( "\\s", "+" ) ) ) +
352 ( resultURL != "" ? ( "\n[Karaf log] : \n" +
353 resultURL + "artifact/" ) : "" ),
You Wang26103292020-08-03 15:36:49 -0700354 teamDomain: 'onf-community' )
Jeremy Ronquilloe4e83912019-07-29 12:58:48 -0700355 print "Abnormal test result."
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700356 throw new Exception( "Abnormal test result." )
357 }
358 else {
359 print "Test results are OK."
360 }
361 }
362}
363
Jon Halld4f33e12020-07-29 14:50:34 -0700364def runTest( JenkinsLabel, toBeRun, prop, TestONTest, graphOnly, testCategory,
365 graph_generator_file, graph_saved_directory ){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700366 // run the test on the machine that contains all the steps : init and run test, copy files, publish result ...
Jon Halld4f33e12020-07-29 14:50:34 -0700367 // JenkinsLabel : name of the test in Jenkins
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700368 // toBeRun : boolean value whether the test will be run or not. If not, it won't be run but shows up with empty
369 // result on pipeline view
370 // prop : dictionary property on the machine
Jon Halld4f33e12020-07-29 14:50:34 -0700371 // TestONTest : Pure name of the test. ( ex. TestONTest of SCPFflowTpFobj will be SCPFflowTp )
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700372 // graphOnly : check if it is generating graph job. If so, it will only generate the generating graph part
373 // testCategory : Map for the test suit ( SCPF, SR, FUNC, ... ) which contains information about the tests
374 // graph_generator_file : Rscript file with the full path.
375 // graph_saved_directory : where the generated graph will be saved to.
376
377 return {
378 catchError {
Jon Halld4f33e12020-07-29 14:50:34 -0700379 stage( JenkinsLabel ) {
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700380 if ( toBeRun ){
Jon Halld4f33e12020-07-29 14:50:34 -0700381 def workSpace = "/var/jenkins/workspace/" + JenkinsLabel
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700382 def fileContents = ""
Jon Hall1d1c4512020-07-29 16:10:40 -0700383 testArguments = testCategory[ JenkinsLabel ].keySet().contains( "arguments" ) ? testCategory[ JenkinsLabel ][ "arguments" ] : ""
Jon Hall4dc60b12020-12-15 16:46:06 -0800384 isTofino = testCategory[ JenkinsLabel ][ "category" ] == "SR-Tofino"
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700385 node( testStation ) {
386 withEnv( [ 'ONOSBranch=' + prop[ "ONOSBranch" ],
387 'ONOSJAVAOPTS=' + prop[ "ONOSJAVAOPTS" ],
388 'TestONBranch=' + prop[ "TestONBranch" ],
389 'ONOSTag=' + prop[ "ONOSTag" ],
390 'WikiPrefix=' + prop[ "WikiPrefix" ],
391 'WORKSPACE=' + workSpace ] ) {
392 if ( !graphOnly ){
393 if ( isSCPF ){
394 // Remove the old database file
Jon Halld4f33e12020-07-29 14:50:34 -0700395 sh SCPFfuncs.cleanupDatabaseFile( JenkinsLabel )
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700396 }
Jon Hall4dc60b12020-12-15 16:46:06 -0800397 if ( !isTofino ) {
398 sh script: configureJavaVersion(), label: "Configure Java Version"
399 sh script: initTest(), label: "Test Initialization: stc shutdown; stc teardown; ./cleanup.sh"
400 }
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700401 catchError{
Jon Halld4f33e12020-07-29 14:50:34 -0700402 sh script: runTestCli_py( TestONTest, testArguments ), label: ( "Run Test: ./cli.py run " + TestONTest + " " + testArguments )
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700403 }
Jon Hall4dc60b12020-12-15 16:46:06 -0800404 if ( !isTofino ) {
405 catchError{
406 sh script: concludeRunTest(), label: "Conclude Running Test: ./cleanup.sh; git clean -df"
407 }
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700408 }
409 catchError{
410 // For the Wiki page
Jon Halld4f33e12020-07-29 14:50:34 -0700411 sh script: cleanAndCopyFiles( TestONTest ), label: "Clean and Copy Files"
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700412 }
413 }
Jon Halld4f33e12020-07-29 14:50:34 -0700414 graphs.databaseAndGraph( prop, JenkinsLabel, TestONTest, graphOnly,
415 graph_generator_file, graph_saved_directory )
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700416 if ( !graphOnly ){
Jon Halld4f33e12020-07-29 14:50:34 -0700417 sh script: fetchLogs( TestONTest ), label: "Fetch Logs"
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700418 if ( !isSCPF ){
419 publishToConfluence( prop[ "manualRun" ], prop[ "postResult" ],
Jon Halld4f33e12020-07-29 14:50:34 -0700420 prop[ "WikiPrefix" ] + "-" + testCategory[ JenkinsLabel ][ 'wikiName' ],
421 workSpace + "/" + testCategory[ JenkinsLabel ][ 'wikiFile' ] )
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700422 }
423 }
424 }
425 }
426 graphs.postResult( prop, graphOnly, nodeLabel )
427 if ( !graphOnly ){
Jon Halld4f33e12020-07-29 14:50:34 -0700428 def resultURL = postLogs( prop[ "WikiPrefix" ] )
429 analyzeResult( prop, workSpace, TestONTest, JenkinsLabel, resultURL,
430 isSCPF ? "" : testCategory[ JenkinsLabel ][ 'wikiName' ],
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700431 isSCPF )
432 }
Jeremy Ronquillob8aac442019-07-31 13:28:01 -0700433 } else {
Jon Halld4f33e12020-07-29 14:50:34 -0700434 echo JenkinsLabel + " is not being run today. Leaving the rest of stage contents blank."
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700435 }
436 }
437 }
438 }
439}
440
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700441def generateGraphs(){
Jeremy Ronquillo06950992019-07-09 11:16:49 -0700442 if ( category != "SCPF" ){
443 // generate the overall graph of the non SCPF tests.
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700444 graphs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ], nodeLabel, category )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700445 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700446}
447
448def sendToSlack(){
Jeremy Ronquillo336110a2019-07-11 14:20:40 -0700449 // send the result of the test to the slack when it is not manually running.
450 // start : start time of the test
451 // isManualRun : string that is whether "false" or "true"
452 // branch : branch of the onos.
453
454 try {
455 if ( prop[ "manualRun" ] == "false" ){
456 end = getCurrentTime()
457 TimeDuration duration = TimeCategory.minus( end, start )
458 // FIXME: for now we disable notifications of normal test results
459 /*
460 slackSend( color: "#5816EE",
461 message: category + "-" + prop[ "WikiPrefix" ] + " tests ended at: " + end.toString() +
462 "\nTime took : " + duration )
463 */
464 }
465 }
466 catch ( all ){
467 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700468}