Bug 1176259 - Unit tests for pulp.server.db.connection cannot be run in isolation
Summary: Unit tests for pulp.server.db.connection cannot be run in isolation
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Pulp
Classification: Retired
Component: z_other
Version: Master
Hardware: All
OS: Linux
high
urgent
Target Milestone: ---
: 2.6.0
Assignee: Brian Bouterse
QA Contact: pulp-qe-list
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-19 21:24 UTC by Randy Barlow
Modified: 2015-01-22 20:56 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-01-22 20:56:39 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Pulp Redmine 132 0 None None None Never

Description Randy Barlow 2014-12-19 21:24:35 UTC
Description of problem:
The database connection tests do not pass if run by themselves.

Version-Release number of selected component (if applicable):
master

How reproducible:
Every time.

Steps to Reproduce:
1. $ nosetests -sx server/test/unit/server/db/test_connection.py

Actual results:
$ nosetests -sx server/test/unit/server/db/test_connection.py
......F
======================================================================
FAIL: test_initialize_username_and_password (unit.server.db.test_connection.TestDatabaseAuthentication)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/home/rbarlow/devel/pulp/server/test/unit/server/db/test_connection.py", line 327, in test_initialize_username_and_password
    max_pool_size=10, port=27017)
  File "/usr/lib/python2.7/site-packages/mock.py", line 846, in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/mock.py", line 835, in assert_called_with
    raise AssertionError(msg)
AssertionError: Expected call: connect('pulp_unittest', username='admin', host='localhost', password='admin', max_pool_size=10, port=27017)
Actual call: connect('pulp_database', username='admin', host='localhost', password='admin', max_pool_size=10, port=27017)
-------------------- >> begin captured logging << --------------------
pulp.server.db.connection: DEBUG: Attempting username and password authentication.
pulp.server.db.connection: DEBUG: Connection Arguments: {'username': 'admin', 'host': 'localhost', 'password': 'admin', 'max_pool_size': 10, 'port': 27017}
pulp.server.db.connection: DEBUG: Querying the database to validate the connection.
pulp.server.db.connection: INFO: Mongo database for connection is version 2.4.0
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 7 tests in 0.044s

FAILED (failures=1)

Expected results:
Tests should all pass.

Comment 1 Randy Barlow 2014-12-19 21:33:11 UTC
Raising the severity, as this could easily lead to damaging developers' databases.

Comment 2 Chris Duryee 2015-01-09 02:05:31 UTC
unassigning this bz from myself for now

Comment 3 Randy Barlow 2015-01-16 20:58:00 UTC
This is now damaging developer databases even when run with run-tests.py. A recent commit[0] seems to have shifted the order in which tests are run, and now run-tests.py will delete your development database ☹

I believe this issue is urgent severity now, as this makes it hard to "sprint" when you DB gets deleted all the time ☺

[0] https://github.com/pulp/pulp/commit/70274cf9be047708da930b25f93c9d3f4feb7f78#diff-b63946c4f3426dfd51c0a07586752ab2R325

Comment 4 Brian Bouterse 2015-01-22 20:56:39 UTC
This bug is about a specific test, but a more general method will  be used to fix it. The other refactor [0] will be used to track its resolution. I'm closing this bug indicating it is being tracked upstream.

[0]: https://pulp.plan.io/issues/132


Note You need to log in before you can comment on or make changes to this bug.