Skip to content

Commit

Permalink
systemtests: devide webui selenium test into several individual tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper authored and pstorz committed Nov 8, 2019
1 parent ec7a98e commit 186b227
Show file tree
Hide file tree
Showing 453 changed files with 5,914 additions and 23 deletions.
34 changes: 25 additions & 9 deletions systemtests/CMakeLists.txt
Expand Up @@ -266,10 +266,22 @@ MESSAGE(STATUS "PYTHON_FOUND: " ${PYTHON_FOUND})
MESSAGE(STATUS "PYTHON_SELENIUM_FOUND: " ${PYTHON_SELENIUM_FOUND})
MESSAGE(STATUS "CHROMEDRIVER_FOUND: " ${CHROMEDRIVER_FOUND})

list(APPEND WEBUI_SELENIUM_TESTS
"webui-admin-client-disabling"
"webui-admin-rerun-job"
"webui-admin-restore"
"webui-admin-run-custom-job"
"webui-admin-run-job"
"webui-readonly-client-disabling"
"webui-readonly-rerun-job"
"webui-readonly-restore"
"webui-readonly-run-custom-job"
"webui-readonly-run-job")

IF(ENABLE_WEBUI_SELENIUM_TEST)
list(APPEND SYSTEM_TESTS "webui-selenium")
list(APPEND SYSTEM_TESTS ${WEBUI_SELENIUM_TESTS})
ELSE()
list(APPEND SYSTEM_TESTS_DISABLED "webui-selenium")
list(APPEND SYSTEM_TESTS_DISABLED ${WEBUI_SELENIUM_TESTS})
ENDIF()

set(BASEPORT 42001)
Expand Down Expand Up @@ -317,13 +329,17 @@ foreach(TEST_NAME ${SYSTEM_TESTS})
file(MAKE_DIRECTORY ${tmpdir})
file(MAKE_DIRECTORY ${working_dir})

