Opened 5 years ago

Closed 5 years ago

#12542 closed (fixed)

Test framework needs a way to restrict the number of databases created in a multi-db setup

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


Brett Hoerner raised an interesting point on django-dev about testing under multi-db:

If you have a master/slave setup, your DATABASES setup will describe multiple databases, but unless you're actually testing the master/slave setup, you don't need multiple databases to test general application logic - you just need a single data source.

Django should provide a way to say "only sync this subset of databases during testing".

The initial suggestion is to allow TEST_NAME=None to be interepreted as "don't create this database under testing".

Attachments (1)

t12542-r12278.1.2.diff (7.3 KB) - added by russellm 5 years ago.
RC1 of a patch allowing for test mirrors for testing master/slave setups

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.1 to 1.2-alpha

comment:2 Changed 5 years ago by jbalogh

  • Cc jbalogh added

My solution was to write a master/slave engine that doesn't depend on having slaves: If no slaves are available, everything goes to default. I'm pretty sure it works, but I obviously haven't figured out how to test it automatically. ;)

One thing I discovered playing around with this: if TEST_NAME=None databases are skipped during test setup, but still exist in DATABASES, they'll all have to point at the same connection. If the "slave" databases are pointing at the master, but with separate connections, the slaves won't see anything happening in the master's transaction.

Changed 5 years ago by russellm

RC1 of a patch allowing for test mirrors for testing master/slave setups

comment:3 Changed 5 years ago by russellm

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

(In [12289]) Fixed #12542 -- Added the TEST_MIRROR setting, allowing testing of read slave databases.

Note: See TracTickets for help on using tickets.
Back to Top