Cinder absolute-limits tests

Added a volume limits client

Added testcase:
- show cinder absolute-limit api

Tests:
 - tests get absolute limits and verify counter and defaults.

Change-Id: I35ac2aeae7e9bda8db69fbc8bf625db1839412ed
This commit is contained in:
bkopilov 2016-05-31 10:01:28 +03:00 committed by Benny Kopilov
parent 65ca5ad1a3
commit 141930822f
8 changed files with 128 additions and 2 deletions

View File

@ -0,0 +1,3 @@
---
features:
- The volume_limits client was added to tempest.lib.

View File

@ -73,6 +73,7 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
cls.volumes_extension_client = cls.os.volumes_extension_client
cls.availability_zone_client = (
cls.os.volume_availability_zone_client)
cls.volume_limits_client = cls.os.volume_limits_client
else:
cls.snapshots_client = cls.os.snapshots_v2_client
cls.volumes_client = cls.os.volumes_v2_client
@ -80,6 +81,7 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
cls.volumes_extension_client = cls.os.volumes_v2_extension_client
cls.availability_zone_client = (
cls.os.volume_v2_availability_zone_client)
cls.volume_limits_client = cls.os.volume_v2_limits_client
@classmethod
def resource_setup(cls):
@ -217,6 +219,7 @@ class BaseVolumeAdminTest(BaseVolumeTest):
cls.admin_encryption_types_client = \
cls.os_adm.encryption_types_client
cls.admin_quotas_client = cls.os_adm.volume_quotas_client
cls.admin_volume_limits_client = cls.os_adm.volume_limits_client
elif cls._api_version == 2:
cls.admin_volume_qos_client = cls.os_adm.volume_qos_v2_client
cls.admin_volume_services_client = \
@ -229,6 +232,7 @@ class BaseVolumeAdminTest(BaseVolumeTest):
cls.admin_encryption_types_client = \
cls.os_adm.encryption_types_v2_client
cls.admin_quotas_client = cls.os_adm.volume_quotas_v2_client
cls.admin_volume_limits_client = cls.os_adm.volume_v2_limits_client
@classmethod
def resource_setup(cls):

View File

@ -0,0 +1,49 @@
# Copyright 2016 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 tempest.api.volume import base
from tempest import config
from tempest import test
CONF = config.CONF
class AbsoluteLimitsV2Tests(base.BaseVolumeTest):
@classmethod
def resource_setup(cls):
super(AbsoluteLimitsV2Tests, cls).resource_setup()
# Create a shared volume for tests
cls.volume = cls.create_volume()
@test.idempotent_id('8e943f53-e9d6-4272-b2e9-adcf2f7c29ad')
def test_get_volume_absolute_limits(self):
# get volume limit for a tenant
absolute_limits = \
self.volume_limits_client.show_limits(
)['limits']['absolute']
# verify volume limits and defaults per tenants
self.assertEqual(absolute_limits['totalGigabytesUsed'],
CONF.volume.volume_size)
self.assertEqual(absolute_limits['totalVolumesUsed'], 1)
self.assertEqual(absolute_limits['totalSnapshotsUsed'], 0)
self.assertEqual(absolute_limits['totalBackupsUsed'], 0)
self.assertEqual(absolute_limits['totalBackupGigabytesUsed'], 0)
class AbsoluteLimitsV1Tests(AbsoluteLimitsV2Tests):
_api_version = 1

View File

@ -306,6 +306,8 @@ class Manager(clients.ServiceClients):
self.volume_v1.AvailabilityZoneClient()
self.volume_v2_availability_zone_client = \
self.volume_v2.AvailabilityZoneClient()
self.volume_limits_client = self.volume_v1.LimitsClient()
self.volume_v2_limits_client = self.volume_v2.LimitsClient()
def _set_object_storage_clients(self):
# Mandatory parameters (always defined)

View File

@ -19,6 +19,7 @@ from tempest.lib.services.volume.v1.encryption_types_client import \
EncryptionTypesClient
from tempest.lib.services.volume.v1.extensions_client import ExtensionsClient
from tempest.lib.services.volume.v1.hosts_client import HostsClient
from tempest.lib.services.volume.v1.limits_client import LimitsClient
from tempest.lib.services.volume.v1.qos_client import QosSpecsClient
from tempest.lib.services.volume.v1.quotas_client import QuotasClient
from tempest.lib.services.volume.v1.services_client import ServicesClient
@ -28,4 +29,5 @@ from tempest.lib.services.volume.v1.volumes_client import VolumesClient
__all__ = ['AvailabilityZoneClient', 'BackupsClient', 'EncryptionTypesClient',
'ExtensionsClient', 'HostsClient', 'QosSpecsClient', 'QuotasClient',
'ServicesClient', 'SnapshotsClient', 'TypesClient', 'VolumesClient']
'ServicesClient', 'SnapshotsClient', 'TypesClient', 'VolumesClient',
'LimitsClient']

View File

@ -0,0 +1,32 @@
# Copyright 2016 Red Hat, Inc.
# 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 LimitsClient(rest_client.RestClient):
"""Volume V1 limits client."""
api_version = "v1"
def show_limits(self):
"""Returns the details of a volume absolute limits."""
url = "limits"
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)

View File

@ -19,6 +19,7 @@ from tempest.lib.services.volume.v2.encryption_types_client import \
EncryptionTypesClient
from tempest.lib.services.volume.v2.extensions_client import ExtensionsClient
from tempest.lib.services.volume.v2.hosts_client import HostsClient
from tempest.lib.services.volume.v2.limits_client import LimitsClient
from tempest.lib.services.volume.v2.qos_client import QosSpecsClient
from tempest.lib.services.volume.v2.quotas_client import QuotasClient
from tempest.lib.services.volume.v2.services_client import ServicesClient
@ -28,4 +29,5 @@ from tempest.lib.services.volume.v2.volumes_client import VolumesClient
__all__ = ['AvailabilityZoneClient', 'BackupsClient', 'EncryptionTypesClient',
'ExtensionsClient', 'HostsClient', 'QosSpecsClient', 'QuotasClient',
'ServicesClient', 'SnapshotsClient', 'TypesClient', 'VolumesClient']
'ServicesClient', 'SnapshotsClient', 'TypesClient', 'VolumesClient',
'LimitsClient']

View File

@ -0,0 +1,32 @@
# Copyright 2016 Red Hat, Inc.
# 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 LimitsClient(rest_client.RestClient):
"""Volume V2 limits client."""
api_version = "v2"
def show_limits(self):
"""Returns the details of a volume absolute limits."""
url = "limits"
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)