Fix of error handling in contrail backup
In cassandra-backup-client-runner-call.sh rsync command redirect to
log file only stdout and all error messages aren't caught by error
handling code
Closes-Bug: PROD-35981
Change-Id: Idd8a069d81c7e110c1cd988e42d7148c0dd5842a
diff --git a/cassandra/files/backup/cassandra-backup-client-runner-call.sh b/cassandra/files/backup/cassandra-backup-client-runner-call.sh
index e507f56..79805d2 100644
--- a/cassandra/files/backup/cassandra-backup-client-runner-call.sh
+++ b/cassandra/files/backup/cassandra-backup-client-runner-call.sh
@@ -125,13 +125,13 @@
ssh-keygen -R {{ backup.client.target.host }} 2>&1 | > $RSYNCLOG
ssh-keyscan {{ backup.client.target.host }} >> ~/.ssh/known_hosts 2>&1 | >> $RSYNCLOG
echo "Rsyncing files to remote host"
- /usr/bin/rsync -rhtPv --rsync-path=rsync --progress $BACKUPDIR/* -e ssh cassandra@{{ backup.client.target.host }}:$SERVERBACKUPDIR >> $RSYNCLOG
+ /usr/bin/rsync -rhtPv --rsync-path="mkdir -p $SERVERBACKUPDIR && rsync" --progress $BACKUPDIR/* -e ssh cassandra@{{ backup.client.target.host }}:$SERVERBACKUPDIR >> $RSYNCLOG 2>&1
# Check if the rsync succeeded or failed
if [ -s $RSYNCLOG ] && ! grep -q "rsync error: " $RSYNCLOG; then
echo "Rsync to remote host completed OK"
else
- echo "Rsync to remote host FAILED"
+ echo "Rsync to remote host FAILED. Check $RSYNCLOG for details"
exit 1
fi
{%- endif %}
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 9761585..b4ce276 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -37,9 +37,13 @@
setup_virtualenv() {
log_info "Setting up Python virtualenv"
+ dependency_check virtualenv
virtualenv $VENV_DIR
source ${VENV_DIR}/bin/activate
python -m pip install salt${PIP_SALT_VERSION}
+ if [[ -f ${CURDIR}/test-requirements.txt ]]; then
+ python -m pip install -r ${CURDIR}/test-requirements.txt
+ fi
}
setup_mock_bin() {
@@ -165,6 +169,13 @@
done
}
+dependency_check() {
+ local DEPENDENCY_COMMANDS=$*
+ for DEPENDENCY_COMMAND in $DEPENDENCY_COMMANDS; do
+ which $DEPENDENCY_COMMAND > /dev/null || ( log_err "Command \"$DEPENDENCY_COMMAND\" can not be found in default path."; exit 1; )
+ done
+}
+
_atexit() {
RETVAL=$?
trap true INT TERM EXIT
diff --git a/tests/test-requirements.txt b/tests/test-requirements.txt
new file mode 100644
index 0000000..bc7dc7f
--- /dev/null
+++ b/tests/test-requirements.txt
@@ -0,0 +1,4 @@
+jsonschema
+reno
+setuptools<45.0.0
+msgpack<1.0.0