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 |
| 30 | branch = null |
| 31 | testsFromList = [:] |
| 32 | graphPaths = [:] |
| 33 | pipeline = [:] |
| 34 | |
| 35 | main() |
| 36 | |
| 37 | def main(){ |
| 38 | init() |
| 39 | runTests() |
| 40 | } |
| 41 | |
| 42 | def init(){ |
| 43 | fileRelated.init() |
| 44 | test_list.init() |
| 45 | readParams() |
| 46 | |
| 47 | if ( category == "SCPF" ){ |
| 48 | SCPFfuncs.init() |
| 49 | isOldFlow = prop[ "isOldFlow" ] == "true" |
| 50 | SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] |
| 51 | } else if ( category == "SR" ){ |
| 52 | // get the name of the Jenkins job. |
| 53 | jobName = env.JOB_NAME |
| 54 | |
| 55 | // additional setup for Segment routing because it is running multiple branch concurrently on different machines. |
| 56 | funcs.additionalInitForSR( jobName ) |
| 57 | } |
| 58 | |
| 59 | funcs.initialize( category ); |
| 60 | |
| 61 | // Read the TestONOS.property from the VM |
| 62 | prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) ) |
| 63 | |
| 64 | // get the list of the test and init branch to it. |
| 65 | testsFromList = test_list.getTestsFromCategory( category ) |
| 66 | |
| 67 | initGraphPaths() |
| 68 | |
| 69 | testsToRun = funcs.getTestsToRun( prop[ "Tests" ] ) |
| 70 | } |
| 71 | |
| 72 | def readParams(){ |
| 73 | category = params.Category // "FUNC", "HA", "USECASE", etc. |
| 74 | branch = params.Branch |
| 75 | } |
| 76 | |
| 77 | def initGraphPaths(){ |
| 78 | graphPaths.put( "trendIndividual", fileRelated.trendIndividual ) |
| 79 | if ( catetgory == "SR" ){ |
| 80 | graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" ) |
| 81 | } else if ( category == "SRHA" ) { |
| 82 | graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" ) |
| 83 | } else { |
| 84 | graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" ) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | def runTests(){ |
| 89 | // run the test sequentially and save the function into the dictionary. |
| 90 | for ( String test : testsToRun.keySet() ){ |
| 91 | def toBeRun = testsToRun.contains( test ) |
| 92 | def stepName = ( toBeRun ? "" : "Not " ) + "Running $test" |
| 93 | def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test ) |
| 94 | pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false, |
| 95 | testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] ) |
| 96 | } |
| 97 | |
| 98 | // get the start time of the test. |
| 99 | start = funcs.getCurrentTime() |
| 100 | |
| 101 | // run the tests sequentially. |
| 102 | for ( test in pipeline.keySet() ){ |
| 103 | pipeline[ test ].call() |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | def generateGraphs(){ |
| 108 | // generate the overall graph of the FUNC tests. |
| 109 | funcs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ] ) |
| 110 | } |
| 111 | |
| 112 | def sendToSlack(){ |
| 113 | // send the notification to Slack that running FUNC tests was ended. |
| 114 | funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] ) |
| 115 | } |