Fix SC2006 backtick syntax is legacy
[releng/builder.git] / jjb / integration / common-functions.sh
index 6cbf10069e4eb740a72357d613afed76eb0861bb..8cdbc0b7525bfbb12268e56d381343feeadad4fe 100644 (file)
@@ -21,6 +21,7 @@ function print_common_env() {
     cat << EOF
 common-functions environment:
 MAVENCONF: ${MAVENCONF}
+ACTUALFEATURES: ${ACTUALFEATURES}
 FEATURESCONF: ${FEATURESCONF}
 CUSTOMPROP: ${CUSTOMPROP}
 LOGCONF: ${LOGCONF}
@@ -29,6 +30,7 @@ CONTROLLERMEM: ${CONTROLLERMEM}
 AKKACONF: ${AKKACONF}
 MODULESCONF: ${MODULESCONF}
 MODULESHARDSCONF: ${MODULESHARDSCONF}
+SUITES: ${SUITES}
 
 EOF
 }
@@ -77,6 +79,9 @@ function configure_karaf_log() {
     echo "Configuring the karaf log... karaf_version: ${karaf_version}, logapi: ${logapi}"
     if [ "${logapi}" == "log4j2" ]; then
         # FIXME: Make log size limit configurable from build parameter.
+        # From Neon the default karaf file size is 64 MB
+        sed -ie 's/log4j2.appender.rolling.policies.size.size = 64MB/log4j2.appender.rolling.policies.size.size = 1GB/g' ${LOGCONF}
+        # Flourine still uses 16 MB
         sed -ie 's/log4j2.appender.rolling.policies.size.size = 16MB/log4j2.appender.rolling.policies.size.size = 1GB/g' ${LOGCONF}
         orgmodule="org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver"
         orgmodule_="${orgmodule//./_}"
@@ -157,6 +162,34 @@ function configure_karaf_log_for_apex() {
     fi
 } # function configure_karaf_log_for_apex()
 
+function configure_odl_features_for_apex() {
+
+    # if the environment variable $ACTUALFEATURES is not null, then rewrite
+    # the puppet config file with the features given in that variable, otherwise
+    # this function is a noop
+
+    local -r controller_ip=$1
+    local -r config_file=/etc/puppet/hieradata/service_configs.json
+
+cat > /tmp/set_odl_features.sh << EOF
+sudo jq '.["opendaylight::extra_features"] |= []' $config_file > tmp.json && mv tmp.json $config_file
+for feature in $(echo $ACTUALFEATURES | sed "s/,/ /g"); do
+    sudo jq --arg jq_arg \$feature '.["opendaylight::extra_features"] |= . + [\$jq_arg]' $config_file > tmp && mv tmp $config_file;
+done
+echo "Modified puppet-opendaylight service_configs.json..."
+cat $config_file
+EOF
+
+    echo "Feature configuration script..."
+    cat /tmp/set_odl_features.sh
+
+    if [ -n "${ACTUALFEATURES}" ]; then
+        scp /tmp/set_odl_features.sh $controller_ip:/tmp/set_odl_features.sh
+        ssh $controller_ip "sudo bash /tmp/set_odl_features.sh"
+    fi
+
+} # function configure_odl_features_for_apex()
+
 function get_os_deploy() {
     local -r num_systems=${1:-$NUM_OPENSTACK_SYSTEM}
     case ${num_systems} in
@@ -190,7 +223,7 @@ function get_test_suites() {
 
     # Use the testplan if specific SUITES are not defined.
     if [ -z "${SUITES}" ]; then
-        suite_list=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
+        suite_list=$(egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ')
     else
         suite_list=""
         workpath="${WORKSPACE}/test/csit/suites"
@@ -500,7 +533,7 @@ EOF
 
     sleep 5
     # FIXME: Do not create .tar and gzip before copying.
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}"); do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         echo "collect_logs: for opendaylight controller ip: ${!CONTROLLERIP}"
         NODE_FOLDER="odl_${i}"
@@ -539,7 +572,7 @@ EOF
     print_job_parameters > ${WORKSPACE}/archives/params.txt
 
     # Control Node
-    for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
+    for i in $(seq 1 "${NUM_OPENSTACK_CONTROL_NODES}"); do
         OSIP=OPENSTACK_CONTROL_NODE_${i}_IP
         if [ "$(is_openstack_feature_enabled n-cpu)" == "1" ]; then
             echo "collect_logs: for openstack combo node ip: ${!OSIP}"
@@ -609,7 +642,7 @@ EOF
     done
 
     # Compute Nodes
-    for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
+    for i in $(seq 1 "${NUM_OPENSTACK_COMPUTE_NODES}"); do
         OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
         echo "collect_logs: for openstack compute node ip: ${!OSIP}"
         NODE_FOLDER="compute_${i}"
@@ -676,7 +709,7 @@ function join() {
 
 function get_nodes_list() {
     # Create the string for nodes
-    for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}") ; do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         nodes[$i]=${!CONTROLLERIP}
     done
@@ -695,7 +728,7 @@ function get_features() {
 
     # Some versions of jenkins job builder result in feature list containing spaces
     # and ending in newline. Remove all that.
-    ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
+    ACTUALFEATURES=$(echo "${ACTUALFEATURES}" | tr -d '\n \r')
     echo "ACTUALFEATURES: ${ACTUALFEATURES}"
 
     # In the case that we want to install features via karaf shell, a space separated list of
@@ -861,7 +894,7 @@ EOF
 # Copy over the configuration script and configuration files to each controller
 # Execute the configuration script on each controller.
 function copy_and_run_configuration_script() {
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}"); do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
         scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
@@ -871,7 +904,7 @@ function copy_and_run_configuration_script() {
 
 # Copy over the startup script to each controller and execute it.
 function copy_and_run_startup_script() {
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}"); do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
         scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
@@ -881,7 +914,7 @@ function copy_and_run_startup_script() {
 
 function copy_and_run_post_startup_script() {
     seed_index=1
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}"); do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         echo "Execute the post startup script on controller ${!CONTROLLERIP}"
         scp ${WORKSPACE}/post-startup-script.sh ${!CONTROLLERIP}:/tmp
@@ -894,7 +927,7 @@ function copy_and_run_post_startup_script() {
 
 function create_controller_variables() {
     echo "Generating controller variables..."
-    for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
+    for i in $(seq 1 "${NUM_ODL_SYSTEM}"); do
         CONTROLLERIP=ODL_SYSTEM_${i}_IP
         odl_variables=${odl_variables}" -v ${CONTROLLERIP}:${!CONTROLLERIP}"
         echo "Lets's take the karaf thread dump"