DB is no longer recreated for individual tests

Bug #1032738 reported by Dan Prince
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Dan Prince

Bug Description

When running individual Nova tests or suites the database is no longer being initialized properly...

Trying to run a random libvirt tests fails with the following exception:

[dprince@dovetail nova]$ ./run_tests.sh test_libvirt:NWFilterTestCase.test_unfilter_instance_undefines_nwfilters

NWFilterTestCase
    test_unfilter_instance_undefines_nwfilters ERROR 0.22

======================================================================
ERROR: test_unfilter_instance_undefines_nwfilters (test_libvirt.NWFilterTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dprince/projects/nova/nova/tests/test_libvirt.py", line 3192, in test_unfilter_instance_undefines_nwfilters
    instance_ref = self._create_instance()
  File "/home/dprince/projects/nova/nova/tests/test_libvirt.py", line 3096, in _create_instance
    'instance_type_id': 1})
  File "/home/dprince/projects/nova/nova/db/api.py", line 563, in instance_create
    return IMPL.instance_create(context, values)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 131, in wrapper
    return f(*args, **kwargs)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 1399, in instance_create
    security_groups)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 1386, in _get_sec_group_models
    session=session)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 3477, in security_group_ensure_default
    columns_to_join=[], session=session)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 131, in wrapper
    return f(*args, **kwargs)
  File "/home/dprince/projects/nova/nova/db/sqlalchemy/api.py", line 3406, in security_group_get_by_name
    result = query.first()
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2156, in first
    ret = list(self[0:1])
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2023, in __getitem__
    return list(res)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2227, in __iter__
    return self._execute_and_instances(context)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2242, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1449, in execute
    params)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
    context)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
    context)
  File "/home/dprince/projects/nova/.venv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 331, in do_execute
    cursor.execute(statement, parameters)
OperationalError: (OperationalError) no such table: security_groups u'SELECT security_groups.created_at AS security_groups_created_at, security_groups.updated_at AS security_groups_updated_at, security_groups.deleted_at AS security_groups_deleted_at, security_groups.deleted AS security_groups_deleted, security_groups.id AS security_groups_id, security_groups.name AS security_groups_name, security_groups.description AS security_groups_description, security_groups.user_id AS security_groups_user_id, security_groups.project_id AS security_groups_project_id \nFROM security_groups \nWHERE security_groups.deleted = ? AND security_groups.project_id = ? AND security_groups.name = ?\n LIMIT ? OFFSET ?' (0, 'fake', 'default', 1, 0)
-------------------- >> begin captured stdout << ---------------------
NWFilterTestCase: Setup called

--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
nova.common.deprecated: WARNING: Deprecated Config: The root_helper option (which lets you specify a root wrapper different from nova-rootwrap, and defaults to using sudo) is now deprecated. You should use the rootwrap_config option instead.
--------------------- >> end captured logging << ---------------------

Slowest 1 tests took 0.22 secs:
    0.22 NWFilterTestCase.test_unfilter_instance_undefines_nwfilters
----------------------------------------------------------------------
Ran 1 test in 0.227s

FAILED (errors=1)

------

We should support running individual tests that require use of the SQLite database.

Dan Prince (dan-prince)
Changed in nova:
assignee: nobody → Dan Prince (dan-prince)
importance: Undecided → High
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/10781

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/10788

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/10781
Committed: http://github.com/openstack/nova/commit/3356d55977a0ff091711dcf368d0cc13ae0567f8
Submitter: Jenkins
Branch: master

commit 3356d55977a0ff091711dcf368d0cc13ae0567f8
Author: Dan Prince <email address hidden>
Date: Fri Aug 3 13:07:47 2012 -0400

    Update reset_db to call setup if _DB is None.

    This resolves issues when running individual tests that require
    a database. With this fix I can once again run individual test
    modules that make use of the database. For example:

      ./run_tests.sh test_libvirt

    Previously this would fail with database errors.

    Fixes LP Bug #1032738.

    Change-Id: Icce7ac9414f0e19eece44819a217634947de7f73

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → folsom-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-3 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.