Merge "Full response for Volume SnapshotsClient methods"
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index c860b4b..66973a7 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -41,8 +41,8 @@
# Create a test shared snapshot for tests
snap_name = data_utils.rand_name(cls.__name__ + '-Snapshot')
params = {cls.name_field: snap_name}
- cls.snapshot = \
- cls.client.create_snapshot(cls.volume['id'], **params)
+ cls.snapshot = cls.client.create_snapshot(
+ cls.volume['id'], **params)['snapshot']
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
'available')
@@ -86,8 +86,8 @@
status = 'creating'
self.admin_snapshots_client.\
reset_snapshot_status(self.snapshot['id'], status)
- snapshot_get \
- = self.admin_snapshots_client.show_snapshot(self.snapshot['id'])
+ snapshot_get = self.admin_snapshots_client.show_snapshot(
+ self.snapshot['id'])['snapshot']
self.assertEqual(status, snapshot_get['status'])
@test.idempotent_id('41288afd-d463-485e-8f6e-4eea159413eb')
@@ -103,8 +103,8 @@
progress_alias = self._get_progress_alias()
self.client.update_snapshot_status(self.snapshot['id'],
status, progress)
- snapshot_get \
- = self.admin_snapshots_client.show_snapshot(self.snapshot['id'])
+ snapshot_get = self.admin_snapshots_client.show_snapshot(
+ self.snapshot['id'])['snapshot']
self.assertEqual(status, snapshot_get['status'])
self.assertEqual(progress, snapshot_get[progress_alias])
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index f9dbb93..c987100 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -122,8 +122,8 @@
@classmethod
def create_snapshot(cls, volume_id=1, **kwargs):
"""Wrapper utility that returns a test snapshot."""
- snapshot = cls.snapshots_client.create_snapshot(volume_id,
- **kwargs)
+ snapshot = cls.snapshots_client.create_snapshot(
+ volume_id, **kwargs)['snapshot']
cls.snapshots.append(snapshot)
cls.snapshots_client.wait_for_snapshot_status(snapshot['id'],
'available')
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 641317a..ce6ba90 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -48,16 +48,18 @@
"key3": "value3"}
expected = {"key2": "value2",
"key3": "value3"}
- body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
+ body = self.client.create_snapshot_metadata(
+ self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the snapshot
self.client.delete_snapshot_metadata_item(
self.snapshot_id, "key1")
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(expected.items()))
self.assertNotIn("key1", body)
@@ -70,17 +72,19 @@
update = {"key3": "value3_update",
"key4": "value4"}
# Create metadata for the snapshot
- body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
+ body = self.client.create_snapshot_metadata(
+ self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
body = self.client.update_snapshot_metadata(
- self.snapshot_id, update)
+ self.snapshot_id, update)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertEqual(update, body)
@test.idempotent_id('e8ff85c5-8f97-477f-806a-3ac364a949ed')
@@ -94,16 +98,18 @@
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the snapshot
- body = self.client.create_snapshot_metadata(self.snapshot_id,
- metadata)
+ body = self.client.create_snapshot_metadata(
+ self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
body = self.client.update_snapshot_metadata_item(
- self.snapshot_id, "key3", update_item)
+ self.snapshot_id, "key3", update_item)['meta']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(self.snapshot_id)
+ body = self.client.show_snapshot_metadata(
+ self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 5860501..058e220 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -49,12 +49,11 @@
and validates result.
"""
if with_detail:
- fetched_snap_list = \
- self.snapshots_client.\
- list_snapshots(detail=True, params=params)
+ fetched_snap_list = self.snapshots_client.list_snapshots(
+ detail=True, params=params)['snapshots']
else:
- fetched_snap_list = \
- self.snapshots_client.list_snapshots(params=params)
+ fetched_snap_list = self.snapshots_client.list_snapshots(
+ params=params)['snapshots']
# Validating params of fetched snapshots
for snap in fetched_snap_list:
@@ -99,14 +98,15 @@
snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Get the snap and check for some of its details
- snap_get = self.snapshots_client.show_snapshot(snapshot['id'])
+ snap_get = self.snapshots_client.show_snapshot(
+ snapshot['id'])['snapshot']
self.assertEqual(self.volume_origin['id'],
snap_get['volume_id'],
"Referred volume origin mismatch")
# Compare also with the output from the list action
tracking_data = (snapshot['id'], snapshot[self.name_field])
- snaps_list = self.snapshots_client.list_snapshots()
+ snaps_list = self.snapshots_client.list_snapshots()['snapshots']
snaps_data = [(f['id'], f[self.name_field]) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
@@ -115,14 +115,14 @@
new_desc = 'This is the new description of snapshot.'
params = {self.name_field: new_s_name,
self.descrip_field: new_desc}
- update_snapshot = \
- self.snapshots_client.update_snapshot(snapshot['id'], **params)
+ update_snapshot = self.snapshots_client.update_snapshot(
+ snapshot['id'], **params)['snapshot']
# Assert response body for update_snapshot method
self.assertEqual(new_s_name, update_snapshot[self.name_field])
self.assertEqual(new_desc, update_snapshot[self.descrip_field])
# Assert response body for show_snapshot method
- updated_snapshot = \
- self.snapshots_client.show_snapshot(snapshot['id'])
+ updated_snapshot = self.snapshots_client.show_snapshot(
+ snapshot['id'])['snapshot']
self.assertEqual(new_s_name, updated_snapshot[self.name_field])
self.assertEqual(new_desc, updated_snapshot[self.descrip_field])
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 8b5a595..a7bdba3 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -80,12 +80,13 @@
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot')
_, snapshot = self.snapshots_client.create_snapshot(
- volume['id'], display_name=snapshot_name)
+ volume['id'], display_name=snapshot_name)['snapshot']
def cleaner():
self.snapshots_client.delete_snapshot(snapshot['id'])
try:
- while self.snapshots_client.show_snapshot(snapshot['id']):
+ while self.snapshots_client.show_snapshot(
+ snapshot['id'])['snapshot']:
time.sleep(1)
except lib_exc.NotFound:
pass
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 03f80d5..f69b7d2 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -69,7 +69,7 @@
snap = self.snapshots_client.create_snapshot(
volume_id=vol_id,
force=True,
- display_name=snap_name)
+ display_name=snap_name)['snapshot']
self.addCleanup(
self.snapshots_client.wait_for_resource_deletion, snap['id'])
self.addCleanup(self.snapshots_client.delete_snapshot, snap['id'])
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index fa1f9dd..3fcf18c 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -40,7 +40,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBodyList(resp, body['snapshots'])
+ return service_client.ResponseBody(resp, body)
def show_snapshot(self, snapshot_id):
"""Returns the details of a single snapshot."""
@@ -48,7 +48,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['snapshot'])
+ return service_client.ResponseBody(resp, body)
def create_snapshot(self, volume_id, **kwargs):
"""
@@ -64,7 +64,7 @@
resp, body = self.post('snapshots', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
- return service_client.ResponseBody(resp, body['snapshot'])
+ return service_client.ResponseBody(resp, body)
def update_snapshot(self, snapshot_id, **kwargs):
"""Updates a snapshot."""
@@ -72,11 +72,11 @@
resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['snapshot'])
+ return service_client.ResponseBody(resp, body)
# NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
- body = self.show_snapshot(snapshot_id)
+ body = self.show_snapshot(snapshot_id)['snapshot']
status = body['status']
# NOTE(afazekas): snapshot can reach an "error"
# state in a "normal" lifecycle
@@ -155,7 +155,7 @@
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def show_snapshot_metadata(self, snapshot_id):
"""Get metadata of the snapshot."""
@@ -163,7 +163,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def update_snapshot_metadata(self, snapshot_id, metadata):
"""Update metadata for the snapshot."""
@@ -172,7 +172,7 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['metadata'])
+ return service_client.ResponseBody(resp, body)
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
"""Update metadata item for the snapshot."""
@@ -181,7 +181,7 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body['meta'])
+ return service_client.ResponseBody(resp, body)
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index c60f45a..9e21326 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -81,8 +81,8 @@
# We have to delete snapshots first or
# volume deletion may block
- _, snaps = admin_manager.snapshots_client.\
- list_snapshots(params={"all_tenants": True})
+ _, snaps = admin_manager.snapshots_client.list_snapshots(
+ params={"all_tenants": True})['snapshots']
LOG.info("Cleanup::remove %s snapshots" % len(snaps))
for v in snaps:
try: