tempest/tempest/api/volume/test_volume_absolute_limits.py
Cliff Parsons c460c429f2 Remove force_tenant_isolation from Cinder tests
The force_tenant_isolation flag was hard-coded to true in four of the
volume test classes. This flag, when set to true, forces Tempest to
create projects and users dynamically, which is a big problem if your
cluster has an immutable user source such as LDAP. Furthermore, if
the user wants to run these tests against a pre-defined user accounts
file, it is not possible without removing the hard-coded flag.

This change removes the hard-coded flag from the Cinder volume test
files that have it. Also, in the cases where there is a resource_setup
function defined and it changed the quota set on the primary project,
this change adds the code in resource_setup to save the original quota
values and the addClassResourceCleanup code to revert those changes
back to their original quota values, just in case the pre-provisioned
accounts (account.yaml) are used rather than dynamic credentials. And
because the AbsoluteLimitsTests class tests no longer need forced
tenant isolation, the class is changed to inherit from BaseVolumeTest
instead of BaseVolumeAdminTest, and the resource_setup() is changed
to save the current limits for comparison in the test case (for the
case where pre-provisioned account volume limits were modified from
their default values).

This change has been tested using dynamic user and project creation and
also with pre-provisioned credentials (accounts.yaml), and all tests
work both ways, depending on how its configured in etc/tempest.conf.
There are no resource leaks or quota-related side effects either way.

Closes-Bug: #1734776
Change-Id: I903be7bef81f162685ed448ba0d19901dca00bf1
2018-06-02 09:35:19 -05:00

58 lines
2.1 KiB
Python

# 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.lib import decorators
CONF = config.CONF
# NOTE(zhufl): This inherits from BaseVolumeAdminTest because
# it requires force_tenant_isolation=True, which need admin
# credentials to create non-admin users for the tests.
class AbsoluteLimitsTests(base.BaseVolumeAdminTest): # noqa
# avoid existing volumes of pre-defined tenant
force_tenant_isolation = True
@classmethod
def resource_setup(cls):
super(AbsoluteLimitsTests, cls).resource_setup()
# Create a shared volume for tests
cls.volume = cls.create_volume()
@classmethod
def skip_checks(cls):
super(AbsoluteLimitsTests, cls).skip_checks()
if not CONF.auth.use_dynamic_credentials:
raise cls.skipException("Must use dynamic credentials.")
@decorators.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)