[iwhd] tests: fix bug introduced on by v1.2-13-g27f3713
by Jim Meyering
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
12 years, 1 month
[iwhd] Created tag v1.5
by Jim Meyering
The signed tag 'v1.5' was created.
Tagger: Jim Meyering <meyering(a)redhat.com>
Date: Sat Mar 10 12:38:11 2012 +0100
iwhd 1.5
Changes since the last tag 'v1.4':
Jim Meyering (7):
maint: post-release administrivia
build: work around F16-vs-F17 systemd unitdir difference
tests: minor clean up for the parallel abuse test
tests: avoid spurious test failure due to port-in-use
reject attempt to add attribute k/v pair to a nonexistent object
tests: adapt test to accommodate just-changed code
version 1.5
12 years, 1 month
[iwhd] maint: post-release administrivia
by Jim Meyering
commit 5a585f662a3b1b54ff0e01111cd2eccc85cbbcce
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Mar 10 12:40:55 2012 +0100
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
.prev-version | 2 +-
NEWS | 3 +++
cfg.mk | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/.prev-version b/.prev-version
index c068b24..c239c60 100644
--- a/.prev-version
+++ b/.prev-version
@@ -1 +1 @@
-1.4
+1.5
diff --git a/NEWS b/NEWS
index 4eab9d3..d68cf0c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
iwhd NEWS -*- outline -*-
+* Noteworthy changes in release ?.? (????-??-??) [?]
+
+
* Noteworthy changes in release 1.5 (2012-03-10) [stable]
** Bug fixes
diff --git a/cfg.mk b/cfg.mk
index 3caf499..179bd4e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -38,7 +38,7 @@ bootstrap-tools = autoconf,automake,gnulib
# Now that we have better tests, make this the default.
export VERBOSE = yes
-old_NEWS_hash = b5da668beab38a7deec511910d17d193
+old_NEWS_hash = 103fb665dacfff3e8c0511af5ea07d4c
sc_prohibit_echo_minus_en:
@prohibit='\<echo -[en]' \
12 years, 1 month
[iwhd] version 1.5
by Jim Meyering
commit 3360abb863faa55bfbea63f90acf2df66f0dc37f
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Mar 10 12:38:11 2012 +0100
version 1.5
* NEWS: Record release date.
NEWS | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 17c2326..4eab9d3 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,6 @@
iwhd NEWS -*- outline -*-
-* Noteworthy changes in release ?.? (????-??-??) [?]
+* Noteworthy changes in release 1.5 (2012-03-10) [stable]
** Bug fixes
12 years, 1 month
[iwhd] tests: adapt test to accommodate just-changed code
by Jim Meyering
commit 86cbea79b614b555899d623de2cce35d819ed9fd
Author: Jim Meyering <meyering(a)redhat.com>
Date: Sat Mar 10 11:27:50 2012 +0100
tests: adapt test to accommodate just-changed code
* t/basic: Adjust another test that set an attribute on a
nonexistent object: create the rsvd_attr object first.
t/basic | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/t/basic b/t/basic
index eba590d..3593afd 100755
--- a/t/basic
+++ b/t/basic
@@ -257,6 +257,7 @@ case $attr_words in
esac
# Ensure that an attempt to add each reserved attribute fails.
+curl -f -X PUT $bucket/rsvd_attr # Create the object we'll use.
for attr in $attr_words; do
case $attr in
# _attrs is defined only for GET, so evokes 404 rather than 400
12 years, 1 month
[iwhd] reject attempt to add attribute k/v pair to a nonexistent object
by Jim Meyering
commit c5d15ba9b5213d8ccd16dbc78f599b2057509874
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Mar 9 22:36:58 2012 +0100
reject attempt to add attribute k/v pair to a nonexistent object
* rest.c (proxy_put_attr): Fail with NOT_FOUND when attempting to
apply an attribute to a nonexistent object.
* t/put-attr-on-nonexistent-object: Test for the above.
* t/Makefile.am (TESTS): Add it.
* t/replication: Create each test object before trying to set
its attributes.
* NEWS (Bug fixes): Mention this.
Reported by Shveta Sachdeva in http://bugzilla.redhat.com/795403
As Pete Zaitecev noted in review, iwhd is still subject to
this problem due to the inherent TOCTOU race: the object whose
existence we've just confirmed may be removed by another party
in the brief interval before we add the attribute.
NEWS | 7 ++++
rest.c | 9 ++++++
t/Makefile.am | 1 +
t/put-attr-on-nonexistent-object | 59 ++++++++++++++++++++++++++++++++++++++
t/replication | 2 +
5 files changed, 78 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index e919cda..17c2326 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,13 @@ iwhd NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ iwhd now rejects an attempt to add attribute k/v pair to a nonexistent
+ object. Before, it would add the attribute, which would then make it
+ appear (listing the parent bucket) as if the still-nonexistent object
+ existed.
+
* Noteworthy changes in release 1.4 (2012-03-05) [stable]
diff --git a/rest.c b/rest.c
index 1aca0af..832c486 100644
--- a/rest.c
+++ b/rest.c
@@ -727,6 +727,15 @@ proxy_put_attr (void *cctx, struct MHD_Connection *conn, const char *url,
DPRINTF("PROXY PUT ATTR %s (%zu)\n",url,*data_size);
if (ms->state == MS_NEW) {
+ /* Given a non-reserved bucket name, reject any attempt
+ to attach attributes to a nonexistent bucket/key. */
+ if (!is_reserved(ms->bucket, reserved_bucket_name)
+ && !is_reserved(ms->key, reserved_name)) {
+ char *my_etag = meta_has_copy(ms->bucket,ms->key,me);
+ if (!my_etag || *my_etag == 0)
+ return do_resp(conn,ms,MHD_HTTP_NOT_FOUND,NULL,
+ "404 no such object\r\n");
+ }
ms->state = MS_NORMAL;
ms->url = strdup(url);
if (!ms->url) {
diff --git a/t/Makefile.am b/t/Makefile.am
index 77094b9..2b4b2e7 100644
--- a/t/Makefile.am
+++ b/t/Makefile.am
@@ -22,6 +22,7 @@ TESTS = \
exercise \
mongo-restart \
provider \
+ put-attr-on-nonexistent-object \
replication \
timeout \
auto \
diff --git a/t/put-attr-on-nonexistent-object b/t/put-attr-on-nonexistent-object
new file mode 100755
index 0000000..721c74a
--- /dev/null
+++ b/t/put-attr-on-nonexistent-object
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Adding an attribute to a nonexistent object must fail.
+# Before iwhd-1.5, it would succeed, and a subsequent listing
+# of the containing bucket would show the nonexistent object.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ..
+
+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 --help > /dev/null || fail_ "the mongod program is not installed"
+
+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
+
+port=$(get_port 9095 $lock_dir/i-) || fail_ "failed to get iwhd port"
+
+printf '[{"path": "FS", "type": "fs", "name": "primary"}]\n' \
+ > iwhd.cfg || fail=1
+
+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; }
+
+
+curl_w() { curl --write-out '%{http_code}' "$@"; }
+
+apply_attribute_to_nonexistent_object ()
+{
+ # Create a bucket.
+ local b=http://localhost:$port/b
+ curl_w -XPUT $b > http-code || fail=1
+ test "$(cat http-code)" = 201 || fail=1
+
+ # Trying to add an attribute to a non-existent object evokes 404 NOT_FOUND
+ local attr=$b/o/color
+ printf blue | curl_w -T - $attr > http-code || fail=1
+ test "$(tr '\012\015' :: < http-code)" = '404 no such object::404' || fail=1
+
+ # Ensure that the object does not appear in a listing:
+ printf '[\n]\n200' > exp || fail=1
+ curl_w -H 'Accept: */json' $b > out || fail=1
+ compare out exp || fail=1
+}
+
+apply_attribute_to_nonexistent_object
+
+Exit $fail
diff --git a/t/replication b/t/replication
index 6ef09a5..4a9cc99 100755
--- a/t/replication
+++ b/t/replication
@@ -89,12 +89,14 @@ printf '$color==#color' | curl -T - $bkt/_default/_policy || fail=1
# Positive test.
# NB this file is also used by the delete test below
+curl -X PUT $bkt/sel_pos || fail=1
printf blue | curl -T - $bkt/sel_pos/color || fail=1
printf foo | curl -T - $bkt/sel_pos || fail=1
wait_for .1 50 "wait_for_repl $api" || fail_ "replication seems stuck"
test -f fs_downstream/rbucket/sel_pos || fail=1
# Negative test.
+curl -X PUT $bkt/sel_neg || fail=1
printf red | curl -T - $bkt/sel_neg/color || fail=1
printf foo | curl -T - $bkt/sel_neg || fail=1
wait_for .1 50 "wait_for_repl $api" || fail_ "replication seems stuck"
12 years, 1 month
[iwhd] tests: avoid spurious test failure due to port-in-use
by Jim Meyering
commit fc10c5558d5f10b160ecef56c57a77740e0651b1
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Mar 9 18:32:04 2012 +0100
tests: avoid spurious test failure due to port-in-use
* t/init.cfg (_port_in_use): New function.
(get_port): Don't blindly use the next port. That would fail if it
happens to be in use by some other process not related to our tests.
Instead, use _port_in_use to test it.
t/init.cfg | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/t/init.cfg b/t/init.cfg
index 2539823..f965c12 100644
--- a/t/init.cfg
+++ b/t/init.cfg
@@ -145,6 +145,15 @@ emit_bucket_list()
fi
}
+# See if someone is listening on the specified port.
+# If so, exit successfully (0). Otherwise, exit nonzero.
+_port_in_use()
+{
+ perl -MIO::Socket -e \
+ 'exit ! IO::Socket::INET->new("PeerAddr"=>"localhost:'"$1"'", \
+ "Timeout"=>1, "Proto"=>"tcp")'
+}
+
# Each test script uses its own mongod instance as well as at least one
# iwhd process. Each of those needs a unique port number, so that the
# tests may be run in parallel without interfering with one another.
@@ -152,7 +161,9 @@ emit_bucket_list()
# Inputs:
# starting_port: start with this port number
# dir_prefix (we mkdir $dir_prefix$i for some $i >= $starting_port)
-# Return the first PID >= $starting_port for which mkdir $dir_prefix$i succeeds
+# Return the first P >= $starting_port for which mkdir $dir_prefix$i
+# succeeds and for which a quick connection test of localhost:$P suggests
+# the port is not in use.
get_port()
{
local starting_port=$1
@@ -160,8 +171,14 @@ get_port()
local i=0
while :; do
local p=$((starting_port + i))
- mkdir $dir_prefix$p 2>/dev/null \
- && { echo $p; echo $$ > $dir_prefix$p/pid; break; }
+ if mkdir $dir_prefix$p 2>/dev/null; then
+ if _port_in_use $p; then
+ echo in-use-by-other > $dir_prefix$p/pid
+ warn_ "INFO: port $p appears to be in use; skipping it"
+ else
+ echo $$ > $dir_prefix$p/pid; echo $p; break
+ fi
+ fi
i=$((i+1))
done
}
12 years, 1 month
[iwhd] tests: minor clean up for the parallel abuse test
by Jim Meyering
commit e083f61c5fb04d93236bb1d6208f8c0422387556
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Mar 8 09:41:31 2012 +0100
tests: minor clean up for the parallel abuse test
* t/exercise (iwhd_pid): Don't omit the newline after http code
in the initial bucket-creating loop. Theoretically this could
have caused a false-positive failure, if one query had failed
with say ?20, and the next with 1??, then their concatenation
would match the "201" that we grep for.
Also, use the curl_w function, rather than open-coding it (without
newline) and compensating for lack of a newline with a following "echo".
t/exercise | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/t/exercise b/t/exercise
index 73a669e..5ef4586 100755
--- a/t/exercise
+++ b/t/exercise
@@ -52,7 +52,7 @@ create_many()
# Create many buckets in parallel, though we'll use only
# the first $nb of them in the following loop.
- seq 2000 | parallel -j 200% curl -s --write-out '%{http_code}' -XPUT \
+ seq 2000 | parallel -j 200% curl -s --write-out '%{http_code}\n' -XPUT \
http://localhost:$port/b-{} > http-code || fail=1
grep -q 201 http-code || fail=1
@@ -79,9 +79,7 @@ create_many()
# Query for objects with A=V in the first bucket:
i=1
b=http://localhost:$port/b-$i
- curl --write-out '%{http_code}' -H 'Accept: */json' \
- -d '$A=="V"' $b/_query > q.json || fail=1
- echo >> q.json
+ curl_w -H 'Accept: */json' -d '$A=="V"' $b/_query > q.json || fail=1
# Require a 200 HTTP return code:
test "$(tail -1 q.json)" = 200 || fail=1
12 years, 1 month
[iwhd] build: work around F16-vs-F17 systemd unitdir difference
by Jim Meyering
commit ebd17b57ebe07281c1f49e7cb723a04e638591d5
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 5 22:27:14 2012 +0100
build: work around F16-vs-F17 systemd unitdir difference
We have chosen to distribute in the "upstream" tarball (hence also to
install) the systemd unit file, iwhd.service. Now we pay for that sin.
In Fedora 16, unitdir is /lib/systemd/system, in spite of $(prefix),
but on Fedora 17 and newer it is /usr/lib/systemd/system when
$(prefix) is /usr.
* Makefile.am (unitdir): Compute at make-install time a value for
$(unitdir) that is consistent with rpm --eval '%{_unitdir}'.
Makefile.am | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b22efc1..16b8fc0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,8 +138,13 @@ iwhd-users.js: $(top_builddir)/config.status
$(AM_V_GEN)echo '[ { "name":"admin", "secret":"replaceme" } ]' \
> $@-t && chmod a-w $@-t && mv $@-t $@
+# F16's unitdir is /lib/systemd/system, in spite of $(prefix), but
+# on F17 it is /usr/lib/systemd/system
+# Account for that by testing rpm --eval '%{_unitdir}'.
+# When that evaluates to "/lib/systemd/system", ignore a prefix of "/usr".
# Honor $(prefix) in the expansion of $(unitdir), except when it is "/usr".
-p = $$(echo '$(prefix)' | sed 's,^/usr$$,,')
+p = $$(case $$(rpm --eval '%{_unitdir}'):$(prefix) in \
+ /lib/systemd/system:/usr) ;; *) echo '$(prefix)';; esac)
unitdir = $(DESTDIR)$(p)/lib/systemd/system
logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d
12 years, 1 month
[iwhd] Created tag v1.4
by Jim Meyering
The signed tag 'v1.4' was created.
Tagger: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 5 16:35:36 2012 +0100
iwhd 1.4
Changes since the last tag 'v1.3':
Jim Meyering (6):
maint: post-release administrivia
maint: Cc the translationproject.org on announcement email
iwhd: remove bogus "attr_" prefixes from json attribute listing
tests: generate expected JSON from expected XML, so they stay in sync
build: update gnulib submodule to latest
version 1.4
12 years, 1 month