blob: 978819a9353ddc699a86f3dd13808903d73f0b35 [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()
42}
43
44def init(){
45 fileRelated.init()
46 test_list.init()
47 readParams()
48
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070049 funcs.initialize( category );
50
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070051 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 Ronquillo21c29fc2019-06-05 11:15:24 -070054 SCPFfuncs.init()
55 isOldFlow = prop[ "isOldFlow" ] == "true"
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070056 SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070057 } else if ( category == "SR" ){
58 // get the name of the Jenkins job.
59 jobName = env.JOB_NAME
60
61 // additional setup for Segment routing because it is running multiple branch concurrently on different machines.
62 funcs.additionalInitForSR( jobName )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070063 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
64 } else {
65 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070066 }
67
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070068 // get the list of the test and init branch to it.
69 testsFromList = test_list.getTestsFromCategory( category )
70
71 initGraphPaths()
72
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070073 testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] )
74 testsToRun = test_list.getTestsFromStringList( testsToRunStrList )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070075}
76
77def readParams(){
78 category = params.Category // "FUNC", "HA", "USECASE", etc.
79 branch = params.Branch
80}
81
82def initGraphPaths(){
83 graphPaths.put( "trendIndividual", fileRelated.trendIndividual )
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070084 if ( category == "SR" ){
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070085 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" )
86 } else if ( category == "SRHA" ) {
87 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" )
88 } else {
89 graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
90 }
91}
92
93def runTests(){
94 // run the test sequentially and save the function into the dictionary.
95 for ( String test : testsToRun.keySet() ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070096 def toBeRun = test
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070097 def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
98 def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
99 pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
100 testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
101 }
102
103 // get the start time of the test.
104 start = funcs.getCurrentTime()
105
106 // run the tests sequentially.
107 for ( test in pipeline.keySet() ){
108 pipeline[ test ].call()
109 }
110}
111
112def generateGraphs(){
113 // generate the overall graph of the FUNC tests.
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -0700114 funcs.generateOverallGraph( prop, testsToRunStrList, graphPaths[ "saveDirectory" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700115}
116
117def sendToSlack(){
118 // send the notification to Slack that running FUNC tests was ended.
119 funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
120}