Add simple logging to make it possible to monitor whether the backup ran
successfully or not
Related-to: PROD-36114
Related-to: JCDA-4782
Change-Id: Ia37c90c87c9d248746b3e997c3a3cede7339a0a8
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 9761585..4af18a6 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
diff --git a/zookeeper/files/backup/zookeeper-backup-client-runner.sh b/zookeeper/files/backup/zookeeper-backup-client-runner.sh
index fbb72e7..64e5f83 100644
--- a/zookeeper/files/backup/zookeeper-backup-client-runner.sh
+++ b/zookeeper/files/backup/zookeeper-backup-client-runner.sh
@@ -101,10 +101,12 @@
if [ $RC -gt 0 ]; then
printf "Error generating tar archive.\n"
+ logger -t "MCP_backup $0" "Error generating tar archive."
[ "$TMPDIR" != "/" ] && rm -rf "$TMPDIR"
exit 1
else
printf "Successfully created a backup tar file.\n"
+ logger -t "MCP_backup $0" "Successfully created a backup tar file."
[ "$TMPDIR" != "/" ] && rm -rf "$TMPDIR"
fi
@@ -125,8 +127,10 @@
if [ -s $RSYNCLOG ] && ! grep -q "rsync error: " $RSYNCLOG; then
echo "Rsync to remote host completed OK"
+ logger -t "MCP_backup $0" "Rsync to remote host completed OK"
else
echo "Rsync to remote host FAILED"
+ logger -t "MCP_backup $0" "Rsync to remote host FAILED"
exit 1
fi