Add 'snapshot_support' attr to share details
Recently was introduced feature where snapshots become optional.
Share started have new attr "snapshot_support". But it is absent in
share payload and, hence, can not be used outside of Manila.
Also, fix lost import of translation function for related snapshot API.
Change-Id: Iddb0cf1e046b9d480a22e79b33c8674a2405362e
Closes-Bug: #1491345
Closes-Bug: #1491346
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 591347e..825b6e0 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -288,7 +288,7 @@
share_network_id=None, share_type_id=None,
consistency_group_id=None, client=None,
cleanup_in_class=True, is_public=False, **kwargs):
- client = client or cls.shares_client
+ client = client or cls.shares_v2_client
description = description or "Tempest's share"
share_network_id = share_network_id or client.share_network_id or None
metadata = metadata or {}
@@ -358,7 +358,7 @@
"Expected only 'args' and 'kwargs' keys. "
"Provided %s" % list(d))
d["kwargs"]["client"] = d["kwargs"].get(
- "client", cls.shares_client)
+ "client", cls.shares_v2_client)
d["share"] = cls._create_share(*d["args"], **d["kwargs"])
d["cnt"] = 0
d["available"] = False
diff --git a/manila_tempest_tests/tests/api/test_shares.py b/manila_tempest_tests/tests/api/test_shares.py
index b5c7e01..27ce1c0 100644
--- a/manila_tempest_tests/tests/api/test_shares.py
+++ b/manila_tempest_tests/tests/api/test_shares.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import six
from tempest import config # noqa
from tempest import test # noqa
from tempest_lib import exceptions as lib_exc # noqa
@@ -35,17 +36,19 @@
raise cls.skipException(message)
cls.share = cls.create_share(cls.protocol)
- @test.attr(type=["gate", ])
- def test_create_delete_share(self):
+ def _create_delete_share(self, version):
# create share
- share = self.create_share(self.protocol)
+ share = self.create_share(
+ self.protocol, version=six.text_type(version))
detailed_elements = {'name', 'id', 'availability_zone',
'description', 'export_location', 'project_id',
'host', 'created_at', 'share_proto', 'metadata',
'size', 'snapshot_id', 'share_network_id',
'status', 'share_type', 'volume_type', 'links',
'is_public'}
+ if version > 2.2:
+ detailed_elements.add('snapshot_support')
self.assertTrue(detailed_elements.issubset(share.keys()),
'At least one expected element missing from share '
'response. Expected %(expected)s, got %(actual)s.' % {
@@ -61,6 +64,14 @@
share['id'])
@test.attr(type=["gate", ])
+ def test_create_delete_share_without_snapshot_support_feature(self):
+ self._create_delete_share(2.1)
+
+ @test.attr(type=["gate", ])
+ def test_create_delete_share_with_snapshot_support_feature(self):
+ self._create_delete_share(2.2)
+
+ @test.attr(type=["gate", ])
@testtools.skipUnless(CONF.share.run_snapshot_tests,
"Snapshot tests are disabled.")
def test_create_delete_snapshot(self):
diff --git a/manila_tempest_tests/tests/api/test_shares_actions.py b/manila_tempest_tests/tests/api/test_shares_actions.py
index 94754a8..58ddbfe 100644
--- a/manila_tempest_tests/tests/api/test_shares_actions.py
+++ b/manila_tempest_tests/tests/api/test_shares_actions.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import six
from tempest import config # noqa
from tempest import test # noqa
from tempest_lib.common.utils import data_utils # noqa
@@ -71,34 +72,45 @@
snapshot_id=cls.snap['id'],
))
- @test.attr(type=["gate", ])
- def test_get_share(self):
+ def _get_share(self, version):
# get share
- share = self.shares_client.get_share(self.shares[0]['id'])
+ share = self.shares_v2_client.get_share(
+ self.shares[0]['id'], version=six.text_type(version))
# verify keys
expected_keys = ["status", "description", "links", "availability_zone",
"created_at", "export_location", "share_proto",
"name", "snapshot_id", "id", "size"]
- actual_keys = share.keys()
+ if version > 2.1:
+ expected_keys.append("snapshot_support")
+ actual_keys = list(share.keys())
[self.assertIn(key, actual_keys) for key in expected_keys]
# verify values
msg = "Expected name: '%s', actual name: '%s'" % (self.share_name,
share["name"])
- self.assertEqual(self.share_name, str(share["name"]), msg)
+ self.assertEqual(self.share_name, six.text_type(share["name"]), msg)
msg = "Expected description: '%s', "\
"actual description: '%s'" % (self.share_desc,
share["description"])
- self.assertEqual(self.share_desc, str(share["description"]), msg)
+ self.assertEqual(
+ self.share_desc, six.text_type(share["description"]), msg)
msg = "Expected size: '%s', actual size: '%s'" % (self.share_size,
share["size"])
self.assertEqual(self.share_size, int(share["size"]), msg)
@test.attr(type=["gate", ])
+ def test_get_share_no_snapshot_support_key(self):
+ self._get_share(2.1)
+
+ @test.attr(type=["gate", ])
+ def test_get_share_with_snapshot_support_key(self):
+ self._get_share(2.2)
+
+ @test.attr(type=["gate", ])
def test_list_shares(self):
# list shares
@@ -114,11 +126,11 @@
msg = "expected id lists %s times in share list" % (len(gen))
self.assertEqual(1, len(gen), msg)
- @test.attr(type=["gate", ])
- def test_list_shares_with_detail(self):
+ def _list_shares_with_detail(self, version):
# list shares
- shares = self.shares_client.list_shares_with_detail()
+ shares = self.shares_v2_client.list_shares_with_detail(
+ version=six.text_type(version))
# verify keys
keys = [
@@ -126,6 +138,8 @@
"created_at", "export_location", "share_proto", "host",
"name", "snapshot_id", "id", "size", "project_id",
]
+ if version > 2.1:
+ keys.append("snapshot_support")
[self.assertIn(key, sh.keys()) for sh in shares for key in keys]
# our shares in list and have no duplicates
@@ -135,6 +149,14 @@
self.assertEqual(1, len(gen), msg)
@test.attr(type=["gate", ])
+ def test_list_shares_with_detail_without_snapshot_support_key(self):
+ self._list_shares_with_detail(2.1)
+
+ @test.attr(type=["gate", ])
+ def test_list_shares_with_detail_and_snapshot_support_key(self):
+ self._list_shares_with_detail(2.2)
+
+ @test.attr(type=["gate", ])
def test_list_shares_with_detail_filter_by_metadata(self):
filters = {'metadata': self.metadata}