[Django] #34222: Django unit tests hang when running against a Postgres database

33 views
Skip to first unread message

Django

unread,
Dec 21, 2022, 11:02:22 AM12/21/22
to django-...@googlegroups.com
#34222: Django unit tests hang when running against a Postgres database
---------------------------------------------+------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
I am trying to get the
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/unit-tests/ Django library tests] running so I can develop a custom
backend and everything works fine with the default SQLite settings file,
but when I provide one for Postgres random tests will hang with no error.
To debug, I am running the test suite with {{{runtests.py --noinput
--parallel=1 -v 2 --settings test_postgres}}}

test_postgres.py:
{{{
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"USER": "user",
"PASSWORD": "password",
"HOST": "127.0.0.1",
"PORT": "5432",
},
"other": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"USER": "user",
"PASSWORD": "password",
"HOST": "127.0.0.1",
"PORT": "5432",
},
}

SECRET_KEY = "django_tests_secret_key"

# Use a fast hasher to speed up tests.
PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

USE_TZ = False

}}}

Am I doing something wrong, or do these test cases hang for others? I
cloned the 4.1.x repo and reset it to 2ff479f to specifically test against
Django 4.1.4 and it consistently crashes *after*
`multiple_database.tests.AuthTestCase` runs. If I get it working, I'll
compile a list of test classes I have to skip to get the tests to run
through without hanging.

--
Ticket URL: <https://code.djangoproject.com/ticket/34222>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 21, 2022, 11:05:39 AM12/21/22
to django-...@googlegroups.com
#34222: Django unit tests hang when running against a Postgres database
-----------------------------------+--------------------------------------

Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 4.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Egor R):

You have the same name for "default" and "other" databases, and they
should be different. Try changing that and see if that helps.

--
Ticket URL: <https://code.djangoproject.com/ticket/34222#comment:1>

Django

unread,
Dec 21, 2022, 11:06:02 AM12/21/22
to django-...@googlegroups.com
#34222: Django unit tests hang when running against a Postgres database
-----------------------------------+--------------------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Egor R):

* cc: Egor R (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/34222#comment:2>

Django

unread,
Dec 21, 2022, 11:26:45 AM12/21/22
to django-...@googlegroups.com
#34222: Django unit tests hang when running against a Postgres database
-----------------------------------+--------------------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: closed

Component: Testing framework | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Adrian Garcia):

* status: new => closed
* resolution: => invalid


Comment:

Replying to [comment:1 Egor R]:


> You have the same name for "default" and "other" databases, and they
should be different. Try changing that and see if that helps.

That solved it, knew it would probably be something incredibly dumb. Now
that I've done a little more Googling it looks like I should have just
copied the Django Docker Box config instead of writing my own.

It's interesting that there are no checks to see if there are two DB
configs for the same database, is there a use case for that?

--
Ticket URL: <https://code.djangoproject.com/ticket/34222#comment:3>

Django

unread,
Dec 21, 2022, 11:43:47 AM12/21/22
to django-...@googlegroups.com
#34222: Django unit tests hang when running against a Postgres database
-----------------------------------+--------------------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: closed
Component: Testing framework | Version: 4.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Egor R):

I'm not that deeply involved with the project, so can't answer that. You
might want to start a discussion on the [https://forum.djangoproject.com/
Django forum] to gauge interest for that.

--
Ticket URL: <https://code.djangoproject.com/ticket/34222#comment:4>

Reply all
Reply to author
Forward
0 new messages