[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone.contrib.usher: efb13f8e5ab02
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone.contrib.usher: efb13f8e5ab02ce49f4a5fad607d2d19c460d896 |
Date: |
Fri, 29 Apr 2011 16:24:31 +0200 (CEST) |
revision: efb13f8e5ab02ce49f4a5fad607d2d19c460d896
date: 2011-04-29T14:11:58
author: Richard Levitte <address@hidden>
branch: net.venge.monotone.contrib.usher
changelog:
* test/run-tests.sh: Reorganise for clarity. Have a clearer output on
what went well and what went wrong.
(populate, usherctl_populate, create_client_key, usherctl_mkproject,
serve, client, client_fg): Use --quiet
(wait_for_clients): behave a bit more like other functions, don't set
OK directly.
(sync, multipull): use wait_for_clients at the end, otherwise the
result isn't very meaningful.
* test/test1/script.txt: have the client_fg tests be quieter.
* test/test2/script.txt: the multipull that we expect to fail is a bit
noisy, shut it up.
(Really, run-tests.sh should log things differently so things aren't so
verbose on screen but can still be checked a bit more thoroughly in a log
file)
manifest:
format_version "1"
new_manifest [24dea03ec0e4d75dcb81b2574fc2bd18a4eb2c07]
old_revision [701c964494a90ebcf3c969e31188f9f99e7c0aae]
patch "test/run-tests.sh"
from [5fb77c0b17770fd0f7d475b364ace469842b296e]
to [3ec71cb41289f08a81c021916bddfadb29b224e6]
patch "test/test1/script.txt"
from [396d4ff0effe51b79acfe0c016030a9d2848e8b0]
to [479ec17c51f85a95cf73763b94e2658ea1422af4]
patch "test/test2/script.txt"
from [90c8fbd0cb741592730841c1e3ba4c41ea4a1f47]
to [449cc6c443d0ebd52aff9a8105d9b37808bd54bb]
============================================================
--- test/run-tests.sh 5fb77c0b17770fd0f7d475b364ace469842b296e
+++ test/run-tests.sh 3ec71cb41289f08a81c021916bddfadb29b224e6
@@ -4,13 +4,33 @@ SRCDIR=$(cd $srcdir && pwd)
SRCDIR=$(cd $srcdir && pwd)
+mkdir -p test-dir && cd test-dir
+TESTDIR=$(pwd)
+export TESTDIR
+echo TESTDIR=$TESTDIR
+rm -f $TESTDIR/status
+
+mkdir -p confdir
+cp $SRCDIR/test/monotonerc confdir/
+
+mtn="mtn --root=. --confdir=$TESTDIR/confdir --ticker=none"
+# If you want to see a lot more mtn output, just remove --quiet
+mtn_quiet="$mtn --quiet"
+mtn_extra_quiet="$mtn_quiet --quiet"
+raw_mtn="mtn"
+raw_mtn_quiet="mtn --quiet"
+
+
+######################################################################
+# Helper functions to do preparations
+
populate() {
echo "$@" >&2
local database=databases/$1
local branch=$2
local count=$3
if ! [ -e $database.mtn ]; then
- mtn -d $database.mtn db init
+ $mtn_quiet -d $database.mtn db init
fi
if [ ! $count ] || [ $count -gt 0 ]; then
$SRCDIR/test/populate-branch.sh $database.mtn $branch $count
@@ -28,7 +48,7 @@ usherctl_populate() {
database )
database="databases/$2"
if ! [ -e $database.mtn ]; then
- mtn -d $database.mtn db init
+ $mtn_quiet -d $database.mtn db init
fi
;;
esac
@@ -41,7 +61,7 @@ create_client_key() {
create_client_key() {
local name="$1"
- (echo; echo) | mtn --db :memory: --keydir ./keys genkey "$name"
+ $mtn_quiet --db :memory: --keydir ./keys au generate_key "$name" ""
}
usherctl_mkproject() {
@@ -56,7 +76,7 @@ usherctl_mkproject() {
$USHERCTL mk${type}project "$servername"
$USHERCTL addpattern "$servername" "$pattern*"
while [ $# -gt 0 ]; do
- mtn --db :memory: --keydir ./keys automate get_public_key `echo $1 | cut -f2 -d:` | \
+ $mtn_quiet --db :memory: --keydir ./keys automate get_public_key `echo $1 | cut -f2 -d:` | \
$USHERCTL addkey "$servername" -t `echo $1 | cut -f1 -d:`
shift
done
@@ -68,17 +88,10 @@ usherctl_mkproject() {
esac
}
-mkdir -p test-dir && cd test-dir
-TESTDIR=$(pwd)
-export TESTDIR
-echo TESTDIR=$TESTDIR
-rm -f $TESTDIR/status
+######################################################################
+# Helper functions to perform tests. These are used as commands in
+# testx/script.txt
-mkdir -p confdir
-cp $SRCDIR/test/monotonerc confdir/
-
-mtn="mtn --confdir=$TESTDIR/confdir --ticker=none"
-
msg_usher() {
MSG_USHER_SLEEP=$(expr $RANDOM % 2);
# see usher.conf.head for address
@@ -89,7 +102,7 @@ serve() {
}
serve() {
- $mtn -d $1.mtn serve --bind $2 &
+ $mtn_quiet -d $1.mtn serve --bind $2 &
SERVERS="$SERVERS $!"
}
@@ -99,10 +112,10 @@ client() {
local uri="$3"
local key="$4"
uri="$(echo $uri | sed 's/HOST/127.0.0.1:8691/')"
- [ -e $database.mtn ] || $mtn db init -d $database.mtn
+ [ -e $database.mtn ] || $mtn_quiet db init -d $database.mtn
key=${key:+"--key $key --keydir ./keys"}
# see usher.conf.head for address
- $mtn --root=. -d $database.mtn $key $what "$uri" &
+ $mtn_extra_quiet --db $database.mtn --timestamps $key $what "$uri" &
local mypid=$!
if $XFAIL; then
XFAIL_CLIENTS="$XFAIL_CLIENTS $mypid"
@@ -112,18 +125,45 @@ client() {
eval CLIENT_${mypid}='"$uri"'
}
+wait_for_clients() {
+ result=true
+ for c in $CLIENTS; do
+ echo -n "Waiting for $c... "
+ if ! wait $c; then
+ echo "Client died horribly: " "$(eval echo '$'CLIENT_$c)"
+ result=false
+ else
+ echo
+ fi
+ done
+ CLIENTS=
+ for c in $XFAIL_CLIENTS; do
+ echo -n "Waiting for $c... "
+ if wait $c; then
+ echo "Client expected to fail but didn't: " "$(eval echo '$'CLIENT_$c)"
+ result=false
+ else
+ echo
+ fi
+ done
+ XFAIL_CLIENTS=
+ eval $result
+}
+
client_fg() {
local what=$1
local database=$2
local uri="$3"
uri="$(echo $uri | sed 's/HOST/127.0.0.1:8691/')"
- [ -e $database.mtn ] || $mtn db init -d $database.mtn
+ [ -e $database.mtn ] || $mtn_quiet db init -d $database.mtn
# see usher.conf.head for address
+ # Do not use --quiet here, the output is precious
$mtn --root=. -d $database.mtn $what "$uri"
}
sync() {
client sync "$@"
+ wait_for_clients > /dev/null
}
multipull() {
@@ -133,6 +173,7 @@ multipull() {
for ((i=0; i<$count; ++i)); do
client pull multipull-$LINE-$i "$pattern" "$key"
done
+ wait_for_clients > /dev/null
}
check_match() {
@@ -150,6 +191,7 @@ check_match() {
echo "check_match: expected '$wanted_server' got '$got_server'"
return 1
fi
+ return 0
}
check_cmd() {
@@ -171,32 +213,21 @@ script() {
fi
}
-wait_for_clients() {
- for c in $CLIENTS; do
- echo "Waiting for $c..."
- if ! wait $c; then
- echo "Client died horribly: " "$(eval echo '$'CLIENT_$c)"
- OK=false
- fi
- done
- CLIENTS=
- for c in $XFAIL_CLIENTS; do
- echo "Waiting for $c..."
- if wait $c; then
- echo "Client expected to fail but didn't: " "$(eval echo '$'CLIENT_$c)"
- OK=false
- fi
- done
- CLIENTS=
-}
+######################################################################
+# Main code
+
EXIT_STATUS=0
tests="$*"
+if [ -n "$TESTTESTS" -a -z "$tests" ]; then
+ tests="$TESTTESTS"
+fi
+
if [ -z "$tests" ]; then tests=$(ls $SRCDIR/test/); fi
for test_name in $tests; do
if [ -d $SRCDIR/test/$test_name -a "$test_name" != "confdir" ]; then
- echo "Running test $test_name..."
+ echo "Preparing to run test $test_name..."
TEST_SRC=$SRCDIR/test/$test_name
cd $TESTDIR
@@ -206,6 +237,7 @@ for test_name in $tests; do
if [ -f $TEST_SRC/projects.txt ]; then
echo "($test_name is a test based on usherctl)"
+
if [ -d keys ]; then
rm -rf keys # We want to start fresh
fi
@@ -222,6 +254,7 @@ for test_name in $tests; do
echo "USHER_CONFDIR=\"$USHER_HOME\""
echo "USHER_PROJECTDIR=\"$USHER_HOME/projects\""
echo "USHER_PIDFILE=\"$USHER_HOME/usher.pid\""
+ echo "USHER_LOGFILE=\"$USHER_HOME/usher.log\""
echo "USHER_LOGDIR=\"$USHER_HOME/logs\""
echo "MTN=\"mtn\""
echo "USHER=\"$(cd ../..; pwd)/usher\""
@@ -278,6 +311,8 @@ for test_name in $tests; do
USHER_STOP="echo 'Killing usher (pid: $USHER_PID)'; kill $USHER_PID"
sleep 1
fi
+
+ echo "Running test $test_name..."
OK=true
LINE=0
@@ -286,28 +321,41 @@ for test_name in $tests; do
CLIENTS=
XFAIL_CLIENTS=
while read -r cmd rest; do
- echo "Testing: $cmd $rest"
+ echo -n "Testing: $cmd $rest ... "
LINE=$(expr $LINE + 1)
case $cmd in
stop)
+ echo
break
;;
'!')
XFAIL=true
if ! eval "$rest"; then
OK=false
+ echo FAIL
+ else
+ echo ok
fi
;;
*)
XFAIL=false
if ! eval $cmd "$rest"; then
OK=false
+ echo FAIL
+ else
+ echo ok
fi
;;
esac
done
- echo "Reached end of script, waiting for clients to die..."
- wait_for_clients
+ echo -n "Reached end of script, waiting for clients to die..."
+ if ! wait_for_clients; then
+ OK=false
+ echo FAIL
+ else
+ echo ok
+ fi
+
if $OK; then
echo "PASS $test_name" >>$TESTDIR/status
else
============================================================
--- test/test1/script.txt 396d4ff0effe51b79acfe0c016030a9d2848e8b0
+++ test/test1/script.txt 479ec17c51f85a95cf73763b94e2658ea1422af4
@@ -66,8 +66,8 @@
check_cmd SHUTDOWN foobar
client_fg sync user2 mtn://HOST/prjek?net.prjek'*' 2>&1 | grep -q foobar
check_cmd STARTUP
-client_fg sync user2 mtn://HOST/prjek?net.prjek'*'
+client_fg sync user2 mtn://HOST/prjek?net.prjek'*' 2>/dev/null >/dev/null
msg_usher STOP prjek baz
client_fg sync user2 mtn://HOST/prjek?net.prjek'*' 2>&1 | grep -q baz
msg_usher START prjek
-client_fg sync user2 mtn://HOST/prjek?net.prjek'*'
+client_fg sync user2 mtn://HOST/prjek?net.prjek'*' 2>/dev/null >/dev/null
============================================================
--- test/test2/script.txt 90c8fbd0cb741592730841c1e3ba4c41ea4a1f47
+++ test/test2/script.txt 449cc6c443d0ebd52aff9a8105d9b37808bd54bb
@@ -1,8 +1,9 @@
serve example 127.0.0.1:25436
# The first multipull will fail, because that key isn't allowed to
-# read that branch
-! multipull 3 mtn://HOST/prjek-s?net.prjek.separate address@hidden
+# read that branch. mtn is a bit loud about failed connections, so we
+# redirect the output to /dev/null
+! multipull 3 mtn://HOST/prjek-s?net.prjek.separate address@hidden 2>/dev/null
multipull 3 mtn://HOST/prjek-s?net.prjek.separate address@hidden
multipull 3 'mtn://HOST/prjek?net.prjek.{fnord,foobar}' address@hidden
multipull 3 mtn://HOST/example?org.example
@@ -45,5 +46,5 @@
check_cmd ADD_SERVER someserver remote 127.0.0.1 25436
sync user1 mtn://HOST/someserver?'*'
-check_cmd ADD_SERVER otherserver local "-d" "user1.mtn" "--confdir=../confdir"
+check_cmd ADD_SERVER otherserver local "-d" "user1.mtn" "--confdir=../confdir" "--timestamps" "--ticker=dot"
multipull 2 mtn://HOST/otherserver?'*'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone.contrib.usher: efb13f8e5ab02ce49f4a5fad607d2d19c460d896,
code <=