Opened 15 years ago
Closed 15 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: | no | UI/UX: | no |
Description
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)
Change History (4)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | 1.1 → 1.2-alpha |
comment:2 by , 15 years ago
Cc: | added |
---|
by , 15 years ago
Attachment: | t12542-r12278.1.2.diff added |
---|
RC1 of a patch allowing for test mirrors for testing master/slave setups
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
My solution was to write a master/slave engine that doesn't depend on having slaves: http://gist.github.com/271740. 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 inDATABASES
, 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.