commit 4ad33d9459210cbfb95d31c698b8ac7b900eb94e
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Mar 13 00:14:22 2012 +0100
tests: fix bug introduced on by v1.2-13-g27f3713
I mistakenly changed some code that was waiting for iwhd to
instead wait for mongod. Due to races, on my primary systems
and on F16, F17 and F18 build systems, this happened never to
cause a test failure. But running tests on a system with a slow
enough disk, it would make tests fail consistently.
* t/init.cfg (wait_for_iwhd): New function.
* t/creation-code: Wait for iwhd, once again.
Also remove obsolete comments about waiting for up to 5 seconds.
* t/delete-missing: Likewise.
* t/exercise: Likewise.
* t/mongo-restart: Likewise.
* t/oauth: Likewise.
* t/provider: Likewise.
* t/put-attr-on-nonexistent-object: Likewise.
* t/registration: Likewise.
* t/replication: Likewise.
t/basic | 5 ++---
t/creation-code | 10 ++++------
t/delete-missing | 10 ++++------
t/exercise | 10 ++++------
t/init.cfg | 5 +++++
t/mongo-restart | 15 ++++++---------
t/oauth | 11 +++++------
t/provider | 10 ++++------
t/put-attr-on-nonexistent-object | 10 ++++------
t/registration | 8 +++-----
t/replication | 11 ++++-------
11 files changed, 45 insertions(+), 60 deletions(-)
---
diff --git a/t/basic b/t/basic
index 3593afd..6e8c083 100755
--- a/t/basic
+++ b/t/basic
@@ -67,9 +67,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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" \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
# Create an empty bucket.
curl -X PUT $bucket || fail=1
diff --git a/t/creation-code b/t/creation-code
index 8a7671c..0c3b3d9 100755
--- a/t/creation-code
+++ b/t/creation-code
@@ -14,9 +14,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -27,9 +26,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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_mongo $m_port \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
diff --git a/t/delete-missing b/t/delete-missing
index 3291a98..13c9f52 100755
--- a/t/delete-missing
+++ b/t/delete-missing
@@ -16,9 +16,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -29,9 +28,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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_mongo $m_port \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
diff --git a/t/exercise b/t/exercise
index 5ef4586..faa9f20 100755
--- a/t/exercise
+++ b/t/exercise
@@ -18,9 +18,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -32,9 +31,8 @@ MALLOC_PERTURB_=31 MALLOC_CHECK_=3 \
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_mongo $m_port \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
diff --git a/t/init.cfg b/t/init.cfg
index f965c12..4d2e3ff 100644
--- a/t/init.cfg
+++ b/t/init.cfg
@@ -54,6 +54,11 @@ wait_for_mongo()
# Use --nojournal when possible.
mongo_opt=$(mongod --help| grep -e --nojournal >/dev/null && echo
--nojournal)
+wait_for_iwhd()
+{
+ wait_for .1 100 "curl -s localhost:$1"
+}
+
emit_provider_list_prefix()
{
test $1 = xml && p='<providers>' || p='['
diff --git a/t/mongo-restart b/t/mongo-restart
index 63a5d9a..cb01935 100755
--- a/t/mongo-restart
+++ b/t/mongo-restart
@@ -16,9 +16,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -29,9 +28,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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_mongo $m_port \
- || fail_ iwhd failed to listen
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
@@ -80,9 +78,8 @@ test "$(cat http-code)" = 500 || fail=1
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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
creation_evokes_201 b2
diff --git a/t/oauth b/t/oauth
index 8dde2ef..022cb0b 100755
--- a/t/oauth
+++ b/t/oauth
@@ -21,9 +21,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -37,8 +36,8 @@ iwhd -v -o -U chiaki:nodame \
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_mongo $m_port \
+## Wait for iwhd to begin listening on $port.
+wait_for .1 50 \
"poke -v -h localhost:$port -u chiaki -p nodame -l" \
|| fail_ iwhd failed to listen
@@ -79,7 +78,7 @@ iwhd_pid=$!
wait_for_mongo $m_port \
"poke -v -h localhost:$port -u chiaki -p nodame -l" \
- || { echo iwhd failed to listen; Exit 1; }
+ || fail_ iwhd failed to listen
poke -h localhost:$port -u chiaki -p nodame -b buk -l || fail=1
poke -h localhost:$port -u chiaki -p badpass -b buk -l && fail=1
diff --git a/t/provider b/t/provider
index 596b821..0d5a4c0 100755
--- a/t/provider
+++ b/t/provider
@@ -12,9 +12,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -27,9 +26,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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_mongo $m_port \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening on $port.
+wait_for_iwhd $port || fail_ iwhd failed to listen
fail=0
diff --git a/t/put-attr-on-nonexistent-object b/t/put-attr-on-nonexistent-object
index 721c74a..6bb5367 100755
--- a/t/put-attr-on-nonexistent-object
+++ b/t/put-attr-on-nonexistent-object
@@ -16,9 +16,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
@@ -29,9 +28,8 @@ iwhd -v -p $port -c iwhd.cfg -d localhost:$m_port &
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_mongo $m_port \
- || { echo iwhd failed to listen; Exit 1; }
+# Wait for iwhd to begin listening.
+wait_for_iwhd $port || fail_ iwhd failed to listen
curl_w() { curl --write-out '%{http_code}' "$@"; }
diff --git a/t/registration b/t/registration
index a1114cd..b729739 100755
--- a/t/registration
+++ b/t/registration
@@ -16,9 +16,8 @@ mongod $mongo_opt --port $m_port --pidfilepath reg/mongod/pid --dbpath
reg/mongo
mongo_pid=$!
cleanup_() { kill -9 $mongo_pid; }
-# Wait for up to 12 seconds for mongod to begin listening.
-wait_for_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
# Nobody sanity-checks nfsdir for being absolute pathname, but as it happens
# iwhd runs dc-condor-image inside the fs back-end top directory, so
@@ -39,8 +38,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_mongo $m_port \
- || framework_failure_ iwhd failed to start
+wait_for_iwhd $port || fail_ iwhd failed to start
# Create an empty bucket.
curl -X PUT
http://localhost:$port/buk || fail=1
diff --git a/t/replication b/t/replication
index 4a9cc99..68b2f75 100755
--- a/t/replication
+++ b/t/replication
@@ -19,9 +19,8 @@ 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_mongo $m_port \
- || framework_failure_ mongod failed to start
+# Wait for mongod to begin listening.
+wait_for_mongo $m_port || fail_ mongod failed to start
port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
d_port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get 2nd iwhd port"
@@ -36,8 +35,7 @@ EOF
iwhd -v -p $port -c iwhd_u.cfg -d localhost:$m_port &
iwhd_pid=$!
-wait_for_mongo $m_port \
- || framework_failure_ "iwhd upstream"
+wait_for_iwhd $port || fail_ iwhd upstream failed to start
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid; }
cat > iwhd_d.cfg << EOF
@@ -48,8 +46,7 @@ EOF
iwhd -v -p $d_port -c iwhd_d.cfg -d localhost:$m_port -m localhost:$port &
iwhd_d_pid=$!
-wait_for_mongo $m_port \
- || framework_failure_ "iwhd downstream"
+wait_for_iwhd $d_port || fail_ iwhd downstream failed to start
cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid $iwhd_d_pid; }
api=http://localhost:$port