Opened 2 years ago

Last modified 2 years ago

#27160 new Cleanup/optimization

Document that running the Django test suite requires creating the databases and, on PostgresQL, a superuser

Reported by: Sergei Zh Owned by: nobody
Component: Documentation Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm talking about Using another settings module subsection.

Django system tests freezes on my machine with default settings (sqlite), so I decided to try postgresql as backend.
I created user with CREATEDB permissions and replaced DB settings with

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'test',
        'PASSWORD': 'test',
        'HOST': 'localhost',
        'NAME': 'test_d'
    },
    'other': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': 'test',
        'PASSWORD': 'test',
        'HOST': 'localhost',
        'NAME': 'test_o',
    }
}

After that I got an error:

django.db.utils.OperationalError: FATAL:  database "test_d" does not exist

When docs says:

Test databases get their names by prepending test_ to the value of the NAME settings for the databases defined in DATABASES. These test databases are deleted when the tests are finished.

I'm waiting that runtests will create test_test_o and test_test_d for me and I no need in test_d and test_o databases at all.

Maybe I'm doing something wrong or docs should be improved?

P.S. After I created dbs manually, I got:

psycopg2.ProgrammingError: permission denied to create extension "hstore".
HINT:  Must be superuser to create this extension.

Mb it's engine specific error, I'm not sure.

Change History (5)

comment:1 Changed 2 years ago by Tim Graham

Summary: Improve `Unit tests` section in `Contributing to Django`Document that running the Django test suite requires creating the databases and, on PostgresQL, a superuser
Triage Stage: UnreviewedAccepted

I'll document these requirements when I get a chance.

It could be nice to remove the requirement of creating the databases, but I'm not sure how feasible this is. The problem looks like it's caused by module level queries for detecting database features.

comment:2 Changed 2 years ago by Chris Jerdonek

Django system tests freezes on my machine with default settings (sqlite)

Can you say more about this, like what OS you are using and what you mean when you say the tests "freeze" (e.g. what is happening exactly)? I'm wondering if it's related to ticket #27086 that I filed recently. It seems like the freezing is the more fundamental problem, since that shouldn't be happening in the first place, right?

comment:3 in reply to:  2 Changed 2 years ago by Sergei Zh

Replying to cjerdonek:

Django system tests freezes on my machine with default settings (sqlite)

Can you say more about this, like what OS you are using and what you mean when you say the tests "freeze" (e.g. what is happening exactly)? I'm wondering if it's related to ticket #27086 that I filed recently. It seems like the freezing is the more fundamental problem, since that shouldn't be happening in the first place, right?

OS X 10.10.5, python 3.4.3 under venv, stable/1.9.x branch

With python tests/runtests.py --parallel=1 -v3 admin_views I get Segmentation Fault 11:

...
test_named_group_field_choices_filter (admin_views.tests.AdminViewBasicTest) ... ok
test_popup_add_POST (admin_views.tests.AdminViewBasicTest) ... ok
test_popup_dismiss_related (admin_views.tests.AdminViewBasicTest) ... ok
Segmentation fault: 11

Don't know what the next testcase, no output name for it.

Without --parallel=1 it suddenly hang on different testcases

# python tests/runtests.py  -v3
test_default_and_given_options (test_runner.tests.CustomTestRunnerOptionsTests) ... ok
test_default_options (test_runner.tests.CustomTestRunnerOptionsTests) ... ok
test_option_name_and_value_separated (test_runner.tests.CustomTestRunnerOptionsTests) ... ok
test_output_normal (test_runner.test_debug_sql.TestDebugSQL) ... ok
test_output_verbose (test_runner.test_debug_sql.TestDebugSQL) ... ok
# hang, zero CPU activity on each child process
# python tests/runtests.py  -v3 admin_views
test_user_fk_delete_popup (admin_views.tests.UserAdminTest)
User deletion through a FK popup should return the appropriate JavaScript response. ... ok
test_user_permission_performance (admin_views.tests.UserAdminTest) ... ok
# the same, hang with 0 CPU activity

I guess we should continue in #27086?

comment:4 Changed 2 years ago by Tim Graham

I think that's a bug in SQLite, see ticket:24080#comment:51.

comment:5 Changed 2 years ago by Sergei Zh

After upgrading sqlite3, segfault is gone, but hanging is still occurs.

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