Add ability to tweak log levels in apex job 26/77826/8
authorJamo Luhrsen <jluhrsen@redhat.com>
Wed, 14 Nov 2018 21:47:39 +0000 (13:47 -0800)
committerJamo Luhrsen <jluhrsen@redhat.com>
Tue, 18 Dec 2018 20:59:13 +0000 (12:59 -0800)
Change-Id: I19bb281d183c3aaa63fd9b6093d88b4ad1d706f1
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
jjb/integration/common-functions.sh
jjb/integration/integration-apex-run-tests.sh

index 2c466d220a3f8c8052102af87620be5fc1e0396d..6cbf10069e4eb740a72357d613afed76eb0861bb 100644 (file)
@@ -90,8 +90,9 @@ function configure_karaf_log() {
     fi
 
     # Add custom logging levels
-    # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
-    # where module is abbreviated and does not include "org.opendaylight."
+    # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated
+    # values like "module:level module2:level2" where module is abbreviated and
+    # does not include "org.opendaylight."
     unset IFS
     echo "controllerdebugmap: ${controllerdebugmap}"
     if [ -n "${controllerdebugmap}" ]; then
@@ -117,6 +118,45 @@ function configure_karaf_log() {
     cat ${LOGCONF}
 } # function configure_karaf_log()
 
+function configure_karaf_log_for_apex() {
+    # TODO: add the extra steps to this function to do any extra work
+    # in this apex environment like we do in our standard environment.
+    # EX: log size, rollover, etc.
+
+    # Modify ODL Log Levels, if needed, for new distribution. This will modify
+    # the control nodes hiera data which will be used during the puppet deploy
+    # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated
+    # values like "module:level module2:level2" where module is abbreviated and
+    # does not include "org.opendaylight."
+
+    local -r controller_ip=$1
+
+    unset IFS
+    # shellcheck disable=SC2153
+    echo "CONTROLLERDEBUGMAP: ${CONTROLLERDEBUGMAP}"
+    if [ -n "${CONTROLLERDEBUGMAP}" ]; then
+        logging_config='\"opendaylight::log_levels\": {'
+        for kv in ${CONTROLLERDEBUGMAP}; do
+            module="${kv%%:*}"
+            level="${kv#*:}"
+            echo "module: $module, level: $level"
+            # shellcheck disable=SC2157
+            if [ -n "${module}" ] && [ -n "${level}" ]; then
+                orgmodule="org.opendaylight.${module}"
+                logging_config="${logging_config} \\\"${orgmodule}\\\": \\\"${level}\\\","
+            fi
+        done
+        # replace the trailing comma with a closing brace followed by trailing comma
+        logging_config=${logging_config%,}" },"
+        echo $logging_config
+
+        # fine a sane line number to inject the custom logging json
+        lineno=$(ssh $OPENSTACK_CONTROL_NODE_1_IP "sudo grep -Fn 'opendaylight::log_mechanism' /etc/puppet/hieradata/service_configs.json" | awk -F: '{print $1}')
+        ssh $controller_ip "sudo sed -i \"${lineno}i ${logging_config}\" /etc/puppet/hieradata/service_configs.json"
+        ssh $controller_ip "sudo cat /etc/puppet/hieradata/service_configs.json"
+    fi
+} # function configure_karaf_log_for_apex()
+
 function get_os_deploy() {
     local -r num_systems=${1:-$NUM_OPENSTACK_SYSTEM}
     case ${num_systems} in
index 2b4fc1ba37509961fc5b66b30e2a2d802b08ec98..4c7692b9d356749867b594043702d8854bc3b597 100644 (file)
@@ -12,6 +12,8 @@ print_job_parameters
 
 get_os_deploy
 
+configure_karaf_log_for_apex $OPENSTACK_CONTROL_NODE_1_IP
+
 # Swap out the ODL distribution
 DISTRO_UNDER_TEST=/tmp/odl.tar.gz
 wget --progress=dot:mega ${ACTUAL_BUNDLE_URL}