#!groovy

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()
current_version = "master"
previous_version = "1.13"
before_previous_version = "1.12"
funcs.initializeTrend( "Fabric" );
funcs.initialize( "Fabric" )
triggerFuncs.init( funcs )

wikiContents = ""
testcases = [
    "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
    "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
    "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
    "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
    "SR1" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
    "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
]
Prefix_organizer = [
    "FU" : "FUNC",
    "HA" : "HA",
    "PL" : "USECASE",
    "SA" : "USECASE",
    "SC" : "SCPF",
    "SR" : "SR",
    "US" : "USECASE",
    "VP" : "USECASE"
]

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 ( manually_run ){
    onos_b = params.ONOSVersion
}
AllTheTests = test_lists.getAllTheTests( onos_b )

day = ""
SCPF_choices = ""
USECASE_choices = ""
FUNC_choices = ""
HA_choices = ""
SR_choices = ""
stat_graph_generator_file = fileRelated.histogramMultiple
pie_graph_generator_file = fileRelated.pieMultiple
graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric/"

post_result = params.PostResult
if( !manually_run ){
    slackSend( channel:'sr-failures', color:'#03CD9F',
               message:":sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:\n"
                        + "Starting tests on : " + now.toString()
                        + "\n:sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles::sparkles:" )

    SR_choices += adder( "SR", "basic", true )
    if ( today == Calendar.FRIDAY ){
        SR_choices += adder( "SR", "extra_A", true )
    } else if( today == Calendar.SATURDAY ){
        SR_choices += adder( "SR", "extra_B", true )
    }
    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{
    testcases[ "SR" ][ "tests" ] = SR_choices
    testcases[ "SR1" ][ "tests" ] = SR_choices
    println "Defaulting to " + day + " tests:"
}

triggerFuncs.print_tests( testcases )

def runTest = [
    "Fabric2" : [:],
    "Fabric3" : [:]
]
if ( manually_run ){
    for( String test in testcases.keySet() ){
        println test
        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{
    runTest[ "Fabric2" ][ "SR1" ] = triggerFuncs.trigger_pipeline( current_version, testcases[ "SR1" ][ "tests" ], testcases[ "SR1" ][ "nodeName" ][ 0 ], "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 = [:]
finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
parallel finalList
/*
if ( !manually_run ){
    funcs.generateStatGraph( "TestStation-Fabric2s",
                             funcs.branchWithPrefix( "master" ),
                             AllTheTests,
                             stat_graph_generator_file,
                             pie_graph_generator_file,
                             graph_saved_directory )
    funcs.generateStatGraph( "TestStation-Fabric3s",
                             funcs.branchWithPrefix( "1.12" ),
                             AllTheTests,
                             stat_graph_generator_file,
                             pie_graph_generator_file,
                             graph_saved_directory )
}*/
def adder( testCat, set, getResult ){
    result = ""
    for( String test in AllTheTests[ testCat ].keySet() ){
        if( AllTheTests[ testCat ][ test ][ set ] ){
            if( getResult )
                result += test + ","
        }
    }
    return result
}
def nodeOn( branch ){
    return branch == "1.12" ? 1 : 0;
}
