Opened 11 years ago

Closed 11 years ago

#21222 closed Cleanup/optimization (fixed)

document that ./runtests.py must use different databases for 'default' and 'other'.

Reported by: Vernon Cole Owned by: nobody
Component: Testing framework Version: dev
Severity: Normal Keywords: runtests infinite wait
Cc: Vernon Cole Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I decided to get off my duff and start testing django-mssql using django 1.6 -- to see whether that 1.6 compatible code I put in really works.

The first step is to get a set of baseline runs of the test suite.

I checked out the git master & did ./runtests.py --settings=test_sqlite ... everything great.
Ran 6211 tests in 263.111s
OK (skipped=331, expected failures=11)

I made another setting like this:

DATABASES = {

'default': {

'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'adotest',
'USER': 'adotestuser',
'PASSWORD': '12345678',
'HOST': 'localhost',
'OPTIONS': {

'autocommit': True, # should be ignored in django 1.6
},

},

'other': {

'ENGINE': 'django.db.backends.sqlite3',

}

}

$ ./runtests.py --settings=test_pg_lite
Ran 6211 tests in 680.520s
OK (skipped=249, expected failures=11)

So lets try with both databases using PostgresSQL...

DATABASES = {

'default': {

'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'adotest',
'USER': 'adotestuser',
'PASSWORD': '12345678',
'HOST': 'localhost',
'OPTIONS': {

'autocommit': True,
},

},

'other': {

'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'adotest',
## 'TEST_NAME': 'other_test',
'USER': 'adotestuser',
'PASSWORD': '12345678',
'HOST': 'localhost',
'OPTIONS': {

'autocommit': True,
},

}

}

$ ./runtests.py --settings=test_pg

<It prints a screenfull of dots and then stops. I left it running all night -- no progress.>
<After several retries, I found that if I kill the PostgreSQL instance I get...>
Ran 4826 tests in 1489.312s
FAILED (failures=27, errors=1482, skipped=239, expected failures=10)

The first of the 1482 tracebacks after I killed the server was:

======================================================================
ERROR: test_fixture_loading (multiple_database.tests.FixtureTestCase)
Multi-db fixtures are loaded correctly
----------------------------------------------------------------------
Traceback (most recent call last):

File "/home/vernon/PycharmProjects/django/django/test/testcases.py", line 173, in call

self._pre_setup()

File "/home/vernon/PycharmProjects/django/django/test/testcases.py", line 719, in _pre_setup

self._fixture_setup()

File "/home/vernon/PycharmProjects/django/django/test/testcases.py", line 853, in _fixture_setup

self._fixture_teardown()

File "/home/vernon/PycharmProjects/django/django/test/testcases.py", line 865, in _fixture_teardown

self.atomics[db_name].exit(None, None, None)

File "/home/vernon/PycharmProjects/django/django/db/transaction.py", line 352, in exit

connection.set_autocommit(True)

File "/home/vernon/PycharmProjects/django/django/db/backends/init.py", line 335, in set_autocommit

self._set_autocommit(autocommit)

File "/home/vernon/PycharmProjects/django/django/db/backends/postgresql_psycopg2/base.py", line 186, in _set_autocommit

self.connection.autocommit = autocommit

InterfaceError: connection already closed

Was it me being clumsy, or is this a major bug?

Change History (4)

comment:1 by Anssi Kääriäinen, 11 years ago

You have two connections to the same DB, and for that reason you are likely ending up in some sort of deadlock. Maybe having more than one connection to the same DB shouldn't validate, but other than that this doesn't seem like a bug at all.

Can you confirm that changing the 'other' alias to use different database (different NAME) fixes the issue?

comment:2 by Aymeric Augustin, 11 years ago

Resolution: invalid
Status: newclosed

Using a different NAME works, the CI tests it.

comment:3 by Vernon Cole, 11 years ago

Cc: Vernon Cole added
Component: UncategorizedTesting framework
Resolution: invalid
Severity: Release blockerNormal
Status: closednew
Summary: ./runtests.py with two Postgress databases hangs infinitly. Did I just discover a 1.6 release blocker, or am I doing something wrong?document that ./runtests.py must use different databases for 'default' and 'other'.
Type: UncategorizedCleanup/optimization

At the very least, this setup restriction should be documented so that some other geek does not repeat my error. I will see whether there is an easy place in the code to detect the problem. I'll submit a documentation change patch.

There is also a problem that TEST_NAME does not work in some situations. I will open another ticket for that.

comment:4 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 9700194195735300f86803b0d023a37a89f4dff0:

Fixed #21222 - Documented that 'default' and 'other' must be different databases when running tests.

Thanks vernondcole for the suggestion.

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