commit 27f37132461149295061848bab3da90b35b5a4bc
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Feb 23 18:45:16 2012 +0100
tests: adapt to mongod's new default of using --journal
With --journal now the default in Fedora's mongod, start-up takes
at least triple the typical maximum of 5 seconds that we allow
for mongod to initialize and respond to a simple query.
Requiring journal initialization also imposed a much greater
disk footprint, especially when running tests in parallel.
For these reasons, now all test-driven mongod invocations use
--nojournal. While the t/auto tests succeeds when run via
"make -j1 check", it consistently fails with -j$N for 1 < $N.
* t/init.cfg (wait_for): Use warn_, not echo, and don't bother
to warn when sleeping for less than .8 seconds.
(wait_for_mongo): New function.
($mongo_opt): Use --nojournal, if possible.
* t/auto: Add comment saying why we do *not* use wait_for_mongo.
* t/basic: Use $mongo_opt when starting mongod.
Don't redirect mongod output to some file no one will see.
* t/creation-code: Likewise
* t/delete-missing: Likewise.
* t/exercise: Likewise.
* t/mongo-restart: Likewise.
* t/oauth: Likewise.
* t/provider: Likewise.
* t/registration: Likewise.
* t/replication: Likewise.
t/auto | 3 ++-
t/basic | 8 ++++----
t/creation-code | 6 +++---
t/delete-missing | 6 +++---
t/exercise | 6 +++---
t/init.cfg | 17 ++++++++++++++++-
t/mongo-restart | 10 +++++-----
t/oauth | 8 ++++----
t/provider | 6 +++---
t/registration | 6 +++---
t/replication | 8 ++++----
11 files changed, 50 insertions(+), 34 deletions(-)
---
diff --git a/t/auto b/t/auto
index c9f18ab..c8d4ee3 100755
--- a/t/auto
+++ b/t/auto
@@ -22,7 +22,8 @@ iwhd -v -p $port -a &
iwhd_pid=$!
cleanup_() { kill $iwhd_pid; }
-# Wait for up to 10 seconds for mongod to begin listening.
+# Wait longer than usual (i.e., don't use wait_for_mongo), since this
+# mongo daemon was started via iwhd itself, and not with $mongo_opt
wait_for .1 100 'mongo localhost:$m_port < /dev/null' \
|| framework_failure_ mongod failed to start
# Wait for up to 20 seconds for iwhd to begin listening on $port.
diff --git a/t/basic b/t/basic
index c098dc7..7578b1a 100755
--- a/t/basic
+++ b/t/basic
@@ -19,13 +19,13 @@ m_port=$(get_port $mongo_base_port $lock_dir/m-) \
mongod --help > /dev/null || fail_ "the mongod program is not installed"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
-# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port \
+ || { warn_ boom; sleep 99d; framework_failure_ mongod failed to start; }
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
bucket=http://localhost:$port/b1
diff --git a/t/creation-code b/t/creation-code
index e71f283..8a7671c 100755
--- a/t/creation-code
+++ b/t/creation-code
@@ -10,12 +10,12 @@ m_port=$(get_port $mongo_base_port $lock_dir/m-) \
mongod --help > /dev/null || fail_ "the mongod program is not installed"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -28,7 +28,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
# Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| { echo iwhd failed to listen; Exit 1; }
diff --git a/t/delete-missing b/t/delete-missing
index 9bc82d6..3291a98 100755
--- a/t/delete-missing
+++ b/t/delete-missing
@@ -12,12 +12,12 @@ m_port=$(get_port $mongo_base_port $lock_dir/m-) \
mongod --help > /dev/null || fail_ "the mongod program is not installed"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -30,7 +30,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
# Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| { echo iwhd failed to listen; Exit 1; }
diff --git a/t/exercise b/t/exercise
index a1a7282..73a669e 100755
--- a/t/exercise
+++ b/t/exercise
@@ -14,12 +14,12 @@ m_port=$(get_port $mongo_base_port $lock_dir/m-) \
mongod --help > /dev/null || fail_ "the mongod program is not installed"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -33,7 +33,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
# Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| { echo iwhd failed to listen; Exit 1; }
diff --git a/t/init.cfg b/t/init.cfg
index 858bd38..2539823 100644
--- a/t/init.cfg
+++ b/t/init.cfg
@@ -31,14 +31,29 @@ wait_for()
esac
local i=0
while :; do
- eval "$cmd" && { echo "cmd took $i x ${sleep_seconds}s:
'$cmd'"; return 0; }
+ eval "$cmd" && { test $i -ge 8 \
+ && warn_ "cmd took $i*$sleep_seconds seconds:
'$cmd'";
+ return 0; }
sleep $sleep_seconds
i=$(expr $i + 1)
+ # Don't even announce that we're waiting unless it's been a few
iterations.
+ test $i = 8 \
+ && warn_ "waiting for up to $2 * $1 seconds"
test $i = $max_n_sleeps \
&& { warn_ "EXPIRED: $i x ${sleep_seconds}s: '$cmd'";
return 1; }
done
}
+wait_for_mongo()
+{
+ wait_for .1 100 "mongo localhost:$1 < /dev/null"
+}
+# If we ever stop using --nojournal here, expect to increase the
+# timeout above to something like ".1 * 300" (i.e., 30 seconds),
+# in order to accommodate the cost of journal initialization.
+# Use --nojournal when possible.
+mongo_opt=$(mongod --help| grep -e --nojournal >/dev/null && echo
--nojournal)
+
emit_provider_list_prefix()
{
test $1 = xml && p='<providers>' || p='['
diff --git a/t/mongo-restart b/t/mongo-restart
index 03335dd..63a5d9a 100755
--- a/t/mongo-restart
+++ b/t/mongo-restart
@@ -12,12 +12,12 @@ m_port=$(get_port $mongo_base_port $lock_dir/m-) \
mongod --help > /dev/null || fail_ "the mongod program is not installed"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -30,7 +30,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
# Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
@@ -77,11 +77,11 @@ test "$(cat http-code)" = 500 || fail=1
echo 'dummy' | curl_w -T -
http://localhost:$port/b1/x > http-code || fail=1
test "$(cat http-code)" = 500 || fail=1
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
creation_evokes_201 b2
diff --git a/t/oauth b/t/oauth
index 7f47414..8dde2ef 100755
--- a/t/oauth
+++ b/t/oauth
@@ -17,12 +17,12 @@ test -f ${abs_top_builddir}/t/poke \
m_port=$(get_port $mongo_base_port $lock_dir/m-) \
|| fail_ "failed to get mongodb port"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -38,7 +38,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
## Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 \
+wait_for_mongo $m_port \
"poke -v -h localhost:$port -u chiaki -p nodame -l" \
|| fail_ iwhd failed to listen
@@ -77,7 +77,7 @@ chmod 600 iwhd.users
iwhd -v -o -u iwhd.users -p $port -c iwhd.cfg -d localhost:$m_port &
iwhd_pid=$!
-wait_for .1 50 \
+wait_for_mongo $m_port \
"poke -v -h localhost:$port -u chiaki -p nodame -l" \
|| { echo iwhd failed to listen; Exit 1; }
diff --git a/t/provider b/t/provider
index 083cfe0..596b821 100755
--- a/t/provider
+++ b/t/provider
@@ -8,12 +8,12 @@ mkdir FS mongod iwhd || framework_failure_ mkdir failed
m_port=$(get_port $mongo_base_port $lock_dir/m-) \
|| fail_ "failed to get mongodb port"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 5 seconds for mongod to begin listening.
-wait_for .1 50 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -28,7 +28,7 @@ iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
# Wait for up to 5 seconds for iwhd to begin listening on $port.
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| { echo iwhd failed to listen; Exit 1; }
fail=0
diff --git a/t/registration b/t/registration
index c5407a3..a1114cd 100755
--- a/t/registration
+++ b/t/registration
@@ -11,13 +11,13 @@ port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd
port"
m_port=$(get_port $mongo_base_port $lock_dir/m-) \
|| fail_ "failed to get mongodb port"
-mongod --port $m_port --pidfilepath reg/mongod/pid --dbpath reg/mongod \
+mongod $mongo_opt --port $m_port --pidfilepath reg/mongod/pid --dbpath reg/mongod \
reg/mongod.log 2>&1 &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 12 seconds for mongod to begin listening.
-wait_for .1 120 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
# Nobody sanity-checks nfsdir for being absolute pathname, but as it happens
@@ -39,7 +39,7 @@ PATH=$PATH:${abs_top_srcdir} iwhd -v -p $port -c iwhd_reg.conf \
iwhd_pid=$!
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
-wait_for .1 50 "curl -s
http://localhost:$port" \
+wait_for_mongo $m_port \
|| framework_failure_ iwhd failed to start
# Create an empty bucket.
diff --git a/t/replication b/t/replication
index 2a7a1ef..6ef09a5 100755
--- a/t/replication
+++ b/t/replication
@@ -15,12 +15,12 @@ mkdir mongod fs_upstream fs_downstream || framework_failure_ mkdir
failed
m_port=$(get_port $mongo_base_port $lock_dir/m-) \
|| fail_ "failed to get mongodb port"
-mongod --port $m_port --pidfilepath mongod/pid --dbpath mongod > mongod.log
2>&1 &
+mongod $mongo_opt --port $m_port --pidfilepath mongod/pid --dbpath mongod &
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
# Wait for up to 12 seconds for mongod to begin listening.
-wait_for .1 120 'mongo localhost:$m_port < /dev/null' \
+wait_for_mongo $m_port \
|| framework_failure_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -36,7 +36,7 @@ EOF
iwhd -v -p $port -c iwhd_u.cfg -d localhost:$m_port &
iwhd_pid=$!
-wait_for .1 50 "curl
http://localhost:$port" \
+wait_for_mongo $m_port \
|| framework_failure_ "iwhd upstream"
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
@@ -48,7 +48,7 @@ EOF
iwhd -v -p $d_port -c iwhd_d.cfg -d localhost:$m_port -m localhost:$port &
iwhd_d_pid=$!
-wait_for .1 50 "curl
http://localhost:$d_port" \
+wait_for_mongo $m_port \
|| framework_failure_ "iwhd downstream"
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid $iwhd_d_pid; }