#!groovy
// Copyright 2018 Open Networking Foundation (ONF)
//
// Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
// the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
// or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
//
//     TestON is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 2 of the License, or
//     (at your option) any later version.
//
//     TestON is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with TestON.  If not, see <http://www.gnu.org/licenses/>.

// This is the Jenkins script for SRHA-pipeline-<branch>

// read dependencies.
funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
test_list = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )

// init configuration to be SR
fileRelated.init()
test_list.init()
funcs.initialize( "SR" )

// Allow to run with --params-file argument
hasArgs = true

// get the name of the Jenkins job.
jobName = env.JOB_NAME

// read the TestON.property depends on which branch it is running.
// ( currently master on Fabric4, 2.1 on Fabric3 and 1.15 on Fabric2 )
def prop = null
prop = funcs.getProperties( "SRHA" )
SRHA_tests = test_list.getTestsFromCategory( "SRHA" )

// set the file paths and directory
graph_generator_file = fileRelated.trendIndividual
graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/"

// get the list of the tests.
echo( "Testcases:" )
def testsToRun = null
testsToRun = funcs.getTestsToRun( prop[ "Tests" ] )
funcs.printTestToRun( testsToRun )

// save the functions to run test in the dictionary.
def tests = [ : ]
for ( String test : SRHA_tests.keySet() ){
    toBeRun = testsToRun.contains( test )
    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
    def pureTestName = ( SRHA_tests[ test ].containsKey( "test" ) ? SRHA_tests[ test ][ "test" ].split().head() : test )
    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
                                       SRHA_tests, graph_generator_file, graph_saved_directory )
}

// get start time
start = funcs.getCurrentTime()

// run the tests sequentially
for ( test in tests.keySet() ){
    tests[ test ].call()
}
//funcs.generateOverallGraph( prop, SR, graph_saved_directory )
// send the notification of ending test after SRHA tests are done.
funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
