Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#12311 closed defect (fixed)

trac.ticket.tests.notification.NotificationTestCase fails with sqlite on Windows

Reported by: Christian Boos Owned by: Jun Omae
Priority: normal Milestone: 1.0.10
Component: database backend Version: 1.0-stable
Severity: minor Keywords: appveyor
Cc: Branch:
Release Notes:

Fixed test failures on Windows in trac.ticket.tests.notification.NotificationTestCase.

API Changes:

Added datetime_now and time_now methods which retrieve the precise current time under Windows 8+ and Windows Server 2012+.

Internal Changes:

Description

======================================================================
ERROR: test_from_author (trac.ticket.tests.notification.NotificationTestCase)
Using the reporter or change author as the notification sender
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\trac\trac\ticket\tests\notification.py", line 480, in test_from_author
    ticket.save_changes('noname', 'Final changes')
  File "C:\projects\trac\trac\ticket\model.py", line 355, in save_changes
    old_db_values.get(name), db_values.get(name)))
  File "C:\projects\trac\trac\db\util.py", line 128, in execute
    cursor.execute(query, params if params is not None else [])
  File "C:\projects\trac\trac\db\util.py", line 61, in execute
    r = self.cursor.execute(sql_escape_percent(sql), args)
  File "C:\projects\trac\trac\db\sqlite_backend.py", line 82, in execute
    result = PyFormatCursor.execute(self, *args)
  File "C:\projects\trac\trac\db\sqlite_backend.py", line 60, in execute
    args or [])
  File "C:\projects\trac\trac\db\sqlite_backend.py", line 52, in _rollback_on_error
    return function(self, *args, **kwargs)
IntegrityError: columns ticket, time, field are not unique

The reproducibility is not 100%. On 1.0-stable Python 2.6.6 and 2.7.11 both x86 and x64) were affected, but on trunk, it happened reliably with x64 builds of Python only. So it happened with both in-memory and file based SQLite databases.

I couldn't reproduce the problem locally.

Attachments (0)

Change History (7)

comment:1 by Christian Boos, 9 years ago

So this is nothing new, I already noticed that a while ago, but it was happening a lot less frequently on my system, see #11301.

However, as that ticket evolved into a "replay-transactions", let's keep the present ticket dedicated to a short term solution that would get our builds green on AppVeyor.

comment:2 by Jun Omae, 9 years ago

We could use GetSystemTimePreciseAsFileTime to retrieve high-resolution system time on Windows 8+ and Windows Server 2012+.

>>> from trac.util.datefmt import datetime_now, utc, localtz
>>> print('\n'.join(datetime_now(localtz).isoformat() for i in xrange(10)))
2016-01-12T01:27:44.808912+09:00
2016-01-12T01:27:44.809091+09:00
2016-01-12T01:27:44.809136+09:00
2016-01-12T01:27:44.809171+09:00
2016-01-12T01:27:44.809203+09:00
2016-01-12T01:27:44.809235+09:00
2016-01-12T01:27:44.809266+09:00
2016-01-12T01:27:44.809298+09:00
2016-01-12T01:27:44.809329+09:00
2016-01-12T01:27:44.809377+09:00

Proof of concept in log:jomae.git@t12311.

comment:4 by Christian Boos, 9 years ago

I tested your branch on AppVeyor (rebased so that it contains the .appveyor.yml file, + one more datetime_now, see log:cboos.git@t12311.appveyor) and it seems like it fixes the issue!

See https://ci.appveyor.com/project/cboos/trac/build/t12311.appveyor.5, the only failure is the test_sync_too_many_merges one (#12312).

Note that I had to re-init the project on AppVeyor, so all the previous experimental builds are gone. I'll soon commit the .appveyor.yml file and explain how one can setup an AppVeyor project (well, at this point it's trivial ;-) ).

Back to your changes: for me they look great, so feel free to grab the ticket and commit the fix!

comment:5 by Jun Omae, 9 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Thanks for the reviewing and testing! Committed in [14480] and merged to trunk in [14481].

comment:6 by Jun Omae, 9 years ago

Owner: set to Jun Omae

comment:7 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)
Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.