#36677: Parallel test runner runs system checks with database aliases before 
those
aliases are set up
---------------------------------------------+-----------------------------
               Reporter:  Jacob Walls        |          Owner:  Jacob Walls
                   Type:  Bug                |         Status:  assigned
              Component:  Testing framework  |        Version:  6.0
               Severity:  Release blocker    |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  1
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+-----------------------------
 #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:
 {{{#!diff
 diff --git a/django/test/runner.py b/django/test/runner.py
 index 25089a6db1..73665a63d2 100644
 --- a/django/test/runner.py
 +++ b/django/test/runner.py
 @@ -463,9 +463,6 @@ def _init_worker(
              process_setup(*process_setup_args)
          django.setup()
          setup_test_environment(debug=debug_mode)
 -        call_command(
 -            "check", stdout=io.StringIO(), stderr=io.StringIO(),
 databases=used_aliases
 -        )

      db_aliases = used_aliases if used_aliases is not None else
 connections
      for alias in db_aliases:
 @@ -477,6 +474,10 @@ def _init_worker(
                  connection._test_serialized_contents = value
          connection.creation.setup_worker_connection(_worker_id)

 +    if is_spawn_or_forkserver:
 +        call_command(
 +            "check", stdout=io.StringIO(), stderr=io.StringIO(),
 databases=used_aliases
 +        )

  def _run_subsuite(args):
      """
 }}}

 Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c.

 Interestingly, this specific failure did not manifest until
 e8190b370e508648b0f0ee9b86876f97d3997e14.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36677>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019a07b3f652-6acbd38c-69e4-41e7-9ac1-52b44241552b-000000%40eu-central-1.amazonses.com.

Reply via email to