Skip to content

Commit

Permalink
regress: first commit to modernize regress tests
Browse files Browse the repository at this point in the history
We will move the exising "regression" tests test by test
into the "systemtests" directory finally removing the
regress folder completely.

The systemtests tests are part of the cmake project
and so can be executed with "make test" directly.

The tests run on the compiled binaries inside of the
CMAKE_BINARY_DIR without needing a "make install" at all.

The idea is to have an individual folder inside of systemtests
for every test that has the tests name.

The first example for how that works is the
systemtests/tests/backup-bareos-test folder.

- Each test folder needs to be indipendent from the other, so that
  ctest can execute each of the tests in parallel.

- The full configuration for each test is stored in etc/bareos
  as .conf.in template files that are edited by cmake during the cmake
  run.

- each test has a "testrunner" script file that executes the test
  itself.

- The "testrunner" sources an individual environment shell script that
  contains the variables that are used for this test.
  • Loading branch information
pstorz committed Feb 27, 2019
1 parent 7d31bf6 commit e8c9b1a
Show file tree
Hide file tree
Showing 105 changed files with 2,691 additions and 99 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -17,5 +17,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
cmake_minimum_required(VERSION 3.0)
project(bareos)

# enable "make test"
enable_testing()
set(CMAKE_CTEST_COMMAND ctest -V)
include(CTest)

add_subdirectory(core)
add_subdirectory(webui)
add_subdirectory(systemtests)
2 changes: 2 additions & 0 deletions core/cmake/BareosSetVariableDefaults.cmake
Expand Up @@ -547,6 +547,8 @@ IF(NOT client-only)

# set first entry as default db backend
LIST(GET db_backends 0 default_db_backend)
set (DEFAULT_DB_TYPE ${default_db_backend} PARENT_SCOPE)
set (DEFAULT_DB_TYPE ${default_db_backend})
endif()

# tcp-wrappers
Expand Down
43 changes: 21 additions & 22 deletions core/scripts/bareos-config-lib.sh.in
@@ -1,14 +1,13 @@
#!/bin/sh

CONFIG_LIB=@scriptdir@/bareos-config-lib.sh
DIR_CFG=${BAREOS_CONFIG_DIR:-@confdir@}
DIR_SCRIPTS=@scriptdir@
DBCHECK="@sbindir@/bareos-dbcheck -c ${DIR_CFG} -B"
BAREOS_SCRIPTS_DIR="${BAREOS_SCRIPTS_DIR:-@scriptdir@}"
BAREOS_CONFIG_LIB=${BAREOS_SCRIPTS_DIR}/bareos-config-lib.sh
BAREOS_CONFIG_DIR=${BAREOS_CONFIG_DIR:-@confdir@}
BAREOS_SBIN_DIR=${BAREOS_SBIN_DIR:-@sbindir@}
DBCHECK="${BAREOS_SBIN_DIR}/bareos-dbcheck -c ${BAREOS_CONFIG_DIR} -B"
AWK="@AWK@"

SEC_GROUPS="tape disk"

WORKING_DIR="@working_dir@"
BAREOS_WORKING_DIR="${BAREOS_WORKING_DIR:-@working_dir@}"
FILE_DAEMON_USER="${BAREOS_FD_GROUP:-@fd_user@}"
FILE_DAEMON_GROUP="${BAREOS_FD_GROUP:-@fd_group@}"
STORAGE_DAEMON_USER="${BAREOS_SD_USER:-@sd_user@}"
Expand All @@ -18,9 +17,9 @@ DIRECTOR_DAEMON_GROUP="${BAREOS_DIR_GROUP:-@dir_group@}"
DAEMON_USER="$DIRECTOR_DAEMON_USER"
DAEMON_GROUP="$DIRECTOR_DAEMON_GROUP"

