Opened 6 hours ago

Last modified 5 hours ago

#36677 assigned Bug

Parallel test runner runs system checks with database aliases before those aliases are set up

Reported by: Jacob Walls Owned by: Jacob Walls
Component: Testing framework Version: 6.0
Severity: Release blocker Keywords:
Cc: Adam Zapletal Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

#36083 made the parallel test runner run system checks in workers. Well and good, but the call is done before database aliases are set up.

This should explain the recent failures with the geodjango label on Github Actions, also reproducible locally, with errors like:

django.db.utils.OperationalError: connection failed: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "django-postgis-other" does not exist

I'm showing this is fixed with:

  • django/test/runner.py

    diff --git a/django/test/runner.py b/django/test/runner.py
    index 25089a6db1..73665a63d2 100644
    a b def _init_worker(  
    463463            process_setup(*process_setup_args)
    464464        django.setup()
    465465        setup_test_environment(debug=debug_mode)
    466         call_command(
    467             "check", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases
    468         )
    469466
    470467    db_aliases = used_aliases if used_aliases is not None else connections
    471468    for alias in db_aliases:
    def _init_worker(  
    477474                connection._test_serialized_contents = value
    478475        connection.creation.setup_worker_connection(_worker_id)
    479476
     477    if is_spawn_or_forkserver:
     478        call_command(
     479            "check", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases
     480        )
    480481
    481482def _run_subsuite(args):
    482483    """

Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.

Interestingly, this specific failure did not manifest until e8190b370e508648b0f0ee9b86876f97d3997e14.

Change History (2)

comment:1 by Natalia Bidart, 5 hours ago

Triage Stage: UnreviewedAccepted

Thank you Jacob for investigating and fixing this!

comment:2 by Jacob Walls, 5 hours ago

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