Opened 3 years ago

Closed 3 years ago

Last modified 15 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 (8)

comment:1 by Simon Charette, 3 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 3 years ago

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

comment:3 by Mariusz Felisiak, 3 years ago

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

comment:4 by Simon Charette, 3 years ago

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

comment:5 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

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 by Adam Johnson, 3 years ago

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

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 15 months ago

In 6c0539ed:

Refs #32446 -- Removed SERIALIZE test database setting per deprecation timeline.

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