DB_NAME="@db_name@"
DB_NAME="${db_name:-@db_name@}"
DB_VERSION="@BDB_VERSION@"
SQL_DDL_DIR="@scriptdir@/ddl"
SQL_DDL_DIR="${BAREOS_SCRIPTS_DIR}/ddl"
SQLITE_BINDIR="@SQLITE_BINDIR@"
MYSQL_BINDIR="@MYSQL_BINDIR@"
POSTGRESQL_BINDIR="@POSTGRESQL_BINDIR@"
Expand Down Expand Up @@ -77,7 +76,7 @@ get_config_lib_file()
# can be used in following way:
# LIB=`bareos-config get_config_lib_file`
# . $LIB
echo "${CONFIG_LIB}"
echo "${BAREOS_CONFIG_LIB}"
}

get_user_fd()
Expand Down Expand Up @@ -122,7 +121,7 @@ get_bareos_dir()

get_working_dir()
{
echo "${WORKING_DIR}"
echo "${BAREOS_WORKING_DIR}"
}

get_database_ddl_dir()
Expand Down Expand Up @@ -297,7 +296,7 @@ setup_sd_user()
#
# Create a new storage_daemon_user
#
useradd -r --comment "bareos" --home ${WORKING_DIR} -g ${STORAGE_DAEMON_GROUP} ${NEW_ADD_GROUPS} --shell /bin/false ${STORAGE_DAEMON_USER} || warn "failed to create user ${STORAGE_DAEMON_USER}"
useradd -r --comment "bareos" --home ${BAREOS_WORKING_DIR} -g ${STORAGE_DAEMON_GROUP} ${NEW_ADD_GROUPS} --shell /bin/false ${STORAGE_DAEMON_USER} || warn "failed to create user ${STORAGE_DAEMON_USER}"
fi
}

Expand All @@ -315,10 +314,10 @@ get_config_path()

if [ -f "${COMPONENT}" ]; then
printf "%s" "${COMPONENT}"
elif [ -f "${DIR_CFG}/${COMPONENT}.conf" ]; then
printf "%s" "${DIR_CFG}/${COMPONENT}.conf"
elif [ -d "${DIR_CFG}/${COMPONENT}.d/" ]; then
printf "%s" "${DIR_CFG}/${COMPONENT}.d/"
elif [ -f "${BAREOS_CONFIG_DIR}/${COMPONENT}.conf" ]; then
printf "%s" "${BAREOS_CONFIG_DIR}/${COMPONENT}.conf"
elif [ -d "${BAREOS_CONFIG_DIR}/${COMPONENT}.d/" ]; then
printf "%s" "${BAREOS_CONFIG_DIR}/${COMPONENT}.d/"
else
warn "failed to find config for component \"${COMPONENT}\"."
return 1
Expand Down Expand Up @@ -1007,7 +1006,7 @@ replace()
SEARCH="$1"
REPLACE="$2"

for file in `grep -l ${SEARCH} ${DIR_CFG}/*.conf ${DIR_CFG}/bareos-*.d/*/*.conf 2>/dev/null`; do
for file in `grep -l ${SEARCH} ${BAREOS_CONFIG_DIR}/*.conf ${BAREOS_CONFIG_DIR}/bareos-*.d/*/*.conf 2>/dev/null`; do
if [ -f "$file" ]; then
echo "replacing '${SEARCH}' with '${REPLACE}' in $file"
if [ "$os_type" = "Darwin" -o "$os_type" = "FreeBSD" ]; then
Expand Down Expand Up @@ -1042,7 +1041,7 @@ replace_password()
SEARCH="$1"
REPLACE="$2"

