[BASHATE] Extended code analysis
Followign code adds linting with bashate to devstack/plugin.sh Change-Id: Iec6e82a6ddc8ce4e405196509777c029139b5025
This commit is contained in:
parent
8d501d5443
commit
9d470036f5
|
@ -121,7 +121,6 @@ function install_monasca {
|
|||
fi
|
||||
|
||||
install_cli_creds
|
||||
|
||||
}
|
||||
|
||||
function post_config_monasca {
|
||||
|
@ -659,12 +658,18 @@ function install_schema_kafka_topics {
|
|||
sudo chown kafka:kafka /opt/kafka/logs
|
||||
sudo chmod 0766 /opt/kafka/logs
|
||||
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic 60-seconds-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 64 --topic metrics
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 12 --topic events
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 12 --topic alarm-state-transitions
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 12 --topic alarm-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 3 --topic retry-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 \
|
||||
--replication-factor 1 --partitions 3 --topic 60-seconds-notifications
|
||||
}
|
||||
|
||||
function install_schema_alarm_database {
|
||||
|
@ -744,7 +749,6 @@ function install_git {
|
|||
}
|
||||
|
||||
function download_monasca_libraries {
|
||||
|
||||
echo_summary "Download Monasca monasca_common and monasca_statsd"
|
||||
|
||||
GIT_DEPTH_OLD=$GIT_DEPTH
|
||||
|
@ -771,7 +775,8 @@ function install_monasca_api_java {
|
|||
|
||||
(cd "${MONASCA_API_DIR}"/java ; sudo mvn clean package -DskipTests)
|
||||
|
||||
local version="$(get_version_from_pom "${MONASCA_API_DIR}"/java)"
|
||||
local version=""
|
||||
version="$(get_version_from_pom "${MONASCA_API_DIR}"/java)"
|
||||
|
||||
sudo cp -f "${MONASCA_API_DIR}"/java/target/monasca-api-${version}-shaded.jar \
|
||||
/opt/monasca/monasca-api.jar
|
||||
|
@ -914,11 +919,15 @@ function install_monasca_api_python {
|
|||
|
||||
# if monasca devstack would use DATABASE_USER everywhere, following line
|
||||
# might be replaced with database_connection_url call
|
||||
local dbAlarmUrl=`get_database_type_$DATABASE_TYPE`://$MONASCA_API_DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST/mon
|
||||
local dbMetricDriver="monasca_api.common.repositories.influxdb.metrics_repository:MetricsRepository"
|
||||
local dbAlarmUrl
|
||||
local dbMetricDriver
|
||||
|
||||
if [[ "${MONASCA_METRICS_DB,,}" == 'cassandra' ]]; then
|
||||
dbMetricDriver="monasca_api.common.repositories.cassandra.metrics_repository:MetricsRepository"
|
||||
else
|
||||
dbMetricDriver="monasca_api.common.repositories.influxdb.metrics_repository:MetricsRepository"
|
||||
fi
|
||||
dbAlarmUrl=`get_database_type_$DATABASE_TYPE`://$MONASCA_API_DATABASE_USER:$DATABASE_PASSWORD@$DATABASE_HOST/mon
|
||||
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/monasca-api/python/api-config.conf /etc/monasca/api-config.conf
|
||||
sudo chown mon-api:root /etc/monasca/api-config.conf
|
||||
|
@ -1023,7 +1032,8 @@ function install_monasca_persister_java {
|
|||
git_clone $MONASCA_PERSISTER_REPO $MONASCA_PERSISTER_DIR $MONASCA_PERSISTER_BRANCH
|
||||
(cd "${MONASCA_PERSISTER_DIR}"/java ; sudo mvn clean package -DskipTests)
|
||||
|
||||
local version="$(get_version_from_pom "${MONASCA_PERSISTER_DIR}"/java)"
|
||||
local version=""
|
||||
version="$(get_version_from_pom "${MONASCA_PERSISTER_DIR}"/java)"
|
||||
|
||||
sudo cp -f "${MONASCA_PERSISTER_DIR}"/java/target/monasca-persister-${version}-shaded.jar \
|
||||
/opt/monasca/monasca-persister.jar
|
||||
|
@ -1465,7 +1475,8 @@ function install_monasca_thresh {
|
|||
git_clone $MONASCA_THRESH_REPO $MONASCA_THRESH_DIR $MONASCA_THRESH_BRANCH
|
||||
(cd "${MONASCA_THRESH_DIR}"/thresh ; sudo mvn clean package -DskipTests)
|
||||
|
||||
local version="$(get_version_from_pom "${MONASCA_THRESH_DIR}"/thresh)"
|
||||
local version=""
|
||||
version="$(get_version_from_pom "${MONASCA_THRESH_DIR}"/thresh)"
|
||||
|
||||
sudo cp -f "${MONASCA_THRESH_DIR}"/thresh/target/monasca-thresh-${version}-shaded.jar \
|
||||
/opt/monasca/monasca-thresh.jar
|
||||
|
@ -1896,8 +1907,7 @@ function recreate_users_postgresql {
|
|||
function validate_version {
|
||||
version_regex="^([0-9]+\.)?([0-9]+\.)?([0-9]+)$"
|
||||
|
||||
if [[ $1 =~ $version_regex ]];
|
||||
then
|
||||
if [[ $1 =~ $version_regex ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
@ -1907,32 +1917,26 @@ function validate_version {
|
|||
# Compares two program version strings of the form 1.0.0.
|
||||
# Returns "lt" if $1 is less than $2, "eq" if equal, and "gt" if greater than.
|
||||
function compare_versions {
|
||||
if [[ $1 == $2 ]]
|
||||
then
|
||||
if [[ $1 == $2 ]]; then
|
||||
echo eq
|
||||
return
|
||||
fi
|
||||
local IFS=.
|
||||
local i ver1=($1) ver2=($2)
|
||||
# fill empty fields in ver1 with zeros
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
|
||||
do
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
|
||||
ver1[i]=0
|
||||
done
|
||||
for ((i=0; i<${#ver1[@]}; i++))
|
||||
do
|
||||
if [[ -z ${ver2[i]} ]]
|
||||
then
|
||||
for ((i=0; i<${#ver1[@]}; i++)); do
|
||||
if [[ -z ${ver2[i]} ]]; then
|
||||
# fill empty fields in ver2 with zeros
|
||||
ver2[i]=0
|
||||
fi
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]}))
|
||||
then
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
||||
echo gt
|
||||
return
|
||||
fi
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]}))
|
||||
then
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]})); then
|
||||
echo lt
|
||||
return
|
||||
fi
|
||||
|
@ -1958,8 +1962,6 @@ function get_version_from_pom {
|
|||
# Uses global variables:
|
||||
# - OFFLINE
|
||||
# - DOWNLOAD_FILE_TIMEOUT
|
||||
# note(trebskit) maybe this function will enter upstream devstack in case it does
|
||||
# we should remove it from here
|
||||
function download_file {
|
||||
local url=$1
|
||||
local file=$2
|
||||
|
@ -1971,7 +1973,7 @@ function download_file {
|
|||
fi
|
||||
|
||||
local curl_z_flag=""
|
||||
if [[ -f ${file} ]]; then
|
||||
if [[ -f "${file}" ]]; then
|
||||
# If the file exists tell cURL to download only if newer version
|
||||
# is available
|
||||
curl_z_flag="-z $file"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# process, which may cause wedges in the gate later.
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
bandit>=1.1.0 # Apache-2.0
|
||||
bashate>=0.2 # Apache-2.0
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
Babel>=2.3.4 # BSD
|
||||
coverage>=4.0 # Apache-2.0
|
||||
|
|
8
tox.ini
8
tox.ini
|
@ -66,12 +66,20 @@ commands =
|
|||
# B101(assert_ussed) - asserts in test layers seems appropriate
|
||||
bandit -r monasca_tempest_tests -n5 -s B101
|
||||
|
||||
[testenv:bashate]
|
||||
whitelist_externals = bashate
|
||||
commands =
|
||||
# Ignore too long lines error E006 from bashate and treat
|
||||
# E005, E042 as errors.
|
||||
bashate -v -iE006 -eE005,E042 devstack/plugin.sh
|
||||
|
||||
[testenv:pep8]
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
commands =
|
||||
{[testenv:flake8]commands}
|
||||
{[testenv:bandit]commands}
|
||||
{[testenv:bashate]commands}
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
|
Loading…
Reference in New Issue