Code

Opened 2 years ago

Closed 2 years ago

#17377 closed Bug (fixed)

Test admin_views.UserAdminTest.test_user_permission_performance depends on side effects

Reported by: gregmuellegger Owned by: nobody
Component: Uncategorized Version: master
Severity: Normal Keywords: test sideeffect
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The test admin_views.UserAdminTest.test_user_permission_performance fails if it's run on its own. If run in conjunction with other tests, it gets a cache hit for looking up a content type. When run on it's own it needs to look that up, causing more queries than expected.

gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest.test_user_permission_performance
Creating test database for alias 'default'...
Creating test database for alias 'other'...
F
======================================================================
FAIL: test_user_permission_performance (regressiontests.admin_views.tests.UserAdminTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gregor/projects/gsoc/django/tests/regressiontests/admin_views/tests.py", line 2987, in test_user_permission_performance
    self.assertEqual(response.status_code, 200)
  File "/home/gregor/projects/gsoc/django/django/test/testcases.py", line 246, in __exit__
    executed, self.num
AssertionError: 8 queries executed, 7 expected

----------------------------------------------------------------------
Ran 1 test in 0.237s

FAILED (failures=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
1 gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest                                
Creating test database for alias 'default'...
Creating test database for alias 'other'...
......
----------------------------------------------------------------------
Ran 6 tests in 0.718s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest.test_user_permission_performance
Creating test database for alias 'default'...
Creating test database for alias 'other'...
F
======================================================================
FAIL: test_user_permission_performance (regressiontests.admin_views.tests.UserAdminTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gregor/projects/gsoc/django/tests/regressiontests/admin_views/tests.py", line 2987, in test_user_permission_performance
    self.assertEqual(response.status_code, 200)
  File "/home/gregor/projects/gsoc/django/django/test/testcases.py", line 246, in __exit__
    executed, self.num
AssertionError: 8 queries executed, 7 expected

----------------------------------------------------------------------
Ran 1 test in 0.228s

FAILED (failures=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

Attachments (1)

issue17377.1.patch (632 bytes) - added by gregmuellegger 2 years ago.
Patch. https://github.com/gregmuellegger/django/tree/issue17377

Download all attachments as: .zip

Change History (3)

comment:1 Changed 2 years ago by gregmuellegger

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 2 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

In [17199]:

Fixed #17377 -- Don't depend on a warm cache in admin_views.UserAdminTest.test_user_permission_performance. Thanks Gregor Müllegger.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.