Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CBSE-351: Wait for a while before querying bucket status

Sometimes bucket is not fully created yet. So "Object Not Found"
message can be returned if querying bucket status right away.

Change-Id: Ic84068de6bb111484ea8f7c4507985bb5afd9c4b
Reviewed-on: http://review.couchbase.org/24214
Tested-by: Bin Cui <bin.cui@gmail.com>
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
Reviewed-on: http://review.couchbase.org/24326
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
commit 8a716cc15a04a1ed2a67eb10ff8fa061f14d6a58 1 parent db9c8a3
@bcui6611 bcui6611 authored
Showing with 24 additions and 4 deletions.
  1. +24 −4 buckets.py
View
28 buckets.py
@@ -135,12 +135,30 @@ def runCmd(self, cmd, server, port,
print ' ramQuota: %s' % bucket['quota']['ram']
print ' ramUsed: %s' % bucket['basicStats']['memUsed']
elif cmd == "bucket-create" and wait_for_bucket_ready:
+ rest_query = restclient.RestClient(server, port, {'debug':self.debug})
timeout_in_seconds = 120
- self.rest_cmd = rest_cmds['bucket-info'] % bucketname
start = time.time()
- rest_query = restclient.RestClient(server, port, {'debug':self.debug})
+ # Make sure the bucket exists before querying its status
+ bucket_exist = False
+ while (time.time() - start) <= timeout_in_seconds and not bucket_exist:
+ buckets = rest_query.restCmd('GET', rest_cmds['bucket-list'],
+ self.user, self.password, opts)
+ for bucket in rest_query.getJson(buckets):
+ if bucket["name"] == bucketname:
+ bucket_exist = True
+ break
+ if not bucket_exist:
+ sys.stderr.write(".")
+ time.sleep(2)
+
+ if not bucket_exist:
+ print "\nFail to create bucket '%s' within %s seconds" %\
+ (bucketname, timeout_in_seconds)
+ return False
+
+ #Query status for all bucket nodes
while (time.time() - start) <= timeout_in_seconds:
- bucket_info = rest_query.restCmd('GET', self.rest_cmd,
+ bucket_info = rest_query.restCmd('GET', rest_cmds['bucket-info'] % bucketname,
self.user, self.password, opts)
json = rest_query.getJson(bucket_info)
all_node_ready = True
@@ -157,7 +175,9 @@ def runCmd(self, cmd, server, port,
else:
sys.stderr.write(".")
time.sleep(2)
- print "\nFail to create bucket within %s seconds" % timeout_in_seconds
+
+ print "\nBucket '%s' is created but not ready to use within %s seconds" %\
+ (bucketname, timeout_in_seconds)
return False
else:
if output == 'json':
Please sign in to comment.
Something went wrong with that request. Please try again.