Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-6003: Load view docs after other docs

Design docs should be uploaded and created after all other docs
are uploaded.

Change-Id: I3f922db6eebb24828efc6148187a63735b7a2bcf
Reviewed-on: http://review.couchbase.org/19131
Reviewed-by: Pavel Paulau <pavel.paulau@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
commit 9522e46af420191c507325a36ae65ceeb5b3d8a8 1 parent d6606d2
@bcui6611 bcui6611 authored
Showing with 23 additions and 9 deletions.
  1. +23 −9 cbdocloader
View
32 cbdocloader
@@ -79,6 +79,7 @@ class DocLoader:
if not subdir:
subdir = self.args[0]
subdirlist = list()
+ viewdirs = list()
for item in os.listdir(subdir):
if os.path.isfile(os.path.join(subdir, item)):
try:
@@ -90,21 +91,33 @@ class DocLoader:
except IOError, error:
print error
else:
- subdirlist.append(os.path.join(subdir, item))
+ if item.find("design_docs") > 0:
+ viewdirs.append(os.path.join(subdir, item))
+ else:
+ subdirlist.append(os.path.join(subdir, item))
for dir in subdirlist:
self.list_files(dir)
+ for dir in viewdirs:
+ self.list_files(dir)
def unzip_file_and_upload(self):
zfobj = zipfile.ZipFile(self.args[0])
for name in zfobj.namelist():
- if not name.endswith('/'):
- print 'working with %s' % name
- dockey = self.gen_dockey(name)
- temp_file = TemporaryFile()
- temp_file.write(zfobj.read(name))
- temp_file.seek(0)
- self.save_doc(dockey, temp_file)
- temp_file.close()
+ if not name.endswith('/') and name.find("design_docs") < 0:
+ self.upload_file(zfobj, name)
+ #upload design docs after all other docs
+ for name in zfobj.namelist():
+ if not name.endswith('/') and name.find("design_docs") >= 0:
+ self.upload_file(zfobj, name)
+
+ def upload_file(self, zfobj, name):
+ print 'working with %s' % name
+ dockey = self.gen_dockey(name)
+ temp_file = TemporaryFile()
+ temp_file.write(zfobj.read(name))
+ temp_file.seek(0)
+ self.save_doc(dockey, temp_file)
+ temp_file.close()
def populate_docs(self):
cb = client.Couchbase(self.options.node,
@@ -121,6 +134,7 @@ class DocLoader:
def verify_queries(self):
for view in self.views:
+ print "View:", view
self.bucket.view(view, stale="update_after")
def main():
Please sign in to comment.
Something went wrong with that request. Please try again.