libvirt test cases fail due to lockutils error when run via testtools

Bug #1369973 reported by Daniel Berrange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Daniel Berrange

Bug Description

When running libvirt tests via testtools.run, there are a number of cases which fail due to lockutils setup

$ .venv/bin/python -m testtools.run nova.tests.virt.libvirt.test_driver
..snip...
======================================================================
ERROR: nova.tests.virt.libvirt.test_driver.IptablesFirewallTestCase.test_multinic_iptables
----------------------------------------------------------------------
pythonlogging:'': {{{INFO [nova.network.driver] Loading network driver 'nova.network.linux_net'}}}

Traceback (most recent call last):
  File "nova/tests/virt/libvirt/test_driver.py", line 10182, in test_multinic_iptables
    self.fw.prepare_instance_filter(instance_ref, network_info)
  File "nova/virt/firewall.py", line 184, in prepare_instance_filter
    self.refresh_provider_fw_rules()
  File "nova/virt/firewall.py", line 474, in refresh_provider_fw_rules
    self._do_refresh_provider_fw_rules()
  File "nova/openstack/common/lockutils.py", line 267, in inner
    with lock(name, lock_file_prefix, external, lock_path):
  File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "nova/openstack/common/lockutils.py", line 231, in lock
    ext_lock = external_lock(name, lock_file_prefix, lock_path)
  File "nova/openstack/common/lockutils.py", line 180, in external_lock
    lock_file_path = _get_lock_path(name, lock_file_prefix, lock_path)
  File "nova/openstack/common/lockutils.py", line 171, in _get_lock_path
    raise cfg.RequiredOptError('lock_path')
RequiredOptError: value required for option: lock_path

The tox.ini / run_tests.sh work around this problem by using "-m nova.openstack.common.lockutils" but this is somewhat tedious to remember to add. A simple mock addition to the tests in question can avoid the issue in the first place.

Changed in nova:
assignee: nobody → Daniel Berrange (berrange)
Sean Dague (sdague)
Changed in nova:
status: New → Confirmed
importance: Undecided → Low
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/121861

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/121861
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=e3fbdfb3aa2251bb57e53b856e6c5c2d89a23150
Submitter: Jenkins
Branch: master

commit e3fbdfb3aa2251bb57e53b856e6c5c2d89a23150
Author: Daniel P. Berrange <email address hidden>
Date: Fri Sep 12 14:00:43 2014 +0100

    libvirt: avoid need for lockutils setup running test cases

    Some of the firewall/driver test cases rely on lockutils being
    setup, so running tests directly fails:

     $ .venv/bin/python -m testtools.run nova.tests.virt.libvirt
     ...snip...
        Traceback (most recent call last):
          File "nova/tests/virt/libvirt/test_driver.py", line 10182, in test_multinic_iptables
            self.fw.prepare_instance_filter(instance_ref, network_info)
          File "nova/virt/firewall.py", line 184, in prepare_instance_filter
            self.refresh_provider_fw_rules()
          File "nova/virt/firewall.py", line 474, in refresh_provider_fw_rules
            self._do_refresh_provider_fw_rules()
          File "nova/openstack/common/lockutils.py", line 267, in inner
            with lock(name, lock_file_prefix, external, lock_path):
          File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
            return self.gen.next()
          File "nova/openstack/common/lockutils.py", line 231, in lock
            ext_lock = external_lock(name, lock_file_prefix, lock_path)
          File "nova/openstack/common/lockutils.py", line 180, in external_lock
            lock_file_path = _get_lock_path(name, lock_file_prefix, lock_path)
          File "nova/openstack/common/lockutils.py", line 171, in _get_lock_path
            raise cfg.RequiredOptError('lock_path')
        RequiredOptError: value required for option: lock_path

    The first workaround is to launch using (which run_tests.sh does)

     $ python -m nova.openstack.common.lockutils

    but it is nicer to developers if we just avoid the need for using
    external lock files during the test suite execution entirely. This
    can be done by mocking the 'external_lock' method to use a transient
    semaphore instead of external lock file on disk.

    Closes-bug: #1369973
    Change-Id: I3dcdf6353986ff35c7237644f467ee7e98423f76

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → juno-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-rc1 → 2014.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.