Merge "Fixing minor issues in *ComponentLogs keywords"
diff --git a/jjb/pipeline/voltha/master/voltha-dt-physical-functional-tests.groovy b/jjb/pipeline/voltha/master/voltha-dt-physical-functional-tests.groovy
index 6155a33..cd94753 100644
--- a/jjb/pipeline/voltha/master/voltha-dt-physical-functional-tests.groovy
+++ b/jjb/pipeline/voltha/master/voltha-dt-physical-functional-tests.groovy
@@ -136,7 +136,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/FunctionalTests")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/FunctionalTests"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -146,7 +146,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/FunctionalTests", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/FunctionalTests", compress: true])
       }
     }
 
@@ -157,7 +157,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/FailureScenarios")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/FailureScenarios"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -167,7 +167,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/FailureScenarios", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/FailureScenarios", compress: true])
       }
     }
 
@@ -178,13 +178,13 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/DataplaneTests")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/DataplaneTests"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/DataplaneTests", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/DataplaneTests", compress: true])
       }
     }
     stage('HA Tests') {
@@ -194,13 +194,13 @@
        ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/ONOSHAScenarios"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true])
       }
     }
 
@@ -211,7 +211,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/MultipleOLTScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/ONOSHAScenarios"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -221,7 +221,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true])
       }
     }
 
@@ -233,13 +233,13 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ErrorScenarios")
+        startComponentsLogs([logsDir: "$WORKSPACE/logs/ErrorScenarios"])
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ErrorScenarios", compress: true)
+        stopComponentsLogs([logsDir: "$WORKSPACE/logs/ErrorScenarios", compress: true])
       }
     }
   }
diff --git a/jjb/pipeline/voltha/master/voltha-scale-test.groovy b/jjb/pipeline/voltha/master/voltha-scale-test.groovy
index 6a8535b..bfe8fc0 100644
--- a/jjb/pipeline/voltha/master/voltha-scale-test.groovy
+++ b/jjb/pipeline/voltha/master/voltha-scale-test.groovy
@@ -124,7 +124,7 @@
       steps {
         timeout(time: 10, unit: 'MINUTES') {
           script {
-            startComponentsLog([
+            startComponentsLogs([
               appsToLog: [
                 'app.kubernetes.io/name=etcd',
                 'app.kubernetes.io/name=kafka',
@@ -527,19 +527,7 @@
   }
   post {
     always {
-      stopComponentsLog([
-        'app.kubernetes.io/name=etcd',
-        'app.kubernetes.io/name=kafka',
-        'app=onos-classic',
-        'app=adapter-open-onu',
-        'app=adapter-open-olt',
-        'app=rw-core',
-        'app=ofagent',
-        'app=bbsim',
-        'app=radius',
-        'app=bbsim-sadis-server',
-        'app=onos-config-loader',
-      ])
+      stopComponentsLogs()
       // collect result, done in the "post" step so it's executed even in the
       // event of a timeout in the tests
       sh '''
diff --git a/jjb/pipeline/voltha/voltha-2.8/voltha-dt-physical-functional-tests.groovy b/jjb/pipeline/voltha/voltha-2.8/voltha-dt-physical-functional-tests.groovy
index 6744891..b39b110 100644
--- a/jjb/pipeline/voltha/voltha-2.8/voltha-dt-physical-functional-tests.groovy
+++ b/jjb/pipeline/voltha/voltha-2.8/voltha-dt-physical-functional-tests.groovy
@@ -111,7 +111,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/FunctionalTests")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/FunctionalTests")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -121,7 +121,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/FunctionalTests", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/FunctionalTests", compress: true)
       }
     }
 
@@ -132,7 +132,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/FailureScenarios")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/FailureScenarios")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -142,7 +142,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/FailureScenarios", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/FailureScenarios", compress: true)
       }
     }
 
@@ -153,13 +153,13 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/DataplaneTests")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/DataplaneTests")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/DataplaneTests", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/DataplaneTests", compress: true)
       }
     }
     stage('HA Tests') {
@@ -169,13 +169,13 @@
        ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ONOSHAScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
       }
     }
 
@@ -186,7 +186,7 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/MultipleOLTScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/ONOSHAScenarios")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if ( ${powerSwitch} ); then
@@ -196,7 +196,7 @@
         fi
         make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/ONOSHAScenarios", compress: true)
       }
     }
 
@@ -208,13 +208,13 @@
         ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/ErrorScenarios"
       }
       steps {
-        startComponentsLog(logsDir: "$WORKSPACE/logs/ErrorScenarios")
+        startComponentsLogs(logsDir: "$WORKSPACE/logs/ErrorScenarios")
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v workflow:${params.workFlow} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
         make -C $WORKSPACE/voltha-system-tests voltha-test || true
         """
-        stopComponentsLog(logsDir: "$WORKSPACE/logs/ErrorScenarios", compress: true)
+        stopComponentsLogs(logsDir: "$WORKSPACE/logs/ErrorScenarios", compress: true)
       }
     }
   }
diff --git a/vars/startComponentsLogs.groovy b/vars/startComponentsLogs.groovy
index 954d0b1..4cea1d2 100644
--- a/vars/startComponentsLogs.groovy
+++ b/vars/startComponentsLogs.groovy
@@ -47,7 +47,7 @@
             def tag = "${tagPrefix}-kail-${logFile}"
             println "Starting logging process for label: ${label}"
             sh """
-            _TAG=${tag} kail -l ${label} --since 1h > ${logsDir}/${logFile}.log&
+            _TAG=${tag} kail -l ${label} --since 1h > ${cfg.logsDir}/${logFile}.log&
             """
         }
     }
diff --git a/vars/stopComponentsLogs.groovy b/vars/stopComponentsLogs.groovy
index fc0f0e9..24d2ad7 100644
--- a/vars/stopComponentsLogs.groovy
+++ b/vars/stopComponentsLogs.groovy
@@ -7,19 +7,25 @@
         compress: false, // wether to compress the logs in a tgz file
     ]
 
+    if (!config) {
+        config = [:]
+    }
+
+    def cfg = defaultConfig + config
+
     def tag = "jenkins-"
     println "Stopping all kail logging process"
     sh """
-    P_IDS="$(ps e -ww -A | grep "_TAG=jenkins-kail" | grep -v grep | awk '{print $1}')"
-    if [ -n "$P_IDS" ]; then
-        for P_ID in $P_IDS; do
-            kill -9 $P_ID
+    P_IDS="\$(ps e -ww -A | grep "_TAG=jenkins-kail" | grep -v grep | awk '{print \$1}')"
+    if [ -n "\$P_IDS" ]; then
+        for P_ID in \$P_IDS; do
+            kill -9 \$P_ID
         done
     fi
     """
-    if (compress) {
+    if (cfg.compress) {
         sh """
-        tar czf ${logsDir}/combined.tgz *
+        tar czf ${cfg.logsDir}/combined.tgz *
         rm *.log
         """