Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
let testing environment run against binary Bareos packages
Browse files Browse the repository at this point in the history
Originally, bareos-regress has been intended to run regression tests
against source code as well as against prebuild and installed packages.
However, over the years, it seams, that regression tests did only run
against source code.

This commit cleans up the regression code quite a bit.

  * As data source for backups, one of the files data/*.tgz can be used
    (with setup_data data/small.tgz, it will be unpacked to $tmp/data/).
    Before, tests did use some subdirectories of the Bareos source code
    (which is not available when running against binary packages).

  * Creates bareos-regress packages (Debian and RPM). These should contain
    all required dependencies. Especially the package
    bareos-regress-config is required, containing the configuration and
    required additional binaries from bareos-core.
  • Loading branch information
joergsteffens committed Oct 2, 2017
1 parent 77d940c commit 7ce2f03
Show file tree
Hide file tree
Showing 495 changed files with 3,858 additions and 10,513 deletions.
2 changes: 2 additions & 0 deletions DartTestfile.txt.in
Expand Up @@ -83,7 +83,9 @@ ADD_TEST(disk:scratchpool-pool-test "@regressdir@/tests/scratchpool-pool-test")
ADD_TEST(disk:six-vol-test "@regressdir@/tests/six-vol-test")
ADD_TEST(disk:span-vol-test "@regressdir@/tests/span-vol-test")
ADD_TEST(disk:sparse-compressed-test "@regressdir@/tests/sparse-compressed-test")
ADD_TEST(disk:sparse-encrypt-test "@regressdir@/tests/sparse-encrypt-test")
ADD_TEST(disk:sparse-test "@regressdir@/tests/sparse-test")
ADD_TEST(disk:sha-test "@regressdir@/tests/sha-test")
ADD_TEST(disk:strip-test "@regressdir@/tests/strip-test")
ADD_TEST(disk:2drive-3pool-test "@regressdir@/tests/2drive-3pool-test")
ADD_TEST(disk:2drive-concurrent-test "@regressdir@/tests/2drive-concurrent-test")
Expand Down
49 changes: 36 additions & 13 deletions Makefile
Expand Up @@ -9,28 +9,25 @@
# Then edit config and set the value for what are appropriate for you.
#

first_rule: all
nothing:

all:

setup: bareos sed
setup: prepare bareos sed

#
# Some machines cannot handle the sticky bit and other garbage that
# is in weird-files, so we load and run it only on Linux machines.
#
bareos: all
@rm -rf bin build weird-files tmp
@rm -f w.tar.gz w.tar
@cp weird-files.tar.gz w.tar.gz
@-gunzip -f w.tar.gz
@-tar xf w.tar
@rm -f w.tar.gz w.tar
@rm -rf tmp working dumps
mkdir tmp working dumps
bareos: prepare
echo "Doing: scripts/setup"
scripts/setup

prepare:
@rm -rf weird-files
# ignore errors
tar -xzf weird-files.tar.gz || true
@rm -rf tmp working dumps
mkdir tmp working dumps

sed:
echo "Doing: scripts/do_sed"
scripts/do_sed
Expand All @@ -47,6 +44,32 @@ full_test:
root_test:
./all-root-tests

DEST := $(DESTDIR)/var/lib/bareos/bareos-regress
install:
mkdir -p $(DEST)
# directories
rsync -a configs $(DEST)
rsync -a data $(DEST)
rsync -a scripts $(DEST)
rsync -a tests $(DEST)
# files
rsync -a \
CTestCustom.cmake \
DartConfiguration.tcl* DartTestfile.txt* \
Makefile all-* \
debug do_* \
encrypt-* endtime experimental-* \
make-ctest-adds misc-tests \
nightly-* prototype.conf \
rtest run* \
startover_libdbi.sh starttime tape \
weird-files.tar.gz \
$(DEST)
mkdir -p $(DEST)/bin
mkdir -p $(DEST)/dumps
mkdir -p $(DEST)/tmp
mkdir -p $(DEST)/working

clean:
scripts/cleanup
rm -f tmp/file-list
Expand Down
139 changes: 69 additions & 70 deletions README
@@ -1,51 +1,79 @@
Bareos Regression
Kern Sibbald
Bareos Regression
=================

Origial author: Kern Sibbald

This is Bareos's regression script directory.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Warning!!!! Make sure not to run it on the same system
with your production Catalog because the tables will all
be cleared. You can run it on the your production system
if you use a different database. E.g. if your production
system uses MySQL, you can use SQLite here.
be deleted (dropped and recreated).
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

bareos-regress package
======================

When using the bareos-regress package,
the software is already preconfigured to test bareos,
provided by the normal install packages.
The Bareos packages include a package that provide the required configuration:
bareos-regress-config

# as root: stop all running bareos daemon

# switch to user to bareos
su - bareos -s /bin/bash

# enable debug output
export REGRESS_DEBUG=1

# run a single test (and verify that it ends with "OK"
tests/backup-bareos-test

# run all disk tests
./all-disk-tests



Local Build
===========

get sources from github
-----------------------

# get Bareos core
git clone https://github.com/bareos/bareos-regress

# get bareos-regress
git clone https://github.com/bareos/bareos-regress

To set it up, create your personal configuration file, by
copying prototype.conf to config or simply editing prototype.conf
directly then copying it to the file config.

cp prototype.conf config
cd bareos-regress
cp prototype.conf config

You must end up with a file named config in the main regress
directory that has all the specifications that correspond to
your system.

If you are using SQLite, make sure that depkgs is pre-built if it
isn't already: (cd your-depkgs; make sqlite).

Note, if you use any database other than SQLite, be sure it is not
your production database because Bareos will delete all the tables
and recreate them. With SQLite, a new different database is created,
so it will not affect your production system.

Using the .conf file, you can now select between any Catalog type:
SQLite, SQLite3, MySQL, or PostgreSQL. Be aware, however, if you
use an installed database on a production server, running these
tests will delete all the tables !!!!!!!!!!!!!!!!!! I run my
tests on a non-production machine, and in addition, I normally use
SQLite as the database, while my production uses MySQL.
Note, be sure it is not your production database
because Bareos will delete all the tables
and recreate them.

Then do:

make setup

You run the above one time. This will build a Makefile from
Makefile.in and your xxx.conf file, copy the Bareos source,
configure, build it, and configure all the Bareos scripts
and conf files. If you change your source, you will need to
redo this command.
You run the above one time.
This will substitute all variables in the *.in files,
copy the Bareos source, configure and build it.
If you change your source, you will need to redo this command.

If you only change some bareos-regress *.in files,
only a "make sed" is required.

Then you can run any of the tests in the tests subdirectory.
Each test whose name ends in -root requires you to be root for
Expand All @@ -54,7 +82,7 @@ test. Aside from the required "make setup", each test is totally
self-initalizing and should clean up after itself.

All the tests expect you to execute them from the main regress
directory!
directory.

Running the disk based tests:

Expand Down Expand Up @@ -92,7 +120,7 @@ or all non-root tests (my normal testing under my account)

./all-non-root-tests

or all tests (I only run these before a production release):
or all tests

su
./all-tests
Expand All @@ -117,22 +145,23 @@ ending with:
and it is assumed to be mounted.
-changer => you have an autochanger

Adding tests:

If you want to add more tests, do so by putting the shell script
in the tests subdirectory. Be careful when adding (or better not)
new clients, pools, and such to the test-bareos-dir.conf.in file
as it may invalidate a good number of tests, which respond to
questions by answering with a number (i.e. the order of the selection
list is known). It might be better to add your own testb-bareos...
configuration file.
Adding tests
============

If you want to add more tests, you can start from the example tests/1-example-test
and follow the instructions in this file, especially about where the configuration comes from
(configs/BASE plus individual extensions).

To avoid re-doing a make setup if you have made a change to the
conf files, and you do not need a new copy of the source, you can simply do:

make sed

Debugging failed tests:


Debugging failed tests
======================

Prior versions required editing the tests/xxxx and changing a debug flag.
However, that has been replaced by two environment variables:
Expand Down Expand Up @@ -181,7 +210,6 @@ In shell window 1
(ignore the error message it prints complaining that the daemon
you are debugging is already running, which is in fact the case).


That is all there is to it. The debugger window will get some
output and will stop waiting for input if anything goes wrong
like a seg fault. At that point, you can enter commands.
Expand All @@ -190,9 +218,11 @@ The procedure avoids modifying the test scripts and trying to
find pids and the such. If you want less debug output when
debugging, don't set REGRESS_DEBUG=1.

===

Also, if you run from time to time on a computer that is not connected
Troubleshooting
===============

If you run from time to time on a computer that is not connected
to the network, please be sure that "hostname" is set to "localhost",
otherwise, your tests may fail because the hostname used by Bareos's
./configure cannot be properly resolved.
Expand Down Expand Up @@ -223,34 +253,3 @@ free_addresses(dlist*) + 53 in section .text
info symbol 0x8082d58
add_address(dlist**, IPADDR::i_type, unsigned short, int, char const*, char
const*, char**) + 568 in section .text

Testing a Binary Installation:

If you have installed your Bareos from a binary release such as (rpms or
debs), you can still run regression tests on it. First, make sure that your
regression config file uses the same catalog backend as your installed
binaries. Then define the variables bin and scripts variables in your config
file.

Example:
bin=/opt/bareos/bin
scripts=/opt/bareos/scripts

The ./scripts/prepare-other-loc will tweak the regress scripts to use
your binary location. You will need to run it manually once before you run any
regression tests.

$ ./scripts/prepare-other-loc
$ ./tests/backup-bareos-test
...

All regression scripts must be run by hand or by calling the test scripts.
These are principally scripts that begin with all_... such as all_disk_tests},
./all_tests

None of the
./do_disk, ./do_all, ./nightly... scripts will work.

If you want to switch back to running the regression scripts from source, first
remove the bin and scripts variables from your config file and
rerun the make setup step.
44 changes: 0 additions & 44 deletions README.mingw32

This file was deleted.

3 changes: 1 addition & 2 deletions configs/BASE/bareos-dir.d/catalog/MyCatalog.conf.in
@@ -1,7 +1,6 @@
Catalog {
Name = MyCatalog
#dbdriver = "@DEFAULT_DB_TYPE@"
#dbdriver = "XXX_REPLACE_WITH_DATABASE_DRIVER_XXX"
dbdriver = "@db_type@"
dbname = "@db_name@"
dbuser = "@db_user@"
dbpassword = "@db_password@"
Expand Down
6 changes: 3 additions & 3 deletions configs/BASE/bareos-dir.d/client/bareos-fd.conf.in
Expand Up @@ -4,8 +4,8 @@ Client {
Address = localhost
Password = "@fd_password@" # password for FileDaemon
TLS Require = yes
TLS Certificate = "@scriptdir@/tls/bareos-dir.bareos.org-cert.pem"
TLS Key = "@scriptdir@/tls/bareos-dir.bareos.org-key.pem"
TLS CA Certificate File = "@scriptdir@/tls/bareos-ca.pem"
TLS Certificate = "@confdir@/tls/bareos-dir.bareos.org-cert.pem"
TLS Key = "@confdir@/tls/bareos-dir.bareos.org-key.pem"
TLS CA Certificate File = "@confdir@/tls/bareos-ca.pem"
TLS Allowed CN = client1.bareos.org
}
1 change: 1 addition & 0 deletions configs/BASE/bareos-dir.d/director/bareos-dir.conf.in
@@ -1,5 +1,6 @@
Director { # define myself
Name = bareos-dir
Dir Port = @dirport@
QueryFile = "@scriptdir@/query.sql"
Maximum Concurrent Jobs = 10
Password = "@dir_password@" # Console password
Expand Down
6 changes: 3 additions & 3 deletions configs/BASE/bareos-dir.d/storage/File1.conf.in
Expand Up @@ -5,9 +5,9 @@ Storage {
Device = File1
Media Type = File1
TLS Require = yes
TLS Certificate = "@scriptdir@/tls/bareos-dir.bareos.org-cert.pem"
TLS Key = "@scriptdir@/tls/bareos-dir.bareos.org-key.pem"
TLS CA Certificate File = "@scriptdir@/tls/bareos-ca.pem"
TLS Certificate = "@confdir@/tls/bareos-dir.bareos.org-cert.pem"
TLS Key = "@confdir@/tls/bareos-dir.bareos.org-key.pem"
TLS CA Certificate File = "@confdir@/tls/bareos-ca.pem"
TLS Verify Peer = no
TLS Allowed CN = bareos-sd1.bareos.org
TLS Allowed CN = bareos-sd2.bareos.org
Expand Down

0 comments on commit 7ce2f03

Please sign in to comment.