blob: 9ac5bc06917981c4c4e7c37d3e8d7b07dbdd6205 [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
21// read the dependency files
22funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
23test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
24fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )
25SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
26
27category = null
28prop = null
29testsToRun = null
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070030testsToRunStrList = null
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070031branch = null
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070032start = null
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070033testsFromList = [:]
34graphPaths = [:]
35pipeline = [:]
36
37main()
38
39def main(){
40 init()
41 runTests()
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -070042 generateGraphs()
43 sendToSlack()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070044}
45
46def init(){
47 fileRelated.init()
48 test_list.init()
49 readParams()
50
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070051 funcs.initialize( category );
52
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070053 if ( category == "SCPF" ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070054 // SCPF needs to obtain properties earlier
55 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070056 SCPFfuncs.init()
57 isOldFlow = prop[ "isOldFlow" ] == "true"
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070058 SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070059 } else if ( category == "SR" ){
60 // get the name of the Jenkins job.
61 jobName = env.JOB_NAME
62
63 // additional setup for Segment routing because it is running multiple branch concurrently on different machines.
64 funcs.additionalInitForSR( jobName )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070065 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
66 } else {
67 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070068 }
69
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070070 // get the list of the test and init branch to it.
71 testsFromList = test_list.getTestsFromCategory( category )
72
73 initGraphPaths()
74
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070075 testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] )
76 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070077}
78
79def readParams(){
80 category = params.Category // "FUNC", "HA", "USECASE", etc.
81 branch = params.Branch
82}
83
84def initGraphPaths(){
85 graphPaths.put( "trendIndividual", fileRelated.trendIndividual )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070086 if ( category == "SR" ){
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070087 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" )
88 } else if ( category == "SRHA" ) {
89 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -070090 } else if ( category == "SCPF" || category == "USECASE" ){
91 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-BM/" )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070092 } else {
93 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
94 }
95}
96
97def runTests(){
98 // run the test sequentially and save the function into the dictionary.
99 for ( String test : testsToRun.keySet() ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -0700100 def toBeRun = test
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700101 def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
102 def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
103 pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
104 testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
105 }
106
107 // get the start time of the test.
108 start = funcs.getCurrentTime()
109
110 // run the tests sequentially.
111 for ( test in pipeline.keySet() ){
112 pipeline[ test ].call()
113 }
114}
115
116def generateGraphs(){
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700117 if ( category == "SCPF" ){
118 jobToRun = "manual-graph-generator-SCPF"
119 ONOSbranchParam = [ $class: 'StringParameterValue', name: 'ONOSbranch', value: test_list.addPrefixToBranch( branch ) ]
120 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: true ]
121 // leaving Test param empty to use default values
122 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
123
124 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: false ]
125 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
126 } else {
127 // generate the overall graph of the FUNC tests.
128 funcs.generateOverallGraph( prop, testsToRunStrList, graphPaths[ "saveDirectory" ] )
129 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700130}
131
132def sendToSlack(){
133 // send the notification to Slack that running FUNC tests was ended.
134 funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
135}