Skip to content

Commit c1198b5

Browse files
committed
Fix issue2550835
Race condition for testing geek date intervals
1 parent b0d626e commit c1198b5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ Fixed:
7575
done in the fix for issue2550802. (Thomas Arendsen Hein)
7676
- Fix batch.propchanged for transitive id properties (would result in a
7777
backtrace when trying to group by property.id)
78+
- Fix issue2550835 which tests for date-range queries with an interval
79+
that depends on the local time. Put the queried date a little later to
80+
avoid a race condition where the queried interval doesn't match the
81+
date because the clock has advanced. (Ralf Schlatterbeck)
7882

7983
Minor:
8084
- demo.py usage message improved: explains "nuke" now. (Bernhard Reiter)

test/db_test_base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,16 +1367,25 @@ def testFilteringRangeInterval(self):
13671367

13681368
def testFilteringRangeGeekInterval(self):
13691369
ae, filter, filter_iter = self.filteringSetup()
1370+
# Note: When querying, create date one minute later than the
1371+
# timespan later queried to avoid race conditions where the
1372+
# creation of the deadline is more than a second ago when
1373+
# queried -- in that case we wouldn't get the expected result.
1374+
# By extending the interval by a minute we would need a very
1375+
# slow machine for this test to fail :-)
13701376
for issue in (
1371-
{ 'deadline': date.Date('. -2d')},
1372-
{ 'deadline': date.Date('. -1d')},
1373-
{ 'deadline': date.Date('. -8d')},
1377+
{ 'deadline': date.Date('. -2d') + date.Interval ('00:01')},
1378+
{ 'deadline': date.Date('. -1d') + date.Interval ('00:01')},
1379+
{ 'deadline': date.Date('. -8d') + date.Interval ('00:01')},
13741380
):
13751381
self.db.issue.create(**issue)
13761382
for filt in filter, filter_iter:
13771383
ae(filt(None, {'deadline': '-2d;'}), ['5', '6'])
13781384
ae(filt(None, {'deadline': '-1d;'}), ['6'])
13791385
ae(filt(None, {'deadline': '-1w;'}), ['5', '6'])
1386+
ae(filt(None, {'deadline': '. -2d;'}), ['5', '6'])
1387+
ae(filt(None, {'deadline': '. -1d;'}), ['6'])
1388+
ae(filt(None, {'deadline': '. -1w;'}), ['5', '6'])
13801389

13811390
def testFilteringIntervalSort(self):
13821391
# 1: '1:10'

0 commit comments

Comments
 (0)