blob: d7add2d157fbf7c5afaafce18dbf753e94cf0101 [file] [log] [blame]
Jeremy Ronquilloc3188b62019-08-19 15:51:17 -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
21test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
22fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
23
24category = null
25prop = null
26testsToRun = null
27testsToRunStrList = null
28branch = null
29branchWithPrefix = null
30nodeLabel = null
31testStation = null
32testsOverride = null
33pipelineTimeout = null
34
35testsFromList = [:]
36pipeline = [:]
37
38def main(){
39 pipelineTimeout = params.TimeOut.toInteger() // integer minutes until the entire pipeline times out. Usually passed from upstream master-trigger job.
40 timeout( time: pipelineTimeout, unit: "MINUTES" ){
41 init()
42 runTests()
43 }
44}
45
46main()
47
48def init(){
49 fileRelated.init()
50 test_list.init()
51 readParams()
52
53 if ( branch == "manually" ){
54 echo '''Warning: entered branch was: "manually". Defaulting to master branch.'''
55 branch = "master"
56 branchWithPrefix = test_list.addPrefixToBranch( branch )
57 }
58 prop = getProperties()
59
60 // get the list of the tests from category
61 testsFromList = test_list.getTestsFromCategory( category )
62
63 tokenizeTokens = "\n;, "
64
65 if ( testsOverride == "" || testsOverride == null ){
66 testsToRunStrList = prop[ "Tests" ].tokenize( tokenizeTokens )
67 } else {
68 testsToRunStrList = testsOverride.tokenize( tokenizeTokens )
69 }
70 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
71}
72
73def getProperties(){
74 // get the properties of the test by reading the TestONOS.property
75
76 filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
77
78 node( testStation ) {
79 return readProperties( file: filePath )
80 }
81}
82
83def readParams(){
84 category = params.Category // "MO", etc.
85 branch = params.Branch // "1.15", "2.1", "master", etc.
86 branchWithPrefix = test_list.addPrefixToBranch( branch )
87 testStation = params.TestStation // "TestStation-BMs", etc.
88 nodeLabel = params.NodeLabel // "BM", "VM", "Fabric-1.x", etc.
89 testsOverride = params.TestsOverride // "FUNCflow, FUNCintent, [...]", overrides property file
90}
91
92def runTests(){
93 // run the test sequentially and save the function into the dictionary.
94 for ( String test : testsFromList.keySet() ){
95 toBeRun = testsToRun.keySet().contains( test )
96 stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
97 pipeline[ stepName ] = runMOtest( test,
98 toBeRun )
99 }
100
101 // run the tests sequentially.
102 for ( test in pipeline.keySet() ){
103 pipeline[ test ].call()
104 }
105}
106
107def runMOtest( test, toBeRun ){
108 return {
109 catchError {
110 stage( test ){
111 if ( toBeRun ){
112 node( testStation ) {
113 sh script: '''. ~/.profile
114 cd ~/onos-test
115 make clean
116 make integration
117 ''', label: "make integration"
118 }
119 }
120 }
121 }
122 }
123}