// Copyright 2017 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 USECASE-pipeline-<branch>

#!groovy

// set the dependencies.
funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )

// init configuration of funcs to be USECASE
fileRelated.init()
funcs.initialize( "USECASE" );

// read the TestON.property files and save it as a dictionary
def prop = null
prop = funcs.getProperties()
USECASE = test_lists.getAllTheTests( prop[ "WikiPrefix" ] )[ "USECASE" ]

// save directory and file.
graph_generator_file = fileRelated.trendIndividual
graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-BM/"

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

// save the function of the test running into the dictionary.
def tests = [:]
for( String test : USECASE.keySet() ){
    toBeRun = testsToRun.contains( test )
    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, test, false, USECASE, graph_generator_file, graph_saved_directory )
}

// get start time of the test.
start = funcs.getCurrentTime()
// run the tests sequntially
for ( test in tests.keySet() ){
    tests[ test ].call()
}

// send the result to slack after USECASE test is done.
funcs.sendResultToSlack( start,  prop[ "manualRun" ], prop[ "WikiPrefix" ] )

// generate the overall graph for USECASE.
funcs.generateOverallGraph( prop, USECASE, graph_saved_directory )
