You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2017/11/16 08:21:59 UTC
[couchdb] branch master updated: Improve Mango test suite
performance (#995)
This is an automated email from the ASF dual-hosted git repository.
willholley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/master by this push:
new 8b4e92a Improve Mango test suite performance (#995)
8b4e92a is described below
commit 8b4e92ae240d82837a0dede78fe5c1f664486f1c
Author: Will Holley <wi...@gmail.com>
AuthorDate: Thu Nov 16 08:21:56 2017 +0000
Improve Mango test suite performance (#995)
* Remove artificial delays from database and index create/delete.
* Wait for indexes to report as created/deleted during test setup.
* Skip unnecessary database delete/create cycles.
* Default to n=1 when creating test databases. We don't have
tests that explicitly test n=3 scenarios and the tests generally
run on a single-node harness. Defaulting to n=1 allows the test
behaviour to be consistent when run on multi-node clusters.
* Add delay on cluster setup for Mango tests to mitigate tests
running before async cluster setup completes.
---
src/mango/test/mango.py | 39 +++++++++++++++++++++++++++-------
test/build/test-run-couch-for-mango.sh | 3 +++
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/mango/test/mango.py b/src/mango/test/mango.py
index 03cc67c..560914b 100644
--- a/src/mango/test/mango.py
+++ b/src/mango/test/mango.py
@@ -81,10 +81,14 @@ class Database(object):
r = self.sess.delete(self.url)
def recreate(self):
+ r = self.sess.get(self.url)
+ db_info = r.json()
+ docs = db_info["doc_count"] + db_info["doc_del_count"]
+ if docs == 0:
+ # db never used - create unnecessary
+ return
self.delete()
- delay()
self.create()
- delay()
def save_doc(self, doc):
self.save_docs([doc])
@@ -126,11 +130,17 @@ class Database(object):
body["index"]["partial_filter_selector"] = partial_filter_selector
body = json.dumps(body)
r = self.sess.post(self.path("_index"), data=body)
- delay()
r.raise_for_status()
assert r.json()["id"] is not None
assert r.json()["name"] is not None
- return r.json()["result"] == "created"
+
+ created = r.json()["result"] == "created"
+ if created:
+ # wait until the database reports the index as available
+ while len(self.get_index(r.json()["id"], r.json()["name"])) < 1:
+ delay(t=0.1)
+
+ return created
def create_text_index(self, analyzer=None, idx_type="text",
partial_filter_selector=None, default_field=None, fields=None,
@@ -157,7 +167,6 @@ class Database(object):
body["ddoc"] = ddoc
body = json.dumps(body)
r = self.sess.post(self.path("_index"), data=body)
- delay()
r.raise_for_status()
return r.json()["result"] == "created"
@@ -169,13 +178,28 @@ class Database(object):
r = self.sess.get(self.path("_index?"+limit+";"+skip))
r.raise_for_status()
return r.json()["indexes"]
+
+ def get_index(self, ddocid, name):
+ if ddocid is None:
+ return [i for i in self.list_indexes() if i["name"] == name]
+
+ ddocid = ddocid.replace("%2F", "/")
+ if not ddocid.startswith("_design/"):
+ ddocid = "_design/" + ddocid
+
+ if name is None:
+ return [i for i in self.list_indexes() if i["ddoc"] == ddocid]
+ else:
+ return [i for i in self.list_indexes() if i["ddoc"] == ddocid and i["name"] == name]
def delete_index(self, ddocid, name, idx_type="json"):
path = ["_index", ddocid, idx_type, name]
r = self.sess.delete(self.path(path), params={"w": "3"})
- delay()
r.raise_for_status()
+ while len(self.get_index(ddocid, name)) == 1:
+ delay(t=0.1)
+
def bulk_delete(self, docs):
body = {
"docids" : docs,
@@ -183,7 +207,6 @@ class Database(object):
}
body = json.dumps(body)
r = self.sess.post(self.path("_index/_bulk_delete"), data=body)
- delay(n=10)
return r.json()
def find(self, selector, limit=25, skip=0, sort=None, fields=None,
@@ -245,7 +268,7 @@ class DbPerClass(unittest.TestCase):
@classmethod
def setUpClass(klass):
klass.db = Database(random_db_name())
- klass.db.create(q=1, n=3)
+ klass.db.create(q=1, n=1)
def setUp(self):
self.db = self.__class__.db
diff --git a/test/build/test-run-couch-for-mango.sh b/test/build/test-run-couch-for-mango.sh
index 0597a8f..472b19b 100755
--- a/test/build/test-run-couch-for-mango.sh
+++ b/test/build/test-run-couch-for-mango.sh
@@ -24,6 +24,9 @@ while ( [ $COUCH_STARTED -ne 0 ] ); do
fi
done
+# wait for cluster setup to complete
+sleep 5
+
cd src/mango/
nosetests
--
To stop receiving notification emails like this one, please contact
['"commits@couchdb.apache.org" <co...@couchdb.apache.org>'].