[ONOS-7994]: Combine TestON Pipeline Scripts Containing Similar Code

Change-Id: I1727233b87ca957c8e23c6c839232b22121847dd
diff --git a/TestON/JenkinsFile/CommonJenkinsFile.groovy b/TestON/JenkinsFile/CommonJenkinsFile.groovy
new file mode 100644
index 0000000..eb7557c
--- /dev/null
+++ b/TestON/JenkinsFile/CommonJenkinsFile.groovy
@@ -0,0 +1,115 @@
+#!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/>.
+
+// read the dependency files
+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' )
+SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
+
+category = null
+prop = null
+testsToRun = null
+branch = null
+testsFromList = [:]
+graphPaths = [:]
+pipeline = [:]
+
+main()
+
+def main(){
+    init()
+    runTests()
+}
+
+def init(){
+    fileRelated.init()
+    test_list.init()
+    readParams()
+
+    if ( category == "SCPF" ){
+        SCPFfuncs.init()
+        isOldFlow = prop[ "isOldFlow" ] == "true"
+        SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ]
+    } else if ( category == "SR" ){
+        // get the name of the Jenkins job.
+        jobName = env.JOB_NAME
+
+        // additional setup for Segment routing because it is running multiple branch concurrently on different machines.
+        funcs.additionalInitForSR( jobName )
+    }
+
+    funcs.initialize( category );
+
+    // Read the TestONOS.property from the VM
+    prop = funcs.getProperties( category, test_list.addPrefixToBranch( branch ) )
+
+    // get the list of the test and init branch to it.
+    testsFromList = test_list.getTestsFromCategory( category )
+
+    initGraphPaths()
+
+    testsToRun = funcs.getTestsToRun( prop[ "Tests" ] )
+}
+
+def readParams(){
+    category = params.Category // "FUNC", "HA", "USECASE", etc.
+    branch = params.Branch
+}
+
+def initGraphPaths(){
+    graphPaths.put( "trendIndividual", fileRelated.trendIndividual )
+    if ( catetgory == "SR" ){
+        graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/" )
+    } else if ( category == "SRHA" ) {
+        graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-Fabric" + "/" )
+    } else {
+        graphPaths.put( "saveDirectory", fileRelated.jenkinsWorkspace + "postjob-VM/" )
+    }
+}
+
+def runTests(){
+    // run the test sequentially and save the function into the dictionary.
+    for ( String test : testsToRun.keySet() ){
+        def toBeRun = testsToRun.contains( test )
+        def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
+        def pureTestName = ( testsToRun[ test ].containsKey( "test" ) ? testsToRun[ test ][ "test" ].split().head() : test )
+        pipeline[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
+                                           testsToRun, graphPaths[ "trendIndividual" ], graphPaths[ "saveDirectory" ] )
+    }
+
+    // get the start time of the test.
+    start = funcs.getCurrentTime()
+
+    // run the tests sequentially.
+    for ( test in pipeline.keySet() ){
+        pipeline[ test ].call()
+    }
+}
+
+def generateGraphs(){
+    // generate the overall graph of the FUNC tests.
+    funcs.generateOverallGraph( prop, testsToRun, graphPaths[ "saveDirectory" ] )
+}
+
+def sendToSlack(){
+    // send the notification to Slack that running FUNC tests was ended.
+    funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
+}
diff --git a/TestON/JenkinsFile/FUNCJenkinsFile b/TestON/JenkinsFile/FUNCJenkinsFile
deleted file mode 100644
index caa8669..0000000
--- a/TestON/JenkinsFile/FUNCJenkinsFile
+++ /dev/null
@@ -1,75 +0,0 @@
-#!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 FUNC-pipeline-<branch>
-
-// read the dependency files
-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' )
-
-fileRelated.init()
-test_list.init()
-
-// initialize the funcs with category of FUNC
-funcs.initialize( "FUNC" );
-
-// This is a Jenkinsfile for a scripted pipeline for the FUNC tests
-def prop = null
-
-// Read the TestONOS.property from the VM
-prop = funcs.getProperties( "FUNC" )
-
-// get the list of the test and init branch to it.
-FUNC_tests = test_list.getTestsFromCategory( "FUNC" )
-
-// init some directories
-graph_generator_file = fileRelated.trendIndividual
-graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/"
-
-// get the list of the test to run
-echo( "Testcases:" )
-def testsToRun = null
-testsToRun = funcs.getTestsToRun( prop[ "Tests" ] )
-funcs.printTestToRun( testsToRun )
-
-// run the test sequentially and save the function into the dictionary.
-def tests = [ : ]
-for ( String test : FUNC_tests.keySet() ){
-    def toBeRun = testsToRun.contains( test )
-    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-    def pureTestName = ( FUNC_tests[ test ].containsKey( "test" ) ? FUNC_tests[ test ][ "test" ].split().head() : test )
-    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
-                                       FUNC_tests, graph_generator_file, graph_saved_directory )
-}
-
-// get the start time of the test.
-start = funcs.getCurrentTime()
-
-// run the tests sequentially.
-for ( test in tests.keySet() ){
-    tests[ test ].call()
-}
-
-// generate the overall graph of the FUNC tests.
-funcs.generateOverallGraph( prop, FUNC_tests, graph_saved_directory )
-
-// send the notification to Slack that running FUNC tests was ended.
-funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
diff --git a/TestON/JenkinsFile/FabricJenkinsfileTrigger b/TestON/JenkinsFile/FabricJenkinsfileTrigger
deleted file mode 100644
index 4c9c822..0000000
--- a/TestON/JenkinsFile/FabricJenkinsfileTrigger
+++ /dev/null
@@ -1,229 +0,0 @@
-#!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_list = 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()
-test_list.init()
-
-// 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 = ""
-
-all_testcases = [:]
-
-// set some variables from the parameter
-manually_run = params.manual_run
-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 ]
-
-dayMap = [ ( Calendar.MONDAY )    : "mon",
-           ( Calendar.TUESDAY )   : "tue",
-           ( Calendar.WEDNESDAY ) : "wed",
-           ( Calendar.THURSDAY )  : "thu",
-           ( Calendar.FRIDAY )    : "fri",
-           ( Calendar.SATURDAY )  : "sat",
-           ( Calendar.SUNDAY )    : "sun" ]
-fullDayMap = [ ( Calendar.MONDAY )    : "Monday",
-               ( Calendar.TUESDAY )   : "Tuesday",
-               ( Calendar.WEDNESDAY ) : "Wednesday",
-               ( Calendar.THURSDAY )  : "Thursday",
-               ( Calendar.FRIDAY )    : "Friday",
-               ( Calendar.SATURDAY )  : "Saturday",
-               ( Calendar.SUNDAY )    : "Sunday" ]
-
-
-// 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_branches = params.branches.tokenize( "\n;, " )
-} else {
-    onos_branches = test_list.getBranchesFromDay( today )
-}
-
-testcases_template = [
-        "FUNC": [ tests: "", nodeName: "VM", wikiContent: "" ],
-        "HA": [ tests: "", nodeName: "VM", wikiContent: "" ],
-        "SCPF": [ tests: "", nodeName: "BM", wikiContent: "" ],
-        "SR": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
-        "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
-        "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
-]
-
-for ( String b in onos_branches ){
-    all_testcases.put( b, testcases_template )
-}
-
-day = ""
-
-// 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 ){
-    for ( String b in onos_branches ){
-        all_testcases[ b ] = triggerFuncs.organize_tests( params.Tests, all_testcases[ b ] )
-    }
-    isOldFlow = params.isOldFlow
-    println "Tests to be run manually : "
-} else {
-    for ( String b in onos_branches ){
-        // set the list of the tests to run.
-        all_testcases[ b ][ "SR" ][ "tests" ] += adder( "SR", dayMap[ today ], true, b )
-        all_testcases[ b ][ "SRHA" ][ "tests" ] += adder( "SRHA", dayMap[ today ], true, b )
-    }
-    println "Defaulting to " + day + " tests:"
-}
-
-// print out the list of the test to run on Jenkins
-for ( String b in onos_branches ){
-    triggerFuncs.print_tests( all_testcases[ b ] )
-}
-
-// This will hold the block of code to be run.
-def runTest = [
-
-]
-for ( String b in onos_branches ){
-    if ( manually_run ){
-        // for manual run situation.
-        for ( String test in all_testcases[ b ].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 ( all_testcases[ b ][ test ][ "tests" ] != "" ){
-                runTest[ all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( b ) ] ][ test ] = triggerFuncs.
-                        trigger_pipeline( b,
-                                          all_testcases[ b ][ test ][ "tests" ],
-                                          all_testcases[ b ][ test ][ "nodeName" ][ nodeOn( 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( "master",
-                                                                      all_testcases[ b ][ "SR" ][ "tests" ],
-                                                                      all_testcases[ b ][ "SR" ][ "nodeName" ][ 2 ],
-                                                                      "SR",
-                                                                      manually_run, onos_tag )
-        runTest[ "Fabric2" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-2.x" ),
-                                                                      all_testcases[ b ][ "SR" ][ "tests" ],
-                                                                      all_testcases[ b ][ "SR" ][ "nodeName" ][ 0 ],
-                                                                      "SR",
-                                                                      manually_run, onos_tag )
-        runTest[ "Fabric3" ][ "SR" ] = triggerFuncs.trigger_pipeline( test_list.convertBranchCodeToBranch( "onos-1.x" ),
-                                                                      all_testcases[ b ][ "SR" ][ "tests" ],
-                                                                      all_testcases[ b ][ "SR" ][ "nodeName" ][ 1 ],
-                                                                      "SR",
-                                                                      manually_run, onos_tag )
-        runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( "master",
-                                                                       all_testcases[ b ][ "SRHA" ][ "tests" ],
-                                                                       all_testcases[ b ][ "SRHA" ][ "nodeName" ],
-                                                                       "SRHA",
-                                                                       manually_run, onos_tag )
-    }
-}
-
-def finalList = [ : ]
-
-// It will run each category of test to run sequentially on each branch.
-finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
-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( category, day, getResult, branch ){
-    // category : the category of the test which will be either FUNC,HA,SR...
-    // day : the day you are trying to add (m,t,w,th... )
-    // getResult : if want to get the list of the test to be run. False will return empty list.
-    //             And once the list is empty, it will not be run.
-    def result = ""
-    selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
-
-    for ( String test in selectedTests.keySet() ){
-        if ( getResult ){
-            result += test + ","
-        }
-    }
-    return result
-}
-
-// check which node is on.
-def nodeOn( branch ){
-    switch ( branch ){
-        case "master": return 2
-        case convertBranchCodeToBranch( "onos-2.x" ): return 0
-        case convertBranchCodeToBranch( "onos-1.x" ): return 1
-        default: return 3
-    }
-}
diff --git a/TestON/JenkinsFile/HAJenkinsFile b/TestON/JenkinsFile/HAJenkinsFile
deleted file mode 100644
index b5f1a7e..0000000
--- a/TestON/JenkinsFile/HAJenkinsFile
+++ /dev/null
@@ -1,74 +0,0 @@
-#!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 HA-pipeline-<branch>
-
-// read the dependency files
-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' )
-
-fileRelated.init()
-test_list.init()
-
-// initialize the funcs with category of HA
-funcs.initialize( "HA" );
-
-// This is a Jenkinsfile for a scripted pipeline for the FUNC tests
-def prop = null
-
-// Read the TestONOS.property from the VM
-prop = funcs.getProperties( "HA" )
-
-// get the list of the test and init branch to it.
-HA_tests = test_list.getTestsFromCategory( "HA" )
-
-// init some directories
-graph_generator_file = fileRelated.trendIndividual
-graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-VM/"
-
-// get the list of the test to run
-echo( "Testcases:" )
-def testsToRun = null
-testsToRun = funcs.getTestsToRun( prop[ "Tests" ] )
-funcs.printTestToRun( testsToRun )
-
-// run the test sequentially and save the function into the dictionary.
-def tests = [ : ]
-for ( String test : HA_tests.keySet() ){
-    toBeRun = testsToRun.contains( test )
-    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-    def pureTestName = ( HA_tests[ test ].containsKey( "test" ) ? HA_tests[ test ][ "test" ].split().head() : test )
-    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
-                                       HA_tests, graph_generator_file, graph_saved_directory )
-}
-
-// get the start time of the test.
-start = funcs.getCurrentTime()
-// run the tests sequentially.
-for ( test in tests.keySet() ){
-    tests[ test ].call()
-}
-
-// generate the overall graph of the HA tests.
-funcs.generateOverallGraph( prop, HA_tests, graph_saved_directory )
-
-// send the notification to Slack that running HA tests was ended.
-funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
diff --git a/TestON/JenkinsFile/VM_BMJenkinsfileTrigger b/TestON/JenkinsFile/MasterTrigger.groovy
similarity index 97%
rename from TestON/JenkinsFile/VM_BMJenkinsfileTrigger
rename to TestON/JenkinsFile/MasterTrigger.groovy
index 8a140ef..8347add 100644
--- a/TestON/JenkinsFile/VM_BMJenkinsfileTrigger
+++ b/TestON/JenkinsFile/MasterTrigger.groovy
@@ -171,7 +171,6 @@
         println "Defaulting to " + day + " tests:"
     }
     for ( list in runList ){
-    //     triggerFuncs.print_tests( all_testcases[ b ] )
         echo "" + list
     }
 }
@@ -227,7 +226,7 @@
     if ( !manually_run ){
         for ( String b in onos_branches ){
             funcs.generateStatGraph( "TestStation-VMs",
-                                     funcs.branchWithPrefix( b ),
+                                     test_list.addPrefixToBranch( b ),
                                      graphPaths[ "histogramMultiple" ],
                                      graphPaths[ "pieMultiple" ],
                                      graphPaths[ "saveDirectory" ] )
diff --git a/TestON/JenkinsFile/SCPFJenkinsFile b/TestON/JenkinsFile/SCPFJenkinsFile
deleted file mode 100644
index b553af4..0000000
--- a/TestON/JenkinsFile/SCPFJenkinsFile
+++ /dev/null
@@ -1,63 +0,0 @@
-#!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 SCPF-pipeline-<branch>
-
-// read the dependency files
-SCPFfuncs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/PerformanceFuncs.groovy' )
-SCPFfuncs.init()
-funcs = evaluate readTrusted( 'TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy' )
-
-// init funcs with SCPF specification
-funcs.initialize( "SCPF", SCPFfuncs )
-
-// read the information from TestON.property on BM
-def prop = null
-prop = funcs.getProperties( "SCPF" )
-
-// get the list of the test to run.
-echo( "Testcases:" )
-def testsToRun = null
-testsToRun = funcs.getTestsToRun( prop[ "Tests" ] )
-funcs.printTestToRun( testsToRun )
-
-// check if it is using old flow.
-isOldFlow = prop[ "isOldFlow" ] == "true"
-SCPFfuncs.oldFlowRuleCheck( isOldFlow, prop[ "ONOSBranch" ] )
-
-// set test to run as a list of function
-def tests = [ : ]
-for ( String test : SCPFfuncs.SCPF.keySet() ){
-    toBeRun = testsToRun.contains( test )
-    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-
-    def pureTestName = test.replaceAll( "WithFlowObj", "" )
-    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false, SCPFfuncs.SCPF, "", "" )
-}
-
-// get start time
-start = funcs.getCurrentTime()
-// run the tests sequentially
-for ( test in tests.keySet() ){
-    tests[ test ].call()
-}
-
-// send result to slack after running test is done.
-funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
diff --git a/TestON/JenkinsFile/SRHAJenkinsFile b/TestON/JenkinsFile/SRHAJenkinsFile
deleted file mode 100644
index 90c882c..0000000
--- a/TestON/JenkinsFile/SRHAJenkinsFile
+++ /dev/null
@@ -1,74 +0,0 @@
-#!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" ] )
diff --git a/TestON/JenkinsFile/SRJenkinsFile b/TestON/JenkinsFile/SRJenkinsFile
deleted file mode 100644
index c24a47b..0000000
--- a/TestON/JenkinsFile/SRJenkinsFile
+++ /dev/null
@@ -1,74 +0,0 @@
-#!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 SR-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" )
-
-// get the name of the Jenkins job.
-jobName = env.JOB_NAME
-
-// additional setup for Segment routing because it is running multiple branch concurrently on different machines.
-funcs.additionalInitForSR( jobName )
-
-// read the TestON.property depends on which branch it is running.
-// ( currently master on Fabric4, 1.15 on Fabric2 and 2.1 on Fabric3 )
-def prop = null
-prop = funcs.getProperties( "SR" )
-SR_tests = test_list.getTestsFromCategory( "SR" )
-
-// set the file paths and directory
-graph_generator_file = fileRelated.trendIndividual
-graph_saved_directory = fileRelated.jenkinsWorkspace + "postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/"
-
-// 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 : SR_tests.keySet() ){
-    toBeRun = testsToRun.contains( test )
-    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-    def pureTestName = ( SR_tests[ test ].containsKey( "test" ) ? SR_tests[ test ][ "test" ].split().head() : test )
-    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
-                                     SR_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 SR tests is done.
-funcs.sendResultToSlack( start, prop[ "manualRun" ], prop[ "WikiPrefix" ] )
diff --git a/TestON/JenkinsFile/USECASEJenkinsFile b/TestON/JenkinsFile/USECASEJenkinsFile
deleted file mode 100644
index 4200f9a..0000000
--- a/TestON/JenkinsFile/USECASEJenkinsFile
+++ /dev/null
@@ -1,69 +0,0 @@
-#!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 USECASE-pipeline-<branch>
-
-// set the 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 of funcs to be USECASE
-fileRelated.init()
-test_list.init()
-funcs.initialize( "USECASE" );
-
-// read the TestON.property files and save it as a dictionary
-def prop = null
-prop = funcs.getProperties( "USECASE" )
-USECASE_tests = test_list.getTestsFromCategory( "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_tests.keySet() ){
-    toBeRun = testsToRun.contains( test )
-    def stepName = ( toBeRun ? "" : "Not " ) + "Running $test"
-    def pureTestName = ( USECASE_tests[ test ].containsKey( "test" ) ? USECASE_tests[ test ][ "test" ].split().head() : test )
-    tests[ stepName ] = funcs.runTest( test, toBeRun, prop, pureTestName, false,
-                                       USECASE_tests, graph_generator_file, graph_saved_directory )
-}
-
-// get start time of the test.
-start = funcs.getCurrentTime()
-// run the tests sequentially
-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_tests, graph_saved_directory )
diff --git a/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy b/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy
index f57fefb..be93b7f 100644
--- a/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy
+++ b/TestON/JenkinsFile/dependencies/JenkinsCommonFuncs.groovy
@@ -114,18 +114,13 @@
     }
 }
 
