2
1
Fork 0
mirror of https://gitlab.com/koha-community/release-tools.git synced 2024-10-28 08:31:14 +00:00

Improve release test scripts

Add brief documentation to the scripts, and incorporate webinstaller testing
for all MARC flavours with both the packages and tarballs.

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Jared Camins-Esakov 2012-05-08 11:13:47 -04:00 committed by Chris Nighswonger
parent 72d5e91ecb
commit 3d780ee808
3 changed files with 164 additions and 115 deletions

View file

@ -1,5 +1,26 @@
#!/usr/bin/perl
# Copyright 2012 C & P Bibliography Services
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
# Usage: httprecorder.pl &
#
# This script runs an HTTP Recorder proxy on port 9000, and saves the resulting
# WWW::Mechanize script to /tmp/kohalog
use HTTP::Proxy;
use HTTP::Recorder;

View file

@ -1,28 +1,52 @@
#!/usr/bin/perl
use Test::More tests => 5;
use Test::WWW::Mechanize;
# Copyright 2012 C & P Bibliography Services
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
# Usage: install-fresh.pl intranet-URL opac-URL marcflavour dbuser dbpass
#
# This script uses Test::WWW::Mechanize to go through the Koha webinstaller
# process, and confirm that the end result is a functional Koha installation.
use Test::More tests => 14;
use Test::WWW::Mechanize;
use Data::Dumper;
use HTML::Form;
my ($intranet, $opac, $flavour, $user, $password) = @ARGV;
my $agent = Test::WWW::Mechanize->new();
$agent->get_ok("$ARGV[0]/cgi-bin/koha/installer/install.pl");
$agent->get_ok("$intranet/cgi-bin/koha/installer/install.pl", 'open installer');
$agent->form_name('mainform');
$agent->field('password', 'koharel');
$agent->field('userid', 'koharel');
$agent->click();
$agent->field('password', $password);
$agent->field('userid', $user);
$agent->click_ok('', 'log in to installer');
$agent->form_name('language');
$agent->field('language', 'en');
$agent->click();
$agent->click_ok('', 'choose language');
$agent->form_name('checkmodules');
$agent->click();
$agent->click_ok('', 'check modules');
$agent->form_name('checkinformation');
$agent->click();
$agent->click_ok('', 'check information');
$agent->form_name('checkdbparameters');
$agent->click();
$agent->click_ok('', 'check db parameters');
$agent->form_number(1);
$agent->click();
@ -32,53 +56,29 @@ $agent->click();
$agent->follow_link(text => 'install basic configuration settings', n => '1');
$agent->form_name('frameworkselection');
$agent->field('marcflavour', 'MARC21');
$agent->click();
$agent->field('marcflavour', $flavour);
$agent->click_ok('', 'framework selection');
$agent->form_name('frameworkselection');
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_creator_data.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/userflags.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/sample_notices_message_transports.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_libraries.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_news.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/patron_atributes.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/patron_categories.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/sample_notices.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_itemtypes.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_holidays.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/marc21_holdings_coded_values.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/sample_notices_message_attributes.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/auth_val.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/marcflavour/marc21/mandatory/authorities_normal_marc21.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/message_transport_types.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/auth_values.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_patrons.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/userpermissions.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/parameters.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/stopwords.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/marcflavour/marc21/optional/marc21_fastadd_framework.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/subtag_registry.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/optional/sample_z3950_servers.sql");
$agent->tick('framework', "$ARGV[2]/koha/intranet/cgi-bin/installer/data/mysql/en/mandatory/class_sources.sql");
$agent->click();
for (my $_ = $agent->content(); pos($_) < length($_) && $_ =~ m/<input type="checkbox" name="framework" value="([^"]*)"/g; ) {
$agent->tick('framework', $1);
}
$agent->click_ok('', 'additional data');
$agent->form_name('finish');
$agent->click();
$agent->click_ok('', 'finish');
$agent->follow_link(text => 'here', n => '1');
$agent->form_name('loginform');
$agent->field('password', 'koharel');
$agent->field('userid', 'koharel');
$agent->field('password', $password);
$agent->field('userid', $user);
$agent->field('branch', '');
$agent->click();
$agent->click_ok('', 'login to staff client');
$agent->get_ok("$ARGV[0]");
$agent->get_ok("$intranet");
$agent->content_contains("Welcome to Koha", "intranet news");
$agent->get_ok("$ARGV[1]");
$agent->get_ok("$opac");
$agent->content_contains("Welcome to Koha...", "opac main user block");

