Skip to content

Commit

Permalink
python: implement connection test for Python-Bareos TLS-PSK
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Jan 22, 2019
1 parent 894a0e5 commit 09488fb
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
1 change: 1 addition & 0 deletions regress/DartTestfile.txt.in
@@ -1,5 +1,6 @@
ADD_TEST(disk:webui-connection-test "../webui/tests/regress/webui-bsock-connection-test")
#ADD_TEST(disk:tray-monitor-connection-test "@regressdir@/tests/tray-monitor-connection-test")
ADD_TEST(disk:python-bareos-connection-test "@regressdir@/tests/python-bareos-connection-test")
ADD_TEST(disk:lan-addr-test "@regressdir@/tests/lan-addr-test")
ADD_TEST(disk:lan-addr-test-passive "@regressdir@/tests/lan-addr-test-passive")
ADD_TEST(disk:reload-test "@regressdir@/tests/reload-test")
Expand Down
108 changes: 108 additions & 0 deletions regress/configs/python-bareos-connection-test/bareos-dir.conf.in
@@ -0,0 +1,108 @@
#
# Default Bareos Director Configuration file
#
# The only thing that MUST be changed is to add one or more
# file or directory names in the Include directive of the
# FileSet resource.
#
# You might also want to change the default email address
# from root to your address. See the "mail" and "operator"
# directives in the Messages resource.
#
Director { # define myself
Name = @hostname@-dir
DIRPort = @dirport@ # where we listen for UA connections
QueryFile = "@scriptdir@/query.sql"
WorkingDirectory = "@working_dir@"
PidDirectory = "@piddir@"
Maximum Concurrent Jobs = 4
Password = "bareos" # Console password
Messages = Standard
}

JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = @hostname@-fd
FileSet = FS_TESTJOB
Storage = File
Messages = Standard
Pool = Default
Priority = 10
Maximum Concurrent Jobs = 16
}

Job {
Name = "BackupClient1"
JobDefs = "DefaultJob"
Client Run Before Job = "@working_dir@/runbeforejob.sh"
Client Run Before Job = "@tmpdir@/runbeforejob.sh"
}


FileSet {
Name = FS_TESTJOB
Include {
File=<@tmpdir@/file-list
}
}


# Client (File Services) to backup
Client {
Name = @hostname@-fd
Address = @hostname@
FDPort = @fdport@
Catalog = MyCatalog
Password = "xevrjURYoCHhn26RaJoWbeWXEY/a3VqGKp/37tgWiuHc" # password for FileDaemon
Maximum Concurrent Jobs = 4

}

# Definiton of file storage device
Storage {
Name = File
Address = @hostname@ # N.B. Use a fully qualified name here
SDPort = @sdport@
Password = "ccV3lVTsQRsdIUGyab0N4sMDavui2hOBkmpBU0aQKOr9"
Device = FileStorage
Media Type = File
Maximum Concurrent Jobs = 4
}

# Generic catalog service
Catalog {
Name = MyCatalog
@libdbi@
dbdriver = "@db_type@"
dbname = @db_name@
user = @db_user@
password = "@db_password@"
}


Messages {
Name = Standard
console = all, !skipped, !saved, !audit
catalog = all, !skipped, !audit
}

# Default pool definition
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365d # one year
}

#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = @hostname@-mon
Password = "mon-dir-password"
CommandACL = status, .status
JobACL = *all*
}
@@ -0,0 +1,5 @@
import bareos.bsock

password=bareos.bsock.Password("bareos")
directorconsole=bareos.bsock.DirectorConsole(address="@hostname@", port=@dirport@, password=password)

43 changes: 43 additions & 0 deletions regress/tests/python-bareos-connection-test
@@ -0,0 +1,43 @@
#!/bin/sh
#
# Run a simple connection test
# with Python-Bareos
#
TestName="python-bareos-connection-test"

bareos_python_test_script="python-bareos-test.py"
bareos_python_module_source_dir="../python-bareos"
python_interpreter="python"
python_tlspsk_module="sslpsk"

. scripts/functions

scripts/cleanup
copy_configs

start_test
run_bareos

error_occurred=0

if [ -z `command -v ${python_interpreter}` ]; then
echo "Error: Could not find python interpreter."
error_occurred=1
elif ! python -c "import ${python_tlspsk_module}"; then
echo "Error: Could not import python module \"${python_tlspsk_module}\"."
error_occurred=1
else
PYTHONPATH=${bareos_python_module_source_dir} ${python_interpreter} configs/${TestName}/${bareos_python_test_script}
if [ $? != 0 ]; then
echo "Python-Bareos test failed."
error_occurred=1
fi
fi

stop_bareos

export estat
let estat=error_occurred

end_test

0 comments on commit 09488fb

Please sign in to comment.