Pass os_identity_api_version into functional tests

Add 'os_identity_api_version' to keystone_v3_conf_settings.
Deduplicate excessive _ironic_osc method.

Change-Id: I9b93ec8a299d3a69629bf294d23d1b1d9e23660e
Closes-Bug: #1646837
This commit is contained in:
Kyrylo Romanenko 2016-12-26 14:58:58 +02:00
parent 835775e45c
commit fab6a8bfef
3 changed files with 18 additions and 25 deletions

View File

@ -83,7 +83,8 @@ class FunctionalTestBase(base.ClientTestBase):
conf_settings += ['os_auth_url', 'os_username',
'os_password', 'os_project_name']
keystone_v3_conf_settings += ['os_user_domain_id',
'os_project_domain_id']
'os_project_domain_id',
'os_identity_api_version']
else:
conf_settings += ['os_auth_token', 'ironic_url']
@ -126,11 +127,14 @@ class FunctionalTestBase(base.ClientTestBase):
return base.execute(cmd, action, flags, params,
cli_dir=self.client.cli_dir)
def _ironic(self, action, flags='', params='', merge_stderr=False):
def _ironic(self, action, cmd='ironic', flags='', params='',
merge_stderr=False):
"""Execute ironic command for the given action.
:param action: the cli command to run using Ironic
:type action: string
:param cmd: the base of cli command to run
:type action: string
:param flags: any optional cli flags to use
:type flags: string
:param params: any optional positional args to use
@ -138,9 +142,15 @@ class FunctionalTestBase(base.ClientTestBase):
:param merge_stderr: whether to merge stderr into the result
:type merge_stderr: bool
"""
flags += ' --os-endpoint-type publicURL'
if cmd == 'openstack':
config = self._get_config()
id_api_version = config['os_identity_api_version']
flags += ' --os-identity-api-version {0}'.format(id_api_version)
else:
flags += ' --os-endpoint-type publicURL'
if hasattr(self, 'os_auth_token'):
return self._cmd_no_auth('ironic', action, flags, params)
return self._cmd_no_auth(cmd, action, flags, params)
else:
for keystone_object in 'user', 'project':
domain_attr = 'os_%s_domain_id' % keystone_object
@ -149,25 +159,8 @@ class FunctionalTestBase(base.ClientTestBase):
'ks_obj': keystone_object,
'value': getattr(self, domain_attr)
}
return self.client.cmd_with_auth('ironic',
action, flags, params,
merge_stderr=merge_stderr)
def _ironic_osc(self, action, flags='', params='', merge_stderr=False):
"""Execute baremetal commands via OpenStack Client."""
config = self._get_config()
id_api_version = config.get('functional', 'os_identity_api_version')
flags += ' --os-identity-api-version {0}'.format(id_api_version)
for keystone_object in 'user', 'project':
domain_attr = 'os_%s_domain_id' % keystone_object
if hasattr(self, domain_attr):
flags += ' --os-%(ks_obj)s-domain-id %(value)s' % {
'ks_obj': keystone_object,
'value': getattr(self, domain_attr)
}
return self.client.cmd_with_auth(
'openstack', action, flags, params, merge_stderr=merge_stderr)
return self.client.cmd_with_auth(
cmd, action, flags, params, merge_stderr=merge_stderr)
def ironic(self, action, flags='', params='', parse=True):
"""Return parsed list of dicts with basic item info.

View File

@ -21,7 +21,7 @@ from ironicclient.tests.functional import base
class TestCase(base.FunctionalTestBase):
def openstack(self, *args, **kwargs):
return self._ironic_osc(*args, **kwargs)
return self._ironic(cmd='openstack', *args, **kwargs)
def get_opts(self, fields=None, output_format='json'):
"""Get options for OSC output fields format.

View File

@ -16,7 +16,7 @@ cat <<END >$CONFIG_FILE
[functional]
api_version = 1
os_auth_url=$OS_AUTH_URL
os_identity_api_version = $OS_IDENTITY_API_VERSION
os_identity_api_version=$OS_IDENTITY_API_VERSION
os_username=$OS_USERNAME
os_password=$OS_PASSWORD
os_project_name=$OS_PROJECT_NAME