for file in `grep -l ${SEARCH} ${DIR_CFG}/*.conf ${DIR_CFG}/bareos-*.d/*/*.conf ${DIR_CFG}/tray-monitor.d/*/*.conf 2>/dev/null`; do
for file in `grep -l ${SEARCH} ${BAREOS_CONFIG_DIR}/*.conf ${BAREOS_CONFIG_DIR}/bareos-*.d/*/*.conf ${BAREOS_CONFIG_DIR}/tray-monitor.d/*/*.conf 2>/dev/null`; do
echo "replacing '${SEARCH}' in $file"
if [ "$os_type" = "Darwin" -o "$os_type" = "FreeBSD" ]; then
sed -i '' "s#${SEARCH}#${REPLACE}#g" "${file}"
Expand All @@ -1061,17 +1060,17 @@ initialize_passwords()
#
# See if we need to generate a set of random passwords.
#
if [ ! -f ${DIR_CFG}/.rndpwd ]; then
if [ ! -f ${BAREOS_CONFIG_DIR}/.rndpwd ]; then
for string in ${PASSWORD_SUBST}
do
pass=`RANDFILE=/dev/urandom openssl rand -base64 33`
echo "${string}=${pass}" >> ${DIR_CFG}/.rndpwd
echo "${string}=${pass}" >> ${BAREOS_CONFIG_DIR}/.rndpwd
done
chmod 400 ${DIR_CFG}/.rndpwd
chmod 400 ${BAREOS_CONFIG_DIR}/.rndpwd
fi

# Source the passwords
. ${DIR_CFG}/.rndpwd
. ${BAREOS_CONFIG_DIR}/.rndpwd

for string in ${PASSWORD_SUBST}
do
Expand Down
Empty file modified core/scripts/bareos-config.in 100644 → 100755
Empty file.
74 changes: 23 additions & 51 deletions core/scripts/bareos-ctl-dir.in 100644 → 100755
@@ -1,64 +1,41 @@
#! /bin/sh
#! /bin/sh -x
#
# bareos-ctl-dir This shell script takes care of starting and stopping
# the bareos Director daemon
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
#
# description: Backup Archiving REcovery Open Sourced.
#

PSCMD="@PSCMD@"
PS="ps"

#
# On Solaris, you may need to use nawk, or alternatively,
# add the GNU binaries to your path, such as /usr/xpg4/bin
#
AWK=@AWK@

# All these are not *really* needed but it makes it
# easier to "steal" this code for the development
# environment where they are different.
#
BIN=@sbindir@/bareos-dir
BAREOS_DIR_BIN=$BIN
PIDDIR=@piddir@
SUBSYSDIR=@subsysdir@

BAREOS_CONFIG_DIR=${BAREOS_CONFIG_DIR:-@confdir@}
BAREOS_DIR_PORT=${BAREOS_DIR_PORT:-@dir_port@}
BAREOS_DIR_USER=${BAREOS_DIR_USER:-@dir_user@}
BAREOS_DIR_GROUP=${BAREOS_DIR_GROUP:-@dir_group@}

export PSCMD="@PSCMD@"
export PS="ps"
export AWK="@AWK@"
export PIDOF="@PIDOF@"
export PGREP="@PGREP@"

BAREOS_DIRECTOR_BINARY="${BAREOS_BIN_DIR:-@sbindir@/bareos-dir}"
export BAREOS_CONFIG_DIR=${BAREOS_CONFIG_DIR:-@confdir@}
BAREOS_DIRECTOR_PORT=${BAREOS_DIRECTOR_PORT:-@dir_port@}
BAREOS_DIRECTOR_USER=${BAREOS_DIRECTOR_USER:-@dir_user@}
BAREOS_DIRECTOR_GROUP=${BAREOS_DIRECTOR_GROUP:-@dir_group@}
BAREOS_SCRIPT_DIR=${BAREOS_SCRIPT_DIR:-@scriptdir@}
Bareos="@BAREOS@"
PIDOF="@PIDOF@"
PGREP="@PGREP@"

OS=`uname -s`

#
# Source the generic functions.
#
. @scriptdir@/bareos-ctl-funcs
. "${BAREOS_SCRIPT_DIR}/bareos-ctl-funcs"

# if /lib/tls exists, force Bareos to use the glibc pthreads instead
if [ -d "/lib/tls" -a $OS = "Linux" -a `uname -r | cut -c1-3` = "2.4" ] ; then
export LD_ASSUME_KERNEL=2.4.19
fi