-def printType(){
-    // print the test type and test machine that was initialized.
-
-    echo testType
-    echo testMachine
-}
-
-def getProperties( category ){
+def getProperties( category, branchWithPrefix ){
     // get the properties of the test by reading the TestONOS.property
 
+    filePath = '''/var/jenkins/TestONOS-''' + category + '''-''' + branchWithPrefix + '''.property'''
+
     node( testMachine ) {
-        return readProperties( file: '/var/jenkins/TestONOS-' + category + '.property' )
+        return readProperties( file: filePath )
     }
 }
 
@@ -142,20 +137,6 @@
     return new Date()
 }
 
-def getTotalTime( start, end ){
-    // get total time of the test using start and end time.
-
-    return TimeCategory.minus( end, start )
-}
-
-def printTestToRun( testList ){
-    // printout the list of the test in the list.
-
-    for ( String test : testList ){
-        println test
-    }
-}
-
 def sendResultToSlack( start, isManualRun, branch ){
     // send the result of the test to the slack when it is not manually running.
     // start : start time of the test
@@ -334,7 +315,6 @@
     node( testMachine ) {
         def alarmFile = workSpace + "/" + pureTestName + "Alarm.txt"
         if ( fileExists( alarmFile ) ) {
-            print "Abnormal test result logged"
             def alarmContents = readFile( alarmFile )
             slackSend( channel: getSlackChannel(),
                        color: "FF0000",
@@ -348,10 +328,10 @@
                                 ( resultURL != "" ? ( "\n[Karaf log] : \n" +
                                                       resultURL + "artifact/" ) : "" ),
                        teamDomain: 'onosproject' )
-            Failed
+            throw new Exception( "Abnormal test result." )
         }
         else {
-            print "Test results are normal"
+            print "Test results are normal."
         }
     }
 }
@@ -573,27 +553,4 @@
                                 "ALL", onos_branch, testListParam, graph_saved_directory, pieTestListParam )
 }
 
-def branchWithPrefix( branch ){
-    // get the branch with the prefix ( "onos-" )
-    return ( ( branch != "master" ) ? "onos-" : "" ) + branch
-}
-
-def testBranchWithPrefix( branch ){
-    // get TestON branch with the prefix ( "onos-" )
-    if ( branch == "1.12" )
-        return "onos-1.13"
-    else if ( branch == "1.13" )
-        return "onos-1.13"
-    else if ( branch == "1.14" )
-        return "onos-1.15"
-    else if ( branch == "1.15" )
-        return "onos-1.15"
-    else if ( branch == "2.0" )
-        return "onos-2.0"
-    else if ( branch == "2.1" )
-        return "onos-2.1"
-    else
-        return "master"
-}
-
 return this
diff --git a/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy b/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
index a93fa1c..2a358df 100644
--- a/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
+++ b/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
@@ -23,6 +23,7 @@
 schedules = [:]
 branches = [:]
 
+// read all json files and save as maps
 def init(){
     def tests_buffer = readTrusted( "TestON/JenkinsFile/dependencies/tests.json" )
     def schedules_buffer = readTrusted( "TestON/JenkinsFile/dependencies/schedule.json" )
@@ -60,6 +61,7 @@
     return str_result[ 0..-2 ]
 }
 
+// given a list of tests as a string, returns the list of tests as a map, similar formatted to tests.json
 def getTestsFromStringList( list ){
     testsResult = [:]
     for ( item in list ){
@@ -85,14 +87,15 @@
     return schedulePropertyResult
 }
 
-def getAllBranches(){
-    return branches
-}
-
 // ********
 // Branches
 // ********
 
+// returns all branches from branches.json
+def getAllBranches(){
+    return branches
+}
+
 // given a day, returns all branches that are run on that day
 def getBranchesFromDay( day, tests=[:] ){
     branchesFromDayResult = []
@@ -125,6 +128,8 @@
     return branch_code
 }
 
+// given a branch, returns the corresponding branch code (hack)
+// Example: given "onos-1.15", returns "onos-1.x"
 def convertBranchToBranchCode( branch ){
     if ( branch == "master" ){
         return branch
@@ -135,6 +140,16 @@
     }
 }
 
+// given a branch without a prefix, returns the branch with the "onos-" prefix
+def addPrefixToBranch( branchNoPrefix ){
+    if ( branchNoPrefix == "master" ){
+        return "master"
+    } else {
+        return "onos-" + branchNoPrefix
+    }
+}
+
+// given a branch with the prefix "onos-", returns the branch without the prefix
 def removePrefixFromBranch( branchWithPrefix ){
     return branchWithPrefix.minus( "onos-" )
 }
@@ -157,6 +172,7 @@
     return testsFromCategoryResult
 }
 
