Change compute volume client to return one value and update tests
This included the volume extensions client and the volume-related methods
in the servers client.
Partially implements: blueprint clients-return-one-value
Change-Id: Ice07e38037665def7a8e2982be85ce4df3726311
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 9d1ea9e..7ccec8e 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -124,12 +124,12 @@
device = '/dev/%s' % CONF.compute.volume_device_name
resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, volume = volumes_client.create_volume(1)
+ volume = volumes_client.create_volume(1)
self.addCleanup(volumes_client.delete_volume, volume['id'])
volumes_client.wait_for_volume_status(volume['id'], 'available')
- resp, body = self.client.attach_volume(server['id'],
- volume['id'],
- device=device)
+ self.client.attach_volume(server['id'],
+ volume['id'],
+ device=device)
volumes_client.wait_for_volume_status(volume['id'], 'in-use')
resp, _ = self.client.delete_server(server['id'])
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index f1e2f7f..c01a95c 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -49,7 +49,7 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
def _create_volume(self):
- resp, volume = self.volumes_extensions_client.create_volume(
+ volume = self.volumes_extensions_client.create_volume(
1, display_name=data_utils.rand_name(
self.__class__.__name__ + '_volume'))
self.addCleanup(self.delete_volume, volume['id'])
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index 180dffd..eb71d6d 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -77,7 +77,7 @@
return server_id
def _volume_clean_up(self, server_id, volume_id):
- resp, body = self.volumes_client.get_volume(volume_id)
+ body = self.volumes_client.get_volume(volume_id)
if body['status'] == 'in-use':
self.servers_client.detach_volume(server_id, volume_id)
self.volumes_client.wait_for_volume_status(volume_id, 'available')
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 7fef52f..40b93a8 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -68,7 +68,7 @@
'available')
# Attach the volume to the server
- _, self.attachment = self.servers_client.attach_volume(
+ self.attachment = self.servers_client.attach_volume(
self.server['id'],
self.volume['id'],
device='/dev/%s' % self.device)
@@ -116,13 +116,13 @@
# Create Server, Volume and attach that Volume to Server
self._create_and_attach()
# List Volume attachment of the server
- _, body = self.servers_client.list_volume_attachments(
+ body = self.servers_client.list_volume_attachments(
self.server['id'])
self.assertEqual(1, len(body))
self.assertIn(self.attachment, body)
# Get Volume attachment of the server
- _, body = self.servers_client.get_volume_attachment(
+ body = self.servers_client.get_volume_attachment(
self.server['id'],
self.attachment['id'])
self.assertEqual(self.server['id'], body['serverId'])
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index d441427..53f5ac0 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -41,11 +41,10 @@
v_name = data_utils.rand_name('Volume-%s-') % self._interface
metadata = {'Type': 'work'}
# Create volume
- resp, volume = self.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
+ volume = self.client.create_volume(size=1,
+ display_name=v_name,
+ metadata=metadata)
self.addCleanup(self.delete_volume, volume['id'])
- self.assertEqual(200, resp.status)
self.assertIn('id', volume)
self.assertIn('displayName', volume)
self.assertEqual(volume['displayName'], v_name,
@@ -56,8 +55,7 @@
# Wait for Volume status to become ACTIVE
self.client.wait_for_volume_status(volume['id'], 'available')
# GET Volume
- resp, fetched_volume = self.client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
+ fetched_volume = self.client.get_volume(volume['id'])
# Verification of details of fetched Volume
self.assertEqual(v_name,
fetched_volume['displayName'],
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index 6bf9519..c0ac99b 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -45,11 +45,11 @@
v_name = data_utils.rand_name('volume-%s' % cls._interface)
metadata = {'Type': 'work'}
try:
- resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
+ volume = cls.client.create_volume(size=1,
+ display_name=v_name,
+ metadata=metadata)
cls.client.wait_for_volume_status(volume['id'], 'available')
- resp, volume = cls.client.get_volume(volume['id'])
+ volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
except Exception:
@@ -79,8 +79,7 @@
def test_volume_list(self):
# Should return the list of Volumes
# Fetch all Volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_volumes()
# Now check if all the Volumes created in setup are in fetched list
missing_volumes = [
v for v in self.volume_list if v not in fetched_list
@@ -95,8 +94,7 @@
def test_volume_list_with_details(self):
# Should return the list of Volumes with details
# Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_volumes_with_detail()
# Now check if all the Volumes created in setup are in fetched list
missing_volumes = [
v for v in self.volume_list if v not in fetched_list
@@ -111,8 +109,7 @@
def test_volume_list_param_limit(self):
# Return the list of volumes based on limit set
params = {'limit': 2}
- resp, fetched_vol_list = self.client.list_volumes(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes(params=params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volumes by limit set")
@@ -121,9 +118,7 @@
def test_volume_list_with_detail_param_limit(self):
# Return the list of volumes with details based on limit set.
params = {'limit': 2}
- resp, fetched_vol_list = \
- self.client.list_volumes_with_detail(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes_with_detail(params=params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volume details by limit set")
@@ -132,10 +127,9 @@
def test_volume_list_param_offset_and_limit(self):
# Return the list of volumes based on offset and limit set.
# get all volumes list
- response, all_vol_list = self.client.list_volumes()
+ all_vol_list = self.client.list_volumes()
params = {'offset': 1, 'limit': 1}
- resp, fetched_vol_list = self.client.list_volumes(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes(params=params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
@@ -150,11 +144,9 @@
def test_volume_list_with_detail_param_offset_and_limit(self):
# Return the list of volumes details based on offset and limit set.
# get all volumes list
- response, all_vol_list = self.client.list_volumes_with_detail()
+ all_vol_list = self.client.list_volumes_with_detail()
params = {'offset': 1, 'limit': 1}
- resp, fetched_vol_list = \
- self.client.list_volumes_with_detail(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes_with_detail(params=params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 179eb09..d667dfd 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -70,7 +70,7 @@
self.addCleanup(self.servers_client.delete_server, server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
mountpoint = '/dev/%s' % CONF.compute.volume_device_name
- _, body = self.servers_client.attach_volume(
+ self.servers_client.attach_volume(
server['id'], self.volume_origin['id'], mountpoint)
self.volumes_client.wait_for_volume_status(self.volume_origin['id'],
'in-use')
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index b1f5cce..8e9f3ea 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -417,7 +417,7 @@
def nova_volume_attach(self):
# TODO(andreaf) Device should be here CONF.compute.volume_device_name
volume = self.servers_client.attach_volume(
- self.server['id'], self.volume['id'], '/dev/vdb')[1]
+ self.server['id'], self.volume['id'], '/dev/vdb')
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 5ea48e0..4624038 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -78,7 +78,7 @@
def nova_volume_attach(self):
volume_device_path = '/dev/' + CONF.compute.volume_device_name
volume = self.servers_client.attach_volume(
- self.server['id'], self.volume['id'], volume_device_path)[1]
+ self.server['id'], self.volume['id'], volume_device_path)
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index cfc1d37..e59858b 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -101,7 +101,7 @@
def _attach_volume(self, server, volume):
# TODO(andreaf) we should use device from config instead if vdb
- _, attached_volume = self.servers_client.attach_volume(
+ attached_volume = self.servers_client.attach_volume(
server['id'], volume['id'], device='/dev/vdb')
self.assertEqual(volume['id'], attached_volume['id'])
self._wait_for_volume_status(attached_volume, 'in-use')
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index cbe1ca8..be23b78 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -364,14 +364,14 @@
post_body)
body = json.loads(body)
self.validate_response(schema.attach_volume, resp, body)
- return resp, body['volumeAttachment']
+ return service_client.ResponseBody(resp, body['volumeAttachment'])
def detach_volume(self, server_id, volume_id):
"""Detaches a volume from a server instance."""
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
(server_id, volume_id))
self.validate_response(schema.detach_volume, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def get_volume_attachment(self, server_id, attach_id):
"""Return details about the given volume attachment."""
@@ -379,7 +379,7 @@
str(server_id), attach_id))
body = json.loads(body)
self.validate_response(schema.get_volume_attachment, resp, body)
- return resp, body['volumeAttachment']
+ return service_client.ResponseBody(resp, body['volumeAttachment'])
def list_volume_attachments(self, server_id):
"""Returns the list of volume attachments for a given instance."""
@@ -387,7 +387,7 @@
str(server_id)))
body = json.loads(body)
self.validate_response(schema.list_volume_attachments, resp, body)
- return resp, body['volumeAttachments']
+ return service_client.ResponseBodyList(resp, body['volumeAttachments'])
def add_security_group(self, server_id, name):
"""Adds a security group to the server."""
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 61d0b23..2e3e49c 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -33,7 +33,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_volumes, resp, body)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def list_volumes_with_detail(self, params=None):
"""List all the details of volumes."""
@@ -44,7 +44,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_volumes, resp, body)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
@@ -52,7 +52,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.create_get_volume, resp, body)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def create_volume(self, size, **kwargs):
"""
@@ -71,23 +71,23 @@
resp, body = self.post('os-volumes', post_body)
body = json.loads(body)
self.validate_response(schema.create_get_volume, resp, body)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
resp, body = self.delete("os-volumes/%s" % str(volume_id))
self.validate_response(schema.delete_volume, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
- resp, body = self.get_volume(volume_id)
+ body = self.get_volume(volume_id)
volume_status = body['status']
start = int(time.time())
while volume_status != status:
time.sleep(self.build_interval)
- resp, body = self.get_volume(volume_id)
+ body = self.get_volume(volume_id)
volume_status = body['status']
if volume_status == 'error':
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index b52eca9..9bc55fa 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -95,7 +95,7 @@
except Exception:
pass
- _, vols = admin_manager.volumes_client.list_volumes({"all_tenants": True})
+ vols = admin_manager.volumes_client.list_volumes({"all_tenants": True})
LOG.info("Cleanup::remove %s volumes" % len(vols))
for v in vols:
try: