Opened 7 years ago

Closed 7 years ago

#12542 closed (fixed)

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

Reported by: Russell Keith-Magee Owned by: nobody
Component: Testing framework Version: 1.2-alpha
Severity: Keywords:
Cc: Jeff Balogh 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 Russell Keith-Magee 7 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 7 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted
Version: 1.11.2-alpha

comment:2 Changed 7 years ago by Jeff Balogh

Cc: Jeff Balogh 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 7 years ago by Russell Keith-Magee

Attachment: t12542-r12278.1.2.diff added

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

comment:3 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(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