Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 47681200D3E for ; Thu, 16 Nov 2017 09:22:01 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 45E90160BE6; Thu, 16 Nov 2017 08:22:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8AE74160BE5 for ; Thu, 16 Nov 2017 09:22:00 +0100 (CET) Received: (qmail 18289 invoked by uid 500); 16 Nov 2017 08:21:59 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 18280 invoked by uid 99); 16 Nov 2017 08:21:59 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Nov 2017 08:21:59 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 1EE0A81C1A; Thu, 16 Nov 2017 08:21:59 +0000 (UTC) Date: Thu, 16 Nov 2017 08:21:59 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb] branch master updated: Improve Mango test suite performance (#995) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <151082051902.19788.5959339189784573520@gitbox.apache.org> From: willholley@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: ead77b26d559415e4bdd302ffae50027112567f4 X-Git-Newrev: 8b4e92ae240d82837a0dede78fe5c1f664486f1c X-Git-Rev: 8b4e92ae240d82837a0dede78fe5c1f664486f1c X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Thu, 16 Nov 2017 08:22:01 -0000 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 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" '].