Merge "Add create_share_from_snapshot_support extra spec"
diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py
index 6d0a466..7d7f3fb 100644
--- a/manila_tempest_tests/config.py
+++ b/manila_tempest_tests/config.py
@@ -30,7 +30,7 @@
help="The minimum api microversion is configured to be the "
"value of the minimum microversion supported by Manila."),
cfg.StrOpt("max_api_microversion",
- default="2.23",
+ default="2.24",
help="The maximum api microversion is configured to be the "
"value of the latest microversion supported by Manila."),
cfg.StrOpt("region",
@@ -96,6 +96,13 @@
"capability called 'snapshot_support' and will be used "
"for setting up custom share type. Defaults to value of "
"other config option 'run_snapshot_tests'."),
+ cfg.BoolOpt("capability_create_share_from_snapshot_support",
+ help="Defines extra spec that satisfies specific back end "
+ "capability called 'create_share_from_snapshot_support' "
+ "and will be used for setting up a custom share type. "
+ "Defaults to the value of run_snapshot_tests. Set it to "
+ "False if the driver being tested does not support "
+ "creating shares from snapshots."),
cfg.StrOpt("share_network_id",
default="",
diff --git a/manila_tempest_tests/plugin.py b/manila_tempest_tests/plugin.py
index 0a97747..dfec0b1 100644
--- a/manila_tempest_tests/plugin.py
+++ b/manila_tempest_tests/plugin.py
@@ -35,14 +35,21 @@
conf.register_group(config_share.share_group)
conf.register_opts(config_share.ShareGroup, group='share')
- # NOTE(vponomaryov): set opt 'capability_snapshot_support' by
- # default equal to opt 'run_snapshot_tests'.
+ # NOTE(vponomaryov): Set options 'capability_snapshot_support' and
+ # 'capability_create_share_from_snapshot_support' to opt
+ # 'run_snapshot_tests' if not configured.
if conf.share.capability_snapshot_support is None:
conf.set_default(
"capability_snapshot_support",
conf.share.run_snapshot_tests,
group="share",
)
+ if conf.share.capability_create_share_from_snapshot_support is None:
+ conf.set_default(
+ "capability_create_share_from_snapshot_support",
+ conf.share.run_snapshot_tests,
+ group="share",
+ )
def get_opt_lists(self):
return [(config_share.share_group.name, config_share.ShareGroup),
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index 0ccc18b..de8c62e 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -726,6 +726,13 @@
self.expected_success(200, resp.status)
return self._parse_resp(body)
+ def delete_share_type_extra_spec(self, share_type_id, extra_spec_name,
+ version=LATEST_MICROVERSION):
+ uri = "types/%s/extra_specs/%s" % (share_type_id, extra_spec_name)
+ resp, body = self.delete(uri, version=version)
+ self.expected_success(202, resp.status)
+ return body
+
def list_access_to_share_type(self, share_type_id,
version=LATEST_MICROVERSION,
action_name=None):
diff --git a/manila_tempest_tests/tests/api/admin/test_consistency_group_actions.py b/manila_tempest_tests/tests/api/admin/test_consistency_group_actions.py
index b9d349c..8b2a21c 100644
--- a/manila_tempest_tests/tests/api/admin/test_consistency_group_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_consistency_group_actions.py
@@ -32,7 +32,7 @@
super(ConsistencyGroupActionsTest, cls).resource_setup()
# Create 2 share_types
name = data_utils.rand_name("tempest-manila")
- extra_specs = cls.add_required_extra_specs_to_dict()
+ extra_specs = cls.add_extra_specs_to_dict()
share_type = cls.create_share_type(name, extra_specs=extra_specs)
cls.share_type = share_type['share_type']
diff --git a/manila_tempest_tests/tests/api/admin/test_consistency_groups.py b/manila_tempest_tests/tests/api/admin/test_consistency_groups.py
index efa2471..22678e5 100644
--- a/manila_tempest_tests/tests/api/admin/test_consistency_groups.py
+++ b/manila_tempest_tests/tests/api/admin/test_consistency_groups.py
@@ -34,7 +34,7 @@
super(ConsistencyGroupsTest, cls).resource_setup()
# Create 2 share_types
name = data_utils.rand_name("tempest-manila")
- extra_specs = cls.add_required_extra_specs_to_dict()
+ extra_specs = cls.add_extra_specs_to_dict()
share_type = cls.create_share_type(name, extra_specs=extra_specs)
cls.share_type = share_type['share_type']
diff --git a/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py b/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
index 0a0d0f4..a850379 100644
--- a/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_consistency_groups_negative.py
@@ -33,7 +33,7 @@
super(ConsistencyGroupsNegativeTest, cls).resource_setup()
# Create share_type
name = data_utils.rand_name("tempest-manila")
- extra_specs = cls.add_required_extra_specs_to_dict()
+ extra_specs = cls.add_extra_specs_to_dict()
share_type = cls.create_share_type(name, extra_specs=extra_specs)
cls.share_type = share_type['share_type']
diff --git a/manila_tempest_tests/tests/api/admin/test_multi_backend.py b/manila_tempest_tests/tests/api/admin/test_multi_backend.py
index 8b7e078..8aeabc3 100644
--- a/manila_tempest_tests/tests/api/admin/test_multi_backend.py
+++ b/manila_tempest_tests/tests/api/admin/test_multi_backend.py
@@ -48,7 +48,7 @@
}
st = cls.create_share_type(
name=st_name,
- extra_specs=cls.add_required_extra_specs_to_dict(extra_specs))
+ extra_specs=cls.add_extra_specs_to_dict(extra_specs))
cls.sts.append(st["share_type"])
st_id = st["share_type"]["id"]
share_data_list.append({"kwargs": {"share_type_id": st_id}})
diff --git a/manila_tempest_tests/tests/api/admin/test_replication.py b/manila_tempest_tests/tests/api/admin/test_replication.py
index 38546e3..e41c92b 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication.py
@@ -48,7 +48,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
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 377bb41..5b56533 100644
--- a/manila_tempest_tests/tests/api/admin/test_replication_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_replication_actions.py
@@ -49,7 +49,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
diff --git a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
index fe4cc43..aa29828 100644
--- a/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
+++ b/manila_tempest_tests/tests/api/admin/test_scheduler_stats.py
@@ -35,8 +35,7 @@
'share_backend_name': data_utils.rand_name("fake_name"),
}
- extra_specs = cls.add_required_extra_specs_to_dict(
- extra_specs=extra_specs)
+ extra_specs = cls.add_extra_specs_to_dict(extra_specs=extra_specs)
return cls.create_share_type(
name, extra_specs=extra_specs,
client=cls.admin_client)
diff --git a/manila_tempest_tests/tests/api/admin/test_share_manage.py b/manila_tempest_tests/tests/api/admin/test_share_manage.py
index 8100040..f943284 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_manage.py
@@ -54,12 +54,16 @@
'driver_handles_share_servers': False,
'snapshot_support': six.text_type(
CONF.share.capability_snapshot_support),
+ 'create_share_from_snapshot_support': six.text_type(
+ CONF.share.capability_create_share_from_snapshot_support)
}
cls.extra_specs_invalid = {
'storage_protocol': CONF.share.capability_storage_protocol,
'driver_handles_share_servers': True,
'snapshot_support': six.text_type(
CONF.share.capability_snapshot_support),
+ 'create_share_from_snapshot_support': six.text_type(
+ CONF.share.capability_create_share_from_snapshot_support),
}
cls.st = cls.create_share_type(
diff --git a/manila_tempest_tests/tests/api/admin/test_share_types.py b/manila_tempest_tests/tests/api/admin/test_share_types.py
index af354bb..076e4bc 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_types.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_types.py
@@ -31,7 +31,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_share_type_create_delete(self):
name = data_utils.rand_name("tempest-manila")
- extra_specs = self.add_required_extra_specs_to_dict()
+ extra_specs = self.add_extra_specs_to_dict()
# Create share type
st_create = self.shares_v2_client.create_share_type(
@@ -64,7 +64,7 @@
self.skip_if_microversion_not_supported(version)
name = data_utils.rand_name("tempest-manila")
- extra_specs = self.add_required_extra_specs_to_dict({"key": "value", })
+ extra_specs = self.add_extra_specs_to_dict({"key": "value", })
# Create share type
st_create = self.create_share_type(
@@ -89,7 +89,7 @@
self.skip_if_microversion_not_supported(version)
name = data_utils.rand_name("tempest-manila")
- extra_specs = self.add_required_extra_specs_to_dict()
+ extra_specs = self.add_extra_specs_to_dict()
# Create share type
st_create = self.create_share_type(
@@ -117,7 +117,7 @@
# Data
share_name = data_utils.rand_name("share")
shr_type_name = data_utils.rand_name("share-type")
- extra_specs = self.add_required_extra_specs_to_dict({
+ extra_specs = self.add_extra_specs_to_dict({
"storage_protocol": CONF.share.capability_storage_protocol,
})
@@ -144,7 +144,7 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
def test_private_share_type_access(self):
name = data_utils.rand_name("tempest-manila")
- extra_specs = self.add_required_extra_specs_to_dict({"key": "value", })
+ extra_specs = self.add_extra_specs_to_dict({"key": "value", })
project_id = self.shares_client.tenant_id
# Create private share type
diff --git a/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs.py b/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs.py
index 81d130f..f4c21b8 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs.py
@@ -15,19 +15,25 @@
import copy
+import ddt
+from tempest import config
from tempest.lib.common.utils import data_utils
from testtools import testcase as tc
from manila_tempest_tests.tests.api import base
+CONF = config.CONF
+LATEST_MICROVERSION = CONF.share.max_api_microversion
+
+
class ExtraSpecsReadAdminTest(base.BaseSharesAdminTest):
@classmethod
def resource_setup(cls):
super(ExtraSpecsReadAdminTest, cls).resource_setup()
cls.share_type_name = data_utils.rand_name("share-type")
- cls.required_extra_specs = cls.add_required_extra_specs_to_dict()
+ cls.required_extra_specs = cls.add_extra_specs_to_dict()
cls.share_type = cls.create_share_type(
cls.share_type_name, extra_specs=cls.required_extra_specs)
@@ -54,11 +60,12 @@
self.assertEqual(self.expected_extra_specs, es_get_all)
+@ddt.ddt
class ExtraSpecsWriteAdminTest(base.BaseSharesAdminTest):
def setUp(self):
super(ExtraSpecsWriteAdminTest, self).setUp()
- self.required_extra_specs = self.add_required_extra_specs_to_dict()
+ self.required_extra_specs = self.add_extra_specs_to_dict()
self.custom_extra_specs = {"key1": "value1", "key2": "value2"}
self.share_type_name = data_utils.rand_name("share-type")
@@ -109,3 +116,17 @@
get = self.shares_client.get_share_type_extra_specs(self.st_id)
self.assertNotIn('key1', get)
+
+ @tc.attr(base.TAG_POSITIVE, base.TAG_API)
+ @ddt.data(*set(['2.24', LATEST_MICROVERSION]))
+ def test_delete_snapshot_support_extra_spec(self, version):
+ self.skip_if_microversion_not_supported(version)
+ # Delete one extra spec for share type
+ self.shares_v2_client.delete_share_type_extra_spec(
+ self.st_id, 'snapshot_support', version=version)
+
+ # Get metadata
+ share_type_extra_specs = self.shares_client.get_share_type_extra_specs(
+ self.st_id)
+
+ self.assertNotIn('snapshot_support', share_type_extra_specs)
diff --git a/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py b/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py
index 34e5009..85cbc5d 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_types_extra_specs_negative.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import ddt
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from testtools import testcase as tc
@@ -20,11 +21,12 @@
from manila_tempest_tests.tests.api import base
+@ddt.ddt
class ExtraSpecsAdminNegativeTest(base.BaseSharesMixedTest):
def _create_share_type(self):
name = data_utils.rand_name("unique_st_name")
- extra_specs = self.add_required_extra_specs_to_dict({"key": "value"})
+ extra_specs = self.add_extra_specs_to_dict({"key": "value"})
return self.create_share_type(
name, extra_specs=extra_specs, client=self.admin_shares_v2_client)
@@ -35,7 +37,7 @@
lib_exc.Forbidden,
self.shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({"key": "new_value"}))
+ self.add_extra_specs_to_dict({"key": "new_value"}))
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_list_extra_specs_with_user(self):
@@ -67,7 +69,8 @@
share_type = self.shares_v2_client.get_share_type(
st['share_type']['id'])
# Verify a non-admin can only read the required extra-specs
- expected_keys = ['driver_handles_share_servers', 'snapshot_support']
+ expected_keys = ['driver_handles_share_servers', 'snapshot_support',
+ 'create_share_from_snapshot_support']
actual_keys = share_type['share_type']['extra_specs'].keys()
self.assertEqual(sorted(expected_keys), sorted(actual_keys),
'Incorrect extra specs visible to non-admin user; '
@@ -105,7 +108,7 @@
lib_exc.BadRequest,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({too_big_key: "value"}))
+ self.add_extra_specs_to_dict({too_big_key: "value"}))
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_too_long_value_with_creation(self):
@@ -115,7 +118,7 @@
lib_exc.BadRequest,
self.admin_shares_v2_client.create_share_type_extra_specs,
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({"key": too_big_value}))
+ self.add_extra_specs_to_dict({"key": too_big_value}))
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_too_long_value_with_update(self):
@@ -123,12 +126,12 @@
st = self._create_share_type()
self.admin_shares_v2_client.create_share_type_extra_specs(
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({"key": "value"}))
+ self.add_extra_specs_to_dict({"key": "value"}))
self.assertRaises(
lib_exc.BadRequest,
self.admin_shares_v2_client.update_share_type_extra_specs,
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({"key": too_big_value}))
+ self.add_extra_specs_to_dict({"key": too_big_value}))
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_try_set_too_long_value_with_update_of_one_key(self):
@@ -136,7 +139,7 @@
st = self._create_share_type()
self.admin_shares_v2_client.create_share_type_extra_specs(
st["share_type"]["id"],
- self.add_required_extra_specs_to_dict({"key": "value"}))
+ self.add_extra_specs_to_dict({"key": "value"}))
self.assertRaises(
lib_exc.BadRequest,
self.admin_shares_v2_client.update_share_type_extra_spec,
@@ -286,12 +289,12 @@
"driver_handles_share_servers")
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
- def test_try_delete_spec_snapshot_support(self):
+ @ddt.data('2.0', '2.23')
+ def test_try_delete_required_spec_snapshot_support_version(self, version):
+ self.skip_if_microversion_not_supported(version)
st = self._create_share_type()
-
# Try delete extra spec 'snapshot_support'
self.assertRaises(
lib_exc.Forbidden,
self.admin_shares_v2_client.delete_share_type_extra_spec,
- st["share_type"]["id"],
- "snapshot_support")
+ st["share_type"]["id"], "snapshot_support", version=version)
diff --git a/manila_tempest_tests/tests/api/admin/test_share_types_negative.py b/manila_tempest_tests/tests/api/admin/test_share_types_negative.py
index b0fb9db..b3bf855 100644
--- a/manila_tempest_tests/tests/api/admin/test_share_types_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_share_types_negative.py
@@ -24,7 +24,7 @@
def _create_share_type(self):
name = data_utils.rand_name("unique_st_name")
- extra_specs = self.add_required_extra_specs_to_dict({"key": "value"})
+ extra_specs = self.add_extra_specs_to_dict({"key": "value"})
return self.create_share_type(
name, extra_specs=extra_specs, client=self.admin_shares_v2_client)
@@ -66,7 +66,7 @@
self.assertRaises(lib_exc.Conflict,
self.create_share_type,
st["share_type"]["name"],
- extra_specs=self.add_required_extra_specs_to_dict(),
+ extra_specs=self.add_extra_specs_to_dict(),
client=self.admin_shares_v2_client)
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
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 eb049c6..779cd18 100644
--- a/manila_tempest_tests/tests/api/admin/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/admin/test_shares_actions.py
@@ -34,7 +34,7 @@
# create share type for share filtering purposes
cls.st_name = data_utils.rand_name("tempest-st-name")
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{'storage_protocol': CONF.share.capability_storage_protocol})
cls.st = cls.create_share_type(
name=cls.st_name,
@@ -64,20 +64,23 @@
cls.snap = cls.create_snapshot_wait_for_active(
cls.shares[0]["id"], cls.snap_name, cls.snap_desc)
- # create second share from snapshot for purposes of sorting and
- # snapshot filtering
- cls.share_name2 = data_utils.rand_name("tempest-share-name")
- cls.share_desc2 = data_utils.rand_name("tempest-share-description")
- cls.metadata2 = {
- 'foo_key_share_2': 'foo_value_share_2',
- 'bar_key_share_2': 'foo_value_share_2',
- }
- cls.shares.append(cls.create_share(
- name=cls.share_name2,
- description=cls.share_desc2,
- metadata=cls.metadata2,
- snapshot_id=cls.snap['id'],
- ))
+ if CONF.share.capability_create_share_from_snapshot_support:
+
+ # create second share from snapshot for purposes of sorting and
+ # snapshot filtering
+ cls.share_name2 = data_utils.rand_name("tempest-share-name")
+ cls.share_desc2 = data_utils.rand_name(
+ "tempest-share-description")
+ cls.metadata2 = {
+ 'foo_key_share_2': 'foo_value_share_2',
+ 'bar_key_share_2': 'foo_value_share_2',
+ }
+ cls.shares.append(cls.create_share(
+ name=cls.share_name2,
+ description=cls.share_desc2,
+ metadata=cls.metadata2,
+ snapshot_id=cls.snap['id'],
+ ))
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
def test_get_share(self):
@@ -154,7 +157,7 @@
for share in shares:
self.assertDictContainsSubset(
filters['metadata'], share['metadata'])
- if CONF.share.run_snapshot_tests:
+ if CONF.share.capability_create_share_from_snapshot_support:
self.assertFalse(self.shares[1]['id'] in [s['id'] for s in shares])
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@@ -250,8 +253,9 @@
filters['share_network_id'], share['share_network_id'])
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
- @testtools.skipUnless(CONF.share.run_snapshot_tests,
- "Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_list_shares_with_detail_filter_by_snapshot_id(self):
filters = {'snapshot_id': self.snap['id']}
diff --git a/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py b/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
index 3cde3e6..6436e5b 100644
--- a/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
+++ b/manila_tempest_tests/tests/api/admin/test_snapshot_manage.py
@@ -55,6 +55,8 @@
'driver_handles_share_servers': False,
'snapshot_support': six.text_type(
CONF.share.capability_snapshot_support),
+ 'create_share_from_snapshot_support': six.text_type(
+ CONF.share.capability_create_share_from_snapshot_support)
}
cls.st = cls.create_share_type(
diff --git a/manila_tempest_tests/tests/api/admin/test_snapshot_manage_negative.py b/manila_tempest_tests/tests/api/admin/test_snapshot_manage_negative.py
index dfd892c..3825be1 100644
--- a/manila_tempest_tests/tests/api/admin/test_snapshot_manage_negative.py
+++ b/manila_tempest_tests/tests/api/admin/test_snapshot_manage_negative.py
@@ -49,6 +49,8 @@
'driver_handles_share_servers': False,
'snapshot_support': six.text_type(
CONF.share.capability_snapshot_support),
+ 'create_share_from_snapshot_support': six.text_type(
+ CONF.share.capability_create_share_from_snapshot_support),
}
cls.st = cls.create_share_type(
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 7bb727d..dcf0bed 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -727,17 +727,30 @@
return share_type
@staticmethod
- def add_required_extra_specs_to_dict(extra_specs=None):
+ def add_extra_specs_to_dict(extra_specs=None):
+ """Add any required extra-specs to share type dictionary"""
dhss = six.text_type(CONF.share.multitenancy_enabled)
snapshot_support = six.text_type(
CONF.share.capability_snapshot_support)
- required = {
+ create_from_snapshot_support = six.text_type(
+ CONF.share.capability_create_share_from_snapshot_support)
+
+ extra_specs_dict = {
"driver_handles_share_servers": dhss,
- "snapshot_support": snapshot_support,
}
+
+ optional = {
+ "snapshot_support": snapshot_support,
+ "create_share_from_snapshot_support": create_from_snapshot_support,
+ }
+ # NOTE(gouthamr): In micro-versions < 2.24, snapshot_support is a
+ # required extra-spec
+ extra_specs_dict.update(optional)
+
if extra_specs:
- required.update(extra_specs)
- return required
+ extra_specs_dict.update(extra_specs)
+
+ return extra_specs_dict
@classmethod
def clear_isolated_creds(cls, creds=None):
diff --git a/manila_tempest_tests/tests/api/test_replication.py b/manila_tempest_tests/tests/api/test_replication.py
index 0bdb7ad..1738e87 100644
--- a/manila_tempest_tests/tests/api/test_replication.py
+++ b/manila_tempest_tests/tests/api/test_replication.py
@@ -51,7 +51,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
@@ -307,7 +307,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
diff --git a/manila_tempest_tests/tests/api/test_replication_negative.py b/manila_tempest_tests/tests/api/test_replication_negative.py
index cfbf210..48b8d5c 100644
--- a/manila_tempest_tests/tests/api/test_replication_negative.py
+++ b/manila_tempest_tests/tests/api/test_replication_negative.py
@@ -48,7 +48,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
@@ -80,7 +80,7 @@
# Create share without replication type
share_type = self.create_share_type(
data_utils.rand_name(constants.TEMPEST_MANILA_PREFIX),
- extra_specs=self.add_required_extra_specs_to_dict(),
+ extra_specs=self.add_extra_specs_to_dict(),
client=self.admin_client)["share_type"]
share = self.create_share(share_type_id=share_type["id"])
self.assertRaises(lib_exc.BadRequest,
diff --git a/manila_tempest_tests/tests/api/test_replication_snapshots.py b/manila_tempest_tests/tests/api/test_replication_snapshots.py
index e3081cc..331437c 100644
--- a/manila_tempest_tests/tests/api/test_replication_snapshots.py
+++ b/manila_tempest_tests/tests/api/test_replication_snapshots.py
@@ -49,7 +49,7 @@
cls.share_zone = cls.zones[0]
cls.replica_zone = cls.zones[-1]
- cls.extra_specs = cls.add_required_extra_specs_to_dict(
+ cls.extra_specs = cls.add_extra_specs_to_dict(
{"replication_type": cls.replication_type})
share_type = cls.create_share_type(
name,
@@ -86,7 +86,12 @@
snapshot = self.create_snapshot_wait_for_active(share["id"])
self.promote_share_replica(share_replica['id'])
self.delete_share_replica(original_replica['id'])
- self.create_share(snapshot_id=snapshot['id'])
+
+ snapshot = self.shares_v2_client.get_snapshot(snapshot['id'])
+ self.assertEqual(constants.STATUS_AVAILABLE, snapshot['status'])
+
+ if CONF.share.capability_create_share_from_snapshot_support:
+ self.create_share(snapshot_id=snapshot['id'])
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_snapshot_before_share_replica(self):
@@ -116,7 +121,12 @@
self.promote_share_replica(share_replica['id'])
self.delete_share_replica(original_replica['id'])
- self.create_share(snapshot_id=snapshot['id'])
+
+ snapshot = self.shares_v2_client.get_snapshot(snapshot['id'])
+ self.assertEqual(constants.STATUS_AVAILABLE, snapshot['status'])
+
+ if CONF.share.capability_create_share_from_snapshot_support:
+ self.create_share(snapshot_id=snapshot['id'])
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_snapshot_before_and_after_share_replica(self):
@@ -152,8 +162,15 @@
# still being created successfully.
self.delete_share_replica(original_replica['id'])
- self.create_share(snapshot_id=snapshot1['id'])
- self.create_share(snapshot_id=snapshot2['id'])
+ snapshot1 = self.shares_v2_client.get_snapshot(snapshot1['id'])
+ self.assertEqual(constants.STATUS_AVAILABLE, snapshot1['status'])
+
+ snapshot2 = self.shares_v2_client.get_snapshot(snapshot2['id'])
+ self.assertEqual(constants.STATUS_AVAILABLE, snapshot2['status'])
+
+ if CONF.share.capability_create_share_from_snapshot_support:
+ self.create_share(snapshot_id=snapshot1['id'])
+ self.create_share(snapshot_id=snapshot2['id'])
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_delete_snapshot_after_adding_replica(self):
@@ -176,6 +193,9 @@
snapshot_id=snapshot["id"])
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_create_replica_from_snapshot_share(self):
"""Test replica for a share that was created from snapshot."""
diff --git a/manila_tempest_tests/tests/api/test_share_types_negative.py b/manila_tempest_tests/tests/api/test_share_types_negative.py
index 9c7883b..8a24325 100644
--- a/manila_tempest_tests/tests/api/test_share_types_negative.py
+++ b/manila_tempest_tests/tests/api/test_share_types_negative.py
@@ -25,7 +25,7 @@
@classmethod
def _create_share_type(cls):
name = data_utils.rand_name("unique_st_name")
- extra_specs = cls.add_required_extra_specs_to_dict()
+ extra_specs = cls.add_extra_specs_to_dict()
return cls.create_share_type(
name, extra_specs=extra_specs,
client=cls.admin_client)
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index af4a54a..d78c913 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -92,6 +92,12 @@
detailed_elements.add('user_id')
self.assertTrue(detailed_elements.issubset(share.keys()), msg)
+ # In v 2.24 and beyond, we add create_share_from_snapshot_support in
+ # show/create/manage share echo.
+ if utils.is_microversion_supported('2.24'):
+ detailed_elements.add('create_share_from_snapshot_support')
+ self.assertTrue(detailed_elements.issubset(share.keys()), msg)
+
# Delete share
self.shares_v2_client.delete_share(share['id'])
self.shares_v2_client.wait_for_resource_deletion(share_id=share['id'])
@@ -136,6 +142,9 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_create_share_from_snapshot(self):
# If multitenant driver used, share_network will be provided by default
@@ -164,9 +173,13 @@
"Only for multitenancy.")
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_create_share_from_snapshot_share_network_not_provided(self):
# We expect usage of share network from parent's share
- # when creating share from snapshot using multitenant driver.
+ # when creating share from snapshot using a driver that supports
+ # multi-tenancy.
# get parent share
parent = self.shares_client.get_share(self.share["id"])
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index da44c7c..d03df33 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -58,20 +58,23 @@
cls.snap = cls.create_snapshot_wait_for_active(
cls.shares[0]["id"], cls.snap_name, cls.snap_desc)
- # create second share from snapshot for purposes of sorting and
- # snapshot filtering
- cls.share_name2 = data_utils.rand_name("tempest-share-name")
- cls.share_desc2 = data_utils.rand_name("tempest-share-description")
- cls.metadata2 = {
- 'foo_key_share_2': 'foo_value_share_2',
- 'bar_key_share_2': 'foo_value_share_2',
- }
- cls.shares.append(cls.create_share(
- name=cls.share_name2,
- description=cls.share_desc2,
- metadata=cls.metadata2,
- snapshot_id=cls.snap['id'],
- ))
+ if CONF.share.capability_create_share_from_snapshot_support:
+
+ # create second share from snapshot for purposes of sorting and
+ # snapshot filtering
+ cls.share_name2 = data_utils.rand_name("tempest-share-name")
+ cls.share_desc2 = data_utils.rand_name(
+ "tempest-share-description")
+ cls.metadata2 = {
+ 'foo_key_share_2': 'foo_value_share_2',
+ 'bar_key_share_2': 'foo_value_share_2',
+ }
+ cls.shares.append(cls.create_share(
+ name=cls.share_name2,
+ description=cls.share_desc2,
+ metadata=cls.metadata2,
+ snapshot_id=cls.snap['id'],
+ ))
def _get_share(self, version):
@@ -101,6 +104,8 @@
expected_keys.append("replication_type")
if utils.is_microversion_ge(version, '2.16'):
expected_keys.append("user_id")
+ if utils.is_microversion_ge(version, '2.24'):
+ expected_keys.append("create_share_from_snapshot_support")
actual_keys = list(share.keys())
[self.assertIn(key, actual_keys) for key in expected_keys]
@@ -158,6 +163,11 @@
self._get_share('2.16')
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+ @utils.skip_if_microversion_not_supported('2.24')
+ def test_get_share_with_create_share_from_snapshot_support(self):
+ self._get_share('2.24')
+
+ @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
def test_list_shares(self):
# list shares
@@ -201,6 +211,8 @@
keys.append("replication_type")
if utils.is_microversion_ge(version, '2.16'):
keys.append("user_id")
+ if utils.is_microversion_ge(version, '2.24'):
+ keys.append("create_share_from_snapshot_support")
[self.assertIn(key, sh.keys()) for sh in shares for key in keys]
# our shares in list and have no duplicates
@@ -248,6 +260,11 @@
self._list_shares_with_detail('2.16')
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
+ def test_list_shares_with_detail_and_create_share_from_snapshot_support(
+ self):
+ self._list_shares_with_detail('2.24')
+
+ @tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
def test_list_shares_with_detail_filter_by_metadata(self):
filters = {'metadata': self.metadata}
@@ -259,7 +276,7 @@
for share in shares:
self.assertDictContainsSubset(
filters['metadata'], share['metadata'])
- if CONF.share.run_snapshot_tests:
+ if CONF.share.capability_create_share_from_snapshot_support:
self.assertFalse(self.shares[1]['id'] in [s['id'] for s in shares])
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@@ -294,6 +311,9 @@
@tc.attr(base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND)
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_list_shares_with_detail_filter_by_snapshot_id(self):
filters = {'snapshot_id': self.snap['id']}
diff --git a/manila_tempest_tests/tests/api/test_shares_negative.py b/manila_tempest_tests/tests/api/test_shares_negative.py
index 7c5619e..42204e1 100644
--- a/manila_tempest_tests/tests/api/test_shares_negative.py
+++ b/manila_tempest_tests/tests/api/test_shares_negative.py
@@ -60,6 +60,9 @@
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_create_share_from_snap_with_less_size(self):
# requires minimum 5Gb available space
@@ -96,7 +99,13 @@
"Only for multitenancy.")
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
+ @testtools.skipUnless(
+ CONF.share.capability_create_share_from_snapshot_support,
+ "Create share from snapshot tests are disabled.")
def test_create_share_from_snap_with_different_share_network(self):
+ # We can't create a share from a snapshot whose base share does not
+ # have 'create_share_from_snapshot_support'.
+
# create share
share = self.create_share(cleanup_in_class=False)