[ONOS-7988]: Refactor Branches used in Jenkins TestON Pipelines

Change-Id: I5801715e2af8315809130c2d0fd262b304f949f4
diff --git a/TestON/JenkinsFile/FabricJenkinsfileTrigger b/TestON/JenkinsFile/FabricJenkinsfileTrigger
index d54231a..b958d17 100644
--- a/TestON/JenkinsFile/FabricJenkinsfileTrigger
+++ b/TestON/JenkinsFile/FabricJenkinsfileTrigger
@@ -29,11 +29,6 @@
 fileRelated.init()
 test_list.init()
 
-// set the versions of the onos.
-current_version = "master"
-previous_version = "1.15"
-before_previous_version = "2.1"
-
 // Function that will initialize the configuration of the Fabric.
 funcs.initializeTrend( "Fabric" )
 funcs.initialize( "Fabric" )
@@ -43,19 +38,10 @@
 // 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: "" ],
-        "SRHA": [ tests: "", nodeName: "Fabric", wikiContent: "" ],
-        "USECASE": [ tests: "", nodeName: "BM", wikiContent: "" ]
-]
+all_testcases = [:]
 
 // set some variables from the parameter
 manually_run = params.manual_run
-onos_b = current_version
-test_branch = ""
 onos_tag = params.ONOSTag
 isOldFlow = true
 
@@ -64,26 +50,45 @@
 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_b = params.ONOSVersion
+    onos_branches = params.branches.tokenize( "\n;, " )
+} else {
+    onos_branches = test_list.getBranchesFromDay( today )
 }
 
-// get the list of the tests from the JenkinsTestONTests.groovy
-// AllTheTests = test_list.getAllTests()
+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 = ""
 
-// list of the test on each test category will be run.
-SCPF_choices = ""
-USECASE_choices = ""
-FUNC_choices = ""
-HA_choices = ""
-SR_choices = ""
-SRHA_choices = ""
-
 // initialize the graph generating files.
 stat_graph_generator_file = fileRelated.histogramMultiple
 pie_graph_generator_file = fileRelated.pieMultiple
@@ -91,42 +96,32 @@
 
 // get the post_result. This will be affected only for the manual runs.
 post_result = params.PostResult
