Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Add basic test support
Browse files Browse the repository at this point in the history
  • Loading branch information
gwicke committed Dec 30, 2015
1 parent 6191bb3 commit 502d74f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# A lie, but that shouldn't matter.
language: c

sudo: true

# We override what to do anyway.
script: sudo ./test.sh
40 changes: 22 additions & 18 deletions lib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,30 @@ ask_config() {
mkdir -p $DATADIR
conf=$DATADIR/config
if [ ! -f $conf ];then
echo
# Ask a couple of config questions & save a config file.
echoinfo "MediaWiki needs to know the domain your wiki will be using."
echoinfo "Examples: www.yourdomain.com, localhost"
read -p "Domain [localhost]: " MEDIAWIKI_DOMAIN </dev/tty
if [ -z "$MEDIAWIKI_DOMAIN" ];then
MEDIAWIKI_DOMAIN='localhost'
echo
# Ask a couple of config questions & save a config file.
echoinfo "MediaWiki needs to know the domain your wiki will be using."
echoinfo "Examples: www.yourdomain.com, localhost"
read -p "Domain [localhost]: " MEDIAWIKI_DOMAIN </dev/tty
if [ -z "$MEDIAWIKI_DOMAIN" ];then
MEDIAWIKI_DOMAIN='localhost'
fi
fi
if [ -z "$AUTO_UPDATE" ]; then
echo
echoinfo "We can set up automatic nightly code updates for you."
echoinfo "Enabling this keeps your installation secure and up to date."
while true; do
read -p "Should we enable automatic nightly code updates? (y/n): " \
AUTO_UPDATE </dev/tty
case $AUTO_UPDATE in
[Yy]* ) AUTO_UPDATE=true; break;;
[Nn]* ) AUTO_UPDATE=false; break;;
* ) echowarn "Please answer yes or no.";;
esac
done
fi
echo
echoinfo "We can set up automatic nightly code updates for you."
echoinfo "Enabling this keeps your installation secure and up to date."
while true; do
read -p "Should we enable automatic nightly code updates? (y/n): " \
AUTO_UPDATE </dev/tty
case $AUTO_UPDATE in
[Yy]* ) AUTO_UPDATE=true; break;;
[Nn]* ) AUTO_UPDATE=false; break;;
* ) echowarn "Please answer yes or no.";;
esac
done
echo "MEDIAWIKI_DOMAIN=\"$MEDIAWIKI_DOMAIN\"" > "$conf"
echo "AUTO_UPDATE=$AUTO_UPDATE" >> "$conf"
echo "MEDIAWIKI_ADMIN_PASS='$MEDIAWIKI_ADMIN_PASS'" >> "$conf"
Expand Down
35 changes: 35 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Basic installer tests

set -e

check_service() {
# Make sure that the wiki is reachable & RESTBase works
curl http://localhost/api/rest_v1/page/html/Main_Page \
| grep -q "MediaWiki has been successfully installed"
}

# Make sure the installer does not ask questions
export MEDIAWIKI_DOMAIN=localhost
export AUTO_UPDATE=true

CHECKOUT=$(pwd)

cd /tmp

cat "$CHECKOUT/mediawiki-containers" | bash -s install

check_service

# Restart the service
service mediawiki-containers restart

sleep 10

check_service

# Exercise the automatic updater
/etc/cron.daily/mediawiki-containers

check_service

0 comments on commit 502d74f

Please sign in to comment.