+// given the test name, returns the category (FUNC, HA, etc.) of that test
 def getCategoryOfTest( test_name, tests=[:] ){
     if ( tests == [:] ){
         tests = allTests
@@ -164,6 +180,7 @@
     return tests[ test_name ][ "category" ]
 }
 
+// returns all categories of all tests, or the given test list
 def getAllTestCategories( tests=[:] ){
     testCategoriesResult = []
     if ( tests == [:] ){
@@ -232,7 +249,7 @@
 }
 
 // Given a test name and branch, return the node label associated.
-def getNodeLabel( test_name, branch, tests ){
+def getNodeLabel( test_name, branch, tests=[:] ){
     if ( tests == [:] ){
         tests = allTests
     }
@@ -244,7 +261,8 @@
     }
 }
 
-def getAllNodeLabels( branch, tests ){
+// given a branch, returns all nodeLabels from all tests, or a given test list
+def getAllNodeLabels( branch, tests=[:] ){
     nodeLabelResult = []
     if ( tests == [:] ){
         tests = allTests
diff --git a/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy b/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy
index 1795ba3..2aba5d2 100644
--- a/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy
+++ b/TestON/JenkinsFile/dependencies/TriggerFuncs.groovy
@@ -30,15 +30,6 @@
     funcs = commonFuncs
 }
 
-def lastCommaRemover( str ){
-    // function that will remove the last comma from the string
-
-    if ( str.size() > 0 && str[ str.size() - 1 ] == ',' ){
-        str = str.substring( 0, str.size() - 1 )
-    }
-    return str
-}
-
 def printDaysForTest(){
     // Print the days for what test has.
     AllTheTests = test_list.getAllTests()
@@ -46,9 +37,9 @@
     result = ""
     for ( String test in AllTheTests.keySet() ){
         result += test + ": ["
-        test_schedule = test_list.getTestSchedule( test )
-        for ( String sch in test_schedule.keySet() ){
-            for ( String day in test_list.convertScheduleKeyToDays( sch ) ){
+        test_schedule = AllTheTests[ test ][ "schedules" ]
+        for ( String sch_dict in test_schedule ){
+            for ( String day in test_list.convertScheduleKeyToDays( sch_dict[ "branch" ] ) ){
                 result += day + " "
             }
         }
@@ -57,58 +48,13 @@
     return result
 }
 
-def runTestSeq( testList ){
-    // Running the test sequentially
-    return {
-        for ( test in testList.keySet() ){
-            testList[ test ].call()
-        }
-    }
-}
-
-def print_tests( tests ){
-    // print the list of the tsets to be run
-
-    for ( String test in tests.keySet() ){
-        if ( tests[ test ][ "tests" ] != "" ){
-            println test + ":"
-            println tests[ test ][ "tests" ]
-        }
-    }
-}
-
-def organize_tests( tests, testcases ){
-    // organize the test to its category using its name.
-    // most of the time it will use the first two character of the test name
-    // but there are some exceptions like FUNCbgpls or FUNCvirNetNB since they are now under USECASE
-
-    // depends on the first two letters of the test name, it will decide which category to put the test into.
-    def prefixes = [
-            "FU": "FUNC",
-            "HA": "HA",
-            "PL": "USECASE",
-            "SA": "USECASE",
-            "SC": "SCPF",
-            "SR": "SR",
-            "US": "USECASE",
-            "VP": "USECASE"
-    ]
-
-    def testList = tests.tokenize( "\n;, " )
-    for ( String test in testList ){
-        String prefix = ( test == "FUNCbgpls" || test == "FUNCvirNetNB" ) ? "US" : ( test[ 0..1 ] )
-        testcases[ prefixes[ prefix ] ][ "tests" ] += test + ","
-    }
-    return testcases
-}
-
 def trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
     // triggering function that will setup the environment and determine which pipeline to trigger
 
     println "Job name: " + jobOn + "-pipeline-" + ( manuallyRun ? "manually" : branch )
     def wiki = branch
-    def onos_branch = funcs.branchWithPrefix( branch )
-    def test_branch = funcs.testBranchWithPrefix( branch )
+    def onos_branch = test_list.addPrefixToBranch( branch )
+    def test_branch = test_list.addPrefixToBranch( branch )
     println "onos_branch with prefix: " + onos_branch
     println "test_branch with prefix: " + test_branch
     node( "TestStation-" + nodeName + "s" ) {
@@ -117,7 +63,7 @@
     }
 
     jobToRun = jobOn + "-pipeline-" + ( manuallyRun ? "manually" : wiki )
-    build job: jobToRun, propagate: false
+    build job: jobToRun, propagate: false, parameters: [ [ $class: 'StringParameterValue', name: 'Category', value: jobOn ], [ $class: 'StringParameterValue', name: 'Branch', value: branch ] ]
 }
 
 def trigger_pipeline( branch, tests, nodeName, jobOn, manuallyRun, onosTag ){
@@ -134,7 +80,7 @@
 def exportEnvProperty( onos_branch, test_branch, jobOn, wiki, tests, postResult, manually_run, onosTag, isOldFlow ){
     // export environment properties to the machine.
 
-    filePath = "/var/jenkins/TestONOS-" + jobOn + ".property"
+    filePath = "/var/jenkins/TestONOS-" + jobOn + "-" + onos_branch + ".property"
 
     stage( "export Property" ) {
         sh '''