[Openstack] Confused about using oslo.config variables in tests

Judd Maltin judd at newgoliath.com
Tue Nov 19 02:57:21 UTC 2013


My code looks like this, and it works just fine:

-----
docker_opts = [
    cfg.IntOpt('registry_default_
port',
               default=5042,
               help=_('Default TCP port to find the '
                      'docker-registry container'),
               deprecated_group='DEFAULT',
               deprecated_name='docker_registry_default_port'),
    cfg.StrOpt('registry_default_ip',
               default='127.0.0.1',
               help=_('Default IP address to find the '
                      'docker-registry container'),),
]

CONF = cfg.CONF
CONF.register_opts(docker_opts, 'docker')
-----

But my tests don't pick up the value..

==============================
========================================
FAIL:
nova.tests.virt.docker.test_driver.DockerDriverTestCase.test_block_stats
----------------------------------------------------------------------
Traceback (most recent call last):
_StringException: Empty attachments:
  pythonlogging:''
  stderr
  stdout

Traceback (most recent call last):
  File "/home/judd/openstack/nova/nova/tests/virt/test_virt_drivers.py",
line 49, in wrapped_func
    return f(self, *args, **kwargs)
  File "/home/judd/openstack/nova/nova/tests/virt/test_virt_drivers.py",
line 485, in test_block_stats
    instance_ref, network_info = self._get_running_instance()
  File "/home/judd/openstack/nova/nova/tests/virt/docker/test_driver.py",
line 71, in _get_running_instance
    [], 'herp', network_info=network_info)
  File "/home/judd/openstack/nova/nova/virt/docker/driver.py", line 294, in
spawn
    image_name = self._get_image_name(context, instance, image_meta)
  File "/home/judd/openstack/nova/nova/virt/docker/driver.py", line 280, in
_get_image_name
    return '{0}:{1}/{2}'.format(CONF.registry_default_ip,
  File
"/home/judd/openstack/nova/.venv/local/lib/python2.7/site-packages/oslo/config/cfg.py",
line 1648, in __getattr__
    raise NoSuchOptError(name)
NoSuchOptError: no such option: registry_default_ip

-----

What is the proper way to make a simple configuration value poke through to
the tests?

The following does not help:


from oslo.config import cfg

from nova import context
from nova import exception
from nova import test
from nova.tests import utils
import nova.tests.virt.docker.mock_
client
from nova.tests.virt.test_virt_drivers import _VirtDriverTestCase

CONF = cfg.CONF

class DockerDriverTestCase(_VirtDriverTestCase, test.TestCase):

    driver_module = 'nova.virt.docker.DockerDriver'

    def setUp(self):
        super(DockerDriverTestCase, self).setUp()

        self.flags(registry_default_ip='127.0.0.1', group='docker')

-- 
Judd Maltin
T: 917-882-1270
F: 501-694-7809
what could possibly go wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20131118/ec420f87/attachment.html>


More information about the Openstack mailing list