blob: 28e0f4b33c636983c0984570e597b7af2dc6675a [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
51 if ( category == "SCPF" ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070052 // SCPF needs to obtain properties earlier
53 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070054 funcs.initialize( "SCPF", SCPFfuncs )
55
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
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070062 funcs.initialize( category );
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070063
64 // additional setup for Segment routing because it is running multiple branch concurrently on different machines.
65 funcs.additionalInitForSR( jobName )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070066 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
67 } else {
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070068 funcs.initialize( category );
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070069 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070070 }
71
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070072 // get the list of the test and init branch to it.
73 testsFromList = test_list.getTestsFromCategory( category )
74
75 initGraphPaths()
76
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070077 testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] )
78 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070079}
80
81def readParams(){
82 category = params.Category // "FUNC", "HA", "USECASE", etc.
83 branch = params.Branch
84}
85
86def initGraphPaths(){
87 graphPaths.put( "trendIndividual", fileRelated.trendIndividual )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070088 if ( category == "SR" ){
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070089 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" )
90 } else if ( category == "SRHA" ) {
91 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -070092 } else if ( category == "SCPF" || category == "USECASE" ){
93 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-BM/" )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070094 } else {
95 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
96 }
97}
98
99def runTests(){
100 // run the test sequentially and save the function into the dictionary.
101 for ( String test : testsToRun.keySet() ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -0700102 def toBeRun = test
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700103 def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
104 def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
105 pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
106 testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
107 }
108
109 // get the start time of the test.
110 start = funcs.getCurrentTime()
111
112 // run the tests sequentially.
113 for ( test in pipeline.keySet() ){
114 pipeline[ test ].call()
115 }
116}
117
118def generateGraphs(){
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700119 if ( category == "SCPF" ){
120 jobToRun = "manual-graph-generator-SCPF"
121 ONOSbranchParam = [ $class: 'StringParameterValue', name: 'ONOSbranch', value: test_list.addPrefixToBranch( branch ) ]
122 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: true ]
123 // leaving Test param empty to use default values
124 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
125
126 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: false ]
127 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
128 } else {
129 // generate the overall graph of the FUNC tests.
130 funcs.generateOverallGraph( prop, testsToRunStrList, graphPaths[ "saveDirectory" ] )
131 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700132}
133
134def sendToSlack(){
135 // send the notification to Slack that running FUNC tests was ended.
136 funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
137}