Add test for showing snapshot metadata item
This patch adds test for the missing API (volume v2): show specific metadata item for a snapshot. Including: [1] Add show snapshot metadata item API to v2 snapshots_client [2] Add unit test for the API [3] Modify test case: test_update_snapshot_metadata_item [4] Add release note According defcore(interop) patch is: I672bbcb9983e7a3ace7769722d6ff97f7bc0ccc8 Change-Id: I3697406e5541bbdb191e4d6e63831be31b471e78
This commit is contained in:
parent
479863dd47
commit
6971907655
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add show snapshot metadata item API to v2 snapshots_client library.
|
||||
This feature enables the possibility to show a snapshot's metadata for
|
||||
a specific key.
|
@ -81,7 +81,7 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
|
||||
self.assertNotIn("key3", body)
|
||||
|
||||
@decorators.idempotent_id('e8ff85c5-8f97-477f-806a-3ac364a949ed')
|
||||
def test_update_snapshot_metadata_item(self):
|
||||
def test_update_show_snapshot_metadata_item(self):
|
||||
# Update metadata item for the snapshot
|
||||
metadata = {"key1": "value1",
|
||||
"key2": "value2",
|
||||
@ -101,6 +101,12 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
|
||||
body = self.snapshots_client.update_snapshot_metadata_item(
|
||||
self.snapshot['id'], "key3", meta=update_item)['meta']
|
||||
self.assertEqual(update_item, body)
|
||||
|
||||
# Get a specific metadata item of the snapshot
|
||||
body = self.snapshots_client.show_snapshot_metadata_item(
|
||||
self.snapshot['id'], "key3")['meta']
|
||||
self.assertEqual({"key3": expect['key3']}, body)
|
||||
|
||||
# Get the metadata of the snapshot
|
||||
body = self.snapshots_client.show_snapshot_metadata(
|
||||
self.snapshot['id'])['metadata']
|
||||
|
@ -164,6 +164,14 @@ class SnapshotsClient(rest_client.RestClient):
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_snapshot_metadata_item(self, snapshot_id, id):
|
||||
"""Show metadata item for the snapshot."""
|
||||
url = "snapshots/%s/metadata/%s" % (snapshot_id, id)
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_snapshot_metadata_item(self, snapshot_id, id, **kwargs):
|
||||
"""Update metadata item for the snapshot."""
|
||||
# TODO(piyush): Current api-site doesn't contain this API description.
|
||||
|
@ -72,6 +72,12 @@ class TestSnapshotsClient(base.BaseServiceTest):
|
||||
]
|
||||
}
|
||||
|
||||
FAKE_SNAPSHOT_METADATA_ITEM = {
|
||||
"meta": {
|
||||
"key1": "value1"
|
||||
}
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestSnapshotsClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
@ -142,6 +148,15 @@ class TestSnapshotsClient(base.BaseServiceTest):
|
||||
self.FAKE_INFO_SNAPSHOT,
|
||||
bytes_body, volume_type_id="cbc36478b0bd8e67e89")
|
||||
|
||||
def _test_show_snapshot_metadata_item(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.show_snapshot_metadata_item,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_SNAPSHOT_METADATA_ITEM,
|
||||
bytes_body,
|
||||
snapshot_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5",
|
||||
id="key1")
|
||||
|
||||
def test_create_snapshot_with_str_body(self):
|
||||
self._test_create_snapshot()
|
||||
|
||||
@ -184,6 +199,12 @@ class TestSnapshotsClient(base.BaseServiceTest):
|
||||
def test_update_snapshot_metadata_with_bytes_body(self):
|
||||
self._test_update_snapshot_metadata(bytes_body=True)
|
||||
|
||||
def test_show_snapshot_metadata_item_with_str_body(self):
|
||||
self._test_show_snapshot_metadata_item()
|
||||
|
||||
def test_show_snapshot_metadata_item_with_bytes_body(self):
|
||||
self._test_show_snapshot_metadata_item(bytes_body=True)
|
||||
|
||||
def test_force_delete_snapshot(self):
|
||||
self.check_service_client_function(
|
||||
self.client.force_delete_snapshot,
|
||||
|
Loading…
x
Reference in New Issue
Block a user