Merge "Add update-snapshot test"
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 0328b44..6b186e5 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -38,7 +38,7 @@
super(VolumesSnapshotTest, cls).tearDownClass()
@attr(type='gate')
- def test_snapshot_create_get_list_delete(self):
+ def test_snapshot_create_get_list_update_delete(self):
# Create a snapshot
s_name = rand_name('snap')
snapshot = self.create_snapshot(self.volume_origin['id'],
@@ -58,6 +58,24 @@
snaps_data = [(f['id'], f['display_name']) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
+ # Updates snapshot with new values
+ new_s_name = rand_name('new-snap')
+ new_desc = 'This is the new description of snapshot.'
+ resp, update_snapshot = \
+ self.snapshots_client.update_snapshot(snapshot['id'],
+ display_name=new_s_name,
+ display_description=new_desc)
+ # Assert response body for update_snapshot method
+ self.assertEqual(200, resp.status)
+ self.assertEqual(new_s_name, update_snapshot['display_name'])
+ self.assertEqual(new_desc, update_snapshot['display_description'])
+ # Assert response body for get_snapshot method
+ resp, updated_snapshot = \
+ self.snapshots_client.get_snapshot(snapshot['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(new_s_name, updated_snapshot['display_name'])
+ self.assertEqual(new_desc, updated_snapshot['display_description'])
+
# Delete the snapshot
self.snapshots_client.delete_snapshot(snapshot['id'])
self.assertEqual(200, resp.status)
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index ce2da90..10ba3fd 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -76,6 +76,14 @@
body = json.loads(body)
return resp, body['snapshot']
+ def update_snapshot(self, snapshot_id, **kwargs):
+ """Updates a snapshot."""
+ put_body = json.dumps({'snapshot': kwargs})
+ resp, body = self.put('snapshots/%s' % snapshot_id, put_body,
+ self.headers)
+ body = json.loads(body)
+ return resp, body['snapshot']
+
# NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
resp, body = self.get_snapshot(snapshot_id)
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 3596017..b7ba56b 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -90,6 +90,16 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
+ def update_snapshot(self, snapshot_id, **kwargs):
+ """Updates a snapshot."""
+ put_body = Element("snapshot", xmlns=XMLNS_11, **kwargs)
+
+ resp, body = self.put('snapshots/%s' % snapshot_id,
+ str(Document(put_body)),
+ self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
# NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
resp, body = self.get_snapshot(snapshot_id)