-if ( !manually_run ){
+
+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 {
     // 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 )
 
-    dayMap = [ ( Calendar.MONDAY )    : "mon",
-               ( Calendar.TUESDAY )   : "tue",
-               ( Calendar.WEDNESDAY ) : "wed",
-               ( Calendar.THURSDAY )  : "thu",
-               ( Calendar.FRIDAY )    : "fri",
-               ( Calendar.SATURDAY )  : "sat",
-               ( Calendar.SUNDAY )    : "sun" ]
-
-    SR_choices += adder( "SR", dayMap[ today ], true )
-    SRHA_choices += adder( "SRHA", dayMap[ today ], true )
-
-}
-
-
-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
-    testcases[ "SRHA" ][ "tests" ] = SRHA_choices
+    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
-triggerFuncs.print_tests( testcases )
+for ( String b in onos_branches ){
+    triggerFuncs.print_tests( all_testcases[ b ] )
+}
 
 // This will hold the block of code to be run.
 def runTest = [
@@ -135,44 +130,46 @@
         "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 )
+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( 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 )
-    runTest[ "Fabric" ][ "SRHA" ] = triggerFuncs.trigger_pipeline( current_version,
-                                                                   testcases[ "SRHA" ][ "tests" ],
-                                                                   testcases[ "SRHA" ][ "nodeName" ],
-                                                                   "SRHA",
-                                                                   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 = [ : ]
@@ -214,13 +211,13 @@
 }*/
 
 // Way to add list of the tests with specific category to the result
-def adder( category, day, getResult ){
+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, onos_b ) )
+    selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
 
     for ( String test in selectedTests.keySet() ){
         if ( getResult ){
@@ -233,9 +230,9 @@
 // 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
+        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/VM_BMJenkinsfileTrigger b/TestON/JenkinsFile/VM_BMJenkinsfileTrigger
index fe06697..b0cd743 100644
--- a/TestON/JenkinsFile/VM_BMJenkinsfileTrigger
+++ b/TestON/JenkinsFile/VM_BMJenkinsfileTrigger
@@ -30,9 +30,6 @@
 
 // set the versions of the onos
 fileRelated.init()
-current_version = "master"
-previous_version = "1.15"
-before_previous_version = "2.1"
 
 // init trend graphs to be on VM.
 funcs.initializeTrend( "VM" );
@@ -42,23 +39,11 @@
 // which will demonstrates the list of the scheduled tests on the days.
 wikiContents = ""
 
-// default FUNC,HA to be VM, SCPF,USECASE to be BM.
-// SR will not be used in here.
-testcases = [
-        "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: "" ]
-]
+all_testcases = [:]
 
 // read the parameters from the Jenkins
 manually_run = params.manual_run
 
-// set default onos_b to be current_version.
-onos_b = current_version
-test_branch = ""
 onos_tag = params.ONOSTag
 isOldFlow = true
 
@@ -67,29 +52,44 @@
 print now.toString()
 today = now[ Calendar.DAY_OF_WEEK ]
 
-// get branch from parameter if it is manually running
+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 ( manually_run ){
-    onos_b = params.ONOSVersion
+    onos_branches = params.branches.tokenize( "\n;, " )
+} else {
+    onos_branches = getBranchesFromDay( dayMap[ today ] )
 }
-else {
-    // otherwise, the version would be different over the weekend.
-    // If today is weekdays, it will be default to current_version.
-    if ( today == Calendar.SATURDAY ){
-        onos_b = previous_version
-    }
-    else if ( today == Calendar.SUNDAY ){
-        onos_b = before_previous_version
-    }
+
+// default FUNC,HA to be VM, SCPF,USECASE to be BM.
+// SR will not be used in here.
+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 )
 }
 
 // list of the tests to be run will be saved in each choices.
 day = ""
-SCPF_choices = ""
-USECASE_choices = ""
-FUNC_choices = ""
-HA_choices = ""
-SR_choices = ""
-SRHA_choices = ""
 
 // init some paths for the files and directories.
 stat_graph_generator_file = fileRelated.histogramMultiple
@@ -100,95 +100,76 @@
 post_result = params.PostResult
 
 // if automatically run, it will remove the comma at the end after dividing the tests.
-if ( !manually_run ){
-    testDivider( today )
-    FUNC_choices = triggerFuncs.lastCommaRemover( FUNC_choices )
-    HA_choices = triggerFuncs.lastCommaRemover( HA_choices )
-    SCPF_choices = triggerFuncs.lastCommaRemover( SCPF_choices )
-    USECASE_choices = triggerFuncs.lastCommaRemover( USECASE_choices )
-    SR_choices = triggerFuncs.lastCommaRemover( SR_choices )
-    SRHA_choices = triggerFuncs.lastCommaRemover( SRHA_choices )
-}
-
-
 if ( manually_run ){
-    testcases = triggerFuncs.organize_tests( params.Tests, testcases )
-
+    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 {
-    testcases[ "SCPF" ][ "tests" ] = SCPF_choices
-    testcases[ "USECASE" ][ "tests" ] = USECASE_choices
-    testcases[ "FUNC" ][ "tests" ] = FUNC_choices
-    testcases[ "HA" ][ "tests" ] = HA_choices
-    testcases[ "SR" ][ "tests" ] = SR_choices
-    testcases[ "SRHA" ][ "tests" ] = SRHA_choices
+    println "Tests to be run manually:"
+} else {
+    testDivider( today )
     println "Defaulting to " + day + " tests:"
 }
 
-triggerFuncs.print_tests( testcases )
+
+for ( String b in onos_branches ){
+    triggerFuncs.print_tests( all_testcases[ b ] )
+}
 
 def runTest = [
         "VM": [ : ],
         "BM": [ : ]
 ]
 
-// set the test running function into the dictionary.
-for ( String test in testcases.keySet() ){
-    println test
-    if ( testcases[ test ][ "tests" ] != "" ){
-        runTest[ testcases[ test ][ "nodeName" ] ][ test ] = triggerFuncs.
-                trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ], test,
-                                  manually_run, onos_tag )
-    }
-}
 def finalList = [ : ]
 
+finalList[ "VM" ] = [ : ]
+finalList[ "BM" ] = [ : ]
+
 // get the name of the job.
 jobName = env.JOB_NAME
 
-// first set the list of the functions to be run.
-finalList[ "VM" ] = triggerFuncs.runTestSeq( runTest[ "VM" ] )
-finalList[ "BM" ] = triggerFuncs.runTestSeq( runTest[ "BM" ] )
+// set the test running function into the dictionary.
+for ( String b in onos_branches ){
+    for ( String test in all_testcases[ b ].keySet() ){
+        if ( all_testcases[ b ][ test ][ "tests" ] != "" ){
+            runTest[ all_testcases[ b ][ test ][ "nodeName" ] ][ test ] = triggerFuncs.
+                    trigger_pipeline( b, all_testcases[ b ][ test ][ "tests" ], all_testcases[ b ][ test ][ "nodeName" ], test,
+                                      manually_run, onos_tag )
+        }
+    }
+
+    // first set the list of the functions to be run.
+    finalList[ "VM" ][ b ] = triggerFuncs.runTestSeq( runTest[ "VM" ] )
+    finalList[ "BM" ][ b ] = triggerFuncs.runTestSeq( runTest[ "BM" ] )
+}
 
 // if first two character of the job name is vm, only call VM.
 // else, only on BM
+
 if ( jobName.take( 2 ) == "vm" ){
-    finalList[ "VM" ].call()
+    parallel finalList[ "VM" ]
 }
 else {
-    finalList[ "BM" ].call()
+    parallel finalList[ "BM" ]
 }
 
+
 // If it is automated running, it will generate the stats graph on VM.
 if ( !manually_run ){
-    funcs.generateStatGraph( "TestStation-VMs",
-                             funcs.branchWithPrefix( onos_b ),
-                             stat_graph_generator_file,
-                             pie_graph_generator_file,
-                             graph_saved_directory )
+    for ( String b in onos_branches ){
+        funcs.generateStatGraph( "TestStation-VMs",
+                                 funcs.branchWithPrefix( b ),
+                                 stat_graph_generator_file,
+                                 pie_graph_generator_file,
+                                 graph_saved_directory )
+    }
 }
 
 // function that will divide tests depends on which day it is.
 def testDivider( today ){
     todayStr = today.toString()
 
-    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 ( today == Calendar.MONDAY ){
         initHtmlForWiki()
         day = fullDayMap[ today ]
@@ -207,41 +188,43 @@
 }
 
 def buildDay( dayStr, getResult ){
-    addingHeader( "FUNC" )
-    FUNC_choices += adder( "FUNC", dayStr, getResult )
-    closingHeader( "FUNC" )
-    addingHeader( "HA" )
-    HA_choices += adder( "HA", dayStr, getResult )
-    closingHeader( "HA" )
-    addingHeader( "SCPF" )
-    SCPF_choices += adder( "SCPF", dayStr, getResult )
-    closingHeader( "SCPF" )
-    addingHeader( "SR" )
-    SR_choices += adder( "SR", dayStr, false )
-    closingHeader( "SR" )
-    addingHeader( "SRHA" )
-    SRHA_choices += adder( "SRHA", dayStr, false )
-    closingHeader( "SRHA" )
-    addingHeader( "USECASE" )
-    USECASE_choices += adder( "USECASE", dayStr, getResult )
-    closingHeader( "USECASE" )
+    for ( String b in onos_branches ){
+        addingHeader( "FUNC", b )
+        all_testcases[ b ][ "FUNC" ][ "tests" ] += adder( "FUNC", dayStr, getResult, b )
+        closingHeader( "FUNC", b )
+        addingHeader( "HA", b )
+        all_testcases[ b ][ "HA" ][ "tests" ] += adder( "HA", dayStr, getResult, b )
+        closingHeader( "HA", b )
+        addingHeader( "SCPF", b )
+        all_testcases[ b ][ "SCPF" ][ "tests" ] += adder( "SCPF", dayStr, getResult, b )
+        closingHeader( "SCPF", b )
+        addingHeader( "SR", b )
+        all_testcases[ b ][ "SR" ][ "tests" ] += adder( "SR", dayStr, false, b )
+        closingHeader( "SR", b )
+        addingHeader( "SRHA", b )
+        all_testcases[ b ][ "SRHA" ][ "tests" ] += adder( "SRHA", dayStr, false, b )
+        closingHeader( "SRHA", b )
+        addingHeader( "USECASE", b )
+        all_testcases[ b ][ "USECASE" ][ "tests" ] += adder( "USECASE", dayStr, getResult, b )
+        closingHeader( "USECASE", b )
+    }
 }
 
 // adder that will return the list of the tests.
-def adder( category, day, getResult ){
+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, onos_b ) )
+    selectedTests = test_list.getTestsFromCategory( category, test_list.getTestsFromDay( day, branch ) )
 
     for ( String test in selectedTests.keySet() ){
         if ( getResult ){
             result += test + ","
         }
         // make HTML columns for wiki page on schedule.
-        makeHtmlColList( category, test )
+        makeHtmlColList( category, test, branch )
     }
     return result
 }
