From e2b56b5713273013d28b768f20106b015b83360d Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 29 Jan 2014 19:25:50 +0000 Subject: [PATCH] Convert cli tests to use global CONF object This commit takes all the uses of config in the cli tests and coverts them to use the global CONF object. Partially implements bp config-cleanup Change-Id: I7a39839d7a4ebbf8372489507486ad2cac7f3adc --- etc/tempest.conf.sample | 2 +- tempest/cli/__init__.py | 29 ++++--------------- tempest/cli/simple_read_only/test_cinder.py | 9 +++--- tempest/cli/simple_read_only/test_glance.py | 8 ++--- tempest/cli/simple_read_only/test_heat.py | 5 ++-- tempest/cli/simple_read_only/test_keystone.py | 5 ++-- tempest/cli/simple_read_only/test_nova.py | 5 ++-- tempest/config.py | 16 ++++++++++ 8 files changed, 36 insertions(+), 43 deletions(-) diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample index 21c85062ad..f7f74b822b 100644 --- a/etc/tempest.conf.sample +++ b/etc/tempest.conf.sample @@ -155,7 +155,7 @@ [cli] # -# Options defined in tempest.cli +# Options defined in tempest.config # # enable cli tests (boolean value) diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py index dfa2124f53..a5e0447ac7 100644 --- a/tempest/cli/__init__.py +++ b/tempest/cli/__init__.py @@ -17,31 +17,15 @@ import os import shlex import subprocess -from oslo.config import cfg - import tempest.cli.output_parser +from tempest import config from tempest.openstack.common import log as logging import tempest.test LOG = logging.getLogger(__name__) -cli_opts = [ - cfg.BoolOpt('enabled', - default=True, - help="enable cli tests"), - cfg.StrOpt('cli_dir', - default='/usr/local/bin', - help="directory where python client binaries are located"), - cfg.IntOpt('timeout', - default=15, - help="Number of seconds to wait on a CLI timeout"), -] - -CONF = cfg.CONF -cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options") -CONF.register_group(cli_group) -CONF.register_opts(cli_opts, group=cli_group) +CONF = config.CONF class ClientTestBase(tempest.test.BaseTestCase): @@ -50,7 +34,6 @@ class ClientTestBase(tempest.test.BaseTestCase): if not CONF.cli.enabled: msg = "cli testing disabled" raise cls.skipException(msg) - cls.identity = cls.config.identity super(ClientTestBase, cls).setUpClass() def __init__(self, *args, **kwargs): @@ -106,10 +89,10 @@ class ClientTestBase(tempest.test.BaseTestCase): # TODO(jogo) make admin=False work creds = ('--os-username %s --os-tenant-name %s --os-password %s ' '--os-auth-url %s ' % - (self.identity.admin_username, - self.identity.admin_tenant_name, - self.identity.admin_password, - self.identity.uri)) + (CONF.identity.admin_username, + CONF.identity.admin_tenant_name, + CONF.identity.admin_password, + CONF.identity.uri)) flags = creds + ' ' + flags return self.cmd(cmd, action, flags, params, fail_ok) diff --git a/tempest/cli/simple_read_only/test_cinder.py b/tempest/cli/simple_read_only/test_cinder.py index 5dcb708cbd..afbd732f9c 100644 --- a/tempest/cli/simple_read_only/test_cinder.py +++ b/tempest/cli/simple_read_only/test_cinder.py @@ -20,7 +20,6 @@ import subprocess import tempest.cli from tempest import config - CONF = config.CONF LOG = logging.getLogger(__name__) @@ -73,14 +72,14 @@ class SimpleReadOnlyCinderClientTest(tempest.cli.ClientTestBase): def test_cinder_quota_defaults(self): """This CLI can accept and string as param.""" roles = self.parser.listing(self.cinder('quota-defaults', - params=self.identity. + params=CONF.identity. admin_tenant_name)) self.assertTableStruct(roles, ['Property', 'Value']) def test_cinder_quota_show(self): """This CLI can accept and string as param.""" roles = self.parser.listing(self.cinder('quota-show', - params=self.identity. + params=CONF.identity. admin_tenant_name)) self.assertTableStruct(roles, ['Property', 'Value']) @@ -146,7 +145,7 @@ class SimpleReadOnlyCinderClientTest(tempest.cli.ClientTestBase): self.cinder('list', flags='--retries 3') def test_cinder_region_list(self): - region = self.config.volume.region + region = CONF.volume.region if not region: - region = self.config.identity.region + region = CONF.identity.region self.cinder('list', flags='--os-region-name ' + region) diff --git a/tempest/cli/simple_read_only/test_glance.py b/tempest/cli/simple_read_only/test_glance.py index b558190a1e..9869483f52 100644 --- a/tempest/cli/simple_read_only/test_glance.py +++ b/tempest/cli/simple_read_only/test_glance.py @@ -16,13 +16,11 @@ import re import subprocess -from oslo.config import cfg - import tempest.cli +from tempest import config from tempest.openstack.common import log as logging -CONF = cfg.CONF - +CONF = config.CONF LOG = logging.getLogger(__name__) @@ -55,7 +53,7 @@ class SimpleReadOnlyGlanceClientTest(tempest.cli.ClientTestBase): 'Size', 'Status']) def test_glance_member_list(self): - tenant_name = '--tenant-id %s' % self.identity.admin_tenant_name + tenant_name = '--tenant-id %s' % CONF.identity.admin_tenant_name out = self.glance('member-list', params=tenant_name) endpoints = self.parser.listing(out) diff --git a/tempest/cli/simple_read_only/test_heat.py b/tempest/cli/simple_read_only/test_heat.py index b45182b614..cf4580c4b8 100644 --- a/tempest/cli/simple_read_only/test_heat.py +++ b/tempest/cli/simple_read_only/test_heat.py @@ -14,12 +14,11 @@ import json import os import yaml -from oslo.config import cfg - import tempest.cli +from tempest import config from tempest.openstack.common import log as logging -CONF = cfg.CONF +CONF = config.CONF LOG = logging.getLogger(__name__) diff --git a/tempest/cli/simple_read_only/test_keystone.py b/tempest/cli/simple_read_only/test_keystone.py index 271a18c05f..1efbede7f6 100644 --- a/tempest/cli/simple_read_only/test_keystone.py +++ b/tempest/cli/simple_read_only/test_keystone.py @@ -16,12 +16,11 @@ import re import subprocess -from oslo.config import cfg - import tempest.cli +from tempest import config from tempest.openstack.common import log as logging -CONF = cfg.CONF +CONF = config.CONF LOG = logging.getLogger(__name__) diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/test_nova.py index f8ba97107a..b0264d0c78 100644 --- a/tempest/cli/simple_read_only/test_nova.py +++ b/tempest/cli/simple_read_only/test_nova.py @@ -15,15 +15,14 @@ import subprocess -from oslo.config import cfg import testtools import tempest.cli +from tempest import config from tempest.openstack.common import log as logging import tempest.test -CONF = cfg.CONF - +CONF = config.CONF LOG = logging.getLogger(__name__) diff --git a/tempest/config.py b/tempest/config.py index 5a9199daf1..704556f26f 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -689,6 +689,20 @@ BaremetalGroup = [ help="Catalog type of the baremetal provisioning service."), ] +cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options") + +CLIGroup = [ + cfg.BoolOpt('enabled', + default=True, + help="enable cli tests"), + cfg.StrOpt('cli_dir', + default='/usr/local/bin', + help="directory where python client binaries are located"), + cfg.IntOpt('timeout', + default=15, + help="Number of seconds to wait on a CLI timeout"), +] + # this should never be called outside of this class class TempestConfigPrivate(object): @@ -759,6 +773,7 @@ class TempestConfigPrivate(object): register_opt_group(cfg.CONF, debug_group, DebugGroup) register_opt_group(cfg.CONF, baremetal_group, BaremetalGroup) register_opt_group(cfg.CONF, input_scenario_group, InputScenarioGroup) + register_opt_group(cfg.CONF, cli_group, CLIGroup) self.compute = cfg.CONF.compute self.compute_feature_enabled = cfg.CONF['compute-feature-enabled'] self.identity = cfg.CONF.identity @@ -784,6 +799,7 @@ class TempestConfigPrivate(object): self.debug = cfg.CONF.debug self.baremetal = cfg.CONF.baremetal self.input_scenario = cfg.CONF['input-scenario'] + self.cli = cfg.CONF.cli if not self.compute_admin.username: self.compute_admin.username = self.identity.admin_username self.compute_admin.password = self.identity.admin_password