Skip to content

Commit

Permalink
Merge pull request #573 from bareos/dev/pstorz/master/enable-mysql-sq…
Browse files Browse the repository at this point in the history
…lite-for-testing

enable testing of deprecated databases (MySQL and SQLite)
  • Loading branch information
pstorz committed Aug 19, 2020
2 parents 74794e0 + 9e01247 commit c65b6b0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
21 changes: 17 additions & 4 deletions core/src/cats/create_bareos_database.in
Expand Up @@ -81,12 +81,25 @@ fi

case ${db_type} in
sqlite3)
echo "The SQLite database backend is deprecated. Please use PostgreSQL instead."
retval=1
if [ -n "$BAREOS_TEST_RUNNING" ]; then
sqlite3 $* ${working_dir}/${db_name}.db ".tables"
# Allow non root access
chown ${dir_user}:${dir_group} ${working_dir}/${db_name}.db
chmod 0640 ${working_dir}/${db_name}.db
retval=0
else
echo "The SQLite database backend is deprecated. Please use PostgreSQL instead."
retval=1
fi
;;
mysql)
echo "The MySQL database backend is deprecated. Please use PostgreSQL instead."
retval=1
if [ -n "$BAREOS_TEST_RUNNING" ]; then
mysql $* -e "CREATE DATABASE ${db_name};"
retval=$?
else
echo "The MySQL database backend is deprecated. Please use PostgreSQL instead."
retval=1
fi
;;
postgresql)
#
Expand Down
28 changes: 22 additions & 6 deletions core/src/cats/make_bareos_tables.in
Expand Up @@ -110,14 +110,30 @@ fi

case ${db_type} in
sqlite3)
echo "The SQLite database backend is deprecated. Please use PostgreSQL instead."
echo "Creation of Bareos SQLite tables aborted."
retval=1
if [ -n "$BAREOS_TEST_RUNNING" ]; then
sqlite3 $* ${working_dir}/${db_name}.db < ${temp_sql_schema}
chmod 640 ${working_dir}/${db_name}.db
retval=0
else
echo "The SQLite database backend is deprecated. Please use PostgreSQL instead."
echo "Creation of Bareos SQLite tables aborted."
retval=1
fi
;;
mysql)
echo "The MySQL database backend is deprecated. Please use PostgreSQL instead."
echo "Creation of Bareos MySQL tables aborted."
retval=1
if [ -n "$BAREOS_TEST_RUNNING" ]; then
mysql $* --database=${db_name} -f < ${temp_sql_schema}
retval=$?
if test $retval = 0; then
echo "Creation of Bareos MySQL tables succeeded."
else
echo "Creation of Bareos MySQL tables failed."
fi
else
echo "The MySQL database backend is deprecated. Please use PostgreSQL instead."
echo "Creation of Bareos MySQL tables aborted."
retval=1
fi
;;
postgresql)
PGOPTIONS='--client-min-messages=warning' psql -f ${temp_sql_schema} -d ${db_name} $*
Expand Down
3 changes: 3 additions & 0 deletions systemtests/environment.in
Expand Up @@ -114,3 +114,6 @@ if [ -d /usr/lib/postgresql ]; then
else
export PATH=/sbin:/usr/sbin:$PATH
fi

# enable deprecated database handling in scripts
export BAREOS_TEST_RUNNING=yes
Expand Up @@ -5,8 +5,6 @@ FileSet {
Options {
Signature = MD5 # calculate md5 checksum per file
}
#File = "@sbindir@"
File=<@tmpdir@/file-list
Plugin = "python:module_path=@python_plugin_module_src_test_dir_relative@:module_name=bareos-fd-local-fileset-with-restoreobjects:filename=@tmpdir@/file-list-python-plugin"
}
}

0 comments on commit c65b6b0

Please sign in to comment.