From: Ian Jackson Subject: [OSSTEST PATCH 11/16] mg-schema-test-database: Sort out daemons; provide `daemons' subcommand Date: Mon, 7 Dec 2015 17:27:29 +0000 Message-ID: <1449509254-27007-12-git-send-email-ian.jackson@eu.citrix.com> References: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a5zZg-00087w-Ko for xen-devel@lists.xenproject.org; Mon, 07 Dec 2015 17:27:44 +0000 In-Reply-To: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org We arrange for the test configuration to look for the daemons on a different host and port, and we provide a convenient way to run such a pair of daemons. Signed-off-by: Ian Jackson --- v2: Moved setting of *Daemon{Host,Port} to this patch (was previously in `mg-schema-test-database: New script') --- mg-schema-test-database | 63 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/mg-schema-test-database b/mg-schema-test-database index a1eb49c..73d92f3 100755 --- a/mg-schema-test-database +++ b/mg-schema-test-database @@ -4,7 +4,8 @@ # # # ./mg-schema-test-database create [_SUFFIX] [TASK...] \ -# [-fMINFLIGHT | -f-NUMFLIGHTS] +# [-fMINFLIGHT | -f-NUMFLIGHTS] \ +# [-hCTRL_DAEMONS_HOST] [-fOWNER_D_PORT[,QUEUE_D_PORT]] # # does `drop' and then creates # - the database osstestdb_test_SUFFIX @@ -16,12 +17,24 @@ # TASKs become idle in the test copy. Others become allocated to # a specially-created `owned by someone in real db' task. # +# Default for CTRL_DAEMONS_HOST is localhost; if no port is supplied, +# we use the corresponding production port + 2; if only one port is +# supplied we use that and the next port number. +# # # ./mg-schema-test-database drop [_SUFFIX] # # deletes your test database and removes the local-config file # # +# ./mg-schema-test-database daemons [_SUFFIX] +# +# synchronously runs owner and queue daemons for your test database +# +# NB that you can't drop a test database with these daemons running, +# because Postgres will refuse to drop a database that anyone is +# connected to. + set -e -o posix ${OSSTEST_DEBUG:+-x} @@ -114,6 +127,9 @@ END } withtest () { + if ! [ -e "$tcfg" ]; then + fail "test $dbname not set up ($tcfg does not exist)" + fi OSSTEST_CONFIG="$test_cfg_setting" "$@" } @@ -194,6 +210,10 @@ create) ;; -f*) minflight="${arg#-f}" ;; + -h*) ctrlhost="${arg#-h}" + ;; + -p*) ctrlports="${arg#-p}" + ;; *) fail "bad arg to create" ;; esac @@ -224,6 +244,18 @@ END ;; esac + if [ "x$ctrlhost" = x ]; then + ctrlhost=localhost + fi + case "$ctrlports" in + *,*) ;; + ?*) ctrlports+=,$(( $ctrlports + 1 )) ;; + '') + ctrlports=$(( $(getconfig OwnerDaemonPort) + 2)),$(( + $(getconfig QueueDaemonPort) + 2)) + ;; + esac + #---------- preparation and data-gathering ---------- bad=$( psql_query <$tcfg.tmp -we ' @@ -258,6 +292,12 @@ END "port=$dbh_tests->{pg_port}\n" or die $!; ' + cat >>$tcfg.tmp <