integrate pgTAP with a -t option for live testing
authorJason Etheridge <jason@esilibrary.com>
Tue, 16 Jul 2013 16:01:42 +0000 (12:01 -0400)
committerJason Etheridge <jason@esilibrary.com>
Tue, 16 Jul 2013 17:48:40 +0000 (13:48 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
installer/wheezy/eg_wheezy_installer.sh

index 53a394b..e7a2974 100755 (executable)
@@ -29,13 +29,14 @@ ADMIN_PASS='demo123';
 # -----------------------------------------------------------------------
 # Handling passed arguments to the script
 # -----------------------------------------------------------------------
-while getopts ays option
+while getopts ayst option
 do
         case "${option}"
         in
                 a) AUTOSTART=1;;
                 y) YES=1;;
                 s) SAMPLEDATA=--load-all-sample;;
+                t) LIVETEST=1;;
         esac
 done
 
@@ -86,6 +87,9 @@ apt-get update;
 apt-get -yq dist-upgrade;
 apt-get -yq install build-essential automake git psmisc ntp rsyslog;
 
+if [ $LIVETEST ]; then
+    cpan TAP::Parser::SourceHandler::pgTAP
+fi;
 
 cp $BASE_DIR/evergreen.ld.conf /etc/ld.so.conf.d/
 ldconfig;
@@ -102,7 +106,7 @@ fi;
 OPENSRF_REPO='git://git.evergreen-ils.org/OpenSRF.git'
 OPENSRF_BRANCH='master'
 EVERGREEN_REPO='git://git.evergreen-ils.org/working/Evergreen.git'
-EVERGREEN_BRANCH='collab/berick/per-distro-install-makefiles'
+EVERGREEN_BRANCH='collab/phasefx/pgtap-and-per-distro-install-makefiles'
 OSRF_COMMAND="
 cd /home/opensrf;
 git clone --depth 0 --branch $OPENSRF_BRANCH $OPENSRF_REPO OpenSRF;
@@ -209,6 +213,19 @@ perl Open-ILS/src/support-scripts/eg_db_config \
     --admin-user $ADMIN_USER \
     --admin-pass $ADMIN_PASS;
 
+if [ $LIVETEST ]; then
+    PG_CMD="
+    git clone --depth 0 https://github.com/theory/pgtap.git \
+    && cd pgtap \
+    && make \
+    && make installcheck
+    "
+    su - postgres -c "$PG_CMD"
+    cd /var/lib/postgresql/pgtap \
+    && make install;
+    echo 'CREATE EXTENSION pgtap;' | su - postgres -c "psql evergreen"
+fi;
+
 # Copy apache configs into place and create SSL cert
 cp Open-ILS/examples/apache/eg.conf       /etc/apache2/sites-available/
 cp Open-ILS/examples/apache/eg_vhost.conf /etc/apache2/
@@ -280,12 +297,20 @@ sed -i 's/KeepAliveTimeout .*/KeepAliveTimeout 1/' /etc/apache2/apache2.conf
 echo Restarting Apache
 /etc/init.d/apache2 restart
 
-cat <<EOF
+if [ $LIVETEST ]; then
+# TODO: Eventually move these tests into a Make target within Evergreen
+    cd /home/opensrf/Evergreen
+    echo Running pgTAP tests
+    su - postgres -c 'cd /home/opensrf/Evergreen ; pg_prove -vr -d evergreen Open-ILS/src/sql/Pg/t/'
+
+else
+    cat <<EOF
 * Test the system
 
 # as opensrf user
 echo "request open-ils.cstore open-ils.cstore.direct.actor.user.retrieve 1" | srfsh
 EOF
+fi;
 
 else