1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-04 15:54:48 +01:00

Add Vagrant support for running automated tests

This commit is contained in:
downtownallday
2020-06-21 09:13:54 -04:00
parent 25f5690655
commit a5ab29c83f
12 changed files with 166 additions and 23 deletions

View File

@@ -84,11 +84,6 @@ install_nextcloud_docker() {
container_started="false"
fi
# H2 "docker: Update /etc/hosts so it can find MiaB-LDAP by name"
# echo "$PRIVATE_IP $PRIMARY_HOSTNAME" | \
# docker exec -i NC bash -c 'cat >>/etc/hosts' \
# || die "docker: could not update /etc/hosts"
# apt-get update
H2 "docker: apt-get update"
docker exec NC apt-get update || die "docker: apt-get update failed"
@@ -98,6 +93,7 @@ install_nextcloud_docker() {
ufw allow ldaps || die "Unable to modify firewall to permit ldaps"
# add MiaB-LDAP's ca_certificate.pem to docker's trusted cert list
# (because setup/ssl.sh created its own self-signed ca)
H2 "docker: update trusted CA list"
docker cp \
$STORAGE_ROOT/ssl/ca_certificate.pem \
@@ -146,14 +142,14 @@ install_nextcloud_docker() {
do_upgrade() {
local populate_name="$1"
if [ -e "local/remote-nextcloud.sh" ]; then
if [ -e "$LOCAL_MODS_DIR/remote-nextcloud.sh" ]; then
# we install w/o remote nextcloud first so we can add
# a user w/contacts and ensure the contact exists in the
# new system
if [ ! -L "local/remote-nextcloud.sh" ]; then
echo "Warning: local/remote-nextcloud.sh is a regular file - should be a symlink"
if [ ! -L "$LOCAL_MODS_DIR/remote-nextcloud.sh" ]; then
echo "Warning: $LOCAL_MODS_DIR/remote-nextcloud.sh is a regular file - should be a symlink"
fi
die "Error: local/remote-nextcloud.sh exists - delete it and try again"
die "Error: $LOCAL_MODS_DIR/remote-nextcloud.sh exists - delete it and try again"
fi
# initialize test system

View File

@@ -8,6 +8,7 @@ export STORAGE_ROOT="${STORAGE_ROOT:-/home/$STORAGE_USER}"
export EMAIL_ADDR="${EMAIL_ADDR:-qa@abc.com}"
export EMAIL_PW="${EMAIL_PW:-Test_1234}"
export PUBLIC_IP="${PUBLIC_IP:-$(source ${MIAB_DIR:-.}/setup/functions.sh; get_default_privateip 4)}"
export LOCAL_MODS_DIR="${LOCAL_MODS_DIR:-local}"
if [ "$TRAVIS" == "true" ]; then
export PRIMARY_HOSTNAME=${PRIMARY_HOSTNAME:-box.abc.com}

View File

@@ -135,12 +135,12 @@ init_miab_testing() {
enable_miab_mod() {
local name="${1}.sh"
if [ ! -e "local/$name" ]; then
mkdir -p "local"
if ! ln -s "../setup/mods.available/$name" "local/$name"
if [ ! -e "$LOCAL_MODS_DIR/$name" ]; then
mkdir -p "$LOCAL_MODS_DIR"
if ! ln -s "$(pwd)/setup/mods.available/$name" "$LOCAL_MODS_DIR/$name"
then
echo "Warning: copying instead of symlinking local/$name"
cp "setup/mods.available/$name" "local/$name"
echo "Warning: copying instead of symlinking $LOCAL_MODS_DIR/$name"
cp "setup/mods.available/$name" "$LOCAL_MODS_DIR/$name"
fi
fi
}

View File

@@ -125,12 +125,12 @@ populate() {
case "$1" in
capture )
. /etc/mailinabox.conf
installed_state_capture "tests/system-setup/state/miab-ldap"
installed_state_capture "/tmp/state/miab-ldap"
exit $?
;;
compare )
. /etc/mailinabox.conf
installed_state_compare "tests/system-setup/state/upstream" "tests/system-setup/state/miab-ldap"
installed_state_compare "/tmp/state/upstream" "/tmp/state/miab-ldap"
exit $?
;;
populate )
@@ -161,15 +161,15 @@ else
populate_by_name "${1:-basic}"
# capture upstream state
installed_state_capture "tests/system-setup/state/upstream"
installed_state_capture "/tmp/state/upstream"
fi
# install miab-ldap and capture state
miab_ldap_install
installed_state_capture "tests/system-setup/state/miab-ldap"
installed_state_capture "/tmp/state/miab-ldap"
# compare states
if ! installed_state_compare "tests/system-setup/state/upstream" "tests/system-setup/state/miab-ldap"; then
if ! installed_state_compare "/tmp/state/upstream" "/tmp/state/miab-ldap"; then
die "Upstream and upgraded states are different !"
fi