#!groovy
// 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 the fabric-pipeline-trigger

// init dependencies functions
funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
test_lists = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy' )
triggerFuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/TriggerFuncs.groovy' )
fileRelated = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsPathAndFiles.groovy' )

fileRelated.init()

// set the versions of the onos.
current_version = "master"
previous_version = "1.13"
before_previous_version = "1.12"

// Function that will initialize the configuration of the Fabric.
funcs.initializeTrend( "Fabric" )
funcs.initialize( "Fabric" )
triggerFuncs.init( funcs )

// Wiki contents is the contents for https://wiki.onosproject.org/display/ONOS/Automated+Test+Schedule
// It will only be used by the VM_BMJenkinsTrigger not in here.
wikiContents = ""

testcases = [
        "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ],
        "HA": [ tests: "", nodeName: "VM", wikiContent: "" ],
        "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ],
        "SR": [ tests: "", nodeName: [ "Fabric2", "Fabric3", "Fabric4" ], wikiContent: "" ],
        "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
]

// set some variables from the parameter
manually_run = params.manual_run
onos_b = current_version
test_branch = ""
onos_tag = params.ONOSTag
isOldFlow = true

// Set tests based on day of week
def now = funcs.getCurrentTime()
print now.toString()
today = now[ Calendar.DAY_OF_WEEK ]

// if it is manually run, it will set the onos version to be what it was passed by.
// Currently, SR-pipeline-manually is not supported due to the special way of it is executed.
if ( manually_run ){
    onos_b = params.ONOSVersion
}

// get the list of the tests from the JenkinsTestONTests.groovy
AllTheTests = test_lists.getAllTheTests( onos_b )


day = ""

// list of the test on each test category will be run.
SCPF_choices = ""
USECASE_choices = ""
FUNC_choices = ""
HA_choices = ""
SR_choices = ""

// initialize the graph generating files.
stat_graph_generator_file = fileRelated.histogramMultiple
pie_graph_generator_file = fileRelated.pieMultiple
graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"

// get the post_result. This will be affected only for the manual runs.
post_result = params.PostResult
if ( !manually_run ){
    // If it is automated running, it will post the beginning message to the channel.
    slackSend( channel: 'sr-failures', color: '#03CD9F',
               message: ":sparkles:" * 16 + "\n" +
                        "Starting tests on : " + now.toString() +
                        "\n" + ":sparkles:" * 16 )

    // Choices will get the list of the test with Segment Routing type tests.
    SR_choices += adder( "SR", "basic", true )
    if ( today == Calendar.FRIDAY ){
        // if today is Friday, it will also test tests with extra_A category
        SR_choices += adder( "SR", "extra_A", true )
    }
    else if ( today == Calendar.SATURDAY ){
        // if today is Saturday, it will add the test with extra_B category
        SR_choices += adder( "SR", "extra_B", true )
    }
    // removing last comma added at the end of the last test name.
    SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
}


if ( manually_run ){
    testcases = triggerFuncs.organize_tests( params.Tests, testcases )

    isOldFlow = params.isOldFlow
    println "Tests to be run manually : "
}
else {
    // set the list of the tests to run.
    testcases[ "SR" ][ "tests" ] = SR_choices
    println "Defaulting to " + day + " tests:"
}

// print out the list of the test to run on Jenkins
triggerFuncs.print_tests( testcases )

// This will hold the block of code to be run.
def runTest = [
        "Fabric2": [ : ],
        "Fabric3": [ : ],
        "Fabric4": [ : ]
]
if ( manually_run ){
    // for manual run situation.
    for ( String test in testcases.keySet() ){
        println test
        // Unless the list of the tests on the test category is empty, it will save the block of code to run in dictionary.
        if ( testcases[ test ][ "tests" ] != "" ){
            runTest[ testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ] ][ test ] = triggerFuncs.
                    trigger_pipeline( onos_b,
                                      testcases[ test ][ "tests" ],
                                      testcases[ test ][ "nodeName" ][ nodeOn( onos_b ) ],
                                      test,
                                      manually_run,
                                      onos_tag )
        }
    }
}
else {
    // for automated situation, it will save current version to Fabric4, previous version to Fabric2 and before_previous_version to Fabric3.
    runTest[ "Fabric4" ][ "SR" ] = triggerFuncs.trigger_pipeline( current_version,
                                                                  testcases[ "SR" ][ "tests" ],
                                                                  testcases[ "SR" ][ "nodeName" ][ 2 ],
                                                                  "SR",
                                                                  manually_run, onos_tag )
    runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( previous_version,
                                                                  testcases[ "SR" ][ "tests" ],
                                                                  testcases[ "SR" ][ "nodeName" ][ 0 ],
                                                                  "SR",
                                                                  manually_run, onos_tag )
    runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( before_previous_version,
                                                                  testcases[ "SR" ][ "tests" ],
                                                                  testcases[ "SR" ][ "nodeName" ][ 1 ],
                                                                  "SR",
                                                                  manually_run, onos_tag )
}

def finalList = [ : ]

// It will run each category of test to run sequentially on each branch.
finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
finalList[ "Fabric4" ] = triggerFuncs.runTestSeq( runTest[ "Fabric4" ] )

// It will then run Fabric2, Fabric3 and Fabric4 concurrently.
// In our case,
//                      ----> Fabric4 : current_version
// This pipeline -----> ----> Fabric2 : previous_version
//                      ----> Fabric3 : before_previous_version
parallel finalList

// Way we are generating pie graphs. not supported in SegmentRouting yet.
/*
if ( !manually_run ){
    funcs.generateStatGraph( "TestStation-Fabric4s",
                             funcs.branchWithPrefix( current_version ),
                             AllTheTests,
                             stat_graph_generator_file,
                             pie_graph_generator_file,
                             graph_saved_directory )
    funcs.generateStatGraph( "TestStation-Fabric2s",
                             funcs.branchWithPrefix( previous_version ),
                             AllTheTests,
                             stat_graph_generator_file,
                             pie_graph_generator_file,
                             graph_saved_directory )
    funcs.generateStatGraph( "TestStation-Fabric3s",
                             funcs.branchWithPrefix( before_previous_version ),
                             AllTheTests,
                             stat_graph_generator_file,
                             pie_graph_generator_file,
                             graph_saved_directory )
}*/

// Way to add list of the tests with specific category to the result
def adder( testCat, set, getResult ){
    // testCat : test Category ( Eg. FUNC, HA, SR ... )
    // set : set of the test ( Eg. basic, extra_A ... )
    // if getResult == true, it will add the result.
    result = ""
    for ( String test in AllTheTests[ testCat ].keySet() ){
        if ( AllTheTests[ testCat ][ test ][ set ] ){
            if ( getResult ){
                result += test + ","
            }
        }
    }
    return result
}

// check which node is on.
def nodeOn( branch ){
    switch ( branch ){
        case current_version: return 2
        case previous_version: return 0
        case before_previous_version: return 1
        default: return 2
    }
}