View file

@ -31,7 +31,7 @@
# SKIP_INSTALL: skip testing the package and tarball installation
export PERL5LIB=`pwd`
RELTOOLS=`dirname $0`
RELTOOLS=$(cd $(dirname "$0"); pwd)
START=$(date +%s)
START_FMT=`date`
@ -42,6 +42,8 @@ else
RELDIR=$HOME/releases
fi
MARCFLAVOURS='MARC21 UNIMARC NORMARC'
BRANCH=`git branch | grep '*' | sed -e 's/^* //' -e 's#/#-#'`
VERSION=`grep 'VERSION = ' kohaversion.pl | sed -e "s/^[^']*'//" -e "s/';//"`
TEST_QA=1
@ -77,87 +79,113 @@ fi
if [ -z "$FAILURE" ] && [ -z "$SKIP_DEB" ] && [ -z "$SKIP_INSTALL" ]; then
echo "Installing package..."
sudo dpkg -i $PKGFILE > $TMPFILE 2>&1 || FAILURE='Installing package';
cat > /tmp/koha-sites.conf <<EOF
OPACPORT=9003
INTRAPORT=9004
EOF
sudo mv /tmp/koha-sites.conf /etc/koha/koha-sites.conf
fi
if [ -z "$FAILURE" ] && [ -z "$SKIP_TGZ" ] && [ -z "$SKIP_INSTALL" ]; then
echo "Installing from tarball..."
export INSTALL_BASE=$RELDIR/fresh/koha
export DESTDIR=$RELDIR/fresh
export KOHA_CONF_DIR=$RELDIR/fresh/etc
export ZEBRA_CONF_DIR=$RELDIR/fresh/etc/zebradb
export PAZPAR2_CONF_DIR=$RELDIR/fresh/etc/pazpar2
export ZEBRA_LOCK_DIR=$RELDIR/fresh/var/lock/zebradb
export ZEBRA_DATA_DIR=$RELDIR/fresh/var/lib/zebradb
export ZEBRA_RUN_DIR=$RELDIR/fresh/var/run/zebradb
export LOG_DIR=$RELDIR/fresh/var/log
export INSTALL_MODE=standard
export DB_TYPE=mysql
export DB_HOST=localhost
export DB_NAME=koharel
export DB_USER=koharel
export DB_PASS=koharel
export INSTALL_ZEBRA=yes
export INSTALL_SRU=no
export INSTALL_PAZPAR2=no
export ZEBRA_MARC_FORMAT=marc21
export ZEBRA_LANGUAGE=en
export ZEBRA_USER=kohauser
export ZEBRA_PASS=zebrastripes
export KOHA_USER=`id -u -n`
export KOHA_GROUP=`id -g -n`
mkdir -p $RELDIR/fresh
tar zxvf $ARCHIVEFILE -C /tmp > $TMPFILE 2>&1 || FAILURE="Untarring tarball"
cd /tmp/koha-$VERSION
if [ -z "$FAILURE" ]; then
echo -e " Running perl Makefile.PL..."
yes '' | perl Makefile.PL > $TMPFILE 2>&1 || FAILURE="Running Makefile.PL";
fi
if [ -z "$FAILURE" ]; then
echo -e " Running make..."
make > $TMPFILE 2>&1 || FAILURE="Running make";
fi
if [ -z "$FAILURE" ]; then
echo -e " Running make test..."
make test > $TMPFILE 2>&1 || FAILURE="Running make test";
fi
if [ -z "$FAILURE" ]; then
echo -e " Running make install..."
make install > $TMPFILE 2>&1 || FAILURE="Running make install";
sed -i -e 's/<VirtualHost 127.0.1.1:80>/<VirtualHost *:9001>/' -e 's/<VirtualHost 127.0.1.1:8080>/<VirtualHost *:9002>/' $RELDIR/fresh/etc/koha-httpd.conf
fi
if [ -z "$SKIP_WEBINSTALL" ]; then
for FLAVOUR in $MARCFLAVOURS; do
VAR=SKIP_$FLAVOUR
if [ -z "$FAILURE" ] && [ -z "$SKIP_DEB" ] && [ -z "$SKIP_INSTALL" ] && [ -z "${!VAR}" ]; then
echo "Installing from package for $FLAVOUR..."
if [ -z "$FAILURE" ]; then
mysql -u koharel -pkoharel -e "CREATE DATABASE koharel;" > $TMPFILE 2>&1 || FAILURE="Creating database";
echo " Running koha-create for $FLAVOUR..."
sudo koha-create --marcflavor=`echo $FLAVOUR | tr '[:upper:]' '[:lower:]'` --create-db pkgrel > $TMPFILE 2>&1 || FAILURE="Koha-create for $FLAVOUR";
fi
if [ -z "$FAILURE" ] && [ -z "$SKIP_WEBINSTALL" ]; then
echo " Running webinstaller for $FLAVOUR..."
prove $RELTOOLS/install-fresh.pl :: http://localhost:9004 http://localhost:9003 $FLAVOUR `sudo xmlstarlet sel -t -v 'yazgfs/config/user' '/etc/koha/sites/pkgrel/koha-conf.xml'` `sudo xmlstarlet sel -t -v 'yazgfs/config/pass' '/etc/koha/sites/pkgrel/koha-conf.xml'` > $TMPFILE 2>&1 || FAILURE="Running webinstaller for $FLAVOUR";
fi
echo " Cleaning up package install for $FLAVOUR..."
sudo koha-remove pkgrel > $TMPFILE 2>&1 || FAILURE="Koha-remove for $FLAVOUR"
fi
done
for FLAVOUR in $MARCFLAVOURS; do
VAR=SKIP_$FLAVOUR
if [ -z "$FAILURE" ] && [ -z "$SKIP_TGZ" ] && [ -z "$SKIP_INSTALL" ] && [ -z "${!VAR}" ]; then
echo "Installing from tarball for $FLAVOUR..."
export INSTALL_BASE=$RELDIR/fresh/koha
export DESTDIR=$RELDIR/fresh
export KOHA_CONF_DIR=$RELDIR/fresh/etc
export ZEBRA_CONF_DIR=$RELDIR/fresh/etc/zebradb
export PAZPAR2_CONF_DIR=$RELDIR/fresh/etc/pazpar2
export ZEBRA_LOCK_DIR=$RELDIR/fresh/var/lock/zebradb
export ZEBRA_DATA_DIR=$RELDIR/fresh/var/lib/zebradb
export ZEBRA_RUN_DIR=$RELDIR/fresh/var/run/zebradb
export LOG_DIR=$RELDIR/fresh/var/log
export INSTALL_MODE=standard
export DB_TYPE=mysql
export DB_HOST=localhost
export DB_NAME=koharel
export DB_USER=koharel
export DB_PASS=koharel
export INSTALL_ZEBRA=yes
export INSTALL_SRU=no
export INSTALL_PAZPAR2=no
export ZEBRA_MARC_FORMAT=`echo $FLAVOUR | tr '[:upper:]' '[:lower:]'`
export ZEBRA_LANGUAGE=en
export ZEBRA_USER=kohauser
export ZEBRA_PASS=zebrastripes
export KOHA_USER=`id -u -n`
export KOHA_GROUP=`id -g -n`
mkdir -p $RELDIR/fresh
tar zxvf $ARCHIVEFILE -C /tmp > $TMPFILE 2>&1 || FAILURE="Untarring tarball for $FLAVOUR"
cd /tmp/koha-$VERSION
if [ -z "$FAILURE" ]; then
echo -e " Running perl Makefile.PL for $FLAVOUR..."
yes '' | perl Makefile.PL > $TMPFILE 2>&1 || FAILURE="Running Makefile.PL for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Adding to sites-available..."
sudo ln -s $RELDIR/fresh/etc/koha-httpd.conf /etc/apache2/sites-available/release-fresh > $TMPFILE 2>&1 || FAILURE="Adding to sites-available";
echo -e " Running make for $FLAVOUR..."
make > $TMPFILE 2>&1 || FAILURE="Running make for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Enabling site..."
sudo a2ensite release-fresh > $TMPFILE 2>&1 || FAILURE="Enabling site";
echo -e " Running make test for $FLAVOUR..."
make test > $TMPFILE 2>&1 || FAILURE="Running make test for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Restarting Apache..."
sudo apache2ctl restart > $TMPFILE 2>&1 || FAILURE="Restarting Apache";
echo -e " Running make install for $FLAVOUR..."
make install > $TMPFILE 2>&1 || FAILURE="Running make install for $FLAVOUR";
sed -i -e 's/<VirtualHost 127.0.1.1:80>/<VirtualHost *:9001>/' -e 's/<VirtualHost 127.0.1.1:8080>/<VirtualHost *:9002>/' $RELDIR/fresh/etc/koha-httpd.conf
fi
if [ -z "$SKIP_WEBINSTALL" ]; then
if [ -z "$FAILURE" ]; then
mysql -u koharel -pkoharel -e "CREATE DATABASE koharel;" > $TMPFILE 2>&1 || FAILURE="Creating database for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Adding to sites-available for $FLAVOUR..."
sudo ln -s $RELDIR/fresh/etc/koha-httpd.conf /etc/apache2/sites-available/release-fresh > $TMPFILE 2>&1 || FAILURE="Adding to sites-available for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Enabling site for $FLAVOUR..."
sudo a2ensite release-fresh > $TMPFILE 2>&1 || FAILURE="Enabling site for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Restarting Apache for $FLAVOUR..."
sudo apache2ctl restart > $TMPFILE 2>&1 || FAILURE="Restarting Apache for $FLAVOUR";
fi
if [ -z "$FAILURE" ]; then
echo " Running webinstaller..."
prove $RELTOOLS/install-fresh.pl :: http://localhost:9002 http://localhost:9001 $RELDIR/fresh > $TMPFILE 2>&1 || FAILURE="Running webinstaller";
if [ -z "$FAILURE" ]; then
echo " Running webinstaller for $FLAVOUR..."
prove $RELTOOLS/install-fresh.pl :: http://localhost:9002 http://localhost:9001 $FLAVOUR koharel koharel > $TMPFILE 2>&1 || FAILURE="Running webinstaller for $FLAVOUR";
fi
echo " Cleaning up for $FLAVOUR..."
mysql -u koharel -pkoharel -e "DROP DATABASE koharel;" > /dev/null 2>&1
sudo a2dissite release-fresh > /dev/null 2>&1
sudo apache2ctl restart > /dev/null 2>&1
sudo rm /etc/apache2/sites-available/release-fresh > /dev/null 2>&1
fi
echo " Cleaning up..."
mysql -u koharel -pkoharel -e "DROP DATABASE koharel;" > /dev/null 2>&1
sudo a2dissite release-fresh > /dev/null 2>&1
sudo apache2ctl restart > /dev/null 2>&1
sudo rm /etc/apache2/sites-available/release-fresh > /dev/null 2>&1
rm -Rf /tmp/koha-$VERSION > /dev/null 2>&1
rm -Rf $RELDIR/fresh > /dev/null 2>&1
fi
rm -Rf /tmp/koha-$VERSION > /dev/null 2>&1
rm -Rf $RELDIR/fresh > /dev/null 2>&1
fi
done
if [ -n "$FAILURE" ]; then cp $TMPFILE $RELDIR/errors.log; fi