1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

Merge pull request #51 from YunoHost-Apps/modernize-tests

Modernize the tests infrastucture
This commit is contained in:
Pierre de La Morinerie 2017-10-12 12:26:33 +05:30 committed by GitHub
commit 27e7851dcc
2 changed files with 32 additions and 10 deletions

2
Vagrantfile vendored
View file

@ -42,13 +42,13 @@ Vagrant.configure("2") do |config|
# Stop on first error
set -e
if ! [[ -f /etc/yunohost/installed ]]; then
# Upgrade Yunohost and the system packages (disabled)
sudo apt-get update
sudo apt-get upgrade --yes
sudo apt-get dist-upgrade --yes
# Finish Yunohost installation
if ! [[ -f /etc/yunohost/installed ]]; then
sudo yunohost tools postinstall --domain ${DOMAIN} --password ${YUNOHOST_ADMIN_PASSWORD} --ignore-dyndns
fi

30
test.sh
View file

@ -54,11 +54,18 @@ function _vagrant_ssh() {
vagrant ssh -c "$command" \
> $tty_output \
2> >(grep --invert-match 'Connection to 127.0.0.1 closed.' 1>&2) # Filter out the SSH deconnection message printed on stderr
local exit_code=$?
return $exit_code
}
function _assert_success() {
local message="$1"
local command="$2"
if [ -z "$command" ]; then
echo "Invalid arguments: command missing."
echo "Usage: _assert_success <message> <command>"
return -1
fi
local RED=`tput setaf 1`
local GREEN=`tput setaf 2`
@ -74,6 +81,19 @@ function _assert_success() {
set -e # Fail again on first error
}
function _assert_mattermost_frontpage_up() {
local domain="$1"
# On the default Yunohost Vagrant box, this file
# bypass all SSOWAT configurations, and redirects the root of the domain to the SSO login form.
# We need to access the frontpage, so we remove this bypass.
_vagrant_ssh "sudo rm -f /etc/ssowat/conf.json.persistent"
_assert_success \
"Mattermost frontpage is reachable" \
"curl --silent --show-error --insecure -L -H 'Host: ${DOMAIN}' --resolve ${DOMAIN}:443:127.0.0.1 https://${DOMAIN}/ | grep -q 'Mattermost'"
}
function setup() {
if $SKIP_SNAPSHOT; then
echo "--- Starting Vagrant box ---"
@ -84,7 +104,7 @@ function setup() {
if (vagrant snapshot list | grep 'yunohost-jessie-pristine' > /dev/null); then
echo "--- Restoring Vagrant snapshot ---"
vagrant snapshot restore --no-provision yunohost-jessie-pristine
vagrant snapshot restore yunohost-jessie-pristine
else
echo "--- Provisioning Vagrant box ---"
vagrant up --provision
@ -105,16 +125,18 @@ function setup() {
function test_simple_install() {
echo "--- Running simple installation test ---"
_vagrant_ssh "sudo yunohost app install '$APP_DIR' --args 'domain=${DOMAIN}&public_site=Yes&analytics=0' $VERBOSE_OPT"
_assert_mattermost_frontpage_up "$DOMAIN"
}
function test_simple_upgrade() {
echo "--- Running simple upgrade test ---"
_vagrant_ssh "sudo yunohost app upgrade $APP_NAME --file '$APP_DIR' $VERBOSE_OPT"
_assert_mattermost_frontpage_up "$DOMAIN"
}
function test_simple_backup() {
echo "--- Running simple backup test ---"
_vagrant_ssh "sudo yunohost backup create --ignore-hooks --apps $APP_NAME $VERBOSE_OPT"
_vagrant_ssh "sudo yunohost backup create --name mattermost-test-backup --ignore-system --apps $APP_NAME $VERBOSE_OPT"
}
function test_simple_remove() {
@ -124,8 +146,8 @@ function test_simple_remove() {
function test_simple_restore() {
echo "--- Running simple restore test ---"
_vagrant_ssh "sudo yunohost backup list | cut -d ' ' -f 2 > backup_name"
_vagrant_ssh "sudo yunohost backup restore \$(cat backup_name) --force --ignore-hooks --apps $APP_NAME $VERBOSE_OPT"
_vagrant_ssh "sudo yunohost backup restore mattermost-test-backup --force --ignore-system --apps $APP_NAME $VERBOSE_OPT"
_assert_mattermost_frontpage_up "$DOMAIN"
}
function test_package_check() {