Merge "Stop forcing creation of "isolated" credentials"
diff --git a/manila_tempest_tests/tests/api/admin/test_migration.py b/manila_tempest_tests/tests/api/admin/test_migration.py
index 1bc67fb..e842ead 100644
--- a/manila_tempest_tests/tests/api/admin/test_migration.py
+++ b/manila_tempest_tests/tests/api/admin/test_migration.py
@@ -450,7 +450,6 @@
new_share_network_id = self.provide_share_network(
self.shares_v2_client,
self.networks_client,
- isolated_creds_client=None,
ignore_multitenancy_config=True,
)
else:
diff --git a/manila_tempest_tests/tests/api/admin/test_quotas.py b/manila_tempest_tests/tests/api/admin/test_quotas.py
index 5dbab2a..116180e 100644
--- a/manila_tempest_tests/tests/api/admin/test_quotas.py
+++ b/manila_tempest_tests/tests/api/admin/test_quotas.py
@@ -39,15 +39,16 @@
msg = "Quota tests are disabled."
raise cls.skipException(msg)
super(SharesAdminQuotasTest, cls).resource_setup()
- cls.user_id = cls.shares_v2_client.user_id
- cls.tenant_id = cls.shares_v2_client.tenant_id
+ cls.client = cls.shares_v2_client
+ cls.user_id = cls.client.user_id
+ cls.tenant_id = cls.client.tenant_id
# create share type
cls.share_type = cls._create_share_type()
cls.share_type_id = cls.share_type['id']
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_default_quotas(self):
- quotas = self.shares_v2_client.default_quotas(self.tenant_id)
+ quotas = self.client.default_quotas(self.tenant_id)
self.assertGreater(int(quotas["gigabytes"]), -2)
self.assertGreater(int(quotas["snapshot_gigabytes"]), -2)
self.assertGreater(int(quotas["shares"]), -2)
@@ -62,7 +63,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_show_quotas(self):
- quotas = self.shares_v2_client.show_quotas(self.tenant_id)
+ quotas = self.client.show_quotas(self.tenant_id)
self.assertGreater(int(quotas["gigabytes"]), -2)
self.assertGreater(int(quotas["snapshot_gigabytes"]), -2)
self.assertGreater(int(quotas["shares"]), -2)
@@ -77,7 +78,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_show_quotas_for_user(self):
- quotas = self.shares_v2_client.show_quotas(
+ quotas = self.client.show_quotas(
self.tenant_id, self.user_id)
self.assertGreater(int(quotas["gigabytes"]), -2)
self.assertGreater(int(quotas["snapshot_gigabytes"]), -2)
@@ -94,7 +95,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_not_supported(PRE_SHARE_GROUPS_MICROVERSION)
def test_show_sg_quotas_using_too_old_microversion(self):
- quotas = self.shares_v2_client.show_quotas(
+ quotas = self.client.show_quotas(
self.tenant_id, version=PRE_SHARE_GROUPS_MICROVERSION)
for key in ('share_groups', 'share_group_snapshots'):
@@ -103,7 +104,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_not_supported(PRE_SHARE_GROUPS_MICROVERSION)
def test_show_sg_quotas_for_user_using_too_old_microversion(self):
- quotas = self.shares_v2_client.show_quotas(
+ quotas = self.client.show_quotas(
self.tenant_id, self.user_id,
version=PRE_SHARE_GROUPS_MICROVERSION)
@@ -114,7 +115,7 @@
@base.skip_if_microversion_not_supported(
PRE_SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_show_replica_quotas_for_user_using_too_old_microversion(self):
- quotas = self.shares_v2_client.show_quotas(
+ quotas = self.client.show_quotas(
self.tenant_id, self.user_id,
version=PRE_SHARE_REPLICA_QUOTAS_MICROVERSION)
@@ -150,10 +151,10 @@
keys.append('replica_gigabytes')
# Get current project quotas
- p_quotas = self.shares_v2_client.show_quotas(self.tenant_id)
+ p_quotas = self.client.show_quotas(self.tenant_id)
- # Get current quotas
- st_quotas = self.shares_v2_client.show_quotas(
+ # Get current share type quotas
+ st_quotas = self.client.show_quotas(
self.tenant_id, share_type=share_type[share_type_key])
# Share type quotas have values equal to project's
@@ -169,13 +170,22 @@
@ddt.ddt
class SharesAdminQuotasUpdateTest(base.BaseSharesAdminTest):
+ # We want to force a fresh project for this test class, since we'll be
+ # manipulating project quotas - and any pre-existing projects may have
+ # resources, quotas and the like that might interfere with our test cases.
force_tenant_isolation = True
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(SharesAdminQuotasUpdateTest, cls).skip_checks()
+ if not CONF.auth.use_dynamic_credentials:
+ raise cls.skipException('Dynamic credentials are required')
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
+
+ @classmethod
+ def resource_setup(cls):
super(SharesAdminQuotasUpdateTest, cls).resource_setup()
# create share type
cls.share_type = cls._create_share_type()
@@ -183,12 +193,9 @@
# create share group type
cls.share_group_type = cls._create_share_group_type()
cls.share_group_type_id = cls.share_group_type['id']
-
- def setUp(self):
- super(self.__class__, self).setUp()
- self.client = self.get_client_with_isolated_creds(client_version='2')
- self.tenant_id = self.client.tenant_id
- self.user_id = self.client.user_id
+ cls.client = cls.shares_v2_client
+ cls.tenant_id = cls.client.tenant_id
+ cls.user_id = cls.client.user_id
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_update_tenant_quota_shares(self):
@@ -197,7 +204,8 @@
new_quota = int(quotas["shares"]) + 2
# set new quota for shares
- updated = self.client.update_quotas(self.tenant_id, shares=new_quota)
+ updated = self.update_quotas(self.tenant_id, shares=new_quota)
+
self.assertEqual(new_quota, int(updated["shares"]))
@ddt.data(
@@ -214,8 +222,8 @@
new_quota = int(quotas[quota_key]) + 2
# Set new quota
- updated = self.client.update_quotas(
- self.tenant_id, **{quota_key: new_quota})
+ updated = self.update_quotas(self.tenant_id, **{quota_key: new_quota})
+
self.assertEqual(new_quota, int(updated[quota_key]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -225,8 +233,10 @@
new_quota = int(quotas["shares"]) - 1
# set new quota for shares
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id, shares=new_quota)
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ shares=new_quota)
+
self.assertEqual(new_quota, int(updated["shares"]))
@ddt.data(
@@ -243,8 +253,10 @@
new_quota = int(quotas[quota_key]) - 1
# Set new quota
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id, **{quota_key: new_quota})
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ **{quota_key: new_quota})
+
self.assertEqual(new_quota, int(updated[quota_key]))
@ddt.data(("share_replicas", False),
@@ -268,8 +280,8 @@
kwargs.update({quota_key: new_quota})
# Set the new quota based on tenant or tenant and user_id
- updated = self.client.update_quotas(
- self.tenant_id, **kwargs)
+ updated = self.update_quotas(self.tenant_id, **kwargs)
+
self.assertEqual(new_quota, int(updated[quota_key]))
@ddt.data(
@@ -283,7 +295,7 @@
# Check if the used microversion supports 'share_replica' and
# 'replica_gigabytes' quotas
replica_quotas_supported = utils.share_replica_quotas_are_supported()
- share_type = self._create_share_type()
+ share_type = self._create_share_type(is_public=is_st_public)
# Get current quotas
quotas = self.client.show_quotas(
@@ -298,10 +310,14 @@
for q in quota_keys:
new_quota = int(quotas[q]) - 1
- # Set new quota
- updated = self.client.update_quotas(
- self.tenant_id, share_type=share_type[share_type_key],
- **{q: new_quota})
+ # Set new quota, cleanup isn't necessary, share type will be
+ # deleted when the test concludes, and that'll take care of
+ # share type quotas
+ updated = self.update_quotas(self.tenant_id,
+ share_type=share_type[share_type_key],
+ cleanup=False,
+ **{q: new_quota})
+
self.assertEqual(new_quota, int(updated[q]))
current_quotas = self.client.show_quotas(
@@ -317,8 +333,8 @@
new_quota = int(quotas["snapshots"]) + 2
# set new quota for snapshots
- updated = self.client.update_quotas(
- self.tenant_id, snapshots=new_quota)
+ updated = self.update_quotas(self.tenant_id, snapshots=new_quota)
+
self.assertEqual(new_quota, int(updated["snapshots"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -328,8 +344,10 @@
new_quota = int(quotas["snapshots"]) - 1
# set new quota for snapshots
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id, snapshots=new_quota)
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ snapshots=new_quota)
+
self.assertEqual(new_quota, int(updated["snapshots"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -341,8 +359,8 @@
gigabytes = int(custom["gigabytes"]) + 2
# set new quota for shares
- updated = self.client.update_quotas(
- self.tenant_id, gigabytes=gigabytes)
+ updated = self.update_quotas(self.tenant_id, gigabytes=gigabytes)
+
self.assertEqual(gigabytes, int(updated["gigabytes"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -354,9 +372,9 @@
snapshot_gigabytes = int(custom["snapshot_gigabytes"]) + 2
# set new quota for shares
- updated = self.client.update_quotas(
- self.tenant_id,
- snapshot_gigabytes=snapshot_gigabytes)
+ updated = self.update_quotas(self.tenant_id,
+ snapshot_gigabytes=snapshot_gigabytes)
+
self.assertEqual(snapshot_gigabytes,
int(updated["snapshot_gigabytes"]))
@@ -369,8 +387,10 @@
gigabytes = int(custom["gigabytes"]) - 1
# set new quota for shares
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id, gigabytes=gigabytes)
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ gigabytes=gigabytes)
+
self.assertEqual(gigabytes, int(updated["gigabytes"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -382,9 +402,10 @@
snapshot_gigabytes = int(custom["snapshot_gigabytes"]) - 1
# set new quota for shares
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id,
- snapshot_gigabytes=snapshot_gigabytes)
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ snapshot_gigabytes=snapshot_gigabytes)
+
self.assertEqual(snapshot_gigabytes,
int(updated["snapshot_gigabytes"]))
@@ -395,8 +416,8 @@
new_quota = int(quotas["share_networks"]) + 2
# set new quota for share-networks
- updated = self.client.update_quotas(
- self.tenant_id, share_networks=new_quota)
+ updated = self.update_quotas(self.tenant_id, share_networks=new_quota)
+
self.assertEqual(new_quota, int(updated["share_networks"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -407,9 +428,10 @@
new_quota = int(quotas["share_networks"]) - 1
# set new quota for share-networks
- updated = self.client.update_quotas(
- self.tenant_id, self.user_id,
- share_networks=new_quota)
+ updated = self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ share_networks=new_quota)
+
self.assertEqual(new_quota, int(updated["share_networks"]))
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@@ -437,8 +459,8 @@
data["share_replicas"] = int(custom["share_replicas"]) + 2
data["replica_gigabytes"] = int(custom["replica_gigabytes"]) + 2
- # set new quota
- updated = self.client.update_quotas(self.tenant_id, **data)
+ # set new quota, turn off cleanup - we'll do it right below
+ updated = self.update_quotas(self.tenant_id, cleanup=False, **data)
self.assertEqual(data["shares"], int(updated["shares"]))
self.assertEqual(data["snapshots"], int(updated["snapshots"]))
self.assertEqual(data["gigabytes"], int(updated["gigabytes"]))
@@ -503,7 +525,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_reset_share_type_quotas(self, share_type_key, is_st_public):
- share_type = self._create_share_type()
+ share_type = self._create_share_type(is_public=is_st_public)
quota_keys = ['shares', 'snapshots', 'gigabytes', 'snapshot_gigabytes']
# get default_quotas
@@ -519,8 +541,8 @@
quota_keys.append('share_replicas')
quota_keys.append('replica_gigabytes')
- # set new quota for project
- updated_p_quota = self.client.update_quotas(
+ # set new project quota
+ updated_p_quota = self.update_quotas(
self.tenant_id,
shares=int(default_quotas['shares']) + 5,
snapshots=int(default_quotas['snapshots']) + 5,
@@ -533,14 +555,15 @@
kwargs.update(self._get_new_replica_quota_values(
default_quotas, 3))
- # set new quota for project
- self.client.update_quotas(
+ # set share type quota for project, don't cleanup, we'll do that below
+ self.update_quotas(
self.tenant_id,
share_type=share_type[share_type_key],
shares=int(default_quotas['shares']) + 3,
snapshots=int(default_quotas['snapshots']) + 3,
gigabytes=int(default_quotas['gigabytes']) + 3,
snapshot_gigabytes=int(default_quotas['snapshot_gigabytes']) + 3,
+ cleanup=False,
**kwargs
)
@@ -561,7 +584,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_quota_for_shares(self):
- self.client.update_quotas(self.tenant_id, shares=-1)
+ self.update_quotas(self.tenant_id, shares=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -569,8 +592,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_user_quota_for_shares(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, shares=-1)
+ self.update_quotas(self.tenant_id, user_id=self.user_id, shares=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -578,7 +600,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_quota_for_snapshots(self):
- self.client.update_quotas(self.tenant_id, snapshots=-1)
+ self.update_quotas(self.tenant_id, snapshots=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -586,8 +608,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_user_quota_for_snapshots(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, snapshots=-1)
+ self.update_quotas(self.tenant_id, user_id=self.user_id, snapshots=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -595,7 +616,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_quota_for_gigabytes(self):
- self.client.update_quotas(self.tenant_id, gigabytes=-1)
+ self.update_quotas(self.tenant_id, gigabytes=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -603,8 +624,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_quota_for_snapshot_gigabytes(self):
- self.client.update_quotas(
- self.tenant_id, snapshot_gigabytes=-1)
+ self.update_quotas(self.tenant_id, snapshot_gigabytes=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -612,8 +632,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_user_quota_for_gigabytes(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, gigabytes=-1)
+ self.update_quotas(self.tenant_id, user_id=self.user_id, gigabytes=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -621,8 +640,9 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_user_quota_for_snapshot_gigabytes(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, snapshot_gigabytes=-1)
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ snapshot_gigabytes=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -630,7 +650,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_quota_for_share_networks(self):
- self.client.update_quotas(self.tenant_id, share_networks=-1)
+ self.update_quotas(self.tenant_id, share_networks=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -638,8 +658,9 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_unlimited_user_quota_for_share_networks(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, share_networks=-1)
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ share_networks=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -650,7 +671,7 @@
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
@utils.skip_if_microversion_not_supported(SHARE_GROUPS_MICROVERSION)
def test_unlimited_quota_for_share_groups(self):
- self.client.update_quotas(self.tenant_id, share_groups=-1)
+ self.update_quotas(self.tenant_id, share_groups=-1)
quotas = self.client.show_quotas(self.tenant_id)
@@ -661,8 +682,9 @@
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
@utils.skip_if_microversion_not_supported(SHARE_GROUPS_MICROVERSION)
def test_unlimited_user_quota_for_share_group_snapshots(self):
- self.client.update_quotas(
- self.tenant_id, self.user_id, share_group_snapshots=-1)
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ share_group_snapshots=-1)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -674,7 +696,7 @@
SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_unlimited_quota_for_replica_quotas(self, quota_key):
kwargs = {quota_key: -1}
- self.client.update_quotas(self.tenant_id, **kwargs)
+ self.update_quotas(self.tenant_id, **kwargs)
quotas = self.client.show_quotas(self.tenant_id)
@@ -686,7 +708,7 @@
SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_unlimited_user_quota_for_replica_quotas(self, quota_key):
kwargs = {quota_key: -1}
- self.client.update_quotas(self.tenant_id, self.user_id, **kwargs)
+ self.update_quotas(self.tenant_id, user_id=self.user_id, **kwargs)
quotas = self.client.show_quotas(self.tenant_id, self.user_id)
@@ -695,35 +717,49 @@
@ddt.data(11, -1)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_update_user_quotas_bigger_than_project_quota(self, user_quota):
- self.client.update_quotas(self.tenant_id, shares=10)
- self.client.update_quotas(
- self.tenant_id, user_id=self.user_id, force=True,
- shares=user_quota)
+ self.update_quotas(self.tenant_id, shares=10)
+
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ force=True,
+ shares=user_quota)
@ddt.data(11, -1)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_update_share_type_quotas_bigger_than_project_quota(self, st_q):
share_type = self._create_share_type()
- self.client.update_quotas(self.tenant_id, shares=10)
- self.client.update_quotas(
- self.tenant_id, share_type=share_type['name'], force=True,
- shares=st_q)
+ self.update_quotas(self.tenant_id, shares=10)
+
+ # no need to cleanup share type quota, share type will be deleted at
+ # the end of the test
+ self.update_quotas(self.tenant_id,
+ share_type=share_type['name'],
+ force=True,
+ cleanup=False,
+ shares=st_q)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_set_share_type_quota_bigger_than_users_quota(self):
share_type = self._create_share_type()
- self.client.update_quotas(self.tenant_id, force=False, shares=13)
- self.client.update_quotas(
- self.tenant_id, user_id=self.user_id, force=False, shares=11)
+
+ self.update_quotas(self.tenant_id, force=False, shares=13)
+
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ force=True,
+ shares=11)
# Share type quota does not depend on user's quota, so we should be
- # able to update it.
- self.client.update_quotas(
- self.tenant_id, share_type=share_type['name'], force=False,
- shares=12)
+ # able to update it. No need for cleanup, since the share type will
+ # be deleted when the test completes, cleaning up quotas and usages
+ self.update_quotas(self.tenant_id,
+ share_type=share_type['name'],
+ force=False,
+ cleanup=False,
+ shares=12)
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@base.skip_if_microversion_lt("2.39")
@@ -733,12 +769,21 @@
for i in (1, 2))
# Set quotas for project, user and both share types
- self.client.update_quotas(self.tenant_id, shares=3, gigabytes=10)
- self.client.update_quotas(
- self.tenant_id, user_id=self.user_id, shares=2, gigabytes=7)
+ self.update_quotas(self.tenant_id, shares=3, gigabytes=10)
+
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ shares=2,
+ gigabytes=7)
+
for st in (st_1['id'], st_2['name']):
- self.client.update_quotas(
- self.tenant_id, share_type=st, shares=2, gigabytes=4)
+ # no need for cleanup, since share types will be deleted at the
+ # end of the test
+ self.update_quotas(self.tenant_id,
+ share_type=st,
+ shares=2,
+ gigabytes=4,
+ cleanup=False)
# Create share, 4Gb, st1 - ok
share_1 = self.create_share(
@@ -814,11 +859,14 @@
@base.skip_if_microversion_lt(SHARE_GROUPS_MICROVERSION)
def test_share_group_quotas_usages(self):
# Set quotas for project (3 SG, 1 SGS) and user (2 SG, 1 SGS)
- self.client.update_quotas(
- self.tenant_id, share_groups=3, share_group_snapshots=1)
- self.client.update_quotas(
- self.tenant_id, user_id=self.user_id,
- share_groups=2, share_group_snapshots=1)
+ self.update_quotas(self.tenant_id,
+ share_groups=3,
+ share_group_snapshots=1)
+
+ self.update_quotas(self.tenant_id,
+ user_id=self.user_id,
+ share_groups=2,
+ share_group_snapshots=1)
# Check usages, they should be 0s
self._check_usages(0, 0)
diff --git a/manila_tempest_tests/tests/api/admin/test_quotas_negative.py b/manila_tempest_tests/tests/api/admin/test_quotas_negative.py
index ae5e227..7d81615 100644
--- a/manila_tempest_tests/tests/api/admin/test_quotas_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_quotas_negative.py
@@ -33,16 +33,26 @@
@ddt.ddt
class SharesAdminQuotasNegativeTest(base.BaseSharesAdminTest):
+ # We want to force some fresh projects for this test class, since we'll be
+ # manipulating project quotas - and any pre-existing projects may have
+ # resources, quotas and the like that might interfere with our test cases.
force_tenant_isolation = True
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(SharesAdminQuotasNegativeTest, cls).skip_checks()
+ if not CONF.auth.use_dynamic_credentials:
+ raise cls.skipException('Dynamic credentials are required')
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
+
+ @classmethod
+ def resource_setup(cls):
super(SharesAdminQuotasNegativeTest, cls).resource_setup()
- cls.user_id = cls.shares_client.user_id
- cls.tenant_id = cls.shares_client.tenant_id
+ cls.client = cls.shares_v2_client
+ cls.user_id = cls.client.user_id
+ cls.tenant_id = cls.client.tenant_id
# create share type
cls.share_type = cls._create_share_type()
cls.share_type_id = cls.share_type['id']
@@ -53,13 +63,12 @@
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_get_quotas_with_empty_tenant_id(self):
self.assertRaises(lib_exc.NotFound,
- self.shares_client.show_quotas, "")
+ self.client.show_quotas, "")
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_reset_quotas_with_empty_tenant_id(self):
- client = self.get_client_with_isolated_creds()
self.assertRaises(lib_exc.NotFound,
- client.reset_quotas, "")
+ self.client.reset_quotas, "")
@ddt.data(
{"shares": -2},
@@ -71,10 +80,10 @@
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_update_quota_with_wrong_data(self, kwargs):
# -1 is acceptable value as unlimited
- client = self.get_client_with_isolated_creds()
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas, client.tenant_id, **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ **kwargs)
@ddt.data(
{"share_groups": -2},
@@ -86,10 +95,10 @@
@utils.skip_if_microversion_not_supported(SHARE_GROUPS_MICROVERSION)
def test_update_sg_quota_with_wrong_data(self, kwargs):
# -1 is acceptable value as unlimited
- client = self.get_client_with_isolated_creds(client_version='2')
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas, client.tenant_id, **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ **kwargs)
@ddt.data(
{"share_replicas": -2},
@@ -100,16 +109,14 @@
SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_update_replica_quotas_wrong_data(self, kwargs):
# -1 is acceptable value as unlimited
-
- client = self.get_client_with_isolated_creds(client_version='2')
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas, client.tenant_id, **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ **kwargs)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_create_share_with_size_bigger_than_quota(self):
- quotas = self.shares_client.show_quotas(
- self.shares_client.tenant_id)
+ quotas = self.client.show_quotas(self.tenant_id)
overquota = int(quotas['gigabytes']) + 2
# try schedule share with size, bigger than gigabytes quota
@@ -122,95 +129,86 @@
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
@utils.skip_if_microversion_not_supported(SHARE_GROUPS_MICROVERSION)
def test_create_share_group_with_exceeding_quota_limit(self):
- client = self.get_client_with_isolated_creds(client_version='2')
- client.update_quotas(client.tenant_id, share_groups=0)
+ self.update_quotas(self.tenant_id, share_groups=0)
# Try schedule share group creation
- self.assertRaises(
- lib_exc.OverLimit,
- self.create_share_group,
- share_group_type_id=self.share_group_type_id,
- share_type_ids=[self.share_type_id],
- client=client,
- cleanup_in_class=False)
+ self.assertRaises(lib_exc.OverLimit,
+ self.create_share_group,
+ share_group_type_id=self.share_group_type_id,
+ share_type_ids=[self.share_type_id],
+ cleanup_in_class=False)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_user_quota_shares_bigger_than_tenant_quota(self):
- client = self.get_client_with_isolated_creds()
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for shares bigger than tenant quota
bigger_value = int(tenant_quotas["shares"]) + 2
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
shares=bigger_value)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_user_quota_snaps_bigger_than_tenant_quota(self):
- client = self.get_client_with_isolated_creds()
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for snapshots bigger than tenant quota
bigger_value = int(tenant_quotas["snapshots"]) + 2
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
snapshots=bigger_value)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_user_quota_gigabytes_bigger_than_tenant_quota(self):
- client = self.get_client_with_isolated_creds()
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for gigabytes bigger than tenant quota
bigger_value = int(tenant_quotas["gigabytes"]) + 2
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
gigabytes=bigger_value)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_user_quota_snap_gigabytes_bigger_than_tenant_quota(self):
- client = self.get_client_with_isolated_creds()
-
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for snapshot gigabytes bigger than tenant quota
bigger_value = int(tenant_quotas["snapshot_gigabytes"]) + 2
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
snapshot_gigabytes=bigger_value)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_user_quota_share_networks_bigger_than_tenant_quota(self):
- client = self.get_client_with_isolated_creds()
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for share_networks bigger than tenant quota
bigger_value = int(tenant_quotas["share_networks"]) + 2
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
share_networks=bigger_value)
@@ -219,18 +217,16 @@
@utils.skip_if_microversion_not_supported(
SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_try_set_user_quota_replicas_bigger_than_tenant_quota(self, key):
- client = self.get_client_with_isolated_creds(client_version='2')
-
# get current quotas for tenant
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# try set user quota for snapshots bigger than tenant quota
bigger_value = int(tenant_quotas[key]) + 2
kwargs = {key: bigger_value}
self.assertRaises(lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- client.user_id,
+ self.update_quotas,
+ self.tenant_id,
+ user_id=self.user_id,
force=False,
**kwargs)
@@ -252,171 +248,147 @@
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_not_supported("2.7")
def test_show_quotas_with_wrong_versions(self, url, version, method_name):
- self.assertRaises(
- lib_exc.NotFound,
- getattr(self.shares_v2_client, method_name),
- self.shares_v2_client.tenant_id,
- version=version, url=url,
- )
+ self.assertRaises(lib_exc.NotFound,
+ getattr(self.client, method_name),
+ self.tenant_id,
+ version=version,
+ url=url)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_show_quota_detail_with_wrong_versions(self):
version = '2.24'
url = 'quota-sets'
- self.assertRaises(
- lib_exc.NotFound,
- self.shares_v2_client.detail_quotas,
- self.shares_v2_client.tenant_id,
- version=version, url=url,
- )
+ self.assertRaises(lib_exc.NotFound,
+ self.client.detail_quotas,
+ self.tenant_id,
+ version=version,
+ url=url)
@ddt.data('show', 'reset', 'update')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_share_type_quotas_using_nonexistent_share_type(self, op):
- client = self.get_client_with_isolated_creds(client_version='2')
kwargs = {"share_type": "fake_nonexistent_share_type"}
if op == 'update':
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
kwargs['shares'] = tenant_quotas['shares']
- self.assertRaises(
- lib_exc.NotFound,
- getattr(client, op + '_quotas'),
- client.tenant_id,
- **kwargs)
+ self.assertRaises(lib_exc.NotFound,
+ getattr(self.client, op + '_quotas'),
+ self.tenant_id,
+ **kwargs)
@ddt.data('id', 'name')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_try_update_share_type_quota_for_share_networks(self, key):
- client = self.get_client_with_isolated_creds(client_version='2')
share_type = self._create_share_type()
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
# Try to set 'share_networks' quota for share type
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- share_type=share_type[key],
- share_networks=int(tenant_quotas["share_networks"]),
- )
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ share_type=share_type[key],
+ share_networks=int(tenant_quotas["share_networks"]))
@ddt.data('share_groups', 'share_group_snapshots')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt(SHARE_GROUPS_MICROVERSION)
def test_try_update_share_type_quota_for_share_groups(self, quota_name):
- client = self.get_client_with_isolated_creds(client_version='2')
share_type = self._create_share_type()
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- share_type=share_type["name"],
- **{quota_name: int(tenant_quotas[quota_name])}
- )
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ share_type=share_type["name"],
+ **{quota_name: int(tenant_quotas[quota_name])})
@ddt.data('share_groups', 'share_group_snapshots')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_not_supported(PRE_SHARE_GROUPS_MICROVERSION)
@base.skip_if_microversion_not_supported(SHARE_GROUPS_MICROVERSION)
def test_share_group_quotas_using_too_old_microversion(self, quota_key):
- client = self.get_client_with_isolated_creds(client_version='2')
- tenant_quotas = client.show_quotas(
- client.tenant_id, version=SHARE_GROUPS_MICROVERSION)
+ tenant_quotas = self.client.show_quotas(
+ self.tenant_id, version=SHARE_GROUPS_MICROVERSION)
kwargs = {
"version": PRE_SHARE_GROUPS_MICROVERSION,
quota_key: tenant_quotas[quota_key],
}
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ self.client.update_quotas,
+ self.tenant_id,
+ **kwargs)
@ddt.data("share_replicas", "replica_gigabytes")
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_not_supported(SHARE_REPLICA_QUOTAS_MICROVERSION)
def test_share_replica_quotas_using_too_old_microversion(self, quota_key):
- client = self.get_client_with_isolated_creds(client_version='2')
- tenant_quotas = client.show_quotas(
- client.tenant_id, version=SHARE_REPLICA_QUOTAS_MICROVERSION)
+ tenant_quotas = self.client.show_quotas(
+ self.tenant_id, version=SHARE_REPLICA_QUOTAS_MICROVERSION)
kwargs = {
"version": PRE_SHARE_REPLICA_QUOTAS_MICROVERSION,
quota_key: tenant_quotas[quota_key],
}
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ **kwargs)
@ddt.data('show', 'reset', 'update')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.38")
def test_share_type_quotas_using_too_old_microversion(self, op):
- client = self.get_client_with_isolated_creds(client_version='2')
share_type = self._create_share_type()
kwargs = {"version": "2.38", "share_type": share_type["name"]}
if op == 'update':
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
kwargs['shares'] = tenant_quotas['shares']
- self.assertRaises(
- lib_exc.BadRequest,
- getattr(client, op + '_quotas'),
- client.tenant_id,
- **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ getattr(self.client, op + '_quotas'),
+ self.tenant_id,
+ **kwargs)
@ddt.data('show', 'reset', 'update')
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_quotas_providing_share_type_and_user_id(self, op):
- client = self.get_client_with_isolated_creds(client_version='2')
share_type = self._create_share_type()
- kwargs = {"share_type": share_type["name"], "user_id": client.user_id}
+ kwargs = {"share_type": share_type["name"], "user_id": self.user_id}
if op == 'update':
- tenant_quotas = client.show_quotas(client.tenant_id)
+ tenant_quotas = self.client.show_quotas(self.tenant_id)
kwargs['shares'] = tenant_quotas['shares']
- self.assertRaises(
- lib_exc.BadRequest,
- getattr(client, op + '_quotas'),
- client.tenant_id,
- **kwargs)
+ self.assertRaises(lib_exc.BadRequest,
+ getattr(self.client, op + '_quotas'),
+ self.tenant_id,
+ **kwargs)
@ddt.data(11, -1)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
@base.skip_if_microversion_lt("2.39")
def test_update_share_type_quotas_bigger_than_project_quota(self, st_q):
- client = self.get_client_with_isolated_creds(client_version='2')
share_type = self._create_share_type()
- client.update_quotas(client.tenant_id, shares=10)
+ self.update_quotas(self.tenant_id, shares=10)
- self.assertRaises(
- lib_exc.BadRequest,
- client.update_quotas,
- client.tenant_id,
- share_type=share_type['name'],
- force=False,
- shares=st_q)
+ self.assertRaises(lib_exc.BadRequest,
+ self.update_quotas,
+ self.tenant_id,
+ share_type=share_type['name'],
+ force=False,
+ shares=st_q)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_create_share_over_quota_limit(self):
- original_quota = self.shares_v2_client.show_quotas(
- self.tenant_id)
self.create_share(share_type_id=self.share_type_id)
- self.shares_v2_client.update_quotas(self.tenant_id, shares=1)
- updated_quota = self.shares_v2_client.show_quotas(self.tenant_id)
- self.addCleanup(self.shares_v2_client.update_quotas,
- self.tenant_id, shares=original_quota['shares'])
+
+ updated_quota = self.update_quotas(self.tenant_id, shares=1)
self.assertEqual(1, updated_quota['shares'])
self.assertRaises(lib_exc.OverLimit,
@@ -427,32 +399,29 @@
@ddt.ddt
class ReplicaQuotasNegativeTest(rep_neg_test.ReplicationNegativeBase):
+ # We want to force some fresh projects for this test class, since we'll be
+ # manipulating project quotas - and any pre-existing projects may have
+ # resources, quotas and the like that might interfere with our test cases.
+ force_tenant_isolation = True
+
@classmethod
def skip_checks(cls):
super(ReplicaQuotasNegativeTest, cls).skip_checks()
+ if not CONF.auth.use_dynamic_credentials:
+ raise cls.skipException('Dynamic credentials are required')
if not CONF.share.run_quota_tests:
msg = "Quota tests are disabled."
raise cls.skipException(msg)
-
utils.check_skip_if_microversion_lt(SHARE_REPLICA_QUOTAS_MICROVERSION)
def _modify_quotas_for_test(self, quota_key, new_limit):
kwargs = {quota_key: new_limit}
- # Get the original quota values
- original_quota = self.admin_client.show_quotas(self.tenant_id)
-
# Update the current quotas
- self.admin_client.update_quotas(self.tenant_id, **kwargs)
-
- # Save the previous value
- old_quota_values = {quota_key: original_quota[quota_key]}
+ self.update_quotas(self.tenant_id, client=self.admin_client, **kwargs)
# Get the updated quotas and add a cleanup
updated_quota = self.admin_client.show_quotas(self.tenant_id)
- self.addCleanup(self.admin_client.update_quotas,
- self.tenant_id,
- **old_quota_values)
# Make sure that the new value was properly set
self.assertEqual(new_limit, updated_quota[quota_key])
@@ -493,6 +462,6 @@
# Make sure that the request to create a third one will fail
self.assertRaises(lib_exc.OverLimit,
- self.shares_v2_client.extend_share,
+ self.client.extend_share,
self.share1['id'],
new_size)
diff --git a/manila_tempest_tests/tests/api/admin/test_replication.py b/manila_tempest_tests/tests/api/admin/test_replication.py
index 60f97a7..9e6a323 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication.py
@@ -50,7 +50,7 @@
)
extra_specs = {"replication_type": cls.replication_type}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
cls.sn_id = None
if cls.multitenancy_enabled:
diff --git a/manila_tempest_tests/tests/api/admin/test_replication_actions.py b/manila_tempest_tests/tests/api/admin/test_replication_actions.py
index 8264798..428229c 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication_actions.py
@@ -53,7 +53,7 @@
# create share type
extra_specs = {"replication_type": cls.replication_type}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
cls.sn_id = None
diff --git a/manila_tempest_tests/tests/api/admin/test_share_networks.py b/manila_tempest_tests/tests/api/admin/test_share_networks.py
index e66e503..b4211bd 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_networks.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_networks.py
@@ -19,9 +19,8 @@
from manila_tempest_tests.tests.api import test_share_networks
-class ShareNetworkAdminTest(
- base.BaseSharesAdminTest,
- test_share_networks.ShareNetworkListMixin):
+class ShareNetworkAdminTest(base.BaseSharesMixedTest,
+ test_share_networks.ShareNetworkListMixin):
@classmethod
def resource_setup(cls):
@@ -49,8 +48,6 @@
cls.sn_with_ldap_ss["id"],
cls.ss_ldap["id"])
- cls.isolated_client = cls.get_client_with_isolated_creds(
- type_of_creds='alt')
cls.data_sn_with_kerberos_ss = {
'name': 'sn_with_kerberos_ss',
'created_at': '2003-03-03',
@@ -64,21 +61,22 @@
'description': 'fake description',
}
- cls.ss_kerberos = cls.isolated_client.create_security_service(
+ cls.ss_kerberos = cls.alt_shares_v2_client.create_security_service(
ss_type='kerberos',
**cls.data_sn_with_ldap_ss)
- cls.sn_with_kerberos_ss = cls.isolated_client.create_share_network(
- cleanup_in_class=True,
- **cls.data_sn_with_kerberos_ss)
+ cls.sn_with_kerberos_ss = (
+ cls.alt_shares_v2_client.create_share_network(
+ cleanup_in_class=True, **cls.data_sn_with_kerberos_ss)
+ )
- cls.isolated_client.add_sec_service_to_share_network(
+ cls.alt_shares_v2_client.add_sec_service_to_share_network(
cls.sn_with_kerberos_ss["id"],
cls.ss_kerberos["id"])
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_list_share_networks_all_tenants(self):
- listed = self.shares_client.list_share_networks_with_detail(
+ listed = self.admin_shares_v2_client.list_share_networks_with_detail(
{'all_tenants': 1})
self.assertTrue(any(self.sn_with_ldap_ss['id'] == sn['id']
for sn in listed))
@@ -87,7 +85,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_list_share_networks_filter_by_project_id(self):
- listed = self.shares_client.list_share_networks_with_detail(
+ listed = self.admin_shares_v2_client.list_share_networks_with_detail(
{'project_id': self.sn_with_kerberos_ss['project_id']})
self.assertTrue(any(self.sn_with_kerberos_ss['id'] == sn['id']
for sn in listed))
diff --git a/manila_tempest_tests/tests/api/admin/test_shares_actions.py b/manila_tempest_tests/tests/api/admin/test_shares_actions.py
index dfadd7a..f4ccfa4 100644
--- a/manila_tempest_tests/tests/api/admin/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_shares_actions.py
@@ -36,7 +36,7 @@
# create share type for share filtering purposes
specs = {"storage_protocol": CONF.share.capability_storage_protocol}
- cls.share_type = cls._create_share_type(specs)
+ cls.share_type = cls._create_share_type(specs=specs)
cls.share_type_id = cls.share_type['id']
# create share
diff --git a/manila_tempest_tests/tests/api/admin/test_snapshot_export_locations_negative.py b/manila_tempest_tests/tests/api/admin/test_snapshot_export_locations_negative.py
index 9d48254..10d6193 100644
--- a/manila_tempest_tests/tests/api/admin/test_snapshot_export_locations_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_snapshot_export_locations_negative.py
@@ -39,7 +39,7 @@
def setup_clients(cls):
super(SnapshotExportLocationsNegativeTest, cls).setup_clients()
cls.admin_client = cls.admin_shares_v2_client
- cls.isolated_client = cls.alt_shares_v2_client
+ cls.different_project_client = cls.alt_shares_v2_client
@classmethod
def resource_setup(cls):
@@ -66,15 +66,15 @@
)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
- def test_list_snapshot_export_locations_by_member(self):
+ def test_list_snapshot_export_locations_by_different_project_user(self):
self.assertRaises(
lib_exc.NotFound,
- self.isolated_client.list_snapshot_export_locations,
+ self.different_project_client.list_snapshot_export_locations,
self.snapshot['id']
)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
- def test_get_snapshot_export_location_by_member(self):
+ def test_get_snapshot_export_location_by_different_project_user(self):
export_locations = (
self.admin_client.list_snapshot_export_locations(
self.snapshot['id']))
@@ -84,10 +84,9 @@
continue
self.assertRaises(
lib_exc.NotFound,
- self.isolated_client.get_snapshot_export_location,
+ self.different_project_client.get_snapshot_export_location,
self.snapshot['id'],
- export_location['id']
- )
+ export_location['id'])
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_get_inexistent_snapshot_instance_export_location(self):
@@ -108,7 +107,8 @@
for el in export_locations:
self.assertRaises(
lib_exc.Forbidden,
- self.isolated_client.get_snapshot_instance_export_location,
+ (self.different_project_client.
+ get_snapshot_instance_export_location),
snapshot_instance['id'], el['id'],
)
@@ -129,7 +129,9 @@
def setup_clients(cls):
super(SnapshotExportLocationsAPIOnlyNegativeTest, cls).setup_clients()
cls.admin_client = cls.admin_shares_v2_client
- cls.isolated_client = cls.alt_shares_v2_client
+ # admin_member_client is a regular user in admin's project
+ cls.admin_member_client = (
+ cls.admin_project_member_client.shares_v2_client)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_list_export_locations_by_nonexistent_snapshot(self):
@@ -152,6 +154,6 @@
self):
self.assertRaises(
lib_exc.Forbidden,
- self.isolated_client.list_snapshot_instance_export_locations,
+ self.admin_member_client.list_snapshot_instance_export_locations,
"fake-inexistent-snapshot-instance-id"
)
diff --git a/manila_tempest_tests/tests/api/admin/test_user_messages_negative.py b/manila_tempest_tests/tests/api/admin/test_user_messages_negative.py
index cf592e4..7d77eec 100644
--- a/manila_tempest_tests/tests/api/admin/test_user_messages_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_user_messages_negative.py
@@ -24,7 +24,7 @@
QUERY_BY_TIMESTAMP_MICROVERSION = '2.52'
-class UserMessageNegativeTest(base.BaseSharesAdminTest):
+class UserMessageNegativeTest(base.BaseSharesMixedTest):
@classmethod
def skip_checks(cls):
@@ -37,10 +37,8 @@
@decorators.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_show_message_of_other_tenants(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt', client_version='2')
self.assertRaises(lib_exc.NotFound,
- isolated_client.get_message,
+ self.alt_shares_v2_client.get_message,
self.message['id'])
@decorators.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
@@ -51,10 +49,8 @@
@decorators.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
def test_delete_message_of_other_tenants(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt', client_version='2')
self.assertRaises(lib_exc.NotFound,
- isolated_client.delete_message,
+ self.alt_shares_v2_client.delete_message,
self.message['id'])
@decorators.attr(type=[base.TAG_NEGATIVE, base.TAG_API])
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 671ccf3..fc5c6a1 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -14,7 +14,6 @@
# under the License.
import copy
-import inspect
import re
import traceback
@@ -100,12 +99,6 @@
def network_synchronized(f):
def wrapped_func(self, *args, **kwargs):
- with_isolated_creds = True if len(args) > 2 else False
- no_lock_required = kwargs.get(
- "isolated_creds_client", with_isolated_creds)
- if no_lock_required:
- # Usage of not reusable network. No need in lock.
- return f(self, *args, **kwargs)
# Use lock assuming reusage of common network.
@lockutils.synchronized("manila_network_lock", external=True)
@@ -134,12 +127,6 @@
# Will be cleaned up in tearDown method
method_resources = []
- # Will be cleaned up in resource_cleanup
- class_isolated_creds = []
-
- # Will be cleaned up in tearDown method
- method_isolated_creds = []
-
# NOTE(andreaf) Override the client manager class to be used, so that
# a stable class is used, which includes plugin registered services as well
client_manager = clients.Clients
@@ -187,73 +174,6 @@
identity_uri=identity_uri)
@classmethod
- def get_client_with_isolated_creds(cls,
- name=None,
- type_of_creds="admin",
- cleanup_in_class=False,
- client_version='1'):
- """Creates isolated creds.
-
- :param name: name, will be used for naming ic and related stuff
- :param type_of_creds: admin, alt or primary
- :param cleanup_in_class: defines place where to delete
- :returns: SharesClient -- shares client with isolated creds.
- :returns: To client added dict attr 'creds' with
- :returns: key elements 'tenant' and 'user'.
- """
- if name is None:
- # Get name of test method
- name = inspect.stack()[1][3]
- if len(name) > 32:
- name = name[0:32]
-
- # Choose type of isolated creds
- ic = cls._get_dynamic_creds(name)
- if "admin" in type_of_creds:
- creds = ic.get_admin_creds().credentials
- elif "alt" in type_of_creds:
- creds = ic.get_alt_creds().credentials
- else:
- creds = ic.get_credentials(type_of_creds).credentials
- ic.type_of_creds = type_of_creds
-
- # create client with isolated creds
- os = clients.Clients(creds)
- if client_version == '1':
- client = os.share_v1.SharesClient()
- elif client_version == '2':
- client = os.share_v2.SharesV2Client()
-
- # Set place where will be deleted isolated creds
- ic_res = {
- "method": ic.clear_creds,
- "deleted": False,
- }
- if cleanup_in_class:
- cls.class_isolated_creds.insert(0, ic_res)
- else:
- cls.method_isolated_creds.insert(0, ic_res)
-
- # Provide share network
- if CONF.share.multitenancy_enabled:
- if (not CONF.service_available.neutron and
- CONF.share.create_networks_when_multitenancy_enabled):
- raise cls.skipException("Neutron support is required")
- nc = os.network.NetworksClient()
- share_network_id = cls.provide_share_network(client, nc, ic)
- client.share_network_id = share_network_id
- resource = {
- "type": "share_network",
- "id": client.share_network_id,
- "client": client,
- }
- if cleanup_in_class:
- cls.class_resources.insert(0, resource)
- else:
- cls.method_resources.insert(0, resource)
- return client
-
- @classmethod
def skip_checks(cls):
super(BaseSharesTest, cls).skip_checks()
if not CONF.service_available.manila:
@@ -307,20 +227,17 @@
def setUp(self):
super(BaseSharesTest, self).setUp()
- self.addCleanup(self.clear_isolated_creds)
self.addCleanup(self.clear_resources)
verify_test_has_appropriate_tags(self)
@classmethod
def resource_cleanup(cls):
cls.clear_resources(cls.class_resources)
- cls.clear_isolated_creds(cls.class_isolated_creds)
super(BaseSharesTest, cls).resource_cleanup()
@classmethod
@network_synchronized
def provide_share_network(cls, shares_client, networks_client,
- isolated_creds_client=None,
ignore_multitenancy_config=False):
"""Used for finding/creating share network for multitenant driver.
@@ -329,9 +246,6 @@
:param shares_client: shares client, which requires share-network
:param networks_client: network client from same tenant as shares
- :param isolated_creds_client: DynamicCredentialProvider instance
- If provided, then its networking will be used if needed.
- If not provided, then common network will be used if needed.
:param ignore_multitenancy_config: provide a share network regardless
of 'multitenancy_enabled' configuration value.
:returns: str -- share network id for shares_client tenant
@@ -375,50 +289,41 @@
share_network_id = sn["id"]
else:
net_id = subnet_id = share_network_id = None
-
- if not isolated_creds_client:
- # Search for networks, created in previous runs
- service_net_name = "share-service"
- networks = networks_client.list_networks()
- if "networks" in networks.keys():
- networks = networks["networks"]
- for network in networks:
- if (service_net_name in network["name"] and
- sc.tenant_id == network['tenant_id']):
- net_id = network["id"]
- if len(network["subnets"]) > 0:
- subnet_id = network["subnets"][0]
- break
-
- # Create suitable network
- if net_id is None or subnet_id is None:
- ic = cls._get_dynamic_creds(service_net_name)
- net_data = ic._create_network_resources(sc.tenant_id)
- network, subnet, router = net_data
+ # Search for networks, created in previous runs
+ service_net_name = "share-service"
+ networks = networks_client.list_networks()
+ if "networks" in networks.keys():
+ networks = networks["networks"]
+ for network in networks:
+ if (service_net_name in network["name"] and
+ sc.tenant_id == network['tenant_id']):
net_id = network["id"]
- subnet_id = subnet["id"]
-
- # Try get suitable share-network
- share_networks = sc.list_share_networks_with_detail()
- for sn in share_networks:
- net_info = (
- utils.share_network_get_default_subnet(sn)
- if utils.share_network_subnets_are_supported()
- else sn)
- if net_info is None:
- continue
- if (net_id == net_info["neutron_net_id"] and
- subnet_id == net_info["neutron_subnet_id"] and
- sn["name"] and search_word in sn["name"]):
- share_network_id = sn["id"]
+ if len(network["subnets"]) > 0:
+ subnet_id = network["subnets"][0]
break
- else:
- sn_name = "autogenerated_by_tempest_for_isolated_creds"
- # Use precreated network and subnet from isolated creds
- net_id = isolated_creds_client.get_credentials(
- isolated_creds_client.type_of_creds).network['id']
- subnet_id = isolated_creds_client.get_credentials(
- isolated_creds_client.type_of_creds).subnet['id']
+
+ # Create suitable network
+ if net_id is None or subnet_id is None:
+ ic = cls._get_dynamic_creds(service_net_name)
+ net_data = ic._create_network_resources(sc.tenant_id)
+ network, subnet, router = net_data
+ net_id = network["id"]
+ subnet_id = subnet["id"]
+
+ # Try get suitable share-network
+ share_networks = sc.list_share_networks_with_detail()
+ for sn in share_networks:
+ net_info = (
+ utils.share_network_get_default_subnet(sn)
+ if utils.share_network_subnets_are_supported()
+ else sn)
+ if net_info is None:
+ continue
+ if (net_id == net_info["neutron_net_id"] and
+ subnet_id == net_info["neutron_subnet_id"] and
+ sn["name"] and search_word in sn["name"]):
+ share_network_id = sn["id"]
+ break
# Create suitable share-network
if share_network_id is None:
@@ -908,6 +813,23 @@
is_public, description)
return share_type
+ @classmethod
+ def update_quotas(cls, project_id, user_id=None, cleanup=True,
+ client=None, **kwargs):
+ client = client or cls.shares_v2_client
+ updated_quotas = client.update_quotas(project_id,
+ user_id=user_id,
+ **kwargs)
+ resource = {
+ "type": "quotas",
+ "id": project_id,
+ "client": client,
+ "user_id": user_id,
+ }
+ if cleanup:
+ cls.method_resources.insert(0, resource)
+ return updated_quotas
+
@staticmethod
def add_extra_specs_to_dict(extra_specs=None):
"""Add any required extra-specs to share type dictionary"""
@@ -935,18 +857,6 @@
return extra_specs_dict
@classmethod
- def clear_isolated_creds(cls, creds=None):
- if creds is None:
- creds = cls.method_isolated_creds
- for ic in creds:
- if "deleted" not in ic.keys():
- ic["deleted"] = False
- if not ic["deleted"]:
- with handle_cleanup_exceptions():
- ic["method"]()
- ic["deleted"] = True
-
- @classmethod
def clear_share_replicas(cls, share_id, client=None):
client = client or cls.shares_v2_client
share_replicas = client.list_share_replicas(
@@ -1024,6 +934,9 @@
client.wait_for_resource_deletion(
share_network_subnet_id=res_id,
sn_id=sn_id)
+ elif res["type"] == "quotas":
+ user_id = res.get('user_id')
+ client.reset_quotas(res_id, user_id=user_id)
else:
LOG.warning("Provided unsupported resource type for "
"cleanup '%s'. Skipping.", res["type"])
@@ -1130,6 +1043,7 @@
share_type_name = data_utils.rand_name("share-type")
bogus_type = self.create_share_type(
+ client=self.admin_shares_v2_client,
name=share_type_name,
extra_specs=extra_specs)['share_type']
@@ -1157,11 +1071,11 @@
cls.admin_shares_v2_client = cls.os_admin.share_v2.SharesV2Client()
@classmethod
- def _create_share_type(cls, specs=None):
+ def _create_share_type(cls, is_public=True, specs=None):
name = data_utils.rand_name("unique_st_name")
extra_specs = cls.add_extra_specs_to_dict(specs)
return cls.create_share_type(
- name, extra_specs=extra_specs,
+ name, extra_specs=extra_specs, is_public=is_public,
client=cls.admin_shares_v2_client)['share_type']
@classmethod
@@ -1355,11 +1269,11 @@
return os
@classmethod
- def _create_share_type(cls, specs=None):
+ def _create_share_type(cls, is_public=True, specs=None):
name = data_utils.rand_name("unique_st_name")
extra_specs = cls.add_extra_specs_to_dict(specs)
return cls.create_share_type(
- name, extra_specs=extra_specs,
+ name, extra_specs=extra_specs, is_public=is_public,
client=cls.admin_shares_v2_client)['share_type']
@classmethod
diff --git a/manila_tempest_tests/tests/api/test_replication_negative.py b/manila_tempest_tests/tests/api/test_replication_negative.py
index 3215641..2d66d38 100644
--- a/manila_tempest_tests/tests/api/test_replication_negative.py
+++ b/manila_tempest_tests/tests/api/test_replication_negative.py
@@ -52,7 +52,7 @@
# create share type
extra_specs = {"replication_type": cls.replication_type}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
cls.sn_id = None
if cls.multitenancy_enabled:
diff --git a/manila_tempest_tests/tests/api/test_replication_snapshots.py b/manila_tempest_tests/tests/api/test_replication_snapshots.py
index 591b3fd..605275c 100644
--- a/manila_tempest_tests/tests/api/test_replication_snapshots.py
+++ b/manila_tempest_tests/tests/api/test_replication_snapshots.py
@@ -53,7 +53,7 @@
# create share type
extra_specs = {"replication_type": cls.replication_type}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
cls.sn_id = None
if cls.multitenancy_enabled:
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 2212fb9..4829dfd 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -420,9 +420,7 @@
)
params = {"is_public": True}
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
- shares = isolated_client.list_shares_with_detail(params)
+ shares = self.alt_shares_client.list_shares_with_detail(params)
keys = [
"status", "description", "links", "availability_zone",
diff --git a/manila_tempest_tests/tests/api/test_shares_from_snapshot_across_pools.py b/manila_tempest_tests/tests/api/test_shares_from_snapshot_across_pools.py
index 2ec167f..d71202d 100644
--- a/manila_tempest_tests/tests/api/test_shares_from_snapshot_across_pools.py
+++ b/manila_tempest_tests/tests/api/test_shares_from_snapshot_across_pools.py
@@ -33,7 +33,7 @@
# create share_type
extra_specs = {"create_share_from_snapshot_support": True,
"snapshot_support": True}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
cls.admin_client = cls.admin_shares_v2_client
cls.pools = cls.get_pools_matching_share_type(cls.share_type,
diff --git a/manila_tempest_tests/tests/api/test_shares_negative.py b/manila_tempest_tests/tests/api/test_shares_negative.py
index a0a1a47..09a45cd 100644
--- a/manila_tempest_tests/tests/api/test_shares_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_negative.py
@@ -150,43 +150,35 @@
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_update_other_tenants_public_share(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
- self.assertRaises(lib_exc.Forbidden, isolated_client.update_share,
- self.share["id"], name="new_name")
+ self.assertRaises(lib_exc.Forbidden,
+ self.alt_shares_v2_client.update_share,
+ self.share["id"],
+ name="new_name")
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_delete_other_tenants_public_share(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
self.assertRaises(lib_exc.Forbidden,
- isolated_client.delete_share,
+ self.alt_shares_v2_client.delete_share,
self.share['id'])
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_set_metadata_of_other_tenants_public_share(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
self.assertRaises(lib_exc.Forbidden,
- isolated_client.set_metadata,
+ self.alt_shares_v2_client.set_metadata,
self.share['id'],
{'key': 'value'})
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_update_metadata_of_other_tenants_public_share(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
self.assertRaises(lib_exc.Forbidden,
- isolated_client.update_all_metadata,
+ self.alt_shares_v2_client.update_all_metadata,
self.share['id'],
{'key': 'value'})
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
def test_delete_metadata_of_other_tenants_public_share(self):
- isolated_client = self.get_client_with_isolated_creds(
- type_of_creds='alt')
self.assertRaises(lib_exc.Forbidden,
- isolated_client.delete_metadata,
+ self.alt_shares_v2_client.delete_metadata,
self.share['id'],
'key')
diff --git a/manila_tempest_tests/tests/api/test_snapshot_rules.py b/manila_tempest_tests/tests/api/test_snapshot_rules.py
index 86cb339..0323916 100644
--- a/manila_tempest_tests/tests/api/test_snapshot_rules.py
+++ b/manila_tempest_tests/tests/api/test_snapshot_rules.py
@@ -34,7 +34,7 @@
super(BaseShareSnapshotRulesTest, cls).resource_setup()
# create share_type
extra_specs = {'mount_snapshot_support': 'True'}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
# create share
diff --git a/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py b/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
index 7a4308d..f9670db 100644
--- a/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
+++ b/manila_tempest_tests/tests/api/test_snapshot_rules_negative.py
@@ -49,7 +49,7 @@
super(SnapshotIpRulesForNFSNegativeTest, cls).resource_setup()
# create share type
extra_specs = {'mount_snapshot_support': 'True'}
- cls.share_type = cls._create_share_type(extra_specs)
+ cls.share_type = cls._create_share_type(specs=extra_specs)
cls.share_type_id = cls.share_type['id']
# create share
cls.share = cls.create_share(cls.protocol,