blob: da75d4dff28e2def7e040a592fe0ed5611c19299 [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
Jeremy Ronquillo62199e72019-07-02 14:24:31 -070053 funcs.initialize( category, SCPFfuncs );
Jeremy Ronquillo5066a3d2019-07-02 13:55:56 -070054 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070055
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" ){
Jeremy Ronquillo62199e72019-07-02 14:24:31 -070060 funcs.initialize( category );
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070061 // get the name of the Jenkins job.
62 jobName = env.JOB_NAME
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070063 // 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 {
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070067 funcs.initialize( category );
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070068 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070069 }
70
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070071 // get the list of the test and init branch to it.
72 testsFromList = test_list.getTestsFromCategory( category )
73
74 initGraphPaths()
75
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070076 testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] )
77 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070078}
79
80def readParams(){
81 category = params.Category // "FUNC", "HA", "USECASE", etc.
82 branch = params.Branch
83}
84
85def initGraphPaths(){
86 graphPaths.put( "trendIndividual", fileRelated.trendIndividual )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070087 if ( category == "SR" ){
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070088 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" )
89 } else if ( category == "SRHA" ) {
90 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -070091 } else if ( category == "SCPF" || category == "USECASE" ){
92 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-BM/" )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070093 } else {
94 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
95 }
96}
97
98def runTests(){
99 // run the test sequentially and save the function into the dictionary.
100 for ( String test : testsToRun.keySet() ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -0700101 def toBeRun = test
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700102 def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
103 def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
104 pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
105 testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
106 }
107
108 // get the start time of the test.
109 start = funcs.getCurrentTime()
110
111 // run the tests sequentially.
112 for ( test in pipeline.keySet() ){
113 pipeline[ test ].call()
114 }
115}
116
117def generateGraphs(){
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700118 if ( category == "SCPF" ){
119 jobToRun = "manual-graph-generator-SCPF"
120 ONOSbranchParam = [ $class: 'StringParameterValue', name: 'ONOSbranch', value: test_list.addPrefixToBranch( branch ) ]
121 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: true ]
122 // leaving Test param empty to use default values
123 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
124
125 isOldFlowParam = [ $class: 'BooleanParameterValue', name: 'isOldFlow', value: false ]
126 build job: jobToRun, propagate: false, parameters: [ ONOSbranchParam, isOldFlowParam ]
127 } else {
128 // generate the overall graph of the FUNC tests.
129 funcs.generateOverallGraph( prop, testsToRunStrList, graphPaths[ "saveDirectory" ] )
130 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700131}
132
133def sendToSlack(){
134 // send the notification to Slack that running FUNC tests was ended.
135 funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
136}