Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14799 closed (fixed)

Test database creation order problem after r14696

Reported by: russellm Owned by: russellm
Component: Testing framework Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

r14696 added a fix for #14415, changing the way test databases are created to ensure that the test setup/teardown process doesn't accidentally destroy the original source database.

However, in the process, it made the test database creation order subject to dictionary ordering. This is problematic because some database have dependencies on other databases during creation.

For example, Django's own test suite won't run if 'other' is created before 'default' because the post_syncdb signal causes a ContentTypes query to be issued, which will try to execute on the default database. If the default database hasn't been created, an error arises.

This is currently causing the buildbots to fail for Postgres.

Attachments (1)

t14799.diff (2.7 KB) - added by russellm 3 years ago.
Draft fix for problem.

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by russellm

Draft fix for problem.

comment:1 Changed 3 years ago by russellm

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to russellm
  • Patch needs improvement set
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

Here's a draft fix for the problem -- it introduces the concept of TEST_DEPENDENCIES, so you can specify which databases must be synchronized before others. By default, every database is assumed to be dependent on 'default' (except, of course, for default itself). This seems to be enough to make Django's test suite run.

comment:2 Changed 3 years ago by jacob

(In [14756]) Ensured that the test suite creates the default DB before any others.

Refs #14799. Technically this fixes the problem, but I'm far from convinced
it's the perfect solution, so I'm leaving the ticket open. I'm committing
this now because it's the minimum required to get the test suite running
again, but this commit can -- and probably should -- be reverted in favor of
a more holistic fix later on.

comment:3 Changed 3 years ago by jacob

(In [14757]) [1.2.X] Ensured that the test suite creates the default DB before any others.

Refs #14799. Backport of [14756], and see the note there for a caveat.

comment:4 Changed 3 years ago by russellm

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

(In [14822]) Fixed #14799 -- Provided a full solution for test database creation order problems.

comment:5 Changed 3 years ago by russellm

(In [14825]) [1.2.X] Fixed #14799 -- Provided a full solution for test database creation order problems.

Backport of r14822, r14823 and r14824 from trunk.

comment:6 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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.