# webui-selenium
IF(${TEST_NAME} STREQUAL "webui-selenium")
set(WEBUICONFDIR ${current_test_directory}/etc/bareos-webui) #used for testenvironment settings
file(MAKE_DIRECTORY ${WEBUICONFDIR})
configure_file("${CMAKE_SOURCE_DIR}/webui/config/autoload/global.php.in" "${current_test_directory}/webui/config/autoload/global.php" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/systemtests/tests/webui-selenium/directors.ini.in" "${current_test_directory}/etc/bareos-webui/directors.ini" @ONLY)
file(COPY "${CMAKE_SOURCE_DIR}/webui/install/configuration.ini" DESTINATION "${current_test_directory}/etc/bareos-webui/")
# webui specific settings
IF(ENABLE_WEBUI_SELENIUM_TEST)
foreach(SELENIUM_TEST ${WEBUI_SELENIUM_TESTS})
IF(${TEST_NAME} STREQUAL SELENIUM_TEST)
set(WEBUICONFDIR ${current_test_directory}/etc/bareos-webui) # used for testenvironment settings
file(MAKE_DIRECTORY ${WEBUICONFDIR})
configure_file("${CMAKE_SOURCE_DIR}/webui/config/autoload/global.php.in" "${current_test_directory}/webui/config/autoload/global.php" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/systemtests/tests/${TEST_NAME}/directors.ini.in" "${current_test_directory}/etc/bareos-webui/directors.ini" @ONLY)
file(COPY "${CMAKE_SOURCE_DIR}/webui/install/configuration.ini" DESTINATION "${current_test_directory}/etc/bareos-webui/")
ENDIF()
endforeach()
ENDIF()

ConfigureFilesToSystemtest("systemtests" "tests/${TEST_NAME}" "*" @ONLY)
Expand Down
2 changes: 2 additions & 0 deletions systemtests/scripts/cleanup
Expand Up @@ -25,6 +25,8 @@ find . -name "gigaslam.gif" -exec rm -f {} \;
#rm -rf ${conf}/bareos-dir-export/
#rm -rf ${conf}/tls/

# cleanup chrome user data (selenium tests)
rm -rf /tmp/chrome-user-data-*

#if [ -f ${scripts}/bareos ]; then
# ${scripts}/bareos stop 2>&1 >/dev/null
Expand Down
Expand Up @@ -79,4 +79,3 @@ dirport = 9101
;cert_file = ""
;cert_file_passphrase = ""
;allowed_cns = ""

Expand Up @@ -35,4 +35,3 @@ Profile {
# Allow access to restore to any filesystem location
Where ACL = *all*
}

60 changes: 60 additions & 0 deletions systemtests/tests/webui-admin-client-disabling/testrunner.in
@@ -0,0 +1,60 @@
#!/bin/sh
#
# Run a simple backup
# then restore it.
#
TestName="$(basename "$(pwd)")"
export TestName

JobName=backup-bareos-fd
. ./environment
. ${scripts}/functions

${scripts}/cleanup
${scripts}/setup


# Directory to backup.
# This directory will be created by setup_data().
BackupDirectory="${tmp}/data"

# Use a tgz to setup data to be backed up.
# Data will be placed at "${tmp}/data/".
setup_data

start_test

cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
@$out $tmp/log1.out
run job=$JobName yes
wait
messages
quit
END_OF_DATA

run_bareos

@PHP@ -S 127.0.0.1:@php_port@ -t @PROJECT_SOURCE_DIR@/../webui/public/ >"$tmp/php.out" 2>&1 &

PHP_PID=$(echo $!)

# run tests but stop the test run on the first error or failure

#
# test with admin profile resource
#
export BAREOS_WEBUI_PROFILE=admin
export BAREOS_WEBUI_TESTNAME=test_client_disabling
echo "test with admin profile:" >"$tmp/selenium.out" 2>&1
@PYTHON@ @CMAKE_SOURCE_DIR@/webui/tests/selenium/webui-selenium-test.py -v SeleniumTest.test_client_disabling >>"$tmp/selenium.out" 2>&1

estat=$?
export estat

kill "${PHP_PID}"

stop_bareos

end_test
81 changes: 81 additions & 0 deletions systemtests/tests/webui-admin-rerun-job/directors.ini.in
@@ -0,0 +1,81 @@
;
; Bareos WebUI Configuration File
;
; File: /usr/local/etc/bareos-webui/directors.ini
;

;------------------------------------------------------------------------------
; Section localhost-dir
;------------------------------------------------------------------------------
[localhost-dir]

; Enable or disable section. Possible values are "yes" or "no", the default is "yes".
enabled = "yes"

; Fill in the IP-Address or FQDN of you director.
diraddress = "localhost"

; Default value is 9101
dirport = @dir_port@

; Set catalog to explicit value if you have multiple catalogs
;catalog = "MyCatalog"

; Set the console name and password for a dedicated pam console;
; the counterpart console-config in the director must have set
; UsePamAuthentication = yes
;pam_console_name = "admin"
;pam_console_password = "admin"

; TLS verify peer
; Possible values: true or false
tls_verify_peer = false

; Server can do TLS
; Possible values: true or false
server_can_do_tls = false

; Server requires TLS
; Possible values: true or false
server_requires_tls = false

; Client can do TLS
; Possible values: true or false
client_can_do_tls = false

; Client requires TLS
; Possible value: true or false
client_requires_tls = false

; Path to the certificate authority file
; E.g. ca_file = "/usr/local/etc/bareos/tls/BareosCA.crt"
;ca_file = ""

; Path to the cert file which needs to contain the client certificate and the key in PEM encoding
; E.g. ca_file = "/usr/local/etc/bareos/tls/restricted-named-console.pem"
;cert_file = ""

; Passphrase needed to unlock the above cert file if set
;cert_file_passphrase = ""

; Allowed common names
; E.g. allowed_cns = "host1.example.com"
;allowed_cns = ""

;------------------------------------------------------------------------------
; Section another-host-dir
;------------------------------------------------------------------------------
[another-host-dir]
enabled = "no"
diraddress = "192.168.120.1"
dirport = 9101
;catalog = "MyCatalog"
;tls_verify_peer = false
;server_can_do_tls = false
;server_requires_tls = false
;client_can_do_tls = false
;client_requires_tls = false
;ca_file = ""
;cert_file = ""
;cert_file_passphrase = ""
;allowed_cns = ""
@@ -0,0 +1,8 @@
Catalog {
Name = MyCatalog
#dbdriver = "@DEFAULT_DB_TYPE@"
dbdriver = "XXX_REPLACE_WITH_DATABASE_DRIVER_XXX"
dbname = "@db_name@"
dbuser = "@db_user@"
dbpassword = "@db_password@"
}
@@ -0,0 +1,7 @@
Client {
Name = bareos-fd
Description = "Client resource of the Director itself."
Address = localhost
Password = "@fd_password@" # password for FileDaemon
FD PORT = @fd_port@
}
@@ -0,0 +1,17 @@
#
# Restricted console used by bareos-webui
#
Console {
Name = admin
Password = "admin"
Profile = "webui-admin"


# As php does not support TLS-PSK,
# and the director has TLS enabled by default,
# we need to either disable TLS or setup
# TLS with certificates.
#
# For testing purposes we disable it here
TLS Enable = No
}
@@ -0,0 +1,7 @@
Console {
Name = bareos-mon
Description = "Restricted console used by tray-monitor to get the status of the director."
Password = "@mon_dir_password@"
CommandACL = status, .status
JobACL = *all*
}
@@ -0,0 +1,17 @@
#
# Restricted console used by bareos-webui
#
Console {
Name = readonly
Password = "readonly"
Profile = "webui-readonly"


# As php does not support TLS-PSK,
# and the director has TLS enabled by default,
# we need to either disable TLS or setup
# TLS with certificates.
#
# For testing purposes we disable it here
TLS Enable = No
}
@@ -0,0 +1,27 @@
Director { # define myself
Name = bareos-dir
QueryFile = "@scriptdir@/query.sql"
Maximum Concurrent Jobs = 10
Password = "@dir_password@" # Console password
Messages = Daemon
Auditing = yes

# Enable the Heartbeat if you experience connection losses
# (eg. because of your router or firewall configuration).
# Additionally the Heartbeat can be enabled in bareos-sd and bareos-fd.
#
# Heartbeat Interval = 1 min

# remove comment in next line to load dynamic backends from specified directory
Backend Directory = @backenddir@

# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all director plugins (*-dir.so) from the "Plugin Directory".
#
# Plugin Directory = "@python_plugin_module_src_dir@"
# Plugin Names = ""
Working Directory = "@working_dir@"
Pid Directory = "@piddir@"
DirPort = @dir_port@
}
@@ -0,0 +1,11 @@
FileSet {
Name = "Catalog"
Description = "Backup the catalog dump and Bareos configuration files."
Include {
Options {
signature = MD5
}
File = "/var/lib/bareos/bareos.sql" # database dump
File = "/usr/local/etc/bareos" # configuration
}
}
@@ -0,0 +1,11 @@
FileSet {
Name = "Catalog"
Description = "Backup the catalog dump and Bareos configuration files."
Include {
Options {
signature = MD5
}
File = "@working_dir@/@db_name@.sql" # database dump
File = "@confdir@" # configuration
}
}
@@ -0,0 +1,31 @@
FileSet {
Name = "LinuxAll"
Description = "Backup all regular filesystems, determined by filesystem type."
Include {
Options {
Signature = MD5 # calculate md5 checksum per file
One FS = No # change into other filessytems
FS Type = btrfs
FS Type = ext2 # filesystems of given types will be backed up
FS Type = ext3 # others will be ignored
FS Type = ext4
FS Type = reiserfs
FS Type = jfs
FS Type = xfs
FS Type = zfs
}
File = /
}
# Things that usually have to be excluded
# You have to exclude /var/lib/bareos/storage
# on your bareos server
Exclude {
File = /var/lib/bareos
File = /var/lib/bareos/storage
File = /proc
File = /tmp
File = /var/tmp
File = /.journal
File = /.fsck
}
}
@@ -0,0 +1,31 @@
FileSet {
Name = "LinuxAll"
Description = "Backup all regular filesystems, determined by filesystem type."
Include {
Options {
Signature = MD5 # calculate md5 checksum per file
One FS = No # change into other filessytems
FS Type = btrfs
FS Type = ext2 # filesystems of given types will be backed up
FS Type = ext3 # others will be ignored
FS Type = ext4
FS Type = reiserfs
FS Type = jfs
FS Type = xfs
FS Type = zfs
}
File = /
}
# Things that usually have to be excluded
# You have to exclude @archivedir@
# on your bareos server
Exclude {
File = @working_dir@
File = @archivedir@
File = /proc
File = /tmp
File = /var/tmp
File = /.journal
File = /.fsck
}
}

0 comments on commit 186b227

Please sign in to comment.