Opened 3 years ago
Closed 3 years ago
#33677 closed Bug (invalid)
Django test does not migrate parallel db's if --keepdb --parallel option is used
Reported by: | Barney Szabolcs | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
To run my tests, I run
./manage.py test --keepdb --parallel -v 2
I use PostgreSQL 11 db on macOS Catalina 10.15.7 (19H2).
The problem is that if I have any change in the db (eg. a field added), the parallel db's don't get migrated and thus the tests fail.
The output when the tests fail after the migration:
Running migrations: Applying mymodel.0007_auto_20220503_1433... OK Using existing clone for alias 'default' ('myproject_test')... Cache table 'rhymedict_cache' already exists. Using existing clone for alias 'default' ('myproject_test')... Using existing clone for alias 'default' ('myproject_test')... Using existing clone for alias 'default' ('myproject_test')... ... ====================================================================== ERROR: test_mytest (myproject.myapp.test.MyTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): ... psycopg2.errors.UndefinedColumn: column "field2" of relation "myapp_mymodel" does not exist LINE 1: ... "field1", "field2") VA... ... django.db.utils.ProgrammingError: column "field2" of relation "myapp_mymodel" does not exist LINE 1: ... "field1", "field2") VA...
After I drop the myproject_test_1... myproject_test_4 db's manually and run the command again:
Using existing test database for alias 'default' ('myproject_test')... Operations to perform: Synchronize unmigrated apps: analytical, compressor, cookielaw, corsheaders, crispy_forms, debug_toolbar, dj_rest_auth, django_hosts, genlocale, import_export, massadmin, menu, messages, rest_framework, rosetta, sitemaps, static_sitemaps, staticfiles Apply all migrations: myapp1, myapp2 Synchronizing apps without migrations: Creating tables... Running deferred SQL... Running migrations: No migrations to apply. Cache table 'myproject_cache' already exists. Using existing clone for alias 'default' ('myproject_test')... Got an error creating the test database: source database "myproject_test" is being accessed by other users DETAIL: There is 1 other session using the database.
Without the --parallel option, the test command runs just fine.
My Django version is 2.2.12
Change History (2)
comment:1 by , 3 years ago
Description: | modified (diff) |
---|
comment:2 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
Thanks for the report, however Django 2.2 is not supported anymore. Can you reproduce this issue on Django 4.0 or the current development branch? We made many improvements in this area.