[VOL-5170] - Test debugging openolt-adapter-sanity-test-voltha

vars/createKubernetesCluster.groovy
vars/volthaStackDeploy.groovy
vars/waitForAdapters.groovy
-----------------------------------
  o npm-groovy-lint cleanups
  o Correct indentation
  o emacs untabify (tabs to spaces)
  o Split long shell commands into distinct sh() blocks.
  o Add sh() attribute 'label' so logged commands are self-documenting.
  o Added more banners to label logged output.

vars/volthaStackDeploy.groovy
-----------------------------
  o remove set +x from sh() commands to add log output.
  o re-enable thrown excpetions for process().  This may generate
    duplicate stack traces but at least we see all errors.

vars/pgrep_port_forward.groovy
------------------------------
  o Convenience script, refactor pgrep/pkill logic into a reusable library
    to avoid inlining copy & paste port-forward setup/teardown logic.
  o Shell command must be hardcoded (YUCK!).  Groovy Strings are type
    GString with no native cast to java.lang.string for sh("$cmd") calls.
    String casting works at times due to def/object type but exceptions
    are thrown when incorrect so use a known/reliable value for now.

jjb/verify/voltha-openolt-adapter.yaml
--------------------------------------
  o Jobgen did not run last attempt, include a config file to force it.

Change-Id: I70843625d6a0ae510594a764697e9e0405dfe64b
diff --git a/vars/createKubernetesCluster.groovy b/vars/createKubernetesCluster.groovy
index 9653840..a95d084 100644
--- a/vars/createKubernetesCluster.groovy
+++ b/vars/createKubernetesCluster.groovy
@@ -19,8 +19,7 @@
 
 // -----------------------------------------------------------------------
 // -----------------------------------------------------------------------
-def getIam(String func)
-{
+String getIam(String func) {
     // Cannot rely on a stack trace due to jenkins manipulation
     String src = 'vars/createKubernetesCluster.groovy'
     String iam = [src, func].join('::')
@@ -28,23 +27,39 @@
 }
 
 // -----------------------------------------------------------------------
+// Intent: Log progress message
 // -----------------------------------------------------------------------
-def call(Map config) {
+void enter(String name) {
+    // Announce ourselves for log usability
+    String iam = getIam(name)
+    println("${iam}: ENTER")
+    return
+}
+
+// -----------------------------------------------------------------------
+// Intent: Log progress message
+// -----------------------------------------------------------------------
+void leave(String name) {
+    // Announce ourselves for log usability
+    String iam = getIam(name)
+    println("${iam}: LEAVE")
+    return
+}
+
+// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
+def call(Map config=[:]) {
 
     String iam = getIam('main')
-    println("** ${iam}: ENTER")
+    enter('main')
 
     // note that I can't define this outside the function as there's no global scope in Groovy
     def defaultConfig = [
-      branch: "master", // branch=master ?!?
-      nodes: 1,
-      name: "kind-ci"
+        branch: 'master', // branch=master ?!?
+        nodes: 1,
+        name: 'kind-ci'
     ]
 
-    if (!config) {
-        config = [:]
-    }
-
     def cfg = defaultConfig + config
 
     println "Deploying Kind cluster with the following parameters: ${cfg}."
@@ -79,7 +94,7 @@
 
     // TODO: Skip kind install, make install-kind-command has done it already
     sh """
-      mkdir -p "$WORKSPACE/bin"
+      mkdir -p $WORKSPACE/bin
 
       # download kind (should we add it to the base image?)
       curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.0/kind-linux-amd64
@@ -90,10 +105,12 @@
     // install voltctl
     installVoltctl("${cfg.branch}")
 
-    sh """
+    sh(label  : 'Start kind cluster',
+       script : """
 cat <<EOM
 
 ** -----------------------------------------------------------------------
+** IAM: ${iam}
 ** Starting kind cluster
 ** -----------------------------------------------------------------------
 EOM
@@ -104,7 +121,10 @@
       for MNODE in \$(kubectl get node --selector='node-role.kubernetes.io/master' -o json | jq -r '.items[].metadata.name'); do
           kubectl taint node "\$MNODE" node-role.kubernetes.io/master:NoSchedule-
       done
+""")
 
+    sh(label  : 'Normalize config permissions',
+       script : """
       ## ----------------------------------------------------------------------
       ## This logic is problematic, when run on a node processing concurrent
       ## jobs over-write will corrupt config for the other running job.
@@ -116,29 +136,37 @@
       umask 022
 
       echo
-      echo "** Generate ~/.volt/config"
+      echo "** Generate $HOME/.volt/config"
       mkdir -p "$HOME/.volt"
-      chmod -R u+w,go-rwx "$HOME/.volt"
       chmod u=rwx "$HOME/.volt"
       voltctl -s localhost:55555 config > "$HOME/.volt/config"
+      chmod -R u+w,go-rwx "$HOME/.volt"
 
       echo
-      echo "** Generate ~/.kube/config"
+      echo "** Generate $HOME/.kube/config"
       mkdir -p "$HOME/.kube"
-      chmod -R u+w,go-rwx "$HOME/.kube"
       chmod u=rwx "$HOME/.kube"
       kind get kubeconfig --name ${cfg.name} > "$HOME/.kube/config"
+      chmod -R u+w,go-rwx "$HOME/.kube"
 
       echo
-      echo "Display .kube/ and .volt"
+      echo "Display .kube/ and .volt/ configs"
       /bin/ls -l "$HOME/.kube" "$HOME/.volt"
+""")
 
-      echo
-      echo "Install Kail"
+    sh(label  : 'Install kail',
+       script : """
+cat <<EOM
+
+** -----------------------------------------------------------------------
+** IAM: ${iam}
+** Install kail
+** -----------------------------------------------------------------------
+EOM
       make -C "$WORKSPACE/voltha-system-tests" KAIL_PATH="$WORKSPACE/bin" kail
-  """
+""")
 
-    println("** ${iam}: LEAVE")
+    enter('leave')
     return
 }