blob: d60df2e30e141b792b3297116ec9fc260f405613 [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 Ronquillo6fbfdd52019-07-09 13:49:34 -070033testStation = null
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070034testsFromList = [:]
35graphPaths = [:]
36pipeline = [:]
37
38main()
39
40def main(){
41 init()
42 runTests()
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -070043 generateGraphs()
44 sendToSlack()
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070045}
46
47def init(){
48 fileRelated.init()
49 test_list.init()
50 readParams()
51
52 if ( category == "SCPF" ){
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070053 // SCPF needs to obtain properties earlier
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070054 funcs.initialize( category, testStation, nodeLabel, SCPFfuncs );
Jeremy Ronquillo5066a3d2019-07-02 13:55:56 -070055 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
Jeremy Ronquillodb20fa62019-07-02 13:48:08 -070056
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070057 SCPFfuncs.init()
58 isOldFlow = prop[ "isOldFlow" ] == "true"
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070059 SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070060 } else if ( category == "SR" ){
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070061 funcs.initialize( category, testStation, nodeLabel );
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070062 // get the name of the Jenkins job.
63 jobName = env.JOB_NAME
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070064 prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
65 } else {
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070066 funcs.initialize( category, testStation, nodeLabel );
Jeremy Ronquilloa8490fb2019-06-26 11:59:50 -070067 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(){
Jeremy Ronquillo6fbfdd52019-07-09 13:49:34 -070080 category = params.Category // "FUNC", "HA", "USECASE", etc.
81 branch = params.Branch // "1.15", "2.1", "master", etc.
82 testStation = params.TestStation // "TestStation-BMs", etc.
83 nodeLabel = params.NodeLabel // "BM", "VM", "Fabric-1.x", etc.
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -070084}
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 Ronquillo06950992019-07-09 11:16:49 -0700119 if ( category != "SCPF" ){
120 // generate the overall graph of the non SCPF tests.
121 funcs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ] )
Jeremy Ronquillobb3001f2019-07-01 12:57:07 -0700122 }
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700123}
124
125def sendToSlack(){
Jeremy Ronquillo06950992019-07-09 11:16:49 -0700126 // send the notification to Slack that running tests ended.
Jeremy Ronquillo21c29fc2019-06-05 11:15:24 -0700127 funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
128}