#27751: Teardown of a PG test database fails if it is an autogenerated test_MYDB
database
-----------------------------------+------------------------------------
     Reporter:  Cynthia Kiser      |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  1.9
     Severity:  Normal             |               Resolution:
     Keywords:  database, testing  |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by Cynthia Kiser):

 The postgres install is pretty standard - using the packages installed via
 apt on Ubuntu 16.04.
 {{{
 $ dpkg -l | grep postgres
 ii  postgresql-9.5                     9.5.5-0ubuntu0.16.04
 amd64        object-relational SQL database, version 9.5 server
 ii  postgresql-client                  9.5+173                         all
 front-end programs for PostgreSQL (supported version)
 ii  postgresql-client-9.5              9.5.5-0ubuntu0.16.04
 amd64        front-end programs for PostgreSQL 9.5
 ii  postgresql-client-common           173                             all
 manager for multiple PostgreSQL client versions
 ii  postgresql-common                  173                             all
 PostgreSQL database-cluster manager
 ii  postgresql-contrib-9.5             9.5.5-0ubuntu0.16.04
 amd64        additional facilities for PostgreSQL
 }}}

 The same VM + same database did not have trouble dropping the test
 database when I was running Django 1.8. The error started appearing as
 soon as I upgraded to 1.9.

 The only thing I am doing that is non-standard is the django database user
 does not have access to the postgres database. My database / user set up
 is as follows (from the referenced demo project):

 I have PosgreSQL 9.5.5 installed on an Ubuntu 16.04 server on a Vagrant
 VM. For this test, I set up the database and database user as follows:
 {{{
 postgres=# create user d110example password 'd110example' CREATEDB;

 postgres=# create database d110example owner d110example;


 postgres=# \l
 List of databases
 Name             |    Owner    | Encoding |   Collate   |    Ctype    |
 Access privileges
 
------------------+-------------+----------+-------------+-------------+-----------------------
 d110example      | d110example | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres         | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0        | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 =c/postgres + postgres=CTc/postgres
 template1        | postgres    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 =c/postgres + postgres=CTc/postgres
 (4 rows)

 postgres=# \du
 List of roles
 Role name   |                         Attributes                         |
 Member of
 
-------------+------------------------------------------------------------+-----------
 d110example | Create DB                                                  |
 {}
 postgres    | Superuser, Create role, Create DB, Replication, Bypass RLS |
 {}


 # And these lines in the pg_hba.conf (my VM answers on 10.1.99.100)

 # local DATABASE            USER            METHOD  [OPTIONS]
 local   d110example         d110example     md5
 local   test_d110example    d110example     md5
 # host  DATABASE            USER            ADDRESS         METHOD
 [OPTIONS]
 host    d110example         d110example     10.1.99.0/24    md5
 host    test_d110example    d110example     10.1.99.0/24    md5
 }}}

 And the database settings from settings.py are as follows. I do not have
 any environment variables set but left them in my example to make it
 easier for other people to run the example on their machines.
 {{{
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
         'NAME': os.environ.get('DATABASE_NAME', 'd110example'),
         'USER': os.environ.get('DATABASE_USER', 'd110example'),
         'PASSWORD': os.environ.get('DATABASE_PASSWORD', 'd110example'),
         'HOST': os.environ.get('DATABASE_HOST', '10.1.99.100'),
         'PORT': os.environ.get('DATABASE_PORT', '5432'),
         'CHARSET': 'utf8',
     },
 }
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27751#comment:5>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.7c46c60e38d8438c90555bb251445e82%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to