Skip to content

Commit

Permalink
Merge pull request #222 from bareos/dev/fbergkemper/master/systemtest…
Browse files Browse the repository at this point in the history
…s-story-2976

systemtests: webui selenium tests integration
  • Loading branch information
franku committed Jul 18, 2019
2 parents 24689b5 + 276879e commit 1c348e2
Show file tree
Hide file tree
Showing 47 changed files with 705 additions and 33 deletions.
68 changes: 59 additions & 9 deletions systemtests/CMakeLists.txt
Expand Up @@ -29,14 +29,25 @@ function(ConfigureFilesToSystemtest srcdir subdirectory globexpression configure
foreach(CURRENT_FILE ${ALL_FILES})
MATH(EXPR COUNT "${COUNT}+1")
string(REPLACE "${CMAKE_SOURCE_DIR}/" "" TARGET_FILE ${CURRENT_FILE})
string(REPLACE ".in" "" TARGET_FILE ${TARGET_FILE})
string(REGEX REPLACE ".in$" "" TARGET_FILE ${TARGET_FILE}) # do not mess with .ini files
#MESSAGE(STATUS "configuring ${TARGET_FILE}" )
string(REPLACE "${srcdir}/${subdirectory}" "" TARGET_FILE ${TARGET_FILE})
configure_file(${CURRENT_FILE} ${PROJECT_BINARY_DIR}/${subdirectory}/${TARGET_FILE} ${configure_option})
endforeach()
MESSAGE(STATUS "Configured ${COUNT} files from ${srcdir} to ${subdirectory} with glob ${globexpression} ${configure_option}" )
endfunction()

# generic function to probe for a python module
function(PythonModuleStatus module)
EXECUTE_PROCESS(COMMAND "${PYTHON}" "-c" "import ${module}" RESULT_VARIABLE ${module}_status ERROR_QUIET)
STRING(TOUPPER ${module} module_uppercase)
IF(${module}_status EQUAL 0)
SET("PYTHON_${module_uppercase}_FOUND" TRUE PARENT_SCOPE)
ELSE()
SET("PYTHON_${module_uppercase}_FOUND" FALSE PARENT_SCOPE)
ENDIF()
endfunction()

macro(CheckForEnabledAndDisabledListEntry TEST_NAME_TO_CHECK)
IF(${TEST_NAME_TO_CHECK} IN_LIST SYSTEM_TESTS AND ${TEST_NAME_TO_CHECK} IN_LIST SYSTEM_TESTS_DISABLED)
message(FATAL_ERROR "The test name: ${TEST_NAME} is listed ambiguously in SYSTEM_TESTS and SYSTEM_TESTS_DISABLED at the same time")
Expand All @@ -48,8 +59,8 @@ file(STRINGS ${CMAKE_SOURCE_DIR}/core/src/cats/cats.h DB_VERSION_STRING REGEX .*
string(REGEX MATCH [0-9]+ BDB_VERSION ${DB_VERSION_STRING})

find_program(PERL perl)


find_program(PYTHON python)
find_program(PHP php)

# set variable values to be replaced by configure_file
#set(DEFAULT_DB_TYPE ${default_db_backend})
Expand Down Expand Up @@ -107,7 +118,6 @@ set(working_dir ${PROJECT_BINARY_DIR}/working)
set(piddir ${PROJECT_BINARY_DIR}/piddir)
file(MAKE_DIRECTORY ${piddir})


#set(BASEPORT ${dir_port})

# for config-lib.sh: do not remove @DB___@ but replace them with the original
Expand All @@ -116,10 +126,6 @@ set(DB_USER @DB_USER@)
set(DB_PASS @DB_PASS@)
set(DB_VERSION @DB_VERSION@)





ConfigureFilesToSystemtest("systemtests" "data" "*.tgz" COPYONLY)

ConfigureFilesToSystemtest("systemtests" "scripts" "functions" @ONLY)
Expand Down Expand Up @@ -194,6 +200,7 @@ IF(PAM_WRAPPER_LIBRARIES) # BareosFindLibrary(pam_wrapper)
ENDIF()
ENDIF()


MESSAGE( STATUS "PAM_EXEC_FOUND: " ${PAM_EXEC_FOUND} )

IF(ENABLE_BCONSOLE_PAM_TEST)
Expand All @@ -202,6 +209,39 @@ ELSE()
list(APPEND SYSTEM_TESTS_DISABLED "bconsole-pam")
ENDIF()

SET(PHP_FOUND FALSE)
SET(PYTHON_FOUND FALSE)
SET(PYTHON_SELENIUM_FOUND "NOT SEARCHED")
SET(CHROMEDRIVER_FOUND "NOT SEARCHED")

IF(PHP)
SET(PHP_FOUND TRUE)
IF(PYTHON)
SET(PYTHON_FOUND TRUE)
PythonModuleStatus("selenium") # sets PYTHON_SELENIUM_FOUND to TRUE or FALSE
IF(${PYTHON_SELENIUM_FOUND})
find_program(CHROMEDRIVER chromedriver)
IF(CHROMEDRIVER)
SET(CHROMEDRIVER_FOUND TRUE)
SET(ENABLE_WEBUI_SELENIUM_TEST TRUE)
ELSE()
SET(CHROMEDRIVER_FOUND FALSE)
ENDIF()
ENDIF()
ENDIF()
ENDIF()

MESSAGE(STATUS "PHP_FOUND: " ${PHP_FOUND})
MESSAGE(STATUS "PYTHON_FOUND: " ${PYTHON_FOUND})
MESSAGE(STATUS "PYTHON_SELENIUM_FOUND: " ${PYTHON_SELENIUM_FOUND})
MESSAGE(STATUS "CHROMEDRIVER_FOUND: " ${CHROMEDRIVER_FOUND})

IF(ENABLE_WEBUI_SELENIUM_TEST)
list(APPEND SYSTEM_TESTS "webui-selenium")
ELSE()
list(APPEND SYSTEM_TESTS_DISABLED "webui-selenium")
ENDIF()

set(BASEPORT 42001)

foreach(TEST_NAME ${SYSTEM_TESTS})
Expand Down Expand Up @@ -229,7 +269,7 @@ foreach(TEST_NAME ${SYSTEM_TESTS})
math(EXPR fd_port "${BASEPORT} + 1")
math(EXPR sd_port "${BASEPORT} + 2")
math(EXPR sd2_port "${BASEPORT} + 3")

math(EXPR php_port "${BASEPORT} + 4")

# set(DEFAULT_DB_TYPE )
set(archivedir ${current_test_directory}/storage)
Expand All @@ -246,6 +286,15 @@ 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/configuration.ini")
ENDIF()

ConfigureFilesToSystemtest("systemtests" "tests/${TEST_NAME}" "*" @ONLY)

configure_file("environment.in" "tests/${TEST_NAME}/environment" @ONLY)
Expand Down Expand Up @@ -318,3 +367,4 @@ execute_process(COMMAND

execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink ${scriptdir}/bareos ${bindir}/bareos)

18 changes: 18 additions & 0 deletions systemtests/environment.in
Expand Up @@ -56,3 +56,21 @@ export db_password=@db_password@
export db_user=@db_user@

export PAM_WRAPPER_LIBRARIES=@PAM_WRAPPER_LIBRARIES@

#
# Selenium test
#

export BAREOS_WEBUI_CONFDIR=@WEBUICONFDIR@

export BAREOS_WEBUI_BROWSER=chrome
export BAREOS_WEBUI_CHROMEDRIVER_PATH=@CHROMEDRIVER@

export BAREOS_WEBUI_BASE_URL=http://localhost:@php_port@/
export BAREOS_WEBUI_USERNAME=admin
export BAREOS_WEBUI_PASSWORD=admin
export BAREOS_WEBUI_CLIENT_NAME=bareos-fd
export BAREOS_WEBUI_RESTOREFILE=${PROJECT_BINARY_DIR}
export BAREOS_WEBUI_LOG_PATH=${logdir}
export BAREOS_WEBUI_DELAY=1

82 changes: 82 additions & 0 deletions systemtests/tests/webui-selenium/directors.ini.in
@@ -0,0 +1,82 @@
;
; 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,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 = "@plugindir@"
# 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 1c348e2

Please sign in to comment.