[VOL-5100] - periodic-voltha-test-bbsim

[VOL-5101] - voltha testing and kind command version

vars/installVoltctl.groovy
--------------------------
  - Update v2.12 to last frozen release version to establish a baseline.
  - Will update when voltctl is published again.

vars/installKind.groovy
-----------------------
  - Jenkins complained about bash FUNCNAME[1] string inlined within a
    script block.  Just remove it, var syntax is valid and script is
    simple enough to stand alone w/o message decorations.

jjb/pipeline/voltha/master/bbsim-tests.groovy
---------------------------------------------
  - Now where is voltctl being downloaded from (?-Makefile-?).
  - Shell commands exist to install if exists but no mention of where it came from.
  - Inline a call to installVoltctl.sh, script is aware of release branching and versions.
  - Added a getIam() method to decorate script log messages.
    - Cannot simply use callstack, internally jenkins will rewrite to support serialization.
  - Move installKind() into a named method with try/catch block, exited quietly last time.
  - Added comments and mild indentation cleanup for statements.

Change-Id: I4402d83c054a4e942505b8375a0ac00578879114
diff --git a/jjb/pipeline/voltha/master/bbsim-tests.groovy b/jjb/pipeline/voltha/master/bbsim-tests.groovy
index 98c9beb..6fecb98 100644
--- a/jjb/pipeline/voltha/master/bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/master/bbsim-tests.groovy
@@ -29,6 +29,25 @@
 String branch_name = 'master'
 
 // -----------------------------------------------------------------------
+// Intent: Due to lack of a reliable stack trace, construct a literal.
+//         Jenkins will re-write the call stack for serialization.
+// -----------------------------------------------------------------------
+def getIam(String func)
+{
+    String src = [
+        'ci-management',
+        'jjb',
+        'pipeline',
+        'voltha',
+	branch_name,
+        'bbsim-tests.groovy'
+    ].join('/')
+
+    String iam = [src, func].join('::')
+    return iam
+}
+
+// -----------------------------------------------------------------------
 // Intent: Determine if working on a release branch.
 //   Note: Conditional is legacy, should also check for *-dev or *-pre
 // -----------------------------------------------------------------------
@@ -40,6 +59,36 @@
 }
 
 // -----------------------------------------------------------------------
+// Intent: Phase helper method
+// -----------------------------------------------------------------------
+Boolean my_install_kind()
+{
+    String iam = getIam('installKind')
+    Boolean ans = False
+
+    println("** ${iam}: ENTER")
+    try
+    {
+	println("** ${iam} Running: installKind() { debug:true }"
+	installKind() { debug:true }
+	println("** ${iam}: Ran to completion")
+	ans = True // iff
+    }
+    catch (Exception err)
+    {
+	ans = False
+	println("** ${iam}: EXCEPTION ${err}")
+	throw err
+    }
+    finally
+    {
+	println("** ${iam}: ENTER")
+    }
+    
+    return(ans)
+}
+
+// -----------------------------------------------------------------------
 // Intent:
 // -----------------------------------------------------------------------
 def execute_test(testTarget, workflow, testLogging, teardown, testSpecificHelmFlags = "")
@@ -52,14 +101,8 @@
     {
         script
         {
-            String iam = [
-                'ci-management',
-                'jjb',
-                'pipeline',
-                'voltha',
-		branch_name,
-                'bbsim-tests.groovy'
-            ].join('/')
+	    // Announce ourselves for log usability
+	    String iam = getIam('execute_test')
 	    println("${iam}: ENTER")
 	    println("${iam}: LEAVE")
         }
@@ -92,9 +135,17 @@
         ].join(' ')
         println(" ** Running: ${cmd}:\n")
         sh("${cmd}")
+
+	// if (! my_install_kail())
+	//    throw new Exception('installKail() failed')
+	if (! my_install_kind())
+	    throw new Exception('installKind() failed')
     }
 
-    stage('Deploy common infrastructure') {
+
+    
+    stage('Deploy common infrastructure')
+    {
         sh '''
     helm repo add onf https://charts.opencord.org
     helm repo update
@@ -330,11 +381,13 @@
                 return !gerritProject.isEmpty()
             }
         }
-      steps {
-        // NOTE that the correct patch has already been checked out
-        // during the getVolthaCode step
-        buildVolthaComponent("${gerritProject}")
-      }
+
+	steps
+	{
+	    // NOTE that the correct patch has already been checked out
+	    // during the getVolthaCode step
+	    buildVolthaComponent("${gerritProject}")
+        }
     }
 
     stage('Create K8s Cluster')
@@ -343,12 +396,6 @@
             {
                 script
                 {
-                    println(' ** Calling installKind.groovy: ENTER')
-                    // chicken-n-egg problem, kind command needed
-                    // to determine if kubernetes cluster is active
-                    installKind() { debug:true }
-                    println(' ** Calling installKind.groovy: LEAVE')
-
 		    def clusterExists = sh(
                         returnStdout: true,
                         script: """kind get clusters | grep "${clusterName}" | wc -l""")
@@ -363,23 +410,19 @@
 
         stage('Replace voltctl')
         {
-            // if the project is voltctl override the downloaded one with the built one
+            // if the project is voltctl, override the downloaded one with the built one
             when {
                 expression {
                     return gerritProject == "voltctl"
                 }
             }
-
+		
+	    // Hmmmm(?) where did the voltctl download happen ?
+	    // Likely Makefile but would be helpful to document here.
             steps
-            {
-                sh """
-        # [TODO] - why is this platform specific (?)
-        # [TODO] - revisit, command alteration has masked an error (see: voltha-2.11).
-        #          find will fail when no filsystem matches are found.
-        #          mv(ls) succeded simply by accident/invoked at a different time.
-        mv `ls $WORKSPACE/voltctl/release/voltctl-*-linux-amd*` $WORKSPACE/bin/voltctl
-        chmod +x $WORKSPACE/bin/voltctl
-        """
+	    {
+		println("${iam} Running: installVoltctl($branch)")
+                installVoltctl("$branch")
             } // steps
         } // stage
 
diff --git a/vars/installKind.groovy b/vars/installKind.groovy
index e7cc57a..f0ed70d 100644
--- a/vars/installKind.groovy
+++ b/vars/installKind.groovy
@@ -42,7 +42,7 @@
 
 function error()
 {
-    echo "** ${FUNCNAME[1]} ERROR: $*"
+    echo "** ERROR: $*"
     exit 1
 }
 
diff --git a/vars/installVoltctl.groovy b/vars/installVoltctl.groovy
index f5f54af..1055e03 100644
--- a/vars/installVoltctl.groovy
+++ b/vars/installVoltctl.groovy
@@ -37,9 +37,9 @@
     // This logic seems odd given we branch & tag repositories
     // for release so hilight non-frozen until we know for sure.
     def released=[
-	// 'voltha-2.12' : '?.?.?'
-	// https://github.com/opencord/voltctl/releases/tag/v1.8.1
-	// 'voltha-2.11' : '1.8.4',
+	// v1.9.1 - https://github.com/opencord/voltctl/releases/tag/untagged-cd611c39178f25b95a87
+	'voltha-2.12' : '1.8.45',
+	// 'voltha-2.11' : '1.8.45',
 	// https://github.com/opencord/voltctl/releases/tag/v1.7.6
 	'voltha-2.10' : '1.7.6',
 	'voltha-2.9'  : '1.7.4',