[tabled patch 5/5] Metadata replication test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a build-time test for the metadata replication feature.
Note that this is not a complete test, in particular it does not
verify that the database was synched correctly at the slave.
But it verifies quite a bit.

Signed-off-by: Pete Zaitcev <zaitcev@xxxxxxxxxx>

---
 server/metarep.c |    2 +-
 test/Makefile.am          |    2 +
 test/metadata-rep         |   48 ++++++++++++++++++++++++++++++++++++
 test/prep-db              |    2 +
 test/stop-daemon          |   15 ++++++++---
 test/tabled-test-bis.conf |   21 +++++++++++++++
 test/wait-for-listen.c    |   11 +++++++-
 6 files changed, 94 insertions(+), 5 deletions(-)

commit 5a8b74d5541bbdf111f037246883182efaf637ba
Author: Pete Zaitcev <zaitcev@xxxxxxxxx>
Date:   Thu Aug 12 12:44:30 2010 -0600

    Test for metadata replication (incomlete - does not verify
    key integrity, just that server thinks it went slave).

diff --git a/test/Makefile.am b/test/Makefile.am
index 9264cba..7799a79 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,6 +7,7 @@ EXTRA_DIST =			\
 	users.data		\
 	chunkd-test.conf	\
 	tabled-test.conf	\
+	tabled-test-bis.conf	\
 	prep-db			\
 	start-daemon		\
 	pid-exists		\
@@ -26,6 +27,7 @@ TESTS =				\
 	large-object		\
 	hdr-content-type	\
 	hdr-meta		\
+	metadata-rep		\
 	stop-daemon		\
 	clean-db
 
diff --git a/test/metadata-rep b/test/metadata-rep
new file mode 100644
index 0000000..b8b84f7
--- /dev/null
+++ b/test/metadata-rep
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+#
+# First, start the tabled-bis
+#
+# We use tee so that if things go pear-shaped in Fedora build system,
+# we get to see the error. In the same time we use the log to see
+# how far the test went.
+#
+# However, a pipeline with tee makes us to use a non-daemonized tabled
+# and then put it into background with normal shell means.
+#
+(../server/tabled -C $top_srcdir/test/tabled-test-bis.conf -E -F 2>&1 | tee tabled-bis.log) &
+
+# Why so much? Well... The time needed is gated by the time the master
+# needs to re-read the group in CLD. Until the re-read happens, the
+# would-be slave is rejected with "unknown slave". We could easily
+# pre-seed the group with the TDBRepName using cldcli, but that would
+# be cheating. So, that's 50s (cldu_rescan_delay). Then, we need to
+# give slave time to retry, done once in 35s (TABLED_MCWAIT_SEC).
+# That's 85s. And add a few seconds for databases to sync.
+echo "Sleeping 90s"
+sleep 90
+
+# Signal slave to dump the authoritative state
+kill -USR1 $(cat tabled-bis.pid)
+sleep 3
+
+grep -s "TDB: group default state Slave" tabled-bis.log
+if [ "$?" != 0 ]; then
+  echo "The slave state is not found in the log" >&2
+  exit 1
+fi
+
+kill $(cat tabled.pid)
+
+# This is pits. The wait-for-listen waits for 25s, but sometimes fails.
+# But when it succeeds, it's always "went up after 0 s". What the deuce.
+sleep 10
+
+echo "Running wait-for-listen"
+./wait-for-listen tabled-bis.acc
+if [ "$?" != 0 ]; then
+  # don't echo anything, wait-for-listen prints an error
+  exit 1
+fi
+
+exit 0
diff --git a/test/prep-db b/test/prep-db
index ef90e1c..a44c9be 100755
--- a/test/prep-db
+++ b/test/prep-db
@@ -2,10 +2,12 @@
 
 DATADIR=data
 TDBDIR=$DATADIR/tdb
+TDB2DIR=$DATADIR/tdb-bis
 CLDDIR=$DATADIR/cld
 CHUNKDIR=$DATADIR/chunk
 
 mkdir -p $TDBDIR
+mkdir -p $TDB2DIR
 mkdir -p $CLDDIR
 mkdir -p $CHUNKDIR
 
diff --git a/test/stop-daemon b/test/stop-daemon
index de5db0c..17a9b13 100755
--- a/test/stop-daemon
+++ b/test/stop-daemon
@@ -19,28 +19,35 @@ killpid () {
 	return 1
 }
 
-rm -f cld.port tabled.acc
+rm -f cld.port tabled.acc tabled-bis.acc tabled-bis.log
 
 ret=0
 
 if [ ! -f tabled.pid ]
 then
 	# Just a warning. Previous test somehow made the daemon to die.
-	echo "No tabled PID file found." >&2
+	echo "No tabled.pid file found." >&2
 else
 	killpid tabled.pid || ret=1
 fi
 
+if [ ! -f tabled-bis.pid ]
+then
+	echo "No tabled-bis.pid file found." >&2
+else
+	killpid tabled-bis.pid || ret=1
+fi
+
 if [ ! -f chunkd.pid ]
 then
-	echo "No chunkd PID file found." >&2
+	echo "No chunkd.pid file found." >&2
 else
 	killpid chunkd.pid || ret=1
 fi
 
 if [ ! -f cld.pid ]
 then
-	echo "No cld PID file found." >&2
+	echo "No cld.pid file found." >&2
 else
 	killpid cld.pid || ret=1
 fi
diff --git a/test/tabled-test-bis.conf b/test/tabled-test-bis.conf
new file mode 100644
index 0000000..0130491
--- /dev/null
+++ b/test/tabled-test-bis.conf
@@ -0,0 +1,21 @@
+
+<PID>tabled-bis.pid</PID>
+<ForceHost>localhost.localdomain</ForceHost>
+<Listen>
+  <Port>auto</Port>
+  <PortFile>tabled-bis.acc</PortFile>
+</Listen>
+<TDB>data/tdb-bis</TDB>
+<TDBRepPort>auto</TDBRepPort>
+<TDBRepName>bis.localhost.localdomain</TDBRepName>
+
+<CLD>
+  <PortFile>cld.port</PortFile>
+  <Host>localhost</Host>
+</CLD>
+
+<ChunkUser>testuser</ChunkUser>
+<ChunkKey>testuser</ChunkKey>
+
+<!-- Setting "default" just to make sure tabled configures it correctly. -->
+<Group>default</Group>
diff --git a/test/wait-for-listen.c b/test/wait-for-listen.c
index fef5028..06bbaeb 100644
--- a/test/wait-for-listen.c
+++ b/test/wait-for-listen.c
@@ -86,13 +86,22 @@ int main(int argc, char **argv)
 {
 	struct server_node snode, *sn = &snode;
 	time_t start_time;
-	const static char accname[] = TEST_FILE_TB;
+	char *accname;
 	char accbuf[80];
 	char *s;
 	int cnt;
 	int sfd;
 	int rc;
 
+	if (argc == 2) {
+		accname = argv[1];
+	} else if (argc == 1) {
+		accname = TEST_FILE_TB;
+	} else {
+		fprintf(stderr, "Usage: wait-for-listen [accessor.file]\n");
+		exit(1);
+	}
+
 	cnt = 0;
 	for (;;) {
 		rc = tb_readport(accname, accbuf, sizeof(accbuf));
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux