[ONOS-7590] Allow Segment Routing tests to run by multiple machines

Change-Id: I8845bceeed51d7a1564e84b8ffa4fa392b2b35c5
diff --git a/TestON/JenkinsFile/JenkinsCommonFuncs.groovy b/TestON/JenkinsFile/JenkinsCommonFuncs.groovy
index 7ba926b..d6ab3b3 100644
--- a/TestON/JenkinsFile/JenkinsCommonFuncs.groovy
+++ b/TestON/JenkinsFile/JenkinsCommonFuncs.groovy
@@ -35,7 +35,13 @@
   testMachine = "TestStation-" + machineType[ type ] + "s";
   generalFuncs.initBasicVars();
 }
-
+def additionalInitForSR( branch ){
+  testMachine = testMachine.insert( testMachine.length-1, fabricOn( branch ) )
+  print testMachine
+}
+def fabricOn( branch ){
+  return branch == "master" ? '2' : '3'
+}
 def printType(){
   echo testType;
   echo testMachine;
@@ -272,10 +278,10 @@
       }
   }
 }
-def generateCategoryStatsGraph( manualRun, postresult, stat_file, pie_file, type, branch, testListPart, save_path, pieTestListPart ){
+def generateCategoryStatsGraph( testMachineOn, manualRun, postresult, stat_file, pie_file, type, branch, testListPart, save_path, pieTestListPart ){
 
   if( isPostingResult( manualRun, postresult ) ){
-    node( testMachine ){
+    node( testMachineOn ){
 
       withCredentials( [
           string( credentialsId: 'db_pass', variable: 'pass' ),
@@ -332,14 +338,14 @@
     echo ''' + database_command + '''
     done '''
 }
-def generateStatGraph( onos_branch, AllTheTests, stat_graph_generator_file, pie_graph_generator_file, graph_saved_directory ){
+def generateStatGraph( testMachineOn, onos_branch, AllTheTests, stat_graph_generator_file, pie_graph_generator_file, graph_saved_directory ){
     testListPart = createStatsList( "FUNC", AllTheTests[ "FUNC" ], true ) +
                    createStatsList( "HA", AllTheTests[ "HA" ], true ) +
                    createStatsList( "USECASE", AllTheTests[ "USECASE" ], false )
     pieTestList = makeTestList( AllTheTests[ "FUNC" ], true ) +
                   makeTestList( AllTheTests[ "HA" ], true ) +
                   makeTestList( AllTheTests[ "USECASE" ], false )
-    generateCategoryStatsGraph( "false", "true", stat_graph_generator_file, pie_graph_generator_file, "ALL", onos_branch, testListPart, graph_saved_directory, pieTestList )
+    generateCategoryStatsGraph( testMachineOn, "false", "true", stat_graph_generator_file, pie_graph_generator_file, "ALL", onos_branch, testListPart, graph_saved_directory, pieTestList )
 }
 def branchWithPrefix( branch ){
     return ( ( branch != "master" ) ? "onos-" : "" ) + branch
diff --git a/TestON/JenkinsFile/JenkinsfileTrigger b/TestON/JenkinsFile/JenkinsfileTrigger
index cc1bfa1..31d606a 100644
--- a/TestON/JenkinsFile/JenkinsfileTrigger
+++ b/TestON/JenkinsFile/JenkinsfileTrigger
@@ -106,7 +106,8 @@
 //finalList[ "BM" ].call()
 
 if ( !manually_run ){
-    funcs.generateStatGraph( funcs.branchWithPrefix( onos_b ),
+    funcs.generateStatGraph( "TestStation-VMs",
+                             funcs.branchWithPrefix( onos_b ),
                              AllTheTests,
                              stat_graph_generator_file,
                              pie_graph_generator_file,
diff --git a/TestON/JenkinsFile/Overall_Graph_Generator b/TestON/JenkinsFile/Overall_Graph_Generator
index 4e2280e..ba34a89 100644
--- a/TestON/JenkinsFile/Overall_Graph_Generator
+++ b/TestON/JenkinsFile/Overall_Graph_Generator
@@ -11,4 +11,9 @@
 onos_branch = params.ONOSbranch
 AllTheTests = test_lists.getAllTheTests("")
 
-funcs.generateStatGraph( onos_branch, AllTheTests, stat_graph_generator_file, pie_graph_generator_file, graph_saved_directory )
\ No newline at end of file
+funcs.generateStatGraph( "TestStation-VMs",
+                         onos_branch,
+                         AllTheTests,
+                         stat_graph_generator_file,
+                         pie_graph_generator_file,
+                         graph_saved_directory )
\ No newline at end of file
diff --git a/TestON/JenkinsFile/SRJenkinsFile b/TestON/JenkinsFile/SRJenkinsFile
index e4e0139..45cb315 100644
--- a/TestON/JenkinsFile/SRJenkinsFile
+++ b/TestON/JenkinsFile/SRJenkinsFile
@@ -6,10 +6,11 @@
 // This is a Jenkinsfile for a scripted pipeline for the SR tests
 def prop = null
 prop = funcs.getProperties()
+funcs.additionalInitForSR( prop[ "ONOSBranch" ] )
 SR = test_lists.getAllTheTests( prop[ "WikiPrefix" ] )[ "SR" ]
 
 graph_generator_file = "~/OnosSystemTest/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R"
-graph_saved_directory = "/var/jenkins/workspace/postjob-Fabric/"
+graph_saved_directory = "/var/jenkins/workspace/postjob-Fabric" + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/"
 
 echo( "Testcases:" )
 def testsToRun = null
diff --git a/TestON/JenkinsFile/SRJenkinsfileTrigger b/TestON/JenkinsFile/SRJenkinsfileTrigger
index 72f0604..d53f70d 100644
--- a/TestON/JenkinsFile/SRJenkinsfileTrigger
+++ b/TestON/JenkinsFile/SRJenkinsfileTrigger
@@ -15,7 +15,7 @@
     "FUNC" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
     "HA" : [ tests : "" , nodeName : "VM", wikiContent : "" ],
     "SCPF" : [ tests : "" , nodeName : "BM", wikiContent : "" ],
-    "SR" : [ tests : "", nodeName : "Fabric", wikiContent : "" ],
+    "SR" : [ tests : "", nodeName : [ "Fabric2", "Fabric3" ], wikiContent : "" ],
     "USECASE" : [ tests : "" , nodeName : "BM", wikiContent : "" ]
 ]
 Prefix_organizer = [
@@ -85,20 +85,30 @@
 def runTest = [
     "VM" : [:],
     "BM" : [:],
-    "Fabric" : [:]
+    "Fabric2" : [:],
+    "Fabric3" : [:]
 ]
 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 )
+        runTest[ testcases[ test ][ "nodeName" ][ 0 ] ][ test ] = triggerFuncs.trigger_pipeline( onos_b, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ][ 0 ], test, manually_run, onos_tag )
+        runTest[ testcases[ test ][ "nodeName" ][ 1 ] ][ test ] = triggerFuncs.trigger_pipeline( previous_version, testcases[ test ][ "tests" ], testcases[ test ][ "nodeName" ][ 1 ], test, manually_run, onos_tag )
     }
 }
 def finalList = [:]
-finalList[ "Fabric" ] = triggerFuncs.runTestSeq( runTest[ "Fabric" ] )
+finalList[ "Fabric2" ] = triggerFuncs.runTestSeq( runTest[ "Fabric2" ] )
+finalList[ "Fabric3" ] = triggerFuncs.runTestSeq( runTest[ "Fabric3" ] )
 parallel finalList
 /*
 if ( !manually_run ){
-    funcs.generateStatGraph( funcs.branchWithPrefix( onos_b ),
+    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,
diff --git a/TestON/JenkinsFile/Trend_Graph_Generator b/TestON/JenkinsFile/Trend_Graph_Generator
index a9795f8..f091c34 100644
--- a/TestON/JenkinsFile/Trend_Graph_Generator
+++ b/TestON/JenkinsFile/Trend_Graph_Generator
@@ -2,9 +2,6 @@
 funcs = evaluate readTrusted( 'TestON/JenkinsFile/JenkinsCommonFuncs.groovy' )
 nodeCluster = params.NodeCluster
 
-graph_generator_file = "~/OnosSystemTest/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R"
-graph_saved_directory = "/var/jenkins/workspace/postjob-" + nodeCluster + "/"
-
 funcs.initializeTrend( nodeCluster );
 def prop = null
 prop = funcs.getProperties()
@@ -12,6 +9,11 @@
 def Tests = params.Test
 prop[ "ONOSBranch" ] = params.ONOSbranch
 
+funcs.additionalInitForSR( prop[ "ONOSBranch" ] )
+
+graph_generator_file = "~/OnosSystemTest/TestON/JenkinsFile/scripts/testCaseGraphGenerator.R"
+graph_saved_directory = "/var/jenkins/workspace/postjob-" + nodeCluster + funcs.fabricOn( prop[ "ONOSBranch" ] ) + "/"
+
 def testsToRun = null
 testsToRun = funcs.getTestsToRun( Tests )
 
diff --git a/TestON/JenkinsFile/TriggerFuncs.groovy b/TestON/JenkinsFile/TriggerFuncs.groovy
index c6fa9ca..cf9f6fc 100644
--- a/TestON/JenkinsFile/TriggerFuncs.groovy
+++ b/TestON/JenkinsFile/TriggerFuncs.groovy
@@ -68,10 +68,8 @@
 // jobOn : "SCPF" or "USECASE" or "FUNC" or "HA"
     return{
         if( jobOn == "SR" ){
-            trigger( "1.11", tests, nodeName, jobOn, manuallyRun, onosTag )
             trigger( "1.12", tests, nodeName, jobOn, manuallyRun, onosTag )
             trigger( "master", tests, nodeName, jobOn, manuallyRun, onosTag )
-            // returnCell( nodeName )
             }else{
             trigger( branch, tests, nodeName, jobOn, manuallyRun, onosTag )
         }