]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
mg-schema-test-database: Make `daemons' be cleverer
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Jul 2016 16:46:20 +0000 (17:46 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 14 Jul 2016 12:03:34 +0000 (13:03 +0100)
Now you can tell it which daemons to run.  This is helpful if you want
to run them separately.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
mg-schema-test-database

index 85cc050022420abbd585e56fef85e3554a43c522..e95b6c5a5090b7724cbcbbb9ca54079066816c71 100755 (executable)
 # deletes your test database and removes the local-config file
 #
 #
-#  ./mg-schema-test-database daemons [_SUFFIX]
+#  ./mg-schema-test-database daemons [_SUFFIX] [DAEMON...]
 #
-# synchronously runs owner and queue daemons for your test database
+# Synchronously runs owner and queue daemons for your test database.
+# If any DAEMON is specified, runs only those daemons.  DAEMON
+# may be `queue' or `owner'; otherwise it is a command which will
+# be broken at spaces, and have `./' prepended if it contains no `/'.
+# If any DAEMON contains the string `queue', it causes the data-plan.pl
+# to be cleared.
 #
 # NB that you can't drop a test database with these daemons running,
 # because Postgres will refuse to drop a database that anyone is
@@ -557,26 +562,36 @@ END
 #========== DAEMONS ==========
 
 daemons)
+       wantdaemons=()
+
        for arg in "$@"; do
                case "$arg" in
                _*)     suffix="$arg" ;;
-               *)      fail 'bad usage' ;;
+               owner|queue)    wantdaemons+=("./ms-${arg}daemon") ;;
+               */*)            wantdaemons+=("$arg") ;;
+               *)              wantdaemons+=("./$arg") ;;
                esac
        done
 
+       if [ "${#wantdaemons[*]}" = 0 ]; then
+               wantdaemons=(./ms-ownerdaemon ./ms-queuedaemon)
+       fi
+
        dbname
 
-       printf "Running daemons for %s....\n" "$dbname"
+       printf "Running daemons (${wantdaemons[*]}) for %s....\n" "$dbname"
 
-       withtest \
-       exec_resetting_sigint ./ms-ownerdaemon &
+       for d in "${wantdaemons[@]}"; do
 
-       sleep 1
+               case "$d" in
+               *queuedaemon*)  rm -f data-plan.pl      ;;
+               esac
 
-       withtest \
-       exec_resetting_sigint ./ms-queuedaemon &
+               withtest \
+               exec_resetting_sigint $d &
 
-       rm -f data-plan.pl
+               sleep 1
+       done
 
        wait