Opened 12 years ago

Closed 10 years ago

#19542 closed Bug (fixed)

Testing with Oracle: mirror databases do not work

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

Description

By "mirror databases" I here mean two related cases:

  1. A database is explicitly designated as "TEST_MIRROR" of another
  2. A database is implicitly a test mirror of another, because they have the same essential parameters

In these cases, the test framework needs to do things a little differently -- create only one database, and make all relevant connections refer to it.

This breaks with Oracle, because setting up test databases there is different from elsewhere. Quoting myself,

The root of the problem is that unlike the other DBMSs, where you can create a new database for testing, Oracle does not have the concept of separate databases within the same server. So, to have a clean schema to work in, the test framework creates a new user (in Oracle there's also a 1-1 correspondence between users and schemas) when it creates the test database.

This is all done in the backend-specific _create_test_db(). The problem is that this code only takes care of a single db (naturally). There is generic code (in DjangoTestSuiteRunner.setup_databases()), that takes care of multiple dbs -- including [...] mirrors. This code isn't aware of the Oracle-specific settings changes. To handle mirrors, it just updates the database name of the mirror to the one set by _create_test_db(). In the Oracle case, this is a no-op (self.connection.settings_dict['NAME'] is not changed); and nobody is left to update the user, password and tablespace parameters, which the backend does change.

Anssi Kääriäinen added that the "guilty" line seems to be line 321 of django/test/simple.py.

Attachments (1)

test_mirroring.tgz (2.8 KB ) - added by Shai Berger 10 years ago.
A simple project which can be used to test that mirroring works in testing. You will need to change credentials, of course.

Download all attachments as: .zip

Change History (7)

comment:1 by Aymeric Augustin, 12 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Aymeric Augustin, 12 years ago

Keywords: oracle added

comment:3 by Shai Berger, 10 years ago

Resolution: fixed
Status: newclosed

Some time within the changes in test-runner, this seems to have been resolved.

comment:4 by Shai Berger, 10 years ago

Resolution: fixed
Status: closednew

Oops. No it wasn't.

comment:5 by Shai Berger, 10 years ago

Has patch: set
Owner: changed from nobody to Shai Berger
Status: newassigned
Version: 1.4master

by Shai Berger, 10 years ago

Attachment: test_mirroring.tgz added

A simple project which can be used to test that mirroring works in testing. You will need to change credentials, of course.

comment:6 by Shai Berger <shai@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 35291df7:

Fixed #19542: Made mirroring databases for tests work with Oracle

No tests are provided because there is no sane way to test database
settings within the Django test suite.

Thanks Aymeric Augustin for review.

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