xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>
Subject: [OSSTEST PATCH 11/16] mg-schema-test-database: Sort out daemons; provide `daemons' subcommand
Date: Mon, 7 Dec 2015 17:27:29 +0000	[thread overview]
Message-ID: <1449509254-27007-12-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1449509254-27007-1-git-send-email-ian.jackson@eu.citrix.com>

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 <ian.jackson@eu.citrix.com>
---
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 <<END
@@ -244,6 +276,8 @@ END
 
 	printf "Setting up %s (minflight=%d, tasks=%s)...\n" \
 		$dbname "$minflight" "${tasks# }"
+	printf "Configuring for any daemons to be on %s:%s.\n" \
+		$ctrlhost $ctrlports
 
 	# create the config overlay
 	perl >$tcfg.tmp -we '
@@ -258,6 +292,12 @@ END
 			"port=$dbh_tests->{pg_port}\n"
 			or die $!;
 	'
+	cat >>$tcfg.tmp <<END
+OwnerDaemonHost $ctrlhost
+QueueDaemonHost $ctrlhost
+OwnerDaemonPort ${ctrlports%,*}
+QueueDaemonPort ${ctrlports#*,}
+END
 	mv -f $tcfg.tmp $tcfg
 
 	# Extract the schema for reference
@@ -444,6 +484,27 @@ END
 
 	;;
 
+#========== DAEMONS ==========
+
+daemons)
+	parse_only_suffix "$@"
+
+	dbname
+
+	printf "Running daemons for %s....\n" "$dbname"
+
+	withtest \
+	exec_resetting_sigint ./ms-ownerdaemon &
+
+	sleep 1
+
+	withtest \
+	exec_resetting_sigint ./ms-queuedaemon &
+
+	wait
+
+	;;
+
 #========== EPILOGUE ==========
 
 *)
-- 
1.7.10.4

  parent reply	other threads:[~2015-12-07 17:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 17:27 (no subject) Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 01/16] tcl daemons: log host and port number we bind to, at startup Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 02/16] cri-getconfig: Break out exec_resetting_sigint Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 03/16] Configuration: No longer set password=<~/.xen-osstest/db-password> Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 04/16] mg-debug-fail: New utility script for debugging Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 05/16] mg-debug-fail: Catch attempts to read from a tty Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 06/16] cri-getconfig: Provide get_psql_cmd and get_pgdump_cmd Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 07/16] cri-getconfig: Provide debugging for get_psql_cmd Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 08/16] Osstest.pm: Break out and export globalconfigfiles Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 09/16] mg-schema-test-database: New script Ian Jackson
2015-12-08 11:06   ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 10/16] mg-schema-test-database: Move setting of test_cfg_setting to dbname Ian Jackson
2015-12-07 17:27 ` Ian Jackson [this message]
2015-12-08 11:06   ` [OSSTEST PATCH 11/16] mg-schema-test-database: Sort out daemons; provide `daemons' subcommand Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 12/16] Configuration: Introduce $c{Username} Ian Jackson
2015-12-08 11:07   ` Ian Campbell
2015-12-08 11:18   ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 13/16] mg-schema-test-database: Change username for back-to-main-db xref Ian Jackson
2015-12-08 11:09   ` Ian Campbell
2015-12-08 14:21     ` Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 14/16] mg-schema-test-database: Bump flight sequence number in test DB Ian Jackson
2015-12-08 11:10   ` Ian Campbell
2015-12-07 17:27 ` [OSSTEST PATCH 15/16] mg-schema-test-database: Safety catch in JobDB database open Ian Jackson
2015-12-08 11:16   ` Ian Campbell
2015-12-08 14:24     ` Ian Jackson
2015-12-07 17:27 ` [OSSTEST PATCH 16/16] mg-schema-test-database: Add workflow doc comment Ian Jackson
2015-12-08 11:19   ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449509254-27007-12-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).