Opened 2 years ago

Last modified 2 years ago

#33677 closed Bug

Django test does not migrate parallel db's if --keepdb --parallel option is used — at Initial Version

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

To run my tests, I run

./manage.py test --keepdb --parallel -v 2

I use postgres db and if I have any change in the db (eg. a field added),
the parallel db's don't get migrated.

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 (0)

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