[Fusionforge-commits] FusionForge branch GUM updated. 430ddd3182e61ff5e13f8a2b1e6e1b309b12ceba

Sylvain Beucler beuc-inria at fusionforge.org
Fri Aug 29 18:24:03 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, GUM has been updated
       via  430ddd3182e61ff5e13f8a2b1e6e1b309b12ceba (commit)
      from  b21ade7eb3b5d773ea01e5b8b2336cf09c129a06 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 430ddd3182e61ff5e13f8a2b1e6e1b309b12ceba
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Fri Aug 29 18:23:24 2014 +0200

    testsuite: systemd provides _async_ init scripts for postgresql, which is a major PITA; attempt to work-around

diff --git a/src/post-install.d/db/configure.sh b/src/post-install.d/db/configure.sh
index 963e7d8..55a87ee 100755
--- a/src/post-install.d/db/configure.sh
+++ b/src/post-install.d/db/configure.sh
@@ -51,3 +51,7 @@ if ! service postgresql status >/dev/null; then
 else
     service postgresql reload
 fi
+if [ -x /bin/systemctl ]; then
+    sleep 1  # systemd's postgresql init scripts is stupidly async
+    # if you have a better way that works across distros...
+fi
diff --git a/tests/func/Testing/SeleniumForge.php b/tests/func/Testing/SeleniumForge.php
index 972ef81..52b998e 100644
--- a/tests/func/Testing/SeleniumForge.php
+++ b/tests/func/Testing/SeleniumForge.php
@@ -134,7 +134,7 @@ class FForge_SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
 
 	protected function reload_nscd()
 	{
-		$this->runCommand("(nscd -i passwd && nscd -i group) >/dev/null || true");
+		$this->runCommand("(nscd -i passwd && nscd -i group) >/dev/null 2>&1 || true");
 	}
 
 	protected function init() {
diff --git a/tests/func/db_reload.sh b/tests/func/db_reload.sh
index 2472edf..e09416d 100755
--- a/tests/func/db_reload.sh
+++ b/tests/func/db_reload.sh
@@ -1,85 +1,84 @@
 #! /bin/sh
-
 # Reinitialize contents of the database to pass new tests (using the backup made in from /root/dump)
-
 # define some convenience functions
 
 is_db_up () {
-    echo "select count(*) from users;" | su - postgres -c "psql $database" > /dev/null 2>&1
+    # 'service postgresql status' is not reliable enough
+    # Also postgresql processes and control tools have too many names, esp. across distos
+    # Note: database shutdown might not be completed yet, use CHECKPOINT to reduce the risk
+    echo "SELECT COUNT(*) FROM users;" | su - postgres -c "psql $database" > /dev/null 2>&1
 }
 
-start_database () {
+stop_apache () {
 
-    echo "Starting the database"
-    if type invoke-rc.d 2>/dev/null
-    then
-	invoke-rc.d postgresql start
-    else
-	service postgresql start
-    fi
+    echo "Stopping apache"
+    service $(forge_get_config apache_service) stop
+}
 
-    echo "Waiting for database to be up..."
+stop_database () {
+
+    echo "Stopping the database"
+    service postgresql stop
+
+    echo "Waiting for database to be down..."
     i=0
-    while [ $i -lt 10 ] && ! is_db_up ; do
+    while [ $i -lt 50 ] && is_db_up ; do
         echo "...not yet ($(date))..."
         i=$(( $i + 1 ))
-        sleep 5
+        sleep 1
     done
-    if is_db_up ; then
+    if ! is_db_up ; then
         echo "...OK"
     else
-        echo "... FAIL: database still down?"
+        echo "... FAIL: database still up?"
     fi
 }
 
-stop_database () {
+start_database () {
 
-    echo "Stopping the database"
-    if type invoke-rc.d 2>/dev/null
-    then
-	invoke-rc.d postgresql stop
-    else
-	service postgresql stop
-    fi
+    echo "Starting the database"
+    invoke-rc.d postgresql start
 
-    echo "Waiting for database to be down..."
+    echo "Waiting for database to be up..."
     i=0
-    while [ $i -lt 15 ] && is_db_up ; do
+    while [ $i -lt 50 ] && ! is_db_up ; do
         echo "...not yet ($(date))..."
         i=$(( $i + 1 ))
-        sleep 5
+        sleep 1
     done
-    if ! is_db_up ; then
+    if is_db_up ; then
         echo "...OK"
     else
-        echo "... FAIL: database still up?"
+        echo "... FAIL: database still down?"
     fi
 }
 
 start_apache () {
 
     echo "Starting apache"
-    if type invoke-rc.d 2>/dev/null
-    then
-    	invoke-rc.d apache2 start
-    else
-    	service httpd start
-    fi
+    service $(forge_get_config apache_service) start
 }
 
-stop_apache () {
 
-    echo "Stopping apache"
-    if type invoke-rc.d 2>/dev/null
-    then
-	invoke-rc.d apache2 stop
-    else
-	service httpd stop
+# Backup the DB, so that it can be restored for the test suite
+# Usually called from install.sh right after the first install (clean DB)
+if [ "$1" = "--backup" ]; then
+    forge_set_password admin myadmin
+    su - postgres -c "pg_dumpall" > /root/dump
+    su postgres -c 'psql -c CHECKPOINT'  # flush to disk
+    stop_database
+    pgdir=/var/lib/postgresql
+    if [ -e /etc/redhat-release ]; then pgdir=/var/lib/pgsql; fi
+    if [ -d $pgdir.backup ]; then
+        rm -fr $pgdir.backup
     fi
-}
+    cp -a --reflink=auto $pgdir $pgdir.backup
+    start_database
+    exit 0
+fi
 
-# Now the main program
 
+# Restore the DB
 if [ $# -eq 1 ]
 then
 	database=$1
@@ -166,5 +165,7 @@ start_database
 
 start_apache
 
-echo "Flushing/restarting nscd"
-nscd -i passwd && nscd -i group || true
+if [ -x /usr/sbin/nscd ]; then
+    echo "Flushing/restarting nscd"
+    nscd -i passwd && nscd -i group
+fi
diff --git a/tests/scripts/deb/install-src.sh b/tests/scripts/deb/install-src.sh
index cf5cbcf..e442ea7 100755
--- a/tests/scripts/deb/install-src.sh
+++ b/tests/scripts/deb/install-src.sh
@@ -43,4 +43,4 @@ make post-install-base post-install-plugin-scmsvn post-install-plugin-blocks \
     post-install-plugin-mediawiki post-install-plugin-moinmoin
 
 # Dump clean DB
-$(dirname $0)/testsuite-prepare.sh
+if [ ! -e /root/dump ]; then $(dirname $0)/../../func/db_reload.sh --backup; fi
diff --git a/tests/scripts/deb/install.sh b/tests/scripts/deb/install.sh
index d487687..8f86629 100755
--- a/tests/scripts/deb/install.sh
+++ b/tests/scripts/deb/install.sh
@@ -40,7 +40,7 @@ else
 	fusionforge-plugin-scmgit fusionforge-plugin-scmsvn fusionforge-plugin-scmbzr \
 	fusionforge-plugin-mediawiki fusionforge-plugin-moinmoin \
 	fusionforge-plugin-blocks
-
-    # Dump clean DB
-    $(dirname $0)/testsuite-prepare.sh
 fi
+
+# Dump clean DB
+if [ ! -e /root/dump ]; then $(dirname $0)/../../func/db_reload.sh --backup; fi
diff --git a/tests/scripts/deb/testsuite-prepare.sh b/tests/scripts/deb/testsuite-prepare.sh
deleted file mode 100755
index caf2e54..0000000
--- a/tests/scripts/deb/testsuite-prepare.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash -e
-# Backup the DB, so that it can be restored for the test suite
-# Usually called from install.sh right after the first install (clean DB)
-
-if [ ! -e /root/dump ]; then
-    forge_set_password admin myadmin
-    su - postgres -c "pg_dumpall" > /root/dump
-    service postgresql stop
-    pgdir=/var/lib/postgresql
-    if [ -e /etc/redhat-release ]; then pgdir=/var/lib/pgsql; fi
-    if [ -d $pgdir.backup ]; then
-        rm -fr $pgdir.backup
-    fi
-    cp -a --reflink=auto $pgdir $pgdir.backup
-    service postgresql start
-fi

-----------------------------------------------------------------------

Summary of changes:
 src/post-install.d/db/configure.sh     |    4 ++
 tests/func/Testing/SeleniumForge.php   |    2 +-
 tests/func/db_reload.sh                |   93 ++++++++++++++++----------------
 tests/scripts/deb/install-src.sh       |    2 +-
 tests/scripts/deb/install.sh           |    6 +--
 tests/scripts/deb/testsuite-prepare.sh |   16 ------
 6 files changed, 56 insertions(+), 67 deletions(-)
 delete mode 100755 tests/scripts/deb/testsuite-prepare.sh


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list