Opened 10 months ago

Closed 9 months ago

Last modified 9 months ago

#32446 closed Cleanup/optimization (fixed)

Deprecate the redundant SERIALIZE test database setting

Reported by: Simon Charette Owned by: Simon Charette
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Simon Charette)

The SERIALIZE test database setting controls whether or not the content of test databases state should be serialized and restored between tests which enables the TransactionTestCase.serialized_rollback feature. It defaults to True and the documentation encourage turning it off to speed up test database creation time.

The requirements of having TransactionTestCase subclasses declare databases they are allowed to interact with that was introduced by #28478 paired with the requirement to opt-in the serialization behaviour through serialized_rollback=False allows the suite to determine if data state serialization for each test database is necessary at discovery time which makes the setting unnecessary.

I therefore suggest we deprecate the SERIALIZE test database and base per-database serialization on the subset of discovered TransactionTestCase.databases declared with serialized_rollback = True. This should change the default to avoiding unnecessary state serialization of test databases which can add up pretty quickly in large Django projects with a lot of apps and models (one unnecessary query for each model present).

Change History (7)

comment:1 Changed 10 months ago by Simon Charette

Description: modified (diff)

comment:2 Changed 10 months ago by Mariusz Felisiak

Owner: changed from nobody to Simon Charette
Triage Stage: UnreviewedAccepted

comment:3 Changed 10 months ago by Mariusz Felisiak

Has patch: set
Needs documentation: set
Needs tests: set
Patch needs improvement: set

comment:4 Changed 10 months ago by Simon Charette

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:5 Changed 9 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:6 Changed 9 months ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 3089018e:

Fixed #32446 -- Deprecated SERIALIZE test database setting.

Whether or not the state of a test database should be serialized can be
inferred from the set of databases allowed to be access from discovered
TestCase/TransactionTestCase enabling the serialized_rollback feature
which makes this setting unnecessary.

This should make a significant test suite bootstraping time difference
on large projects that didn't explicitly disable test database
serialization.

comment:7 Changed 9 months ago by Adam Johnson

Great work! I will be able to delete a section in my book now.

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