Merge "[VOL-3780] Correctly collecting logs in openonu-go test"
diff --git a/jjb/pipeline/voltha/master/openonu-go-periodic-test-bbsim.groovy b/jjb/pipeline/voltha/master/openonu-go-periodic-test-bbsim.groovy
index 1010e80..0001fac 100644
--- a/jjb/pipeline/voltha/master/openonu-go-periodic-test-bbsim.groovy
+++ b/jjb/pipeline/voltha/master/openonu-go-periodic-test-bbsim.groovy
@@ -38,16 +38,6 @@
         ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9
         '''
       }
-      // stop logging
-      sh """
-        P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
-        if [ -n "\$P_IDS" ]; then
-          echo \$P_IDS
-          for P_ID in \$P_IDS; do
-            kill -9 \$P_ID
-          done
-        fi
-      """
     }
   }
   stage('Deploy Voltha') {
@@ -98,9 +88,42 @@
 
     make -C $WORKSPACE/voltha-system-tests ${testTarget} || true
     """
+    // stop logging
+    sh """
+      P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
+      if [ -n "\$P_IDS" ]; then
+        echo \$P_IDS
+        for P_ID in \$P_IDS; do
+          kill -9 \$P_ID
+        done
+      fi
+    """
   }
 }
 
+def collectArtifacts(exitStatus) {
+  getPodsInfo("$WORKSPACE/${exitStatus}")
+  sh """
+  kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
+  """
+  archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
+  sh '''
+    sync
+    pkill kail || true
+    which voltctl
+    md5sum $(which voltctl)
+  '''
+  step([$class: 'RobotPublisher',
+    disableArchiveOutput: false,
+    logFileName: "RobotLogs/*/log*.html",
+    otherFiles: '',
+    outputFileName: "RobotLogs/*/output*.xml",
+    outputPath: '.',
+    passThreshold: 100,
+    reportFileName: "RobotLogs/*/report*.html",
+    unstableThreshold: 0]);
+}
+
 pipeline {
 
   /* no label, executor is determined by JJB */
@@ -165,7 +188,7 @@
       steps {
         script {
           def mibUploadHelmFlags = "--set pon=2,onu=2,controlledActivation=only-onu "
-          execute_test("1t8gem", "att", "mib-upload-templating-openonu-go-adapter-test", "$WORKSPACE/mibupload", mibUploadHelmFlags)
+          execute_test("mibupload", "att", "mib-upload-templating-openonu-go-adapter-test", "$WORKSPACE/mibupload", mibUploadHelmFlags)
         }
       }
     }
@@ -196,36 +219,13 @@
   }
   post {
     aborted {
-      getPodsInfo("$WORKSPACE/failed")
-      sh """
-      kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log
-      """
-      archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
+      collectArtifacts("aborted")
     }
     failure {
-      getPodsInfo("$WORKSPACE/failed")
-      sh """
-      kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log
-      """
-      archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
+      collectArtifacts("failed")
     }
     always {
-      step([$class: 'RobotPublisher',
-        disableArchiveOutput: false,
-        logFileName: "RobotLogs/*/log*.html",
-        otherFiles: '',
-        outputFileName: "RobotLogs/*/output*.xml",
-        outputPath: '.',
-        passThreshold: 100,
-        reportFileName: "RobotLogs/*/report*.html",
-        unstableThreshold: 0]);
-      archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
-      sh '''
-        sync
-        pkill kail || true
-        which voltctl
-        md5sum $(which voltctl)
-      '''
+      collectArtifacts("always")
     }
   }
 }
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index bb42b7b..5449361 100755
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -101,6 +101,7 @@
           olts: 2
           onus: 2
           pons: 2
+          make-target: openonu-go-adapter-multi-olt-test
           make-target-1t4gemtest: 1t4gem-openonu-go-adapter-multi-olt-test
           make-target-1t8gemtest: 1t8gem-openonu-go-adapter-multi-olt-test
           make-target-reconciletest: reconcile-openonu-go-adapter-multi-olt-test
@@ -114,6 +115,7 @@
           code-branch: '$GERRIT_BRANCH'
           gerrit-project: '$GERRIT_PROJECT'
           gerritRefspec: '$GERRIT_REFSPEC'
+          make-target: openonu-go-adapter-multi-olt-test
           make-target-1t4gemtest: 1t4gem-openonu-go-adapter-multi-olt-test
           make-target-1t8gemtest: 1t8gem-openonu-go-adapter-multi-olt-test
           make-target-reconciletest: reconcile-openonu-go-adapter-multi-olt-test