Adding timeout to Jenkins TestON Pipelines
Change-Id: Ib4fd0dd842bc33eebd227a5ebecad640868291d1
diff --git a/TestON/JenkinsFile/CommonJenkinsFile.groovy b/TestON/JenkinsFile/CommonJenkinsFile.groovy
index 2edc09d..33ed5d1 100644
--- a/TestON/JenkinsFile/CommonJenkinsFile.groovy
+++ b/TestON/JenkinsFile/CommonJenkinsFile.groovy
@@ -27,6 +27,8 @@
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
+INITIALIZATION_TIMEOUT_MINUTES = 10 // timeout init() function if it takes too long.
+
category = null
prop = null
testsToRun = null
@@ -39,6 +41,8 @@
testsOverride = null
isGraphOnly = false
isSCPF = false
+pipelineTimeout = null
+
testsFromList = [:]
graphPaths = [:]
pipeline = [:]
@@ -46,10 +50,14 @@
main()
def main(){
- init()
- runTests()
- generateGraphs()
- sendToSlack()
+ timeout( time: INITIALIZATION_TIMEOUT_MINUTES, unit: "MINUTES" ){
+ init()
+ }
+ timeout( time: pipelineTimeout, unit: "MINUTES" ){
+ runTests()
+ generateGraphs()
+ sendToSlack()
+ }
}
def init(){
@@ -92,6 +100,7 @@
nodeLabel = params.NodeLabel // "BM", "VM", "Fabric-1.x", etc.
testsOverride = params.TestsOverride // "FUNCflow, FUNCintent, [...]", overrides property file
isGraphOnly = params.OnlyRefreshGraphs // true or false
+ pipelineTimeout = params.TimeOut.toInteger() // integer minutes until the entire pipeline times out. Usually passed from upstream master-trigger job.
}
def getProperties(){
diff --git a/TestON/JenkinsFile/MasterTrigger.groovy b/TestON/JenkinsFile/MasterTrigger.groovy
index c095810..c94aecb 100644
--- a/TestON/JenkinsFile/MasterTrigger.groovy
+++ b/TestON/JenkinsFile/MasterTrigger.groovy
@@ -28,6 +28,8 @@
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
+INITIALIZATION_TIMEOUT_MINUTES = 10 // timeout init() function if it takes too long.
+
onos_tag = null
manually_run = null
now = null
@@ -39,6 +41,7 @@
isFabric = null
testsParam = null
simulateDay = null
+pipelineTimeOut = null
dayMap = [:]
fullDayMap = [:]
@@ -50,9 +53,13 @@
main()
def main() {
- init()
- runTests()
- generateGraphs()
+ timeout( time: INITIALIZATION_TIMEOUT_MINUTES, unit: "MINUTES" ){
+ init()
+ }
+ timeout( time: pipelineTimeOut, unit: "MINUTES" ){
+ runTests()
+ generateGraphs()
+ }
}
// **************
@@ -92,6 +99,7 @@
testsParam = params.Tests
isFabric = params.isFabric
simulateDay = params.simulate_day
+ pipelineTimeOut = params.TimeOut.toInteger()
}
// Set tests based on day of week
@@ -362,7 +370,6 @@
def test_branch = test_list.addPrefixToBranch( branch )
assignedNode = null
node( label: nodeLabel ) {
-
envSetup( onos_branch, test_branch, onosTag, jobOn, manuallyRun, nodeLabel )
exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, post_result, manuallyRun, onosTag, isOldFlow, nodeLabel )
assignedNode = env.NODE_NAME
@@ -372,7 +379,8 @@
build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ],
[ $class: 'StringParameterValue', name: 'Branch', value: branch ],
[ $class: 'StringParameterValue', name: 'TestStation', value: assignedNode ],
- [ $class: 'StringParameterValue', name: 'NodeLabel', value: nodeLabel ] ]
+ [ $class: 'StringParameterValue', name: 'NodeLabel', value: nodeLabel ],
+ [ $class: 'StringParameterValue', name: 'TimeOut', value: pipelineTimeOut.toString() ] ]
}
def trigger_pipeline( branch, tests, nodeLabel, jobOn, manuallyRun, onosTag ){