Opened 8 years ago
Last modified 8 years ago
#12419 closed enhancement
speed-up notification tests on Windows — at Initial Version
Reported by: | Christian Boos | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.11 |
Component: | notification | Version: | 1.0dev |
Severity: | normal | Keywords: | tests smtplib |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I was always annoyed by the slowness of the notification tests, but never got around to address that.
While working on migrating the ticket notification templates, I finally found the issue. Rather, there were 2 issues, both related to the way we invoke smtplib.SMTP
in trac.notification.mail.SmtpEmailSender.send
:
- when setting
host
to'localhost'
, the connect will go through the results ofgetaddrinfo
, first attempting'::1'
, which will timeout after one second, and only then trying'127.0.0.1'
; so we pass the appropriate host value directly to avoid this timeout - when not setting
local_hostname
, a name resolution would take place and that can also take time on Windows (gethostbyaddr
, see #3481)
The speed-up is quite nice, as this is what I have on trunk:
$ time make test=trac/ticket/tests/notification.py Python: /c/Dev/Python2710x64/python Package Version ---------------------------------------------------------------------------------- Python : 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] Setuptools : 19.2 Genshi : 0.7 Babel : 2.1.1 sqlite3 : 2.6.0 (3.6.21) PySqlite : 2.8.1 (3.7.5) MySQLdb : 1.2.5 Psycopg2 : 2.6.1 (dt dec pq3 ext lo64) SVN bindings : 1.9.3 (r1718519) Mercurial : 3.2-rc+51-af1e3ef18120 Pygments : 2.1 Textile : not installed Pytz : 2015.7 Docutils : 0.12 Twill : 0.9 LXML : not installed coverage : 4.0.3 figleaf : not installed Variables: PATH=C:/Dev/Python2710x64;C:/Dev/Python2710x64/Scripts;C:/Dev/VisualSVNServer35/bin;$PATH PYTHONPATH=.;C:/Dev/VisualSVNServer35/PythonPackages;$PYTHONPATH TRAC_TEST_DB_URI= server-options= -p 9000 -a '*,D:/Trac/envs/htdigest.BCT,BCT' -r -e D:/Trac/envs External dependencies: Git version: git version 1.9.4.msysgit.1 python setup.py -q test -s trac.ticket.tests.notification.suite SKIP: validation of XHTML output in functional tests (no lxml installed) .............................................................. ---------------------------------------------------------------------- Ran 62 tests in 143.636s OK real 2m26.226s user 0m0.015s sys 0m0.000s
And this is with the fix:
$ time make test=trac/ticket/tests/notification.py [...] python setup.py -q test -s trac.ticket.tests.notification.suite SKIP: validation of XHTML output in functional tests (no lxml installed) .............................................................. ---------------------------------------------------------------------- Ran 62 tests in 1.724s OK real 0m4.321s user 0m0.000s sys 0m0.015s
Maybe I should backport it to 1.0-stable as well.
Note:
See TracTickets
for help on using tickets.