From 5cfcae4edf4d08d00d1b479c54893ee9070c9df1 Mon Sep 17 00:00:00 2001 From: Dobroslaw Zybort Date: Fri, 8 Sep 2017 13:56:48 +0200 Subject: [PATCH 1/4] Fix shellcheck SC2164 (cherry picked from commit f2e01de6cabee3f6c511d9c113d18c304e418d6c) --- monasca-python/build.sh | 4 ++-- tempest-tests/start.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/monasca-python/build.sh b/monasca-python/build.sh index c24c9ca4e..8ab5b4898 100644 --- a/monasca-python/build.sh +++ b/monasca-python/build.sh @@ -101,7 +101,7 @@ EXTRA_DEPS="${EXTRA_DEPS:-""}" echo "Installing APK Dependencies" && install_apk_deps mkdir -p /app -cd /app +cd /app || exit # actual build happens here cat << EOF @@ -115,7 +115,7 @@ echo "Cloning ${REPO}@${BRANCH}" && clone "${REPO}" "${BRANCH}" echo "Installing ${REPO}" && install "${CONSTRAINTS}" "${EXTRAS}" "${EXTRA_DEPS}" # end of actual build -cd - +cd - || exit rm -rf /install.sh /clone.sh /install_apk_deps.sh /app /root/.cache/pip apk del build-dep diff --git a/tempest-tests/start.sh b/tempest-tests/start.sh index fa5d38d10..ab85d9070 100755 --- a/tempest-tests/start.sh +++ b/tempest-tests/start.sh @@ -60,7 +60,7 @@ python template.py \ /etc/tempest/tempest.conf.j2 \ /etc/tempest/tempest.conf -cd /monasca-api +cd /monasca-api || exit export OS_TEST_PATH=./monasca_tempest_tests/tests/api if [ ! -r .testrepository ]; then From e59cde20d5a5bb24be46880697733814a4325914 Mon Sep 17 00:00:00 2001 From: Dobroslaw Zybort Date: Fri, 8 Sep 2017 14:02:22 +0200 Subject: [PATCH 2/4] Fix shellcheck SC2155 (cherry picked from commit 585a953daa23bcac59c52b84e5631b7389b55fd0) --- elasticsearch-init/upload.sh | 5 ++--- smoke-tests/start.sh | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elasticsearch-init/upload.sh b/elasticsearch-init/upload.sh index 2114f2dd5..d7d94630f 100644 --- a/elasticsearch-init/upload.sh +++ b/elasticsearch-init/upload.sh @@ -4,7 +4,8 @@ TPL_DIR=/templates _get_tpl_name_from_file() { local tpl=$1 - local tpl_name=$(basename $tpl) + local tpl_name + tpl_name=$(basename $tpl) echo $tpl_name } @@ -23,5 +24,3 @@ for template in $TPLS; do curl -XPUT --retry 2 --retry-delay 2 $ELASTICSEARCH_URI/_template/${tpl_name} -d @$TPL_DIR/$template done - - diff --git a/smoke-tests/start.sh b/smoke-tests/start.sh index 6402ec00b..29753347f 100755 --- a/smoke-tests/start.sh +++ b/smoke-tests/start.sh @@ -10,6 +10,7 @@ export OS_DOMAIN_NAME=${OS_DOMAIN_NAME:-"Default"} export OS_AUTH_URL=${OS_AUTH_URL:-"http://keystone:35357/v3"} export MONASCA_URL=${MONASCA_URL:-"http://monasca-api:8070"} -export WEBHOOK_IP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}') +export WEBHOOK_IP +WEBHOOK_IP=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}') /smoke-test From b56033414fa8f2d06a00e6ffd22334b41892dbd9 Mon Sep 17 00:00:00 2001 From: Dobroslaw Zybort Date: Mon, 11 Sep 2017 08:49:03 +0200 Subject: [PATCH 3/4] Fix some shellcheck SC2086, quotes --- elasticsearch-init/upload.sh | 8 ++++---- elasticsearch-init/wait-for.sh | 8 ++++---- monasca-python/build.sh | 6 +++--- tempest-tests/start.sh | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/elasticsearch-init/upload.sh b/elasticsearch-init/upload.sh index d7d94630f..9dd888160 100644 --- a/elasticsearch-init/upload.sh +++ b/elasticsearch-init/upload.sh @@ -5,8 +5,8 @@ TPL_DIR=/templates _get_tpl_name_from_file() { local tpl=$1 local tpl_name - tpl_name=$(basename $tpl) - echo $tpl_name + tpl_name=$(basename "$tpl") + echo "$tpl_name" } if [ ! -d $TPL_DIR ]; then @@ -19,8 +19,8 @@ fi for template in $TPLS; do echo "Handling template file $template" - tpl_name=`_get_tpl_name_from_file $template` + tpl_name=`_get_tpl_name_from_file "$template"` - curl -XPUT --retry 2 --retry-delay 2 $ELASTICSEARCH_URI/_template/${tpl_name} -d @$TPL_DIR/$template + curl -XPUT --retry 2 --retry-delay 2 "$ELASTICSEARCH_URI"/_template/"${tpl_name}" -d @$TPL_DIR/"$template" done diff --git a/elasticsearch-init/wait-for.sh b/elasticsearch-init/wait-for.sh index b2915da26..e4840f69b 100644 --- a/elasticsearch-init/wait-for.sh +++ b/elasticsearch-init/wait-for.sh @@ -1,15 +1,15 @@ #!/bin/sh -: ${SLEEP_LENGTH:=2} +: "${SLEEP_LENGTH:=2}" wait_for() { - echo Waiting for $1 to listen on $2... - while ! nc -z $1 $2; do echo sleeping; sleep $SLEEP_LENGTH; done + echo "Waiting for $1 to listen on $2..." + while ! nc -z "$1" "$2"; do echo sleeping; sleep "$SLEEP_LENGTH"; done } for var in "$@" do host=${var%:*} port=${var#*:} - wait_for $host $port + wait_for "$host" "$port" done diff --git a/monasca-python/build.sh b/monasca-python/build.sh index 8ab5b4898..8e9171048 100644 --- a/monasca-python/build.sh +++ b/monasca-python/build.sh @@ -24,7 +24,7 @@ else if [ "z$extra_deps" != "z" ]; then for extra in $extra_deps; do - pip install --no-cache-dir $extra -c $constraints + pip install --no-cache-dir "$extra" -c "$constraints" done else echo "No extra dependencies" @@ -32,13 +32,13 @@ else if [ "z$extras" != "z" ]; then for extra in $extras; do - pip install --no-cache-dir .[${extra}] -c $constraints + pip install --no-cache-dir .["${extra}"] -c "$constraints" done else echo "No extras" fi - pip install --no-cache-dir -r requirements.txt -c $constraints + pip install --no-cache-dir -r requirements.txt -c "$constraints" python setup.py install } fi diff --git a/tempest-tests/start.sh b/tempest-tests/start.sh index ab85d9070..f2cb6dbdf 100755 --- a/tempest-tests/start.sh +++ b/tempest-tests/start.sh @@ -36,7 +36,7 @@ if [ "$MONASCA_WAIT_FOR_API" = "true" ]; then echo "Waiting for Monasca API to become available..." success="false" - for i in $(seq $MONASCA_API_WAIT_RETRIES); do + for i in $(seq "$MONASCA_API_WAIT_RETRIES"); do monasca --os-user-domain-name "${OS_DOMAIN_NAME}" --os-project-name "${OS_TENANT_NAME}" \ --os-auth-url "${AUTH_URI_V3}" --os-username "${OS_USERNAME}" \ --os-password "${OS_PASSWORD}" alarm-list --limit 1 From 8dcbf57d36bc31a439e1207a640edd821c66259c Mon Sep 17 00:00:00 2001 From: Dobroslaw Zybort Date: Mon, 11 Sep 2017 09:13:16 +0200 Subject: [PATCH 4/4] Fix some flake8 and pylint warnings in tempest --- tempest-tests/template.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tempest-tests/template.py b/tempest-tests/template.py index fddbdd086..3ca16e4cc 100755 --- a/tempest-tests/template.py +++ b/tempest-tests/template.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# coding=utf-8 # (C) Copyright 2017 Hewlett Packard Enterprise Development LP # @@ -13,6 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. + from __future__ import print_function import os @@ -30,8 +32,9 @@ def main(): out_path = sys.argv[2] with open(in_path, 'r') as in_file, open(out_path, 'w') as out_file: - t = Template(in_file.read()) - out_file.write(t.render(os.environ)) + tmt = Template(in_file.read()) + out_file.write(tmt.render(os.environ)) + if __name__ == '__main__': main()