Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#36677 closed Bug (fixed)

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: Ready for checkin
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 (5)

comment:1 by Natalia Bidart, 3 weeks ago

Triage Stage: UnreviewedAccepted

Thank you Jacob for investigating and fixing this!

comment:2 by Jacob Walls, 3 weeks ago

comment:3 by Natalia Bidart, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:4 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In b6c9246d:

Fixed #36677 -- Fixed scheduling of system checks in ParallelTestSuite workers.

Running system checks in workers must happen after database aliases
are set up.

Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.

comment:5 by Jacob Walls <jacobtylerwalls@…>, 3 weeks ago

In da9f73c5:

[6.0.x] Fixed #36677 -- Fixed scheduling of system checks in ParallelTestSuite workers.

Running system checks in workers must happen after database aliases
are set up.

Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.

Backport of b6c9246d0a3ef5f9a40b15cc289b495351eae109 from main.

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