launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29848
[Merge] ~ines-almeida/launchpad:refactor-itermitently-failing-timing-test into launchpad:master
Ines Almeida has proposed merging ~ines-almeida/launchpad:refactor-itermitently-failing-timing-test into launchpad:master.
Commit message:
Update test so that it doesn't fail itermitently
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/440115
As it is, test fails 0.01% of the times because of a timing issue.
This should fix it by setting self.now to the current transaction timestamp instead of the current time (which is more relevant).
Because test only fails 0.01% of the time, it's hard to test this change, but running this test 20 times locally all passed.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:refactor-itermitently-failing-timing-test into launchpad:master.
diff --git a/lib/lp/bugs/tests/test_bugtracker.py b/lib/lp/bugs/tests/test_bugtracker.py
index 5c9cdca..3d60dd7 100644
--- a/lib/lp/bugs/tests/test_bugtracker.py
+++ b/lib/lp/bugs/tests/test_bugtracker.py
@@ -9,6 +9,7 @@ from urllib.parse import urlencode
import responses
import transaction
from lazr.lifecycle.snapshot import Snapshot
+from storm.store import Store
from testtools.matchers import Equals, MatchesListwise, MatchesStructure
from zope.component import getUtility
from zope.security.interfaces import Unauthorized
@@ -23,6 +24,7 @@ from lp.bugs.model.bugtracker import (
make_bugtracker_title,
)
from lp.registry.interfaces.person import IPersonSet
+from lp.services.database.sqlbase import get_transaction_timestamp
from lp.testing import (
TestCase,
TestCaseWithFactory,
@@ -91,7 +93,8 @@ class BugTrackerTestCase(TestCaseWithFactory):
for i in range(5):
self.factory.makeBugWatch(bugtracker=self.bug_tracker)
- self.now = datetime.now(timezone.utc)
+ store = Store.of(self.bug_tracker)
+ self.now = get_transaction_timestamp(store)
def test_multi_product_constraints_observed(self):
"""BugTrackers for which multi_product=True should return None