Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 1 | #!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 |
| 22 | funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' ) |
| 23 | test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' ) |
| 24 | fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' ) |
| 25 | SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' ) |
| 26 | |
| 27 | category = null |
| 28 | prop = null |
| 29 | testsToRun = null |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 30 | testsToRunStrList = null |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 31 | branch = null |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 32 | start = null |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 33 | testStation = null |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 34 | testsFromList = [:] |
| 35 | graphPaths = [:] |
| 36 | pipeline = [:] |
| 37 | |
| 38 | main() |
| 39 | |
| 40 | def main(){ |
| 41 | init() |
| 42 | runTests() |
Jeremy Ronquillo | bb3001f | 2019-07-01 12:57:07 -0700 | [diff] [blame] | 43 | generateGraphs() |
| 44 | sendToSlack() |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | def init(){ |
| 48 | fileRelated.init() |
| 49 | test_list.init() |
| 50 | readParams() |
| 51 | |
| 52 | if ( category == "SCPF" ){ |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 53 | // SCPF needs to obtain properties earlier |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 54 | funcs.initialize( category, testStation, nodeLabel, SCPFfuncs ); |
Jeremy Ronquillo | 5066a3d | 2019-07-02 13:55:56 -0700 | [diff] [blame] | 55 | prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) ) |
Jeremy Ronquillo | db20fa6 | 2019-07-02 13:48:08 -0700 | [diff] [blame] | 56 | |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 57 | SCPFfuncs.init() |
| 58 | isOldFlow = prop[ "isOldFlow" ] == "true" |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 59 | SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 60 | } else if ( category == "SR" ){ |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 61 | funcs.initialize( category, testStation, nodeLabel ); |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 62 | // get the name of the Jenkins job. |
| 63 | jobName = env.JOB_NAME |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 64 | prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) ) |
| 65 | } else { |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 66 | funcs.initialize( category, testStation, nodeLabel ); |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 67 | prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 70 | // get the list of the test and init branch to it. |
| 71 | testsFromList = test_list.getTestsFromCategory( category ) |
| 72 | |
| 73 | initGraphPaths() |
| 74 | |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 75 | testsToRunStrList = funcs.getTestsToRun( prop[ "Tests" ] ) |
| 76 | testsToRun = test_list.getTestsFromStringList( testsToRunStrList ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | def readParams(){ |
Jeremy Ronquillo | 6fbfdd5 | 2019-07-09 13:49:34 -0700 | [diff] [blame] | 80 | 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 Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | def initGraphPaths(){ |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 87 | graphPaths.put( "trendIndividual", fileRelated.rScriptPaths[ "scripts" ][ "trendIndividual" ] ) |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 88 | if ( category == "SR" ){ |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 89 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "base" ] + "postjob-" + ( testStation - "TestStation-" - "s" ) + "/" ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 90 | } else if ( category == "SRHA" ) { |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 91 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "Fabric" ] ) |
Jeremy Ronquillo | bb3001f | 2019-07-01 12:57:07 -0700 | [diff] [blame] | 92 | } else if ( category == "SCPF" || category == "USECASE" ){ |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 93 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "BM" ] ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 94 | } else { |
Jeremy Ronquillo | 1e5d7f2 | 2019-07-17 14:18:42 -0700 | [diff] [blame] | 95 | graphPaths.put( "saveDirectory", fileRelated.workspaces[ "VM" ] ) |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | |
| 99 | def runTests(){ |
| 100 | // run the test sequentially and save the function into the dictionary. |
| 101 | for ( String test : testsToRun.keySet() ){ |
Jeremy Ronquillo | a8490fb | 2019-06-26 11:59:50 -0700 | [diff] [blame] | 102 | def toBeRun = test |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 103 | 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 | |
| 118 | def generateGraphs(){ |
Jeremy Ronquillo | 0695099 | 2019-07-09 11:16:49 -0700 | [diff] [blame] | 119 | if ( category != "SCPF" ){ |
| 120 | // generate the overall graph of the non SCPF tests. |
| 121 | funcs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ] ) |
Jeremy Ronquillo | bb3001f | 2019-07-01 12:57:07 -0700 | [diff] [blame] | 122 | } |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | def sendToSlack(){ |
Jeremy Ronquillo | 0695099 | 2019-07-09 11:16:49 -0700 | [diff] [blame] | 126 | // send the notification to Slack that running tests ended. |
Jeremy Ronquillo | 21c29fc | 2019-06-05 11:15:24 -0700 | [diff] [blame] | 127 | funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] ) |
| 128 | } |