From nobody Thu Apr 25 02:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521641793481914.0105938174084; Wed, 21 Mar 2018 07:16:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 845C4F448C; Wed, 21 Mar 2018 14:16:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AD6880A4E; Wed, 21 Mar 2018 14:16:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C3C41181BA0F; Wed, 21 Mar 2018 14:07:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LE7rkI015577 for ; Wed, 21 Mar 2018 10:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35B782022C07; Wed, 21 Mar 2018 14:07:53 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-136.pek2.redhat.com [10.72.12.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82731200BCA1 for ; Wed, 21 Mar 2018 14:07:50 +0000 (UTC) From: Fam Zheng To: patchew-devel@redhat.com Date: Wed, 21 Mar 2018 22:07:44 +0800 Message-Id: <20180321140744.11753-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] testing: Fix invalidation of prefetch cache upon set_property X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 21 Mar 2018 14:16:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" "testing.ready" didn't work due to the stale cache of Message._properties, since Message._properties cannot reflect the .set_property() updates. Fix it with a harder invalidating code path. Signed-off-by: Fam Zheng --- api/models.py | 14 ++++++++++---- tests/test_testing.py | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/models.py b/api/models.py index de01a61..a672bd4 100644 --- a/api/models.py +++ b/api/models.py @@ -408,9 +408,15 @@ class Message(models.Model): =20 def get_properties(self): if hasattr(self, '_properties'): - return self._properties + if self._properties is not None: + return self._properties + else: + # The prefetch cache is invalidated, query again + all_props =3D MessageProperty.objects.filter(message=3Dsel= f) + else: + all_props =3D self.properties.all() r =3D {} - for m in self.properties.all(): + for m in all_props: if m.blob: r[m.name] =3D load_blob_json(m.value) else: @@ -434,8 +440,8 @@ class Message(models.Model): mp.value =3D value mp.blob =3D blob mp.save() - if hasattr(self, '_properties'): - del(self._properties) + # Invalidate cache + self._properties =3D None =20 def set_property(self, prop, value): old_val =3D self.get_property(prop) diff --git a/tests/test_testing.py b/tests/test_testing.py index 0897bbc..dcb3dbc 100755 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -43,6 +43,9 @@ class TestingTest(PatchewTestCase): self.msg.set_property("git.tag", "dummy tag") self.msg.set_property("git.base", "dummy base") =20 + def test_testing_ready(self): + self.assertTrue(self.msg.get_property("testing.ready", True)) + def msg_testing_done(self, log=3DNone, **report): if not 'passed' in report: report['passed'] =3D True --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel