Separate capabilities service method from account_client

list_extension() method in account_client is to lists
the activated capabilities of swift.

That is separate API than account service and should have
separate service client.
- http://developer.openstack.org/api-ref/object-storage/?expanded=list-activated-capabilities-detail
Partially implements blueprint consistent-service-method-names

Change-Id: I344c424020f9e10832040935fd0df43e596003c3
This commit is contained in:
ghanshyam 2016-12-12 18:45:23 +09:00
parent 08f2e625b4
commit f29831d8dd
9 changed files with 45 additions and 18 deletions

View File

@ -50,6 +50,7 @@ class BaseObjectTest(tempest.test.BaseTestCase):
cls.object_client = cls.os.object_client
cls.container_client = cls.os.container_client
cls.account_client = cls.os.account_client
cls.capabilities_client = cls.os.capabilities_client
@classmethod
def resource_setup(cls):
@ -65,7 +66,7 @@ class BaseObjectTest(tempest.test.BaseTestCase):
cls.policies = None
if CONF.object_storage_feature_enabled.discoverability:
_, body = cls.account_client.list_extensions()
_, body = cls.capabilities_client.list_capabilities()
if 'swift' in body and 'policies' in body['swift']:
cls.policies = body['swift']['policies']

View File

@ -132,7 +132,7 @@ class AccountTest(base.BaseObjectTest):
not CONF.object_storage_feature_enabled.discoverability,
'Discoverability function is disabled')
def test_list_extensions(self):
resp, extensions = self.account_client.list_extensions()
resp, extensions = self.capabilities_client.list_capabilities()
self.assertThat(resp, custom_matchers.AreAllWellFormatted())

View File

@ -32,7 +32,7 @@ class ContainerNegativeTest(base.BaseObjectTest):
if CONF.object_storage_feature_enabled.discoverability:
# use /info to get default constraints
_, body = cls.account_client.list_extensions()
_, body = cls.capabilities_client.list_capabilities()
cls.constraints = body['swift']
@test.attr(type=["negative"])

View File

@ -311,6 +311,8 @@ class Manager(clients.ServiceClients):
self.account_client = object_storage.AccountClient(self.auth_provider,
**params)
self.capabilities_client = object_storage.CapabilitiesClient(
self.auth_provider, **params)
self.container_client = object_storage.ContainerClient(
self.auth_provider, **params)
self.object_client = object_storage.ObjectClient(self.auth_provider,

View File

@ -169,7 +169,7 @@ def get_extension_client(os, service):
'nova': os.extensions_client,
'cinder': os.volumes_extension_client,
'neutron': os.network_extensions_client,
'swift': os.account_client,
'swift': os.capabilities_client,
}
# NOTE (e0ne): Use Cinder API v2 by default because v1 is deprecated
if CONF.volume_feature_enabled.api_v2:
@ -201,7 +201,7 @@ def verify_extensions(os, service, results):
if service != 'swift':
resp = extensions_client.list_extensions()
else:
__, resp = extensions_client.list_extensions()
__, resp = extensions_client.list_capabilities()
# For Nova, Cinder and Neutron we use the alias name rather than the
# 'name' field because the alias is considered to be the canonical
# name.

View File

@ -13,7 +13,10 @@
# the License.
from tempest.services.object_storage.account_client import AccountClient
from tempest.services.object_storage.capabilities_client import \
CapabilitiesClient
from tempest.services.object_storage.container_client import ContainerClient
from tempest.services.object_storage.object_client import ObjectClient
__all__ = ['AccountClient', 'ContainerClient', 'ObjectClient']
__all__ = ['AccountClient', 'CapabilitiesClient', 'ContainerClient',
'ObjectClient']

View File

@ -144,13 +144,3 @@ class AccountClient(rest_client.RestClient):
body = body.strip().splitlines()
self.expected_success([200, 204], resp.status)
return resp, body
def list_extensions(self):
self.skip_path()
try:
resp, body = self.get('info')
finally:
self.reset_path()
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body

View File

@ -0,0 +1,31 @@
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_serialization import jsonutils as json
from tempest.lib.common import rest_client
class CapabilitiesClient(rest_client.RestClient):
def list_capabilities(self):
self.skip_path()
try:
resp, body = self.get('info')
finally:
self.reset_path()
body = json.loads(body)
self.expected_success(200, resp.status)
return resp, body

View File

@ -401,7 +401,7 @@ class TestDiscovery(base.TestCase):
'not_fake': 'metadata',
'swift': 'metadata'})
fake_os = mock.MagicMock()
fake_os.account_client.list_extensions = fake_list_extensions
fake_os.capabilities_client.list_capabilities = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['fake1', 'fake2', 'fake3'])))
@ -423,7 +423,7 @@ class TestDiscovery(base.TestCase):
'not_fake': 'metadata',
'swift': 'metadata'})
fake_os = mock.MagicMock()
fake_os.account_client.list_extensions = fake_list_extensions
fake_os.capabilities_client.list_capabilities = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
verify_tempest_config, 'get_enabled_extensions',
return_value=(['all'])))