@@ -271,40 +254,44 @@
                 <th class="confluenceTh"><p>Saturday</p></th>
                 <th class="confluenceTh"><p>Sunday</p></th>
             </tr>'''
-    for ( String test in testcases.keySet() ){
-        testcases[ test ][ 'wikiContent' ] = '''
-            <tr>
-                <th colspan="1" class="confluenceTh">''' + test + '''</th>'''
+    for ( String b in onos_branches ){
+        for ( String test in all_testcases[ b ].keySet() ){
+            all_testcases[ b ][ test ][ 'wikiContent' ] = '''
+                <tr>
+                    <th colspan="1" class="confluenceTh">''' + test + '''</th>'''
+        }
     }
 }
 
 // adding header functionality.
-def addingHeader( testCategory ){
-    testcases[ testCategory ][ 'wikiContent' ] += '''
+def addingHeader( testCategory, branch ){
+    all_testcases[ branch ][ testCategory ][ 'wikiContent' ] += '''
                 <td class="confluenceTd">
                     <ul>'''
 }
 
 // making column list for html
-def makeHtmlColList( testCategory, testName ){
-    testcases[ testCategory ][ 'wikiContent' ] += '''
+def makeHtmlColList( testCategory, testName, branch ){
+    all_testcases[ branch ][ testCategory ][ 'wikiContent' ] += '''
                         <li>''' + testName + '''</li>'''
 
 }
 
 // closing the header for html
-def closingHeader( testCategory ){
-    testcases[ testCategory ][ 'wikiContent' ] += '''
+def closingHeader( testCategory, branch ){
+    all_testcases[ branch ][ testCategory ][ 'wikiContent' ] += '''
                     </ul>
                 </td>'''
 }
 
 // close the html for the wiki page.
 def closeHtmlForWiki(){
-    for ( String test in testcases.keySet() ){
-        wikiContents += testcases[ test ][ 'wikiContent' ]
-        wikiContents += '''
-            </tr>'''
+    for ( String b in onos_branches ){
+        for ( String test in all_testcases[ b ].keySet() ){
+            wikiContents += all_testcases[ b ][ test ][ 'wikiContent' ]
+            wikiContents += '''
+                </tr>'''
+        }
     }
     wikiContents += '''
         </tbody>
@@ -312,9 +299,9 @@
     <p><strong>Everyday</strong>, all SegmentRouting tests are built and run on every supported branch.</p>
     <p>On <strong>Weekdays</strong>, all the other tests are built and run on the master branch.</p>
     <p>On <strong>Saturdays</strong>, all the other tests are built and run on the ''' +
-                    funcs.branchWithPrefix( previous_version ) + ''' branch.</p>
+                    test_list.convertBranchCodeToBranch( "onos-2.x" ) + ''' branch.</p>
     <p>On <strong>Sundays</strong>, all the other tests are built and run on the ''' +
-                    funcs.branchWithPrefix( before_previous_version ) + ''' branch.</p>'''
+                    test_list.convertBranchCodeToBranch( "onos-1.x" ) + ''' branch.</p>'''
 }
 
 // post the result to wiki page using publish to confluence.
diff --git a/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy b/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
index e271d48..6ee0485 100644
--- a/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
+++ b/TestON/JenkinsFile/dependencies/JenkinsTestONTests.groovy
@@ -21,22 +21,32 @@
 
 allTests = [:]
 schedules = [:]
+branches = [:]
 
 def init(){
     def tests_buffer = readTrusted( "TestON/JenkinsFile/dependencies/tests.json" )
     def schedules_buffer = readTrusted( "TestON/JenkinsFile/dependencies/schedule.json" )
+    def branches_buffer = readTrusted( "TestON/JenkinsFile/dependencies/branches.json" )
     allTests = readJSON text: tests_buffer
     schedules = readJSON text: schedules_buffer
+    branches = readJSON text: branches_buffer
 }
 
+// returns the entire set of TestON tests from the json file
 def getAllTests(){
     return allTests
 }
 
+// returns the entire set of schedules from the json file
 def getSchedules(){
     return schedules
 }
 
+def getAllBranches(){
+    return branches
+}
+
+// given a test category ("FUNC", "HA", etc.), returns all tests associated with that category
 def getTestsFromCategory( category, tests=[:] ){
     result = [:]
     if ( tests == [:] ){
@@ -50,18 +60,24 @@
     return result
 }
 
-def getTestsFromDay( day, branch, tests=[:] ){
-    result = [:]
-    if ( tests == [:] ){
-        tests = allTests
-    }
+// given a day, returns schedules that contain that day
+def getValidSchedules( day ){
     validSchedules = []
     for ( String key in schedules.keySet() ){
         if ( schedules[ key ].contains( day ) ){
             validSchedules += key
         }
     }
-    echo validSchedules.toString()
+    return validSchedules
+}
+
+// given a day and branch, returns all tests that run on the given day on the given branch
+def getTestsFromDay( day, branch, tests=[:] ){
+    result = [:]
+    if ( tests == [:] ){
+        tests = allTests
+    }
+    validSchedules = getValidSchedules( day )
     for ( String key in tests.keySet() ){
         schedule = tests[ key ][ "schedule" ][ branch ]
         if ( validSchedules.contains( schedule ) ){
@@ -71,6 +87,26 @@
     return result
 }
 
+// given a day, returns all branches that are run on that day
+def getBranchesFromDay( day, tests=[:] ){
+    result = []
+    if ( tests == [:] ){
+        tests = allTests
+    }
+    validSchedules = getValidSchedules( day )
+
+    for ( String key in tests.keySet() ){
+        for ( String branch in tests[ key ][ "schedule" ].keySet() ){
+            sch = tests[ key ][ "schedule" ][ branch ]
+            if ( validSchedules.contains( sch ) && !result.contains( sch ) ){
+                result += convertBranchCodeToBranch( branch )
+            }
+        }
+    }
+    return result
+}
+
+// given a nodeLabel ("vm", "bm", etc.), returns all tests that run on that node.
 def getTestsFromNodeLabel( nodeLabel, tests=[:] ){
     if ( tests == [:] ){
         tests = allTests
@@ -82,6 +118,7 @@
     }
 }
 
+// returns the test list as a string
 def getTestListAsString( tests ){
     result = ""
     for ( String test in tests.keySet() ){
@@ -90,12 +127,25 @@
     return result[ 0..-2 ]
 }
 
+// returns the schedule for a given test
 def getTestSchedule( test ){
     return allTests[ test ][ "schedule" ]
 }
 
+// returns a list of days from the given schedule
 def convertScheduleKeyToDays( sch ){
     return schedules[ sch ]
 }
 
+def convertBranchCodeToBranch( branch_code, withPrefix=true ){
+    for ( String branch_type in branches.keySet() ){
+        for ( String b in branches[ branch_type ].keySet() ){
+            if ( branch_code == b ){
+                return withPrefix ? ( "onos-" + branches[ branch_type ][ b ] ) : branches[ branch_type ][ b ]
+            }
+        }
+    }
+    return branch_code
+}
+
 return this
diff --git a/TestON/JenkinsFile/dependencies/branches.json b/TestON/JenkinsFile/dependencies/branches.json
new file mode 100644
index 0000000..5be761f
--- /dev/null
+++ b/TestON/JenkinsFile/dependencies/branches.json
@@ -0,0 +1,11 @@
+{
+    "latest_branches": {
+        "onos-1.x": "1.15",
+        "onos-2.x": "2.1"
+    },
+    "support_branches": {
+        "onos-1.sb1": "1.12",
+        "onos-1.sb2": "1.14",
+        "onos-2.sb1": "2.0"
+    }
+}