Opened 8 years ago
Closed 5 years ago
#27160 closed Cleanup/optimization (worksforme)
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 (6)
comment:1 by , 8 years ago
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: | Unreviewed → Accepted |
follow-up: 3 comment:2 by , 8 years ago
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 by , 8 years ago
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:6 by , 5 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Maybe this ticket is not valid anymore.
In Testing Overview for version 3, it is already states that requires an user with sufficient privileges
On PostgreSQL, USER will also need read access to the built-in postgres database.
Aside from using a separate database, the test runner will otherwise use all of the same database settings you have in your settings file: ENGINE, USER, HOST, etc. The test database is created by the user specified by USER, so you’ll need to make sure that the given user account has sufficient privileges to create a new database on the system.
https://docs.djangoproject.com/en/3.0/topics/testing/overview/
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.