[patch iwhd 1/2] Eliminate sleep 5 in t/oauth

Pete Zaitcev zaitcev at redhat.com
Tue Oct 18 22:40:46 UTC 2011


The segment remained from the time when we meant to use curl instead of
rolling the "poke" binary. We do not need to waste 5 seconds now.

Since we're at it, fix the listing of buckets in "poke". The library
hstor.c fully supports it, but we forgot to hook it up in the tool.

---
 t/oauth  |    6 +++---
 t/poke.c |   22 +++++++++++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/t/oauth b/t/oauth
index 26d3964..44da7b0 100644
--- a/t/oauth
+++ b/t/oauth
@@ -38,9 +38,9 @@ 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; }
-sleep 5
+wait_for .1 50 \
+ "poke -v -h localhost:$port -u chiaki -p nodame -l" \
+  || { echo iwhd failed to listen; Exit 1; }
 
 cat <<EOF >object.data
 Test
diff --git a/t/poke.c b/t/poke.c
index 48e4f9f..8e307dc 100644
--- a/t/poke.c
+++ b/t/poke.c
@@ -331,10 +331,26 @@ static void do_list(struct params *par, struct hstor_client *httpstor, char *err
 	struct hstor_keylist *list;
 	struct hstor_object *obj;
 
+	if (!par->bucket) {
+		struct hstor_blist *blist;
+		struct hstor_bucket *b;
+
+		blist = hstor_list_buckets(httpstor);
+		if (!blist)
+			error(1, 0, "Failed to list root");
+
+		SLIST_FOREACH(b, &blist->list, blink) {
+			printf("bucket `%s'\n", b->name);
+		}
+
+		hstor_free_blist(blist);
+		return;
+	}
+
 	list = hstor_keys(httpstor, par->bucket);
 	if (!list)
-		error(1, 0, "Failed to list, prefix `%s'",
-		    par->key? par->key: "(none)");
+		error(1, 0, "Failed to list, bucket `%s' prefix `%s'",
+		    par->bucket, par->key? par->key: "(none)");
 
 	SLIST_FOREACH(obj, &list->contents, clink) {
 		/* XXX replace with etag when available. */
@@ -544,7 +560,7 @@ static void parse_args(struct params *par, int argc, char **argv)
 		fprintf(stderr, "Host (-h) is missing\n");
 		Usage();
 	}
-	if (par->bucket == NULL) {
+	if (par->mode != MODE_LIST && par->bucket == NULL) {
 		fprintf(stderr, "Bucket (-b) is missing\n");
 		Usage();
 	}


More information about the iwhd-devel mailing list