case "$1" in
start)
if [ -x ${BIN} ]; then
if [ -x "${BAREOS_DIRECTOR_BINARY}" ]; then
echo "Starting the $Bareos Director daemon"
OPTIONS=''
if [ "${BAREOS_DIR_USER}" != '' ]; then
OPTIONS="${OPTIONS} -u ${BAREOS_DIR_USER}"
if [ "${BAREOS_DIRECTOR_USER}" != '' ]; then
OPTIONS="${OPTIONS} -u ${BAREOS_DIRECTOR_USER}"
fi

if [ "${BAREOS_DIR_GROUP}" != '' ]; then
OPTIONS="${OPTIONS} -g ${BAREOS_DIR_GROUP}"
if [ "${BAREOS_DIRECTOR_GROUP}" != '' ]; then
OPTIONS="${OPTIONS} -g ${BAREOS_DIRECTOR_GROUP}"
fi

if [ "${BAREOS_CONFIG_DIR}" != '' ]; then
Expand All @@ -70,19 +47,14 @@ case "$1" in
exit 1
fi

if [ "x${VALGRIND_DIR}" = "x1" ]; then
valgrind --leak-check=full ${BIN} -v $2 $3 ${OPTIONS}
else
${BIN} -v $2 $3 ${OPTIONS}
fi
sleep 1
"${BAREOS_DIRECTOR_BINARY}" -v $2 $3 ${OPTIONS}
fi
;;

stop)
if [ -x ${BIN} ]; then
if [ -x "${BAREOS_DIRECTOR_BINARY}" ]; then
echo "Stopping the $Bareos Director daemon"
killproc ${BIN} ${BAREOS_DIR_PORT}
killproc "${BAREOS_DIRECTOR_BINARY}" "${BAREOS_DIRECTOR_PORT}"
fi
;;

Expand All @@ -93,7 +65,7 @@ case "$1" in
;;

status)
[ -x ${BIN} ] && status ${BIN} ${BAREOS_DIR_PORT}
[ -x "${BAREOS_DIRECTOR_BINARY}" ] && status "${BAREOS_DIRECTOR_BINARY}" "${BAREOS_DIRECTOR_PORT}"
exit $?
;;

Expand Down
Empty file modified core/scripts/bareos-ctl-fd.in 100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions core/scripts/bareos-ctl-funcs 100644 → 100755
Expand Up @@ -75,11 +75,11 @@ killproc() {
if ${PS} -p "$pid">/dev/null 2>&1; then
# TERM first, then KILL if not dead
kill -TERM $pid 2>/dev/null
sleep 1
#sleep 0.1
if ${PS} -p "$pid" >/dev/null 2>&1 ; then
sleep 1
#sleep 0.1
if ${PS} -p "$pid" >/dev/null 2>&1 ; then
sleep 3
#sleep 0.3
if ${PS} -p "$pid" >/dev/null 2>&1 ; then
kill -KILL $pid 2>/dev/null
fi
Expand All @@ -103,7 +103,7 @@ killproc() {
fi
# Remove pid file if any.
if [ "$notset" = "1" ]; then
rm -f ${PIDDIR}/$base.$2.pid
rm -f "${PIDDIR}/$base.$2.pid"
fi
return $RC
}
Expand All @@ -113,10 +113,10 @@ checkcfg() {
RC=0
echo "Checking Configuration and Database connection ... "
if [ ! -z "${DIR_USER}" -a "${DIR_USER}" != "${USER}" ]; then
su -s /bin/sh ${DIR_USER} -c "${BAREOS_DIR_BIN} ${OPTIONS} -f -t"
su -s /bin/sh "${DIR_USER}" -c "${BAREOS_DIRECTOR_BINARY}" ${OPTIONS} -f -t
RC=$?
else
${BAREOS_DIR_BIN} ${OPTIONS} -f -t
"${BAREOS_DIRECTOR_BINARY}" ${OPTIONS} -f -t
RC=$?
fi
return $RC
Expand Down
Empty file modified core/scripts/bareos-ctl-sd.in 100644 → 100755
Empty file.
34 changes: 14 additions & 20 deletions core/scripts/bareos.in 100644 → 100755
Expand Up @@ -3,17 +3,11 @@
# bareos This shell script takes care of starting and stopping
# the bareos daemons.
#
# This is pretty much watered down version of the RedHat script
# that works on Solaris as well as Linux, but it won't work everywhere.
#
# description: Backup Archiving REcovery Open Sourced.
#

# All these are not *really* needed but it makes it
# easier to "steal" this code for the development
# environment where they are different.
#
SCRIPTDIR=@scriptdir@
export BAREOS_CONFIG_DIR=${BAREOS_CONFIG_DIR:-@confdir@}
BAREOS_SCRIPTDIR=${BAREOS_SCRIPTDIR:-@scriptdir@}
#
# Disable Glibc malloc checks, it doesn't help and it keeps from getting
# good dumps
Expand All @@ -22,16 +16,16 @@ export MALLOC_CHECK_

case "$1" in
start)
[ -x ${SCRIPTDIR}/bareos-ctl-sd ] && ${SCRIPTDIR}/bareos-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bareos-ctl-fd ] && ${SCRIPTDIR}/bareos-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bareos-ctl-dir ] && ${SCRIPTDIR}/bareos-ctl-dir $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-sd ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-sd $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-fd ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-fd $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-dir ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-dir $1 $2
;;

stop)
# Stop the FD first so that SD will fail jobs and update catalog
[ -x ${SCRIPTDIR}/bareos-ctl-fd ] && ${SCRIPTDIR}/bareos-ctl-fd $1 $2
[ -x ${SCRIPTDIR}/bareos-ctl-sd ] && ${SCRIPTDIR}/bareos-ctl-sd $1 $2
[ -x ${SCRIPTDIR}/bareos-ctl-dir ] && ${SCRIPTDIR}/bareos-ctl-dir $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-fd ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-fd $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-sd ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-sd $1 $2
[ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-dir ] && ${BAREOS_SCRIPTDIR}/bareos-ctl-dir $1 $2
;;

restart)
Expand All @@ -41,16 +35,16 @@ case "$1" in
;;

status)
if [ -x ${SCRIPTDIR}/bareos-ctl-dir ]; then
${SCRIPTDIR}/bareos-ctl-dir status
if [ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-dir ]; then
${BAREOS_SCRIPTDIR}/bareos-ctl-dir status
status_dir=$?
fi
if [ -x ${SCRIPTDIR}/bareos-ctl-sd ]; then
${SCRIPTDIR}/bareos-ctl-sd status
if [ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-sd ]; then
${BAREOS_SCRIPTDIR}/bareos-ctl-sd status
status_sd=$?
fi
if [ -x ${SCRIPTDIR}/bareos-ctl-fd ]; then
${SCRIPTDIR}/bareos-ctl-fd status
if [ -x ${BAREOS_SCRIPTDIR}/bareos-ctl-fd ]; then
${BAREOS_SCRIPTDIR}/bareos-ctl-fd status
status_fd=$?
fi
status_all=`expr ${status_dir:-0} + ${status_sd:-0} + ${status_fd:-0}`
Expand Down
Empty file modified core/src/cats/create_bareos_database.in 100644 → 100755
Empty file.
Empty file modified core/src/cats/drop_bareos_database.in 100644 → 100755
Empty file.
Empty file modified core/src/cats/drop_bareos_tables.in 100644 → 100755
Empty file.
Empty file modified core/src/cats/grant_bareos_privileges.in 100644 → 100755
Empty file.
Empty file modified core/src/cats/make_bareos_tables.in 100644 → 100755
Empty file.
Empty file modified core/src/cats/update_bareos_tables.in 100644 → 100755
Empty file.

0 comments on commit e8c9b1a

Please sign in to comment.