Merge "Change compute image client methods to return one value"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 2e1d6f3..02609ae 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -135,6 +135,9 @@
# concurrent test processes. (boolean value)
#locking_credentials_provider = false
+# Roles to assign to all users created by tempest (list value)
+#tempest_roles =
+
[baremetal]
@@ -917,6 +920,11 @@
# operations testing. (integer value)
#large_ops_number = 0
+# DHCP client used by images to renew DCHP lease. If left empty,
+# update operation will be skipped. Supported clients: "udhcpc",
+# "dhclient" (string value)
+#dhcp_client = udhcpc
+
[service_available]
diff --git a/tempest/api/compute/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py
index 3bdcfd6..425ce13 100644
--- a/tempest/api/compute/admin/test_agents.py
+++ b/tempest/api/compute/admin/test_agents.py
@@ -37,8 +37,7 @@
hypervisor='common', os='linux', architecture='x86_64',
version='7.0', url='xxx://xxxx/xxx/xxx',
md5hash='add6bb58e139be103324d04d82d8f545')
- resp, body = self.client.create_agent(**params)
- self.assertEqual(200, resp.status)
+ body = self.client.create_agent(**params)
self.agent_id = body['agent_id']
def tearDown(self):
@@ -67,8 +66,7 @@
hypervisor='kvm', os='win', architecture='x86',
version='7.0', url='xxx://xxxx/xxx/xxx',
md5hash='add6bb58e139be103324d04d82d8f545')
- resp, body = self.client.create_agent(**params)
- self.assertEqual(200, resp.status)
+ body = self.client.create_agent(**params)
self.addCleanup(self.client.delete_agent, body['agent_id'])
for expected_item, value in params.items():
self.assertEqual(value, body[expected_item])
@@ -79,27 +77,23 @@
params = self._param_helper(
version='8.0', url='xxx://xxxx/xxx/xxx2',
md5hash='add6bb58e139be103324d04d82d8f547')
- resp, body = self.client.update_agent(self.agent_id, **params)
- self.assertEqual(200, resp.status)
+ body = self.client.update_agent(self.agent_id, **params)
for expected_item, value in params.items():
self.assertEqual(value, body[expected_item])
@test.attr(type='gate')
def test_delete_agent(self):
# Delete an agent.
- resp, _ = self.client.delete_agent(self.agent_id)
- self.assertEqual(200, resp.status)
+ self.client.delete_agent(self.agent_id)
# Verify the list doesn't contain the deleted agent.
- resp, agents = self.client.list_agents()
- self.assertEqual(200, resp.status)
+ agents = self.client.list_agents()
self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))
@test.attr(type='gate')
def test_list_agents(self):
# List all agents.
- resp, agents = self.client.list_agents()
- self.assertEqual(200, resp.status)
+ agents = self.client.list_agents()
self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)
self.assertIn(self.agent_id, map(lambda x: x['agent_id'], agents))
@@ -110,14 +104,12 @@
hypervisor='xen', os='linux', architecture='x86',
version='7.0', url='xxx://xxxx/xxx/xxx1',
md5hash='add6bb58e139be103324d04d82d8f546')
- resp, agent_xen = self.client.create_agent(**params)
- self.assertEqual(200, resp.status)
+ agent_xen = self.client.create_agent(**params)
self.addCleanup(self.client.delete_agent, agent_xen['agent_id'])
agent_id_xen = agent_xen['agent_id']
params_filter = {'hypervisor': agent_xen['hypervisor']}
- resp, agents = self.client.list_agents(params_filter)
- self.assertEqual(200, resp.status)
+ agents = self.client.list_agents(params_filter)
self.assertTrue(len(agents) > 0, 'Cannot get any agents.(%s)' % agents)
self.assertIn(agent_id_xen, map(lambda x: x['agent_id'], agents))
self.assertNotIn(self.agent_id, map(lambda x: x['agent_id'], agents))
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 7c2e604..a866ede 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -35,7 +35,7 @@
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
- resp, hosts_all = cls.os_adm.hosts_client.list_hosts()
+ hosts_all = cls.os_adm.hosts_client.list_hosts()
hosts = map(lambda x: x['host_name'],
filter(lambda y: y['service'] == 'compute', hosts_all))
cls.host = hosts[0]
@@ -52,14 +52,12 @@
def test_aggregate_create_delete(self):
# Create and delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self._try_delete_aggregate, aggregate['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(aggregate_name, aggregate['name'])
self.assertIsNone(aggregate['availability_zone'])
- resp, _ = self.client.delete_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
+ self.client.delete_aggregate(aggregate['id'])
self.client.wait_for_resource_deletion(aggregate['id'])
@test.attr(type='gate')
@@ -67,26 +65,23 @@
# Create and delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
+ aggregate = self.client.create_aggregate(
name=aggregate_name, availability_zone=az_name)
self.addCleanup(self._try_delete_aggregate, aggregate['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(aggregate_name, aggregate['name'])
self.assertEqual(az_name, aggregate['availability_zone'])
- resp, _ = self.client.delete_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
+ self.client.delete_aggregate(aggregate['id'])
self.client.wait_for_resource_deletion(aggregate['id'])
@test.attr(type='gate')
def test_aggregate_create_verify_entry_in_list(self):
# Create an aggregate and ensure it is listed.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, aggregates = self.client.list_aggregates()
- self.assertEqual(200, resp.status)
+ aggregates = self.client.list_aggregates()
self.assertIn((aggregate['id'], aggregate['availability_zone']),
map(lambda x: (x['id'], x['availability_zone']),
aggregates))
@@ -95,11 +90,10 @@
def test_aggregate_create_update_metadata_get_details(self):
# Create an aggregate and ensure its details are returned.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, body = self.client.get_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
+ body = self.client.get_aggregate(aggregate['id'])
self.assertEqual(aggregate['name'], body['name'])
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
@@ -107,13 +101,11 @@
# set the metadata of the aggregate
meta = {"key": "value"}
- resp, body = self.client.set_metadata(aggregate['id'], meta)
- self.assertEqual(200, resp.status)
+ body = self.client.set_metadata(aggregate['id'], meta)
self.assertEqual(meta, body["metadata"])
# verify the metadata has been set
- resp, body = self.client.get_aggregate(aggregate['id'])
- self.assertEqual(200, resp.status)
+ body = self.client.get_aggregate(aggregate['id'])
self.assertEqual(meta, body["metadata"])
@test.attr(type='gate')
@@ -121,11 +113,10 @@
# Update an aggregate and ensure properties are updated correctly
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
+ aggregate = self.client.create_aggregate(
name=aggregate_name, availability_zone=az_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(aggregate_name, aggregate['name'])
self.assertEqual(az_name, aggregate['availability_zone'])
self.assertIsNotNone(aggregate['id'])
@@ -134,15 +125,13 @@
new_aggregate_name = aggregate_name + '_new'
new_az_name = az_name + '_new'
- resp, resp_aggregate = self.client.update_aggregate(aggregate_id,
- new_aggregate_name,
- new_az_name)
- self.assertEqual(200, resp.status)
+ resp_aggregate = self.client.update_aggregate(aggregate_id,
+ new_aggregate_name,
+ new_az_name)
self.assertEqual(new_aggregate_name, resp_aggregate['name'])
self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
- resp, aggregates = self.client.list_aggregates()
- self.assertEqual(200, resp.status)
+ aggregates = self.client.list_aggregates()
self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
map(lambda x:
(x['id'], x['name'], x['availability_zone']),
@@ -153,18 +142,16 @@
# Add an host to the given aggregate and remove.
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(200, resp.status)
+ body = self.client.add_host(aggregate['id'], self.host)
self.assertEqual(aggregate_name, body['name'])
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
self.assertIn(self.host, body['hosts'])
- resp, body = self.client.remove_host(aggregate['id'], self.host)
- self.assertEqual(200, resp.status)
+ body = self.client.remove_host(aggregate['id'], self.host)
self.assertEqual(aggregate_name, body['name'])
self.assertEqual(aggregate['availability_zone'],
body['availability_zone'])
@@ -175,12 +162,12 @@
# Add an host to the given aggregate and list.
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
- resp, aggregates = self.client.list_aggregates()
+ aggregates = self.client.list_aggregates()
aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates)
self.assertEqual(1, len(aggs))
agg = aggs[0]
@@ -193,12 +180,12 @@
# Add an host to the given aggregate and get details.
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
- resp, body = self.client.get_aggregate(aggregate['id'])
+ body = self.client.get_aggregate(aggregate['id'])
self.assertEqual(aggregate_name, body['name'])
self.assertIsNone(body['availability_zone'])
self.assertIn(self.host, body['hosts'])
@@ -209,7 +196,7 @@
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
az_name = data_utils.rand_name(self.az_name_prefix)
- resp, aggregate = self.client.create_aggregate(
+ aggregate = self.client.create_aggregate(
name=aggregate_name, availability_zone=az_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.client.add_host(aggregate['id'], self.host)
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index 219d12e..a450e5d 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -34,7 +34,7 @@
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
- resp, hosts_all = cls.os_adm.hosts_client.list_hosts()
+ hosts_all = cls.os_adm.hosts_client.list_hosts()
hosts = map(lambda x: x['host_name'],
filter(lambda y: y['service'] == 'compute', hosts_all))
cls.host = hosts[0]
@@ -66,8 +66,7 @@
def test_aggregate_create_with_existent_aggregate_name(self):
# creating an aggregate with existent aggregate name is forbidden
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.Conflict,
@@ -78,8 +77,7 @@
def test_aggregate_delete_as_user(self):
# Regular user is not allowed to delete an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.Unauthorized,
@@ -96,8 +94,7 @@
def test_aggregate_get_details_as_user(self):
# Regular user is not allowed to get aggregate details.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.Unauthorized,
@@ -119,7 +116,7 @@
@test.attr(type=['negative', 'gate'])
def test_aggregate_add_non_exist_host(self):
# Adding a non-exist host to an aggregate should raise exceptions.
- resp, hosts_all = self.os_adm.hosts_client.list_hosts()
+ hosts_all = self.os_adm.hosts_client.list_hosts()
hosts = map(lambda x: x['host_name'], hosts_all)
while True:
non_exist_host = data_utils.rand_name('nonexist_host_')
@@ -127,7 +124,7 @@
break
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.NotFound, self.client.add_host,
@@ -137,8 +134,7 @@
def test_aggregate_add_host_as_user(self):
# Regular user is not allowed to add a host to an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.Unauthorized,
@@ -149,12 +145,10 @@
def test_aggregate_add_existent_host(self):
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(200, resp.status)
+ self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
self.assertRaises(exceptions.Conflict, self.client.add_host,
@@ -165,11 +159,9 @@
# Regular user is not allowed to remove a host from an aggregate.
self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- resp, body = self.client.add_host(aggregate['id'], self.host)
- self.assertEqual(200, resp.status)
+ self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
self.assertRaises(exceptions.Unauthorized,
@@ -180,8 +172,7 @@
def test_aggregate_remove_nonexistent_host(self):
non_exist_host = data_utils.rand_name('nonexist_host_')
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- resp, aggregate = self.client.create_aggregate(name=aggregate_name)
- self.assertEqual(200, resp.status)
+ aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.assertRaises(exceptions.NotFound, self.client.remove_host,
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 25965fd..b9d47bb 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -30,19 +30,17 @@
@test.attr(type='gate')
def test_list_hosts(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
+ hosts = self.client.list_hosts()
self.assertTrue(len(hosts) >= 2, str(hosts))
@test.attr(type='gate')
def test_list_hosts_with_zone(self):
self.useFixture(fixtures.LockFixture('availability_zone'))
- resp, hosts = self.client.list_hosts()
+ hosts = self.client.list_hosts()
host = hosts[0]
zone_name = host['zone']
params = {'zone': zone_name}
- resp, hosts = self.client.list_hosts(params)
- self.assertEqual(200, resp.status)
+ hosts = self.client.list_hosts(params)
self.assertTrue(len(hosts) >= 1)
self.assertIn(host, hosts)
@@ -51,31 +49,27 @@
# If send the request with a blank zone, the request will be successful
# and it will return all the hosts list
params = {'zone': ''}
- resp, hosts = self.client.list_hosts(params)
+ hosts = self.client.list_hosts(params)
self.assertNotEqual(0, len(hosts))
- self.assertEqual(200, resp.status)
@test.attr(type='gate')
def test_list_hosts_with_nonexistent_zone(self):
# If send the request with a nonexistent zone, the request will be
# successful and no hosts will be retured
params = {'zone': 'xxx'}
- resp, hosts = self.client.list_hosts(params)
+ hosts = self.client.list_hosts(params)
self.assertEqual(0, len(hosts))
- self.assertEqual(200, resp.status)
@test.attr(type='gate')
def test_show_host_detail(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
+ hosts = self.client.list_hosts()
hosts = [host for host in hosts if host['service'] == 'compute']
self.assertTrue(len(hosts) >= 1)
for host in hosts:
hostname = host['host_name']
- resp, resources = self.client.show_host_detail(hostname)
- self.assertEqual(200, resp.status)
+ resources = self.client.show_host_detail(hostname)
self.assertTrue(len(resources) >= 1)
host_resource = resources[0]['resource']
self.assertIsNotNone(host_resource)
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 055219f..fc918a3 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -31,8 +31,7 @@
cls.non_admin_client = cls.os.hosts_client
def _get_host_name(self):
- resp, hosts = self.client.list_hosts()
- self.assertEqual(200, resp.status)
+ hosts = self.client.list_hosts()
self.assertTrue(len(hosts) >= 1)
hostname = hosts[0]['host_name']
return hostname
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index de3debb..fbfef87 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -30,8 +30,7 @@
def _list_hypervisors(self):
# List of hypervisors
- resp, hypers = self.client.get_hypervisor_list()
- self.assertEqual(200, resp.status)
+ hypers = self.client.get_hypervisor_list()
return hypers
def assertHypervisors(self, hypers):
@@ -46,8 +45,7 @@
@test.attr(type='gate')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
- resp, hypers = self.client.get_hypervisor_list_details()
- self.assertEqual(200, resp.status)
+ hypers = self.client.get_hypervisor_list_details()
self.assertHypervisors(hypers)
@test.attr(type='gate')
@@ -56,9 +54,7 @@
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
- resp, details = (self.client.
- get_hypervisor_show_details(hypers[0]['id']))
- self.assertEqual(200, resp.status)
+ details = self.client.get_hypervisor_show_details(hypers[0]['id'])
self.assertTrue(len(details) > 0)
self.assertEqual(details['hypervisor_hostname'],
hypers[0]['hypervisor_hostname'])
@@ -70,15 +66,13 @@
self.assertHypervisors(hypers)
hostname = hypers[0]['hypervisor_hostname']
- resp, hypervisors = self.client.get_hypervisor_servers(hostname)
- self.assertEqual(200, resp.status)
+ hypervisors = self.client.get_hypervisor_servers(hostname)
self.assertTrue(len(hypervisors) > 0)
@test.attr(type='gate')
def test_get_hypervisor_stats(self):
# Verify the stats of the all hypervisor
- resp, stats = self.client.get_hypervisor_stats()
- self.assertEqual(200, resp.status)
+ stats = self.client.get_hypervisor_stats()
self.assertTrue(len(stats) > 0)
@test.attr(type='gate')
@@ -94,9 +88,7 @@
ironic_only = True
hypers_without_ironic = []
for hyper in hypers:
- resp, details = (self.client.
- get_hypervisor_show_details(hypers[0]['id']))
- self.assertEqual(200, resp.status)
+ details = self.client.get_hypervisor_show_details(hypers[0]['id'])
if details['hypervisor_type'] != 'ironic':
hypers_without_ironic.append(hyper)
ironic_only = False
@@ -110,8 +102,8 @@
# because hypervisors might be disabled, this loops looking
# for any good hit.
try:
- resp, uptime = self.client.get_hypervisor_uptime(hyper['id'])
- if (resp.status == 200) and (len(uptime) > 0):
+ uptime = self.client.get_hypervisor_uptime(hyper['id'])
+ if len(uptime) > 0:
has_valid_uptime = True
break
except Exception:
@@ -124,7 +116,6 @@
def test_search_hypervisor(self):
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
- resp, hypers = self.client.search_hypervisor(
+ hypers = self.client.search_hypervisor(
hypers[0]['hypervisor_hostname'])
- self.assertEqual(200, resp.status)
self.assertHypervisors(hypers)
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index b1f2351..a137a61 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -35,8 +35,7 @@
def _list_hypervisors(self):
# List of hypervisors
- resp, hypers = self.client.get_hypervisor_list()
- self.assertEqual(200, resp.status)
+ hypers = self.client.get_hypervisor_list()
return hypers
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index e7a39f8..5cf4a31 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -31,29 +31,27 @@
@test.attr(type='gate')
def test_list_services(self):
- resp, services = self.client.list_services()
- self.assertEqual(200, resp.status)
+ services = self.client.list_services()
self.assertNotEqual(0, len(services))
@test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
params = {'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ services = self.client.list_services(params)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(binary_name, service['binary'])
@test.attr(type='gate')
def test_get_service_by_host_name(self):
- resp, services = self.client.list_services()
+ services = self.client.list_services()
host_name = services[0]['host']
services_on_host = [service for service in services if
service['host'] == host_name]
params = {'host': host_name}
- resp, services = self.client.list_services(params)
+ services = self.client.list_services(params)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -66,13 +64,12 @@
@test.attr(type='gate')
def test_get_service_by_service_and_host_name(self):
- resp, services = self.client.list_services()
+ services = self.client.list_services()
host_name = services[0]['host']
binary_name = services[0]['binary']
params = {'host': host_name, 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ services = self.client.list_services(params)
self.assertEqual(1, len(services))
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index 534afc5..bb19a39 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -37,26 +37,23 @@
@test.attr(type=['negative', 'gate'])
def test_get_service_by_invalid_params(self):
# return all services if send the request with invalid parameter
- resp, services = self.client.list_services()
+ services = self.client.list_services()
params = {'xxx': 'nova-compute'}
- resp, services_xxx = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ services_xxx = self.client.list_services(params)
self.assertEqual(len(services), len(services_xxx))
@test.attr(type=['negative', 'gate'])
def test_get_service_by_invalid_service_and_valid_host(self):
- resp, services = self.client.list_services()
+ services = self.client.list_services()
host_name = services[0]['host']
params = {'host': host_name, 'binary': 'xxx'}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ services = self.client.list_services(params)
self.assertEqual(0, len(services))
@test.attr(type=['negative', 'gate'])
def test_get_service_with_valid_service_and_invalid_host(self):
- resp, services = self.client.list_services()
+ services = self.client.list_services()
binary_name = services[0]['binary']
params = {'host': 'xxx', 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
+ services = self.client.list_services(params)
self.assertEqual(0, len(services))
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 10903e0..6b6c8e7 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -271,7 +271,7 @@
def _delete_volume(volumes_client, volume_id):
"""Deletes the given volume and waits for it to be gone."""
try:
- resp, _ = volumes_client.delete_volume(volume_id)
+ volumes_client.delete_volume(volume_id)
# TODO(mriedem): We should move the wait_for_resource_deletion
# into the delete_volume method as a convenience to the caller.
volumes_client.wait_for_resource_deletion(volume_id)
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index a9c72fb..d537d83 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -14,12 +14,18 @@
# under the License.
from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
from tempest import exceptions
from tempest import test
class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
+ def setUp(self):
+ # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
+ self.useFixture(fixtures.LockFixture('compute_quotas'))
+ super(AbsoluteLimitsNegativeTestJSON, self).setUp()
+
@classmethod
def resource_setup(cls):
super(AbsoluteLimitsNegativeTestJSON, cls).resource_setup()
@@ -46,7 +52,4 @@
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
- self.server_client.create_server,
- name='test', meta=meta_data,
- flavor_ref=self.flavor_ref,
- image_ref=self.image_ref)
+ self.create_test_server, meta=meta_data)
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index cb75d07..e04439f 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -36,7 +36,7 @@
cls.created_server_ids = []
def _get_compute_hostnames(self):
- _resp, body = self.admin_hosts_client.list_hosts()
+ body = self.admin_hosts_client.list_hosts()
return [
host_record['host_name']
for host_record in body
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 1d22fbd..7fef52f 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -61,7 +61,7 @@
self.servers_client.list_addresses(self.server['id']))
# Create a volume and wait for it to become ready
- _, self.volume = self.volumes_client.create_volume(
+ self.volume = self.volumes_client.create_volume(
1, display_name='test')
self.addCleanup(self._delete_volume)
self.volumes_client.wait_for_volume_status(self.volume['id'],
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index e70519e..65aeb24 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -15,7 +15,6 @@
import itertools
import netaddr
-import testtools
from tempest.api.network import base
from tempest.common import custom_matchers
@@ -571,9 +570,16 @@
test_subnet_ids,
'Subnet are not in the same network')
- @testtools.skipUnless(CONF.network_feature_enabled.ipv6_subnet_attributes,
- "IPv6 extended attributes for subnets not "
- "available")
+
+class NetworksIpV6TestAttrs(NetworksIpV6TestJSON):
+
+ @classmethod
+ def resource_setup(cls):
+ if not CONF.network_feature_enabled.ipv6_subnet_attributes:
+ raise cls.skipException("IPv6 extended attributes for "
+ "subnets not available")
+ super(NetworksIpV6TestAttrs, cls).resource_setup()
+
@test.attr(type='smoke')
def test_create_delete_subnet_with_v6_attributes_stateful(self):
self._create_verify_delete_subnet(
@@ -581,20 +587,54 @@
ipv6_ra_mode='dhcpv6-stateful',
ipv6_address_mode='dhcpv6-stateful')
- @testtools.skipUnless(CONF.network_feature_enabled.ipv6_subnet_attributes,
- "IPv6 extended attributes for subnets not "
- "available")
@test.attr(type='smoke')
def test_create_delete_subnet_with_v6_attributes_slaac(self):
self._create_verify_delete_subnet(
ipv6_ra_mode='slaac',
ipv6_address_mode='slaac')
- @testtools.skipUnless(CONF.network_feature_enabled.ipv6_subnet_attributes,
- "IPv6 extended attributes for subnets not "
- "available")
@test.attr(type='smoke')
def test_create_delete_subnet_with_v6_attributes_stateless(self):
self._create_verify_delete_subnet(
ipv6_ra_mode='dhcpv6-stateless',
ipv6_address_mode='dhcpv6-stateless')
+
+ def _test_delete_subnet_with_ports(self, mode):
+ """Create subnet and delete it with existing ports"""
+ slaac_network = self.create_network()
+ subnet_slaac = self.create_subnet(slaac_network,
+ **{'ipv6_ra_mode': mode,
+ 'ipv6_address_mode': mode})
+ port = self.create_port(slaac_network)
+ self.assertIsNotNone(port['fixed_ips'][0]['ip_address'])
+ self.client.delete_subnet(subnet_slaac['id'])
+ self.subnets.pop()
+ subnets = self.client.list_subnets()
+ subnet_ids = [subnet['id'] for subnet in subnets['subnets']]
+ self.assertNotIn(subnet_slaac['id'], subnet_ids,
+ "Subnet wasn't deleted")
+ self.assertRaisesRegexp(
+ exceptions.Conflict,
+ "There are one or more ports still in use on the network",
+ self.client.delete_network,
+ slaac_network['id'])
+
+ @test.attr(type='smoke')
+ def test_create_delete_slaac_subnet_with_ports(self):
+ """Test deleting subnet with SLAAC ports
+
+ Create subnet with SLAAC, create ports in network
+ and then you shall be able to delete subnet without port
+ deletion. But you still can not delete the network.
+ """
+ self._test_delete_subnet_with_ports("slaac")
+
+ @test.attr(type='smoke')
+ def test_create_delete_stateless_subnet_with_ports(self):
+ """Test deleting subnet with DHCPv6 stateless ports
+
+ Create subnet with DHCPv6 stateless, create ports in network
+ and then you shall be able to delete subnet without port
+ deletion. But you still can not delete the network.
+ """
+ self._test_delete_subnet_with_ports("dhcpv6-stateless")
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 7ab5ebd..bf85e90 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -13,9 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+import netaddr
import socket
from tempest.api.network import base
+from tempest.api.network import base_security_groups as sec_base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest import config
@@ -24,7 +26,7 @@
CONF = config.CONF
-class PortsTestJSON(base.BaseNetworkTest):
+class PortsTestJSON(sec_base.BaseSecGroupTest):
_interface = 'json'
"""
@@ -83,6 +85,35 @@
self.assertTrue(port1['admin_state_up'])
self.assertTrue(port2['admin_state_up'])
+ @classmethod
+ def _get_ipaddress_from_tempest_conf(cls):
+ """Return first subnet gateway for configured CIDR """
+ if cls._ip_version == 4:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+
+ elif cls._ip_version == 6:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+
+ return netaddr.IPAddress(cidr)
+
+ @test.attr(type='smoke')
+ def test_create_port_in_allowed_allocation_pools(self):
+ network = self.create_network()
+ net_id = network['id']
+ address = self._get_ipaddress_from_tempest_conf()
+ allocation_pools = {'allocation_pools': [{'start': str(address + 4),
+ 'end': str(address + 6)}]}
+ subnet = self.create_subnet(network, **allocation_pools)
+ self.addCleanup(self.client.delete_subnet, subnet['id'])
+ body = self.client.create_port(network_id=net_id)
+ self.addCleanup(self.client.delete_port, body['port']['id'])
+ port = body['port']
+ ip_address = port['fixed_ips'][0]['ip_address']
+ start_ip_address = allocation_pools['allocation_pools'][0]['start']
+ end_ip_address = allocation_pools['allocation_pools'][0]['end']
+ ip_range = netaddr.IPRange(start_ip_address, end_ip_address)
+ self.assertIn(ip_address, ip_range)
+
@test.attr(type='smoke')
def test_show_port(self):
# Verify the details of port
@@ -119,8 +150,11 @@
def test_port_list_filter_by_router_id(self):
# Create a router
network = self.create_network()
- self.create_subnet(network)
+ self.addCleanup(self.client.delete_network, network['id'])
+ subnet = self.create_subnet(network)
+ self.addCleanup(self.client.delete_subnet, subnet['id'])
router = self.create_router(data_utils.rand_name('router-'))
+ self.addCleanup(self.client.delete_router, router['id'])
port = self.client.create_port(network_id=network['id'])
# Add router interface to port created above
self.client.add_router_interface_with_port_id(
@@ -146,31 +180,41 @@
self.assertEqual(sorted(fields), sorted(port.keys()))
@test.attr(type='smoke')
- def test_update_port_with_second_ip(self):
+ def test_create_update_port_with_second_ip(self):
# Create a network with two subnets
network = self.create_network()
+ self.addCleanup(self.client.delete_network, network['id'])
subnet_1 = self.create_subnet(network)
+ self.addCleanup(self.client.delete_subnet, subnet_1['id'])
subnet_2 = self.create_subnet(network)
+ self.addCleanup(self.client.delete_subnet, subnet_2['id'])
fixed_ip_1 = [{'subnet_id': subnet_1['id']}]
fixed_ip_2 = [{'subnet_id': subnet_2['id']}]
- # Create a port with a single IP address from first subnet
- port = self.create_port(network,
- fixed_ips=fixed_ip_1)
- self.assertEqual(1, len(port['fixed_ips']))
-
- # Update the port with a second IP address from second subnet
fixed_ips = fixed_ip_1 + fixed_ip_2
- port = self.update_port(port, fixed_ips=fixed_ips)
+
+ # Create a port with multiple IP addresses
+ port = self.create_port(network,
+ fixed_ips=fixed_ips)
+ self.addCleanup(self.client.delete_port, port['id'])
self.assertEqual(2, len(port['fixed_ips']))
+ check_fixed_ips = [subnet_1['id'], subnet_2['id']]
+ for item in port['fixed_ips']:
+ self.assertIn(item['subnet_id'], check_fixed_ips)
# Update the port to return to a single IP address
port = self.update_port(port, fixed_ips=fixed_ip_1)
self.assertEqual(1, len(port['fixed_ips']))
+ # Update the port with a second IP address from second subnet
+ port = self.update_port(port, fixed_ips=fixed_ips)
+ self.assertEqual(2, len(port['fixed_ips']))
+
def _update_port_with_security_groups(self, security_groups_names):
- post_body = {"network_id": self.network['id']}
- self.create_subnet(self.network)
+ subnet_1 = self.create_subnet(self.network)
+ self.addCleanup(self.client.delete_subnet, subnet_1['id'])
+ fixed_ip_1 = [{'subnet_id': subnet_1['id']}]
+
security_groups_list = list()
for name in security_groups_names:
group_create_body = self.client.create_security_group(
@@ -180,24 +224,48 @@
security_groups_list.append(group_create_body['security_group']
['id'])
# Create a port
+ sec_grp_name = data_utils.rand_name('secgroup')
+ security_group = self.client.create_security_group(name=sec_grp_name)
+ self.addCleanup(self.client.delete_security_group,
+ security_group['security_group']['id'])
+ post_body = {
+ "name": data_utils.rand_name('port-'),
+ "security_groups": [security_group['security_group']['id']],
+ "network_id": self.network['id'],
+ "admin_state_up": True,
+ "fixed_ips": fixed_ip_1}
body = self.client.create_port(**post_body)
self.addCleanup(self.client.delete_port, body['port']['id'])
port = body['port']
+
# Update the port with security groups
- update_body = {"security_groups": security_groups_list}
+ subnet_2 = self.create_subnet(self.network)
+ fixed_ip_2 = [{'subnet_id': subnet_2['id']}]
+ update_body = {"name": data_utils.rand_name('port-'),
+ "admin_state_up": False,
+ "fixed_ips": fixed_ip_2,
+ "security_groups": security_groups_list}
body = self.client.update_port(port['id'], **update_body)
- # Verify the security groups updated to port
port_show = body['port']
+ # Verify the security groups and other attributes updated to port
+ exclude_keys = set(port_show).symmetric_difference(update_body)
+ exclude_keys.add('fixed_ips')
+ exclude_keys.add('security_groups')
+ self.assertThat(port_show, custom_matchers.MatchesDictExceptForKeys(
+ update_body, exclude_keys))
+ self.assertEqual(fixed_ip_2[0]['subnet_id'],
+ port_show['fixed_ips'][0]['subnet_id'])
+
for security_group in security_groups_list:
self.assertIn(security_group, port_show['security_groups'])
@test.attr(type='smoke')
- def test_update_port_with_security_group(self):
+ def test_update_port_with_security_group_and_extra_attributes(self):
self._update_port_with_security_groups(
[data_utils.rand_name('secgroup')])
@test.attr(type='smoke')
- def test_update_port_with_two_security_groups(self):
+ def test_update_port_with_two_security_groups_and_extra_attributes(self):
self._update_port_with_security_groups(
[data_utils.rand_name('secgroup'),
data_utils.rand_name('secgroup')])
@@ -222,23 +290,14 @@
@test.attr(type='smoke')
def test_create_port_with_no_securitygroups(self):
network = self.create_network()
- self.create_subnet(network)
+ self.addCleanup(self.client.delete_network, network['id'])
+ subnet = self.create_subnet(network)
+ self.addCleanup(self.client.delete_subnet, subnet['id'])
port = self.create_port(network, security_groups=[])
+ self.addCleanup(self.client.delete_port, port['id'])
self.assertIsNotNone(port['security_groups'])
self.assertEmpty(port['security_groups'])
- @test.attr(type='smoke')
- def test_update_port_with_no_securitygroups(self):
- network = self.create_network()
- self.create_subnet(network)
- port = self.create_port(network)
- # Verify that port is created with default security group
- self.assertIsNotNone(port['security_groups'])
- self.assertNotEmpty(port['security_groups'])
- updated_port = self.update_port(port, security_groups=[])
- self.assertIsNotNone(updated_port['security_groups'])
- self.assertEmpty(updated_port['security_groups'])
-
class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
_interface = 'json'
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 21f2578..d3dffbf 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -68,13 +68,13 @@
environment=None, files=None):
if parameters is None:
parameters = {}
- resp, body = cls.client.create_stack(
+ body = cls.client.create_stack(
stack_name,
template=template_data,
parameters=parameters,
environment=environment,
files=files)
- stack_id = resp['location'].split('/')[-1]
+ stack_id = body.response['location'].split('/')[-1]
stack_identifier = '%s/%s' % (stack_name, stack_id)
cls.stacks.append(stack_identifier)
return stack_identifier
@@ -164,7 +164,7 @@
def list_resources(self, stack_identifier):
"""Get a dict mapping of resource names to types."""
- _, resources = self.client.list_resources(stack_identifier)
+ resources = self.client.list_resources(stack_identifier)
self.assertIsInstance(resources, list)
for res in resources:
self.assert_fields_in_dict(res, 'logical_resource_id',
@@ -175,5 +175,5 @@
for r in resources)
def get_stack_output(self, stack_identifier, output_key):
- _, body = self.client.get_stack(stack_identifier)
+ body = self.client.get_stack(stack_identifier)
return self.stack_output(body, output_key)
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 8352719..ea6d4be 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -65,14 +65,14 @@
cls.stack_id = cls.stack_identifier.split('/')[1]
try:
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
- _, resources = cls.client.list_resources(cls.stack_identifier)
+ resources = cls.client.list_resources(cls.stack_identifier)
except exceptions.TimeoutException as e:
if CONF.compute_feature_enabled.console_output:
# attempt to log the server console to help with debugging
# the cause of the server not signalling the waitcondition
# to heat.
- _, body = cls.client.get_resource(cls.stack_identifier,
- 'Server')
+ body = cls.client.get_resource(cls.stack_identifier,
+ 'Server')
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
_, output = cls.servers_client.get_console_output(
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index bf6c79c..db1ac9a 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -47,7 +47,7 @@
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
def _list_stacks(self, expected_num=None, **filter_kwargs):
- _, stacks = self.client.list_stacks(params=filter_kwargs)
+ stacks = self.client.list_stacks(params=filter_kwargs)
self.assertIsInstance(stacks, list)
if expected_num is not None:
self.assertEqual(expected_num, len(stacks))
@@ -63,7 +63,7 @@
@test.attr(type='gate')
def test_stack_show(self):
"""Getting details about created stack should be possible."""
- _, stack = self.client.get_stack(self.stack_name)
+ stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
'parameters', 'outputs', 'disable_rollback',
@@ -82,10 +82,10 @@
@test.attr(type='gate')
def test_suspend_resume_stack(self):
"""Suspend and resume a stack."""
- _, suspend_stack = self.client.suspend_stack(self.stack_identifier)
+ self.client.suspend_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'SUSPEND_COMPLETE')
- _, resume_stack = self.client.resume_stack(self.stack_identifier)
+ self.client.resume_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'RESUME_COMPLETE')
@@ -99,8 +99,8 @@
@test.attr(type='gate')
def test_show_resource(self):
"""Getting details about created resource should be possible."""
- _, resource = self.client.get_resource(self.stack_identifier,
- self.resource_name)
+ resource = self.client.get_resource(self.stack_identifier,
+ self.resource_name)
self.assertIsInstance(resource, dict)
self.assert_fields_in_dict(resource, 'resource_name', 'description',
'links', 'logical_resource_id',
@@ -113,7 +113,7 @@
@test.attr(type='gate')
def test_resource_metadata(self):
"""Getting metadata for created resources should be possible."""
- _, metadata = self.client.show_resource_metadata(
+ metadata = self.client.show_resource_metadata(
self.stack_identifier,
self.resource_name)
self.assertIsInstance(metadata, dict)
@@ -122,7 +122,7 @@
@test.attr(type='gate')
def test_list_events(self):
"""Getting list of created events for the stack should be possible."""
- _, events = self.client.list_events(self.stack_identifier)
+ events = self.client.list_events(self.stack_identifier)
self.assertIsInstance(events, list)
for event in events:
@@ -137,13 +137,13 @@
@test.attr(type='gate')
def test_show_event(self):
"""Getting details about an event should be possible."""
- _, events = self.client.list_resource_events(self.stack_identifier,
- self.resource_name)
+ events = self.client.list_resource_events(self.stack_identifier,
+ self.resource_name)
self.assertNotEqual([], events)
events.sort(key=lambda event: event['event_time'])
event_id = events[0]['id']
- _, event = self.client.show_event(self.stack_identifier,
- self.resource_name, event_id)
+ event = self.client.show_event(self.stack_identifier,
+ self.resource_name, event_id)
self.assertIsInstance(event, dict)
self.assert_fields_in_dict(event, 'resource_name', 'event_time',
'links', 'logical_resource_id',
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index 1da340c..772bab3 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -43,7 +43,7 @@
cls.stack_id = cls.stack_identifier.split('/')[1]
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
- _, resources = cls.client.list_resources(cls.stack_identifier)
+ resources = cls.client.list_resources(cls.stack_identifier)
cls.test_resources = {}
for resource in resources:
cls.test_resources[resource['logical_resource_id']] = resource
@@ -70,7 +70,7 @@
@test.attr(type='gate')
def test_stack_keypairs_output(self):
- _, stack = self.client.get_stack(self.stack_name)
+ stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
output_map = {}
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index d7fbd65..5cdd8b4 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -28,7 +28,7 @@
@test.attr(type='smoke')
def test_stack_list_responds(self):
- _, stacks = self.client.list_stacks()
+ stacks = self.client.list_stacks()
self.assertIsInstance(stacks, list)
@test.attr(type='smoke')
@@ -44,20 +44,20 @@
self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
# check for stack in list
- _, stacks = self.client.list_stacks()
+ stacks = self.client.list_stacks()
list_ids = list([stack['id'] for stack in stacks])
self.assertIn(stack_id, list_ids)
# fetch the stack
- _, stack = self.client.get_stack(stack_identifier)
+ stack = self.client.get_stack(stack_identifier)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by name
- _, stack = self.client.get_stack(stack_name)
+ stack = self.client.get_stack(stack_name)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by id
- _, stack = self.client.get_stack(stack_id)
+ stack = self.client.get_stack(stack_id)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# delete the stack
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index 307468e..0288fd4 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -42,7 +42,7 @@
cls.stack_id = cls.stack_identifier.split('/')[1]
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
cls.test_resources = {}
- _, resources = cls.client.list_resources(cls.stack_identifier)
+ resources = cls.client.list_resources(cls.stack_identifier)
for resource in resources:
cls.test_resources[resource['logical_resource_id']] = resource
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 262c576..6113cab 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -38,13 +38,13 @@
@test.attr(type='gate')
def test_show_template(self):
"""Getting template used to create the stack."""
- _, template = self.client.show_template(self.stack_identifier)
+ self.client.show_template(self.stack_identifier)
@test.attr(type='gate')
def test_validate_template(self):
"""Validating template passing it content."""
- _, parameters = self.client.validate_template(self.template,
- self.parameters)
+ self.client.validate_template(self.template,
+ self.parameters)
class TemplateAWSTestJSON(TemplateYAMLTestJSON):
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index f47078c..6fddb21 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -33,7 +33,7 @@
def _cinder_verify(self, volume_id, template):
self.assertIsNotNone(volume_id)
- _, volume = self.volumes_client.get_volume(volume_id)
+ volume = self.volumes_client.get_volume(volume_id)
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index 9e24993..65c4bd3 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -60,14 +60,14 @@
extra_specs = {spec_key_with_prefix: backend_name_key}
else:
extra_specs = {spec_key_without_prefix: backend_name_key}
- _, self.type = self.volume_types_client.create_volume_type(
+ self.type = self.volume_types_client.create_volume_type(
type_name, extra_specs=extra_specs)
self.volume_type_id_list.append(self.type['id'])
params = {self.name_field: vol_name, 'volume_type': type_name}
- _, self.volume = self.admin_volume_client.create_volume(size=1,
- **params)
+ self.volume = self.admin_volume_client.create_volume(size=1,
+ **params)
if with_prefix:
self.volume_id_list_with_prefix.append(self.volume['id'])
else:
@@ -131,7 +131,7 @@
# the multi backend feature has been enabled
# if multi-backend is enabled: os-vol-attr:host should be like:
# host@backend_name
- _, volume = self.admin_volume_client.get_volume(volume_id)
+ volume = self.admin_volume_client.get_volume(volume_id)
volume1_host = volume['os-vol-host-attr:host']
msg = ("multi-backend reporting incorrect values for volume %s" %
@@ -142,10 +142,10 @@
# this test checks that the two volumes created at setUp don't
# belong to the same backend (if they are, than the
# volume backend distinction is not working properly)
- _, volume = self.admin_volume_client.get_volume(volume1_id)
+ volume = self.admin_volume_client.get_volume(volume1_id)
volume1_host = volume['os-vol-host-attr:host']
- _, volume = self.admin_volume_client.get_volume(volume2_id)
+ volume = self.admin_volume_client.get_volume(volume2_id)
volume2_host = volume['os-vol-host-attr:host']
msg = ("volumes %s and %s were created in the same backend" %
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 31dc09f..6c64298 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -30,7 +30,7 @@
vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
- _, cls.volume = \
+ cls.volume = \
cls.volumes_client.create_volume(size=1, **params)
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')
@@ -38,7 +38,7 @@
# 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.snapshot = \
cls.client.create_snapshot(cls.volume['id'], **params)
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
'available')
@@ -68,9 +68,9 @@
# and force delete temp snapshot
temp_snapshot = self.create_snapshot(self.volume['id'])
if status:
- _, body = self.admin_snapshots_client.\
+ self.admin_snapshots_client.\
reset_snapshot_status(temp_snapshot['id'], status)
- _, volume_delete = self.admin_snapshots_client.\
+ self.admin_snapshots_client.\
force_delete_snapshot(temp_snapshot['id'])
self.client.wait_for_resource_deletion(temp_snapshot['id'])
@@ -81,9 +81,9 @@
def test_reset_snapshot_status(self):
# Reset snapshot status to creating
status = 'creating'
- _, body = self.admin_snapshots_client.\
+ self.admin_snapshots_client.\
reset_snapshot_status(self.snapshot['id'], status)
- _, snapshot_get \
+ snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
self.assertEqual(status, snapshot_get['status'])
@@ -98,9 +98,9 @@
progress = '80%'
status = 'error'
progress_alias = self._get_progress_alias()
- _, body = self.client.update_snapshot_status(self.snapshot['id'],
- status, progress)
- _, snapshot_get \
+ self.client.update_snapshot_status(self.snapshot['id'],
+ status, progress)
+ snapshot_get \
= self.admin_snapshots_client.get_snapshot(self.snapshot['id'])
self.assertEqual(status, snapshot_get['status'])
self.assertEqual(progress, snapshot_get[progress_alias])
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index e966613..a214edf 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -22,7 +22,7 @@
@test.attr(type='gate')
def test_list_hosts(self):
- _, hosts = self.hosts_client.list_hosts()
+ hosts = self.hosts_client.list_hosts()
self.assertTrue(len(hosts) >= 2, "No. of hosts are < 2,"
"response of list hosts is: % s" % hosts)
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 80ef914..52f2d90 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -33,13 +33,13 @@
@test.attr(type='gate')
def test_list_quotas(self):
- _, quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
+ quotas = self.quotas_client.get_quota_set(self.demo_tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@test.attr(type='gate')
def test_list_default_quotas(self):
- _, quotas = self.quotas_client.get_default_quota_set(
+ quotas = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quotas)
@@ -47,14 +47,14 @@
@test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
- _, default_quota_set = self.quotas_client.get_default_quota_set(
+ default_quota_set = self.quotas_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'gigabytes': 1009,
'volumes': 11,
'snapshots': 11}
# Update limits for all quota resources
- _, quota_set = self.quotas_client.update_quota_set(
+ quota_set = self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
@@ -70,7 +70,7 @@
@test.attr(type='gate')
def test_show_quota_usage(self):
- _, quota_usage = self.quotas_client.get_quota_usage(
+ quota_usage = self.quotas_client.get_quota_usage(
self.os_adm.credentials.tenant_id)
for key in QUOTA_KEYS:
self.assertIn(key, quota_usage)
@@ -79,14 +79,14 @@
@test.attr(type='gate')
def test_quota_usage(self):
- _, quota_usage = self.quotas_client.get_quota_usage(
+ quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
volume = self.create_volume(size=1)
self.addCleanup(self.admin_volume_client.delete_volume,
volume['id'])
- _, new_quota_usage = self.quotas_client.get_quota_usage(
+ new_quota_usage = self.quotas_client.get_quota_usage(
self.demo_tenant_id)
self.assertEqual(quota_usage['volumes']['in_use'] + 1,
@@ -103,7 +103,7 @@
tenant = identity_client.create_tenant(tenant_name)
tenant_id = tenant['id']
self.addCleanup(identity_client.delete_tenant, tenant_id)
- _, quota_set_default = self.quotas_client.get_default_quota_set(
+ quota_set_default = self.quotas_client.get_default_quota_set(
tenant_id)
volume_default = quota_set_default['volumes']
@@ -111,7 +111,7 @@
volumes=(int(volume_default) + 5))
self.quotas_client.delete_quota_set(tenant_id)
- _, quota_set_new = self.quotas_client.get_quota_set(tenant_id)
+ quota_set_new = self.quotas_client.get_quota_set(tenant_id)
self.assertEqual(volume_default, quota_set_new['volumes'])
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index c367ebb..5cf6af0 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -31,7 +31,7 @@
# NOTE(gfidente): no need to restore original quota set
# after the tests as they only work with tenant isolation.
- _, quota_set = cls.quotas_client.update_quota_set(
+ cls.quotas_client.update_quota_set(
cls.demo_tenant_id,
**cls.shared_quota_set)
@@ -62,7 +62,7 @@
**self.shared_quota_set)
new_quota_set = {'gigabytes': 2, 'volumes': 2, 'snapshots': 1}
- _, quota_set = self.quotas_client.update_quota_set(
+ self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
self.assertRaises(exceptions.OverLimit,
@@ -70,7 +70,7 @@
size=1)
new_quota_set = {'gigabytes': 2, 'volumes': 1, 'snapshots': 2}
- _, quota_set = self.quotas_client.update_quota_set(
+ self.quotas_client.update_quota_set(
self.demo_tenant_id,
**self.shared_quota_set)
self.assertRaises(exceptions.OverLimit,
diff --git a/tempest/api/volume/admin/test_volume_services.py b/tempest/api/volume/admin/test_volume_services.py
index fffc5cb..46db70f 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -27,19 +27,19 @@
@classmethod
def resource_setup(cls):
super(VolumesServicesV2TestJSON, cls).resource_setup()
- _, cls.services = cls.admin_volume_services_client.list_services()
+ cls.services = cls.admin_volume_services_client.list_services()
cls.host_name = cls.services[0]['host']
cls.binary_name = cls.services[0]['binary']
@test.attr(type='gate')
def test_list_services(self):
- _, services = self.admin_volume_services_client.list_services()
+ services = self.admin_volume_services_client.list_services()
self.assertNotEqual(0, len(services))
@test.attr(type='gate')
def test_get_service_by_service_binary_name(self):
params = {'binary': self.binary_name}
- _, services = self.admin_volume_services_client.list_services(params)
+ services = self.admin_volume_services_client.list_services(params)
self.assertNotEqual(0, len(services))
for service in services:
self.assertEqual(self.binary_name, service['binary'])
@@ -50,7 +50,7 @@
service['host'] == self.host_name]
params = {'host': self.host_name}
- _, services = self.admin_volume_services_client.list_services(params)
+ services = self.admin_volume_services_client.list_services(params)
# we could have a periodic job checkin between the 2 service
# lookups, so only compare binary lists.
@@ -64,7 +64,7 @@
def test_get_service_by_service_and_host_name(self):
params = {'host': self.host_name, 'binary': self.binary_name}
- _, services = self.admin_volume_services_client.list_services(params)
+ services = self.admin_volume_services_client.list_services(params)
self.assertEqual(1, len(services))
self.assertEqual(self.host_name, services[0]['host'])
self.assertEqual(self.binary_name, services[0]['binary'])
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index a481224..58f1551 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -34,7 +34,7 @@
@test.attr(type='smoke')
def test_volume_type_list(self):
# List Volume types.
- _, body = self.volume_types_client.list_volume_types()
+ body = self.volume_types_client.list_volume_types()
self.assertIsInstance(body, list)
@test.attr(type='smoke')
@@ -49,14 +49,14 @@
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
body = {}
- _, body = self.volume_types_client.create_volume_type(
+ body = self.volume_types_client.create_volume_type(
vol_type_name,
extra_specs=extra_specs)
self.assertIn('id', body)
self.addCleanup(self._delete_volume_type, body['id'])
self.assertIn('name', body)
params = {self.name_field: vol_name, 'volume_type': vol_type_name}
- _, volume = self.volumes_client.create_volume(
+ volume = self.volumes_client.create_volume(
size=1, **params)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
@@ -67,7 +67,7 @@
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
- _, fetched_volume = self.volumes_client.get_volume(volume['id'])
+ fetched_volume = self.volumes_client.get_volume(volume['id'])
self.assertEqual(vol_name, fetched_volume[self.name_field],
'The fetched Volume is different '
'from the created Volume')
@@ -87,7 +87,7 @@
vendor = CONF.volume.vendor_name
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
- _, body = self.volume_types_client.create_volume_type(
+ body = self.volume_types_client.create_volume_type(
name,
extra_specs=extra_specs)
self.assertIn('id', body)
@@ -98,7 +98,7 @@
"to the requested name")
self.assertTrue(body['id'] is not None,
"Field volume_type id is empty or not found.")
- _, fetched_volume_type = self.volume_types_client.get_volume_type(
+ fetched_volume_type = self.volume_types_client.get_volume_type(
body['id'])
self.assertEqual(name, fetched_volume_type['name'],
'The fetched Volume_type is different '
@@ -116,11 +116,11 @@
provider = "LuksEncryptor"
control_location = "front-end"
name = data_utils.rand_name("volume-type-")
- _, body = self.volume_types_client.create_volume_type(name)
+ body = self.volume_types_client.create_volume_type(name)
self.addCleanup(self._delete_volume_type, body['id'])
# Create encryption type
- _, encryption_type = self.volume_types_client.create_encryption_type(
+ encryption_type = self.volume_types_client.create_encryption_type(
body['id'], provider=provider,
control_location=control_location)
self.assertIn('volume_type_id', encryption_type)
@@ -132,7 +132,7 @@
"equal to the requested control_location")
# Get encryption type
- _, fetched_encryption_type = (
+ fetched_encryption_type = (
self.volume_types_client.get_encryption_type(
encryption_type['volume_type_id']))
self.assertEqual(provider,
@@ -150,7 +150,7 @@
resource = {"id": encryption_type['volume_type_id'],
"type": "encryption-type"}
self.volume_types_client.wait_for_resource_deletion(resource)
- _, deleted_encryption_type = (
+ deleted_encryption_type = (
self.volume_types_client.get_encryption_type(
encryption_type['volume_type_id']))
self.assertEmpty(deleted_encryption_type)
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 3b9f6bb..460a6c3 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -25,7 +25,7 @@
def resource_setup(cls):
super(VolumeTypesExtraSpecsV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
- _, cls.volume_type = cls.volume_types_client.create_volume_type(
+ cls.volume_type = cls.volume_types_client.create_volume_type(
vol_type_name)
@classmethod
@@ -37,11 +37,11 @@
def test_volume_type_extra_specs_list(self):
# List Volume types extra specs.
extra_specs = {"spec1": "val1"}
- _, body = self.volume_types_client.create_volume_type_extra_specs(
+ body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
- _, body = self.volume_types_client.list_volume_types_extra_specs(
+ body = self.volume_types_client.list_volume_types_extra_specs(
self.volume_type['id'])
self.assertIsInstance(body, dict)
self.assertIn('spec1', body)
@@ -50,13 +50,13 @@
def test_volume_type_extra_specs_update(self):
# Update volume type extra specs
extra_specs = {"spec2": "val1"}
- _, body = self.volume_types_client.create_volume_type_extra_specs(
+ body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'], extra_specs)
self.assertEqual(extra_specs, body,
"Volume type extra spec incorrectly created")
extra_spec = {"spec2": "val2"}
- _, body = self.volume_types_client.update_volume_type_extra_specs(
+ body = self.volume_types_client.update_volume_type_extra_specs(
self.volume_type['id'],
extra_spec.keys()[0],
extra_spec)
@@ -68,7 +68,7 @@
def test_volume_type_extra_spec_create_get_delete(self):
# Create/Get/Delete volume type extra spec.
extra_specs = {"spec3": "val1"}
- _, body = self.volume_types_client.create_volume_type_extra_specs(
+ body = self.volume_types_client.create_volume_type_extra_specs(
self.volume_type['id'],
extra_specs)
self.assertEqual(extra_specs, body,
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 40af37e..fff0199 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -29,7 +29,7 @@
super(ExtraSpecsNegativeV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
cls.extra_specs = {"spec1": "val1"}
- _, cls.volume_type = cls.volume_types_client.create_volume_type(
+ cls.volume_type = cls.volume_types_client.create_volume_type(
vol_type_name,
extra_specs=cls.extra_specs)
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 8db6106..4feba73 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -31,8 +31,8 @@
cls.name_field = cls.special_fields['name_field']
params = {cls.name_field: vol_name}
- _, cls.volume = cls.client.create_volume(size=1,
- **params)
+ cls.volume = cls.client.create_volume(size=1,
+ **params)
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@@ -45,9 +45,9 @@
def _reset_volume_status(self, volume_id, status):
# Reset the volume status
- _, body = self.admin_volume_client.reset_volume_status(volume_id,
- status)
- return _, body
+ body = self.admin_volume_client.reset_volume_status(volume_id,
+ status)
+ return body
def tearDown(self):
# Set volume's status to available after test
@@ -58,8 +58,8 @@
# Create a temp volume for force delete tests
vol_name = utils.rand_name('Volume')
params = {self.name_field: vol_name}
- _, temp_volume = self.client.create_volume(size=1,
- **params)
+ temp_volume = self.client.create_volume(size=1,
+ **params)
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@@ -68,16 +68,15 @@
# Create volume, reset volume status, and force delete temp volume
temp_volume = self._create_temp_volume()
if status:
- _, body = self._reset_volume_status(temp_volume['id'], status)
- _, volume_delete = self.admin_volume_client.\
- force_delete_volume(temp_volume['id'])
+ self._reset_volume_status(temp_volume['id'], status)
+ self.admin_volume_client.force_delete_volume(temp_volume['id'])
self.client.wait_for_resource_deletion(temp_volume['id'])
@test.attr(type='gate')
def test_volume_reset_status(self):
# test volume reset status : available->error->available
- _, body = self._reset_volume_status(self.volume['id'], 'error')
- _, volume_get = self.admin_volume_client.get_volume(
+ self._reset_volume_status(self.volume['id'], 'error')
+ volume_get = self.admin_volume_client.get_volume(
self.volume['id'])
self.assertEqual('error', volume_get['status'])
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 1357d31..0739480 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -40,8 +40,8 @@
# Create backup
backup_name = data_utils.rand_name('Backup')
create_backup = self.backups_adm_client.create_backup
- _, backup = create_backup(self.volume['id'],
- name=backup_name)
+ backup = create_backup(self.volume['id'],
+ name=backup_name)
self.addCleanup(self.backups_adm_client.delete_backup,
backup['id'])
self.assertEqual(backup_name, backup['name'])
@@ -51,16 +51,16 @@
'available')
# Get a given backup
- _, backup = self.backups_adm_client.get_backup(backup['id'])
+ backup = self.backups_adm_client.get_backup(backup['id'])
self.assertEqual(backup_name, backup['name'])
# Get all backups with detail
- _, backups = self.backups_adm_client.list_backups_with_detail()
+ backups = self.backups_adm_client.list_backups_with_detail()
self.assertIn((backup['name'], backup['id']),
[(m['name'], m['id']) for m in backups])
# Restore backup
- _, restore = self.backups_adm_client.restore_backup(backup['id'])
+ restore = self.backups_adm_client.restore_backup(backup['id'])
# Delete backup
self.addCleanup(self.admin_volume_client.delete_volume,
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 52e48f3..127a216 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -97,7 +97,7 @@
name_field = cls.special_fields['name_field']
kwargs[name_field] = name
- _, volume = cls.volumes_client.create_volume(size, **kwargs)
+ volume = cls.volumes_client.create_volume(size, **kwargs)
cls.volumes.append(volume)
cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
@@ -106,8 +106,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)
cls.snapshots.append(snapshot)
cls.snapshots_client.wait_for_snapshot_status(snapshot['id'],
'available')
@@ -198,8 +198,8 @@
"""create a test Qos-Specs."""
name = name or data_utils.rand_name(cls.__name__ + '-QoS')
consumer = consumer or 'front-end'
- _, qos_specs = cls.volume_qos_client.create_qos(name, consumer,
- **kwargs)
+ qos_specs = cls.volume_qos_client.create_qos(name, consumer,
+ **kwargs)
cls.qos_specs.append(qos_specs['id'])
return qos_specs
diff --git a/tempest/api/volume/test_availability_zone.py b/tempest/api/volume/test_availability_zone.py
index c3d5d02..bd3d2a1 100644
--- a/tempest/api/volume/test_availability_zone.py
+++ b/tempest/api/volume/test_availability_zone.py
@@ -31,7 +31,7 @@
@test.attr(type='gate')
def test_get_availability_zone_list(self):
# List of availability zone
- _, availability_zone = self.client.get_availability_zone_list()
+ availability_zone = self.client.get_availability_zone_list()
self.assertTrue(len(availability_zone) > 0)
diff --git a/tempest/api/volume/test_extensions.py b/tempest/api/volume/test_extensions.py
index 0f6c2d6..dbbdea4 100644
--- a/tempest/api/volume/test_extensions.py
+++ b/tempest/api/volume/test_extensions.py
@@ -30,7 +30,7 @@
@test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
- _, extensions = self.volumes_extension_client.list_extensions()
+ extensions = self.volumes_extension_client.list_extensions()
if len(CONF.volume_feature_enabled.api_extensions) == 0:
raise self.skipException('There are not any extensions configured')
extension_list = [extension.get('alias') for extension in extensions]
diff --git a/tempest/api/volume/test_qos.py b/tempest/api/volume/test_qos.py
index a719b79..60c327b 100644
--- a/tempest/api/volume/test_qos.py
+++ b/tempest/api/volume/test_qos.py
@@ -47,12 +47,12 @@
self.volume_qos_client.wait_for_resource_deletion(body['id'])
# validate the deletion
- _, list_qos = self.volume_qos_client.list_qos()
+ list_qos = self.volume_qos_client.list_qos()
self.assertNotIn(body, list_qos)
def _create_test_volume_type(self):
vol_type_name = utils.rand_name("volume-type")
- _, vol_type = self.volume_types_client.create_volume_type(
+ vol_type = self.volume_types_client.create_volume_type(
vol_type_name)
self.addCleanup(self.volume_types_client.delete_volume_type,
vol_type['id'])
@@ -63,7 +63,7 @@
self.created_qos['id'], vol_type_id)
def _test_get_association_qos(self):
- _, body = self.volume_qos_client.get_association_qos(
+ body = self.volume_qos_client.get_association_qos(
self.created_qos['id'])
associations = []
@@ -97,24 +97,24 @@
@test.attr(type='smoke')
def test_get_qos(self):
"""Tests the detail of a given qos-specs"""
- _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertEqual(self.qos_name, body['name'])
self.assertEqual(self.qos_consumer, body['consumer'])
@test.attr(type='smoke')
def test_list_qos(self):
"""Tests the list of all qos-specs"""
- _, body = self.volume_qos_client.list_qos()
+ body = self.volume_qos_client.list_qos()
self.assertIn(self.created_qos, body)
@test.attr(type='smoke')
def test_set_unset_qos_key(self):
"""Test the addition of a specs key to qos-specs"""
args = {'iops_bytes': '500'}
- _, body = self.volume_qos_client.set_qos_key(self.created_qos['id'],
- iops_bytes='500')
+ body = self.volume_qos_client.set_qos_key(self.created_qos['id'],
+ iops_bytes='500')
self.assertEqual(args, body)
- _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertEqual(args['iops_bytes'], body['specs']['iops_bytes'])
# test the deletion of a specs key from qos-specs
@@ -123,7 +123,7 @@
operation = 'qos-key-unset'
self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],
operation, keys)
- _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ body = self.volume_qos_client.get_qos(self.created_qos['id'])
self.assertNotIn(keys[0], body['specs'])
@test.attr(type='smoke')
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 0dceb3d..03474ba 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -42,15 +42,15 @@
"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)
# Get the metadata of the snapshot
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Delete one item metadata of the snapshot
self.client.delete_snapshot_metadata_item(
self.snapshot_id, "key1")
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expected, body)
@test.attr(type='gate')
@@ -62,16 +62,16 @@
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)
# Get the metadata of the snapshot
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
- _, body = self.client.update_snapshot_metadata(
+ body = self.client.update_snapshot_metadata(
self.snapshot_id, update)
# Get the metadata of the snapshot
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(update, body)
@test.attr(type='gate')
@@ -85,16 +85,16 @@
"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)
# Get the metadata of the snapshot
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(metadata, body)
# Update metadata item
- _, body = self.client.update_snapshot_metadata_item(
+ body = self.client.update_snapshot_metadata_item(
self.snapshot_id, "key3", update_item)
# Get the metadata of the snapshot
- _, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ body = self.client.get_snapshot_metadata(self.snapshot_id)
self.assertEqual(expect, body)
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
index ac5d016..4739fd2 100644
--- a/tempest/api/volume/test_volume_metadata.py
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -41,15 +41,15 @@
"key3": "value3",
"key4": "<value&special_chars>"}
- _, body = self.volumes_client.create_volume_metadata(self.volume_id,
- metadata)
+ body = self.volumes_client.create_volume_metadata(self.volume_id,
+ metadata)
# Get the metadata of the volume
- _, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the volume
self.volumes_client.delete_volume_metadata_item(
self.volume_id, "key1")
- _, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertNotIn("key1", body)
del metadata["key1"]
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
@@ -65,16 +65,16 @@
"key1": "value1_update"}
# Create metadata for the volume
- _, body = self.volumes_client.create_volume_metadata(
+ body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
# Get the metadata of the volume
- _, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata
- _, body = self.volumes_client.update_volume_metadata(
+ body = self.volumes_client.update_volume_metadata(
self.volume_id, update)
# Get the metadata of the volume
- _, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(update.items()))
@test.attr(type='gate')
@@ -88,14 +88,14 @@
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the volume
- _, body = self.volumes_client.create_volume_metadata(
+ body = self.volumes_client.create_volume_metadata(
self.volume_id, metadata)
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
- _, body = self.volumes_client.update_volume_metadata_item(
+ body = self.volumes_client.update_volume_metadata_item(
self.volume_id, "key3", update_item)
# Get the metadata of the volume
- _, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ body = self.volumes_client.get_volume_metadata(self.volume_id)
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index 2011c1b..b2961bd 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -58,24 +58,24 @@
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
- _, transfer = self.client.create_volume_transfer(volume['id'])
+ transfer = self.client.create_volume_transfer(volume['id'])
transfer_id = transfer['id']
auth_key = transfer['auth_key']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# Get a volume transfer
- _, body = self.client.get_volume_transfer(transfer_id)
+ body = self.client.get_volume_transfer(transfer_id)
self.assertEqual(volume['id'], body['volume_id'])
# List volume transfers, the result should be greater than
# or equal to 1
- _, body = self.client.list_volume_transfers()
+ body = self.client.list_volume_transfers()
self.assertThat(len(body), matchers.GreaterThan(0))
# Accept a volume transfer by alt_tenant
- _, body = self.alt_client.accept_volume_transfer(transfer_id,
- auth_key)
+ body = self.alt_client.accept_volume_transfer(transfer_id,
+ auth_key)
self.alt_client.wait_for_volume_status(volume['id'], 'available')
def test_create_list_delete_volume_transfer(self):
@@ -84,13 +84,13 @@
self.addCleanup(self._delete_volume, volume['id'])
# Create a volume transfer
- _, body = self.client.create_volume_transfer(volume['id'])
+ body = self.client.create_volume_transfer(volume['id'])
transfer_id = body['id']
self.client.wait_for_volume_status(volume['id'],
'awaiting-transfer')
# List all volume transfers (looking for the one we created)
- _, body = self.client.list_volume_transfers()
+ body = self.client.list_volume_transfers()
for transfer in body:
if volume['id'] == transfer['volume_id']:
break
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 4fd27b1..ceabb1c 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -57,11 +57,11 @@
def test_attach_detach_volume_to_instance(self):
# Volume is attached and detached successfully from an instance
mountpoint = '/dev/vdc'
- _, body = self.client.attach_volume(self.volume['id'],
- self.server['id'],
- mountpoint)
+ self.client.attach_volume(self.volume['id'],
+ self.server['id'],
+ mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
- _, body = self.client.detach_volume(self.volume['id'])
+ self.client.detach_volume(self.volume['id'])
self.client.wait_for_volume_status(self.volume['id'], 'available')
@test.stresstest(class_setup_per='process')
@@ -70,9 +70,9 @@
def test_get_volume_attachment(self):
# Verify that a volume's attachment information is retrieved
mountpoint = '/dev/vdc'
- _, body = self.client.attach_volume(self.volume['id'],
- self.server['id'],
- mountpoint)
+ self.client.attach_volume(self.volume['id'],
+ self.server['id'],
+ mountpoint)
self.client.wait_for_volume_status(self.volume['id'], 'in-use')
# NOTE(gfidente): added in reverse order because functions will be
# called in reverse order to the order they are added (LIFO)
@@ -80,7 +80,7 @@
self.volume['id'],
'available')
self.addCleanup(self.client.detach_volume, self.volume['id'])
- _, volume = self.client.get_volume(self.volume['id'])
+ volume = self.client.get_volume(self.volume['id'])
self.assertIn('attachments', volume)
attachment = self.client.get_attachment_from_volume(volume)
self.assertEqual(mountpoint, attachment['device'])
@@ -96,9 +96,9 @@
# there is no way to delete it from Cinder, so we delete it from Glance
# using the Glance image_client and from Cinder via tearDownClass.
image_name = data_utils.rand_name('Image-')
- _, body = self.client.upload_volume(self.volume['id'],
- image_name,
- CONF.volume.disk_format)
+ body = self.client.upload_volume(self.volume['id'],
+ image_name,
+ CONF.volume.disk_format)
image_id = body["image_id"]
self.addCleanup(self.image_client.delete_image, image_id)
self.image_client.wait_for_image_status(image_id, 'active')
@@ -107,14 +107,14 @@
@test.attr(type='gate')
def test_reserve_unreserve_volume(self):
# Mark volume as reserved.
- _, body = self.client.reserve_volume(self.volume['id'])
+ body = self.client.reserve_volume(self.volume['id'])
# To get the volume info
- _, body = self.client.get_volume(self.volume['id'])
+ body = self.client.get_volume(self.volume['id'])
self.assertIn('attaching', body['status'])
# Unmark volume as reserved.
- _, body = self.client.unreserve_volume(self.volume['id'])
+ body = self.client.unreserve_volume(self.volume['id'])
# To get the volume info
- _, body = self.client.get_volume(self.volume['id'])
+ body = self.client.get_volume(self.volume['id'])
self.assertIn('available', body['status'])
def _is_true(self, val):
@@ -124,20 +124,19 @@
def test_volume_readonly_update(self):
# Update volume readonly true
readonly = True
- _, body = self.client.update_volume_readonly(self.volume['id'],
- readonly)
+ self.client.update_volume_readonly(self.volume['id'],
+ readonly)
# Get Volume information
- _, fetched_volume = self.client.get_volume(self.volume['id'])
+ fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(True, bool_flag)
# Update volume readonly false
readonly = False
- _, body = self.client.update_volume_readonly(self.volume['id'],
- readonly)
+ self.client.update_volume_readonly(self.volume['id'], readonly)
# Get Volume information
- _, fetched_volume = self.client.get_volume(self.volume['id'])
+ fetched_volume = self.client.get_volume(self.volume['id'])
bool_flag = self._is_true(fetched_volume['metadata']['readonly'])
self.assertEqual(False, bool_flag)
diff --git a/tempest/api/volume/test_volumes_extend.py b/tempest/api/volume/test_volumes_extend.py
index 2b816ef..ebe6084 100644
--- a/tempest/api/volume/test_volumes_extend.py
+++ b/tempest/api/volume/test_volumes_extend.py
@@ -32,9 +32,9 @@
# Extend Volume Test.
self.volume = self.create_volume()
extend_size = int(self.volume['size']) + 1
- _, body = self.client.extend_volume(self.volume['id'], extend_size)
+ self.client.extend_volume(self.volume['id'], extend_size)
self.client.wait_for_volume_status(self.volume['id'], 'available')
- _, volume = self.client.get_volume(self.volume['id'])
+ volume = self.client.get_volume(self.volume['id'])
self.assertEqual(int(volume['size']), extend_size)
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index a9c10aa..6d9c438 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -54,7 +54,7 @@
# Create a volume
kwargs[self.name_field] = v_name
kwargs['metadata'] = metadata
- _, volume = self.client.create_volume(**kwargs)
+ volume = self.client.create_volume(**kwargs)
self.assertIn('id', volume)
self.addCleanup(self._delete_volume, volume['id'])
self.client.wait_for_volume_status(volume['id'], 'available')
@@ -65,7 +65,7 @@
self.assertTrue(volume['id'] is not None,
"Field volume id is empty or not found.")
# Get Volume information
- _, fetched_volume = self.client.get_volume(volume['id'])
+ fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(v_name,
fetched_volume[self.name_field],
'The fetched Volume name is different '
@@ -90,18 +90,18 @@
# Update Volume
# Test volume update when display_name is same with original value
params = {self.name_field: v_name}
- _, update_volume = self.client.update_volume(volume['id'], **params)
+ self.client.update_volume(volume['id'], **params)
# Test volume update when display_name is new
new_v_name = data_utils.rand_name('new-Volume')
new_desc = 'This is the new description of volume'
params = {self.name_field: new_v_name,
self.descrip_field: new_desc}
- _, update_volume = self.client.update_volume(volume['id'], **params)
+ update_volume = self.client.update_volume(volume['id'], **params)
# Assert response body for update_volume method
self.assertEqual(new_v_name, update_volume[self.name_field])
self.assertEqual(new_desc, update_volume[self.descrip_field])
# Assert response body for get_volume method
- _, updated_volume = self.client.get_volume(volume['id'])
+ updated_volume = self.client.get_volume(volume['id'])
self.assertEqual(volume['id'], updated_volume['id'])
self.assertEqual(new_v_name, updated_volume[self.name_field])
self.assertEqual(new_desc, updated_volume[self.descrip_field])
@@ -116,15 +116,14 @@
new_v_desc = data_utils.rand_name('@#$%^* description')
params = {self.descrip_field: new_v_desc,
'availability_zone': volume['availability_zone']}
- _, new_volume = self.client.create_volume(size=1, **params)
+ new_volume = self.client.create_volume(size=1, **params)
self.assertIn('id', new_volume)
self.addCleanup(self._delete_volume, new_volume['id'])
self.client.wait_for_volume_status(new_volume['id'], 'available')
params = {self.name_field: volume[self.name_field],
self.descrip_field: volume[self.descrip_field]}
- _, update_volume = self.client.update_volume(new_volume['id'],
- **params)
+ self.client.update_volume(new_volume['id'], **params)
# NOTE(jdg): Revert back to strict true/false checking
# after fix for bug #1227837 merges
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 9c0d238..91beae9 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -66,7 +66,7 @@
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
- _, 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'])
@@ -84,10 +84,10 @@
and validates result.
"""
if with_detail:
- _, fetched_vol_list = \
+ fetched_vol_list = \
self.client.list_volumes_with_detail(params=params)
else:
- _, fetched_vol_list = self.client.list_volumes(params=params)
+ fetched_vol_list = self.client.list_volumes(params=params)
# Validating params of fetched volumes
# In v2, only list detail view includes items in params.
@@ -111,7 +111,7 @@
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
- _, fetched_list = self.client.list_volumes()
+ fetched_list = self.client.list_volumes()
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -119,14 +119,14 @@
def test_volume_list_with_details(self):
# Get a list of Volumes with details
# Fetch all Volumes
- _, fetched_list = self.client.list_volumes_with_detail()
+ fetched_list = self.client.list_volumes_with_detail()
self.assertVolumesIn(fetched_list, self.volume_list)
@test.attr(type='gate')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- _, fetched_vol = self.client.list_volumes(params)
+ fetched_vol = self.client.list_volumes(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@@ -135,7 +135,7 @@
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- _, fetched_vol = self.client.list_volumes_with_detail(params)
+ fetched_vol = self.client.list_volumes_with_detail(params)
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@@ -143,7 +143,7 @@
@test.attr(type='gate')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
- _, fetched_list = self.client.list_volumes(params)
+ fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -151,7 +151,7 @@
@test.attr(type='gate')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
- _, fetched_list = self.client.list_volumes_with_detail(params)
+ fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
self.assertVolumesIn(fetched_list, self.volume_list)
@@ -161,7 +161,7 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- _, fetched_list = self.client.list_volumes(params)
+ fetched_list = self.client.list_volumes(params)
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -171,7 +171,7 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- _, fetched_list = self.client.list_volumes_with_detail(params)
+ fetched_list = self.client.list_volumes_with_detail(params)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 5d3fdef..dc8d8e2 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -224,38 +224,40 @@
@test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_negative_volume_status(self):
# Mark volume as reserved.
- _, body = self.client.reserve_volume(self.volume['id'])
+ self.client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
self.assertRaises(exceptions.BadRequest,
self.client.reserve_volume,
self.volume['id'])
# Unmark volume as reserved.
- _, body = self.client.unreserve_volume(self.volume['id'])
+ self.client.unreserve_volume(self.volume['id'])
@test.attr(type=['negative', 'gate'])
def test_list_volumes_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {self.name_field: v_name}
- _, fetched_volume = self.client.list_volumes(params)
+ fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_nonexistent_name(self):
v_name = data_utils.rand_name('Volume-')
params = {self.name_field: v_name}
- _, fetched_volume = self.client.list_volumes_with_detail(params)
+ fetched_volume = \
+ self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
- _, fetched_volume = self.client.list_volumes(params)
+ fetched_volume = self.client.list_volumes(params)
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative', 'gate'])
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
- _, fetched_volume = self.client.list_volumes_with_detail(params)
+ fetched_volume = \
+ self.client.list_volumes_with_detail(params)
self.assertEqual(0, len(fetched_volume))
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index b7e9422..179eb09 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -44,11 +44,11 @@
and validates result.
"""
if with_detail:
- _, fetched_snap_list = \
+ fetched_snap_list = \
self.snapshots_client.\
list_snapshots_with_detail(params=params)
else:
- _, fetched_snap_list = \
+ fetched_snap_list = \
self.snapshots_client.list_snapshots(params=params)
# Validating params of fetched snapshots
@@ -94,14 +94,14 @@
snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Get the snap and check for some of its details
- _, snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
+ snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
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()
snaps_data = [(f['id'], f[self.name_field]) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
@@ -110,13 +110,13 @@
new_desc = 'This is the new description of snapshot.'
params = {self.name_field: new_s_name,
self.descrip_field: new_desc}
- _, update_snapshot = \
+ update_snapshot = \
self.snapshots_client.update_snapshot(snapshot['id'], **params)
# 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 get_snapshot method
- _, updated_snapshot = \
+ updated_snapshot = \
self.snapshots_client.get_snapshot(snapshot['id'])
self.assertEqual(new_s_name, updated_snapshot[self.name_field])
self.assertEqual(new_desc, updated_snapshot[self.descrip_field])
@@ -172,7 +172,7 @@
# create a snap based volume and deletes it
snapshot = self.create_snapshot(self.volume_origin['id'])
# NOTE(gfidente): size is required also when passing snapshot_id
- _, volume = self.volumes_client.create_volume(
+ volume = self.volumes_client.create_volume(
size=1,
snapshot_id=snapshot['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index c20f3d8..bc14b2c 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -41,7 +41,7 @@
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
- _, 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'])
@@ -65,7 +65,7 @@
'sort_dir': sort_dir,
'sort_key': sort_key
}
- _, fetched_volume = self.client.list_volumes_with_detail(params)
+ fetched_volume = self.client.list_volumes_with_detail(params)
self.assertEqual(limit, len(fetched_volume),
"The count of volumes is %s, expected:%s " %
(len(fetched_volume), limit))
diff --git a/tempest/clients.py b/tempest/clients.py
index 8d59742..63bae6c 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -133,15 +133,22 @@
Top level manager for OpenStack tempest clients
"""
+ default_params = {
+ 'disable_ssl_certificate_validation':
+ CONF.identity.disable_ssl_certificate_validation,
+ 'ca_certs': CONF.identity.ca_certificates_file,
+ 'trace_requests': CONF.debug.trace_requests
+ }
+
def __init__(self, credentials=None, interface='json', service=None):
# Set interface and client type first
self.interface = interface
# super cares for credentials validation
super(Manager, self).__init__(credentials=credentials)
- self._set_compute_clients(self.interface)
- self._set_identity_clients(self.interface)
- self._set_volume_clients(self.interface)
+ self._set_compute_clients()
+ self._set_identity_clients()
+ self._set_volume_clients()
self.baremetal_client = BaremetalClientJSON(self.auth_provider)
self.network_client = NetworkClientJSON(self.auth_provider)
@@ -170,23 +177,25 @@
self.container_client = ContainerClient(self.auth_provider)
self.object_client = ObjectClient(self.auth_provider)
self.orchestration_client = OrchestrationClient(
- self.auth_provider)
+ self.auth_provider,
+ CONF.orchestration.catalog_type,
+ CONF.orchestration.region or CONF.identity.region,
+ endpoint_type=CONF.orchestration.endpoint_type,
+ build_interval=CONF.orchestration.build_interval,
+ build_timeout=CONF.orchestration.build_timeout,
+ **self.default_params)
+
self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
self.data_processing_client = DataProcessingClient(
self.auth_provider)
- def _set_compute_clients(self, type):
- self._set_compute_json_clients()
-
- # Common compute clients
+ def _set_compute_clients(self):
self.agents_client = AgentsClientJSON(self.auth_provider)
self.networks_client = NetworksClientJSON(self.auth_provider)
self.migrations_client = MigrationsClientJSON(self.auth_provider)
self.security_group_default_rules_client = (
SecurityGroupDefaultRulesClientJSON(self.auth_provider))
-
- def _set_compute_json_clients(self):
self.certificates_client = CertificatesClientJSON(self.auth_provider)
self.servers_client = ServersClientJSON(self.auth_provider)
self.limits_client = LimitsClientJSON(self.auth_provider)
@@ -213,10 +222,7 @@
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientJSON(self.auth_provider)
- def _set_identity_clients(self, type):
- self._set_identity_json_clients()
-
- def _set_identity_json_clients(self):
+ def _set_identity_clients(self):
self.identity_client = IdentityClientJSON(self.auth_provider)
self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider)
self.endpoints_client = EndPointClientJSON(self.auth_provider)
@@ -228,20 +234,12 @@
self.token_v3_client = V3TokenClientJSON()
self.credentials_client = CredentialsClientJSON(self.auth_provider)
- def _set_volume_clients(self, type):
- self._set_volume_json_clients()
- # Common volume clients
- # NOTE : As XML clients are not implemented for Qos-specs.
- # So, setting the qos_client here. Once client are implemented,
- # qos_client would be moved to its respective if/else.
- # Bug : 1312553
+ def _set_volume_clients(self):
self.volume_qos_client = QosSpecsClientJSON(self.auth_provider)
self.volume_qos_v2_client = QosSpecsV2ClientJSON(
self.auth_provider)
self.volume_services_v2_client = VolumesServicesV2ClientJSON(
self.auth_provider)
-
- def _set_volume_json_clients(self):
self.backups_client = BackupsClientJSON(self.auth_provider)
self.backups_v2_client = BackupsClientV2JSON(self.auth_provider)
self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 227fbe6..a0bbb70 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -142,7 +142,7 @@
def list(self):
client = self.client
- __, snaps = client.list_snapshots()
+ snaps = client.list_snapshots()
LOG.debug("List count, %s Snapshots" % len(snaps))
return snaps
@@ -218,7 +218,7 @@
def list(self):
client = self.client
- _, stacks = client.list_stacks()
+ stacks = client.list_stacks()
LOG.debug("List count, %s Stacks" % len(stacks))
return stacks
@@ -323,7 +323,7 @@
def list(self):
client = self.client
- _, vols = client.list_volumes()
+ vols = client.list_volumes()
LOG.debug("List count, %s Volumes" % len(vols))
return vols
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 001e3dc..6e1ca7a 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -836,7 +836,7 @@
#######################
def _get_volume_by_name(client, name):
- r, body = client.volumes.list_volumes()
+ body = client.volumes.list_volumes()
for volume in body:
if name == volume['display_name']:
return volume
@@ -857,8 +857,8 @@
size = volume['gb']
v_name = volume['name']
- resp, body = client.volumes.create_volume(size=size,
- display_name=v_name)
+ body = client.volumes.create_volume(size=size,
+ display_name=v_name)
client.volumes.wait_for_volume_status(body['id'], 'available')
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 890c77a..a7e0ee3 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -154,7 +154,7 @@
def verify_extensions(os, service, results):
extensions_client = get_extension_client(os, service)
- if service == 'neutron':
+ if service == 'neutron' or service == 'cinder':
resp = extensions_client.list_extensions()
else:
__, resp = extensions_client.list_extensions()
diff --git a/tempest/common/http.py b/tempest/common/http.py
deleted file mode 100644
index b3793bc..0000000
--- a/tempest/common/http.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# Copyright 2013 Citrix Systems, Inc.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import httplib2
-
-
-class ClosingHttp(httplib2.Http):
- def request(self, *args, **kwargs):
- original_headers = kwargs.get('headers', {})
- new_headers = dict(original_headers, connection='close')
- new_kwargs = dict(kwargs, headers=new_headers)
- return super(ClosingHttp, self).request(*args, **new_kwargs)
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index f478f95..a663931 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -124,6 +124,8 @@
self._assign_user_role(tenant, user, swift_operator_role)
if admin:
self._assign_user_role(tenant, user, CONF.identity.admin_role)
+ for role in CONF.auth.tempest_roles:
+ self._assign_user_role(tenant, user, role)
return self._get_credentials(user, tenant)
def _get_credentials(self, user, tenant):
diff --git a/tempest/common/negative_rest_client.py b/tempest/common/negative_rest_client.py
index a9ae1c3..d9842e6 100644
--- a/tempest/common/negative_rest_client.py
+++ b/tempest/common/negative_rest_client.py
@@ -15,7 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common import rest_client
+from tempest_lib.common import rest_client
+
from tempest import config
CONF = config.CONF
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
deleted file mode 100644
index 8786a17..0000000
--- a/tempest/common/rest_client.py
+++ /dev/null
@@ -1,567 +0,0 @@
-# Copyright 2012 OpenStack Foundation
-# Copyright 2013 IBM Corp.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import collections
-import json
-import logging as real_logging
-import re
-import time
-
-import jsonschema
-import six
-
-from tempest.common import http
-from tempest.common.utils import misc as misc_utils
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-
-# redrive rate limited calls at most twice
-MAX_RECURSION_DEPTH = 2
-
-# All the successful HTTP status codes from RFC 7231 & 4918
-HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206, 207)
-
-
-class RestClient(object):
-
- TYPE = "json"
-
- LOG = logging.getLogger(__name__)
-
- def __init__(self, auth_provider, service, region,
- endpoint_type='publicURL',
- build_interval=1, build_timeout=60,
- disable_ssl_certificate_validation=False, ca_certs=None,
- trace_requests=''):
- self.auth_provider = auth_provider
- self.service = service
- self.region = region
- self.endpoint_type = endpoint_type
- self.build_interval = build_interval
- self.build_timeout = build_timeout
- self.trace_requests = trace_requests
-
- # The version of the API this client implements
- self.api_version = None
- self._skip_path = False
- self.general_header_lc = set(('cache-control', 'connection',
- 'date', 'pragma', 'trailer',
- 'transfer-encoding', 'via',
- 'warning'))
- self.response_header_lc = set(('accept-ranges', 'age', 'etag',
- 'location', 'proxy-authenticate',
- 'retry-after', 'server',
- 'vary', 'www-authenticate'))
- dscv = disable_ssl_certificate_validation
- self.http_obj = http.ClosingHttp(
- disable_ssl_certificate_validation=dscv, ca_certs=ca_certs)
-
- def _get_type(self):
- return self.TYPE
-
- def get_headers(self, accept_type=None, send_type=None):
- if accept_type is None:
- accept_type = self._get_type()
- if send_type is None:
- send_type = self._get_type()
- return {'Content-Type': 'application/%s' % send_type,
- 'Accept': 'application/%s' % accept_type}
-
- def __str__(self):
- STRING_LIMIT = 80
- str_format = ("service:%s, base_url:%s, "
- "filters: %s, build_interval:%s, build_timeout:%s"
- "\ntoken:%s..., \nheaders:%s...")
- return str_format % (self.service, self.base_url,
- self.filters, self.build_interval,
- self.build_timeout,
- str(self.token)[0:STRING_LIMIT],
- str(self.get_headers())[0:STRING_LIMIT])
-
- @property
- def user(self):
- return self.auth_provider.credentials.username
-
- @property
- def user_id(self):
- return self.auth_provider.credentials.user_id
-
- @property
- def tenant_name(self):
- return self.auth_provider.credentials.tenant_name
-
- @property
- def tenant_id(self):
- return self.auth_provider.credentials.tenant_id
-
- @property
- def password(self):
- return self.auth_provider.credentials.password
-
- @property
- def base_url(self):
- return self.auth_provider.base_url(filters=self.filters)
-
- @property
- def token(self):
- return self.auth_provider.get_token()
-
- @property
- def filters(self):
- _filters = dict(
- service=self.service,
- endpoint_type=self.endpoint_type,
- region=self.region
- )
- if self.api_version is not None:
- _filters['api_version'] = self.api_version
- if self._skip_path:
- _filters['skip_path'] = self._skip_path
- return _filters
-
- def skip_path(self):
- """
- When set, ignore the path part of the base URL from the catalog
- """
- self._skip_path = True
-
- def reset_path(self):
- """
- When reset, use the base URL from the catalog as-is
- """
- self._skip_path = False
-
- @classmethod
- def expected_success(cls, expected_code, read_code):
- assert_msg = ("This function only allowed to use for HTTP status"
- "codes which explicitly defined in the RFC 7231 & 4918."
- "{0} is not a defined Success Code!"
- ).format(expected_code)
- if isinstance(expected_code, list):
- for code in expected_code:
- assert code in HTTP_SUCCESS, assert_msg
- else:
- assert expected_code in HTTP_SUCCESS, assert_msg
-
- # NOTE(afazekas): the http status code above 400 is processed by
- # the _error_checker method
- if read_code < 400:
- pattern = """Unexpected http success status code {0},
- The expected status code is {1}"""
- if ((not isinstance(expected_code, list) and
- (read_code != expected_code)) or
- (isinstance(expected_code, list) and
- (read_code not in expected_code))):
- details = pattern.format(read_code, expected_code)
- raise exceptions.InvalidHttpSuccessCode(details)
-
- def post(self, url, body, headers=None, extra_headers=False):
- return self.request('POST', url, extra_headers, headers, body)
-
- def get(self, url, headers=None, extra_headers=False):
- return self.request('GET', url, extra_headers, headers)
-
- def delete(self, url, headers=None, body=None, extra_headers=False):
- return self.request('DELETE', url, extra_headers, headers, body)
-
- def patch(self, url, body, headers=None, extra_headers=False):
- return self.request('PATCH', url, extra_headers, headers, body)
-
- def put(self, url, body, headers=None, extra_headers=False):
- return self.request('PUT', url, extra_headers, headers, body)
-
- def head(self, url, headers=None, extra_headers=False):
- return self.request('HEAD', url, extra_headers, headers)
-
- def copy(self, url, headers=None, extra_headers=False):
- return self.request('COPY', url, extra_headers, headers)
-
- def get_versions(self):
- resp, body = self.get('')
- body = self._parse_resp(body)
- versions = map(lambda x: x['id'], body)
- return resp, versions
-
- def _get_request_id(self, resp):
- for i in ('x-openstack-request-id', 'x-compute-request-id'):
- if i in resp:
- return resp[i]
- return ""
-
- def _safe_body(self, body, maxlen=4096):
- # convert a structure into a string safely
- try:
- text = six.text_type(body)
- except UnicodeDecodeError:
- # if this isn't actually text, return marker that
- return "<BinaryData: removed>"
- if len(text) > maxlen:
- return text[:maxlen]
- else:
- return text
-
- def _log_request_start(self, method, req_url, req_headers=None,
- req_body=None):
- if req_headers is None:
- req_headers = {}
- caller_name = misc_utils.find_test_caller()
- if self.trace_requests and re.search(self.trace_requests, caller_name):
- self.LOG.debug('Starting Request (%s): %s %s' %
- (caller_name, method, req_url))
-
- def _log_request_full(self, method, req_url, resp,
- secs="", req_headers=None,
- req_body=None, resp_body=None,
- caller_name=None, extra=None):
- if 'X-Auth-Token' in req_headers:
- req_headers['X-Auth-Token'] = '<omitted>'
- log_fmt = """Request (%s): %s %s %s%s
- Request - Headers: %s
- Body: %s
- Response - Headers: %s
- Body: %s"""
-
- self.LOG.debug(
- log_fmt % (
- caller_name,
- resp['status'],
- method,
- req_url,
- secs,
- str(req_headers),
- self._safe_body(req_body),
- str(resp),
- self._safe_body(resp_body)),
- extra=extra)
-
- def _log_request(self, method, req_url, resp,
- secs="", req_headers=None,
- req_body=None, resp_body=None):
- if req_headers is None:
- req_headers = {}
- # if we have the request id, put it in the right part of the log
- extra = dict(request_id=self._get_request_id(resp))
- # NOTE(sdague): while we still have 6 callers to this function
- # we're going to just provide work around on who is actually
- # providing timings by gracefully adding no content if they don't.
- # Once we're down to 1 caller, clean this up.
- caller_name = misc_utils.find_test_caller()
- if secs:
- secs = " %.3fs" % secs
- if not self.LOG.isEnabledFor(real_logging.DEBUG):
- self.LOG.info(
- 'Request (%s): %s %s %s%s' % (
- caller_name,
- resp['status'],
- method,
- req_url,
- secs),
- extra=extra)
-
- # Also look everything at DEBUG if you want to filter this
- # out, don't run at debug.
- self._log_request_full(method, req_url, resp, secs, req_headers,
- req_body, resp_body, caller_name, extra)
-
- def _parse_resp(self, body):
- body = json.loads(body)
-
- # We assume, that if the first value of the deserialized body's
- # item set is a dict or a list, that we just return the first value
- # of deserialized body.
- # Essentially "cutting out" the first placeholder element in a body
- # that looks like this:
- #
- # {
- # "users": [
- # ...
- # ]
- # }
- try:
- # Ensure there are not more than one top-level keys
- if len(body.keys()) > 1:
- return body
- # Just return the "wrapped" element
- first_key, first_item = body.items()[0]
- if isinstance(first_item, (dict, list)):
- return first_item
- except (ValueError, IndexError):
- pass
- return body
-
- def response_checker(self, method, resp, resp_body):
- if (resp.status in set((204, 205, 304)) or resp.status < 200 or
- method.upper() == 'HEAD') and resp_body:
- raise exceptions.ResponseWithNonEmptyBody(status=resp.status)
- # NOTE(afazekas):
- # If the HTTP Status Code is 205
- # 'The response MUST NOT include an entity.'
- # A HTTP entity has an entity-body and an 'entity-header'.
- # In the HTTP response specification (Section 6) the 'entity-header'
- # 'generic-header' and 'response-header' are in OR relation.
- # All headers not in the above two group are considered as entity
- # header in every interpretation.
-
- if (resp.status == 205 and
- 0 != len(set(resp.keys()) - set(('status',)) -
- self.response_header_lc - self.general_header_lc)):
- raise exceptions.ResponseWithEntity()
- # NOTE(afazekas)
- # Now the swift sometimes (delete not empty container)
- # returns with non json error response, we can create new rest class
- # for swift.
- # Usually RFC2616 says error responses SHOULD contain an explanation.
- # The warning is normal for SHOULD/SHOULD NOT case
-
- # Likely it will cause an error
- if method != 'HEAD' and not resp_body and resp.status >= 400:
- self.LOG.warning("status >= 400 response with empty body")
-
- def _request(self, method, url, headers=None, body=None):
- """A simple HTTP request interface."""
- # Authenticate the request with the auth provider
- req_url, req_headers, req_body = self.auth_provider.auth_request(
- method, url, headers, body, self.filters)
-
- # Do the actual request, and time it
- start = time.time()
- self._log_request_start(method, req_url)
- resp, resp_body = self.raw_request(
- req_url, method, headers=req_headers, body=req_body)
- end = time.time()
- self._log_request(method, req_url, resp, secs=(end - start),
- req_headers=req_headers, req_body=req_body,
- resp_body=resp_body)
-
- # Verify HTTP response codes
- self.response_checker(method, resp, resp_body)
-
- return resp, resp_body
-
- def raw_request(self, url, method, headers=None, body=None):
- if headers is None:
- headers = self.get_headers()
- return self.http_obj.request(url, method,
- headers=headers, body=body)
-
- def request(self, method, url, extra_headers=False, headers=None,
- body=None):
- # if extra_headers is True
- # default headers would be added to headers
- retry = 0
-
- if headers is None:
- # NOTE(vponomaryov): if some client do not need headers,
- # it should explicitly pass empty dict
- headers = self.get_headers()
- elif extra_headers:
- try:
- headers = headers.copy()
- headers.update(self.get_headers())
- except (ValueError, TypeError):
- headers = self.get_headers()
-
- resp, resp_body = self._request(method, url,
- headers=headers, body=body)
-
- while (resp.status == 413 and
- 'retry-after' in resp and
- not self.is_absolute_limit(
- resp, self._parse_resp(resp_body)) and
- retry < MAX_RECURSION_DEPTH):
- retry += 1
- delay = int(resp['retry-after'])
- time.sleep(delay)
- resp, resp_body = self._request(method, url,
- headers=headers, body=body)
- self._error_checker(method, url, headers, body,
- resp, resp_body)
- return resp, resp_body
-
- def _error_checker(self, method, url,
- headers, body, resp, resp_body):
-
- # NOTE(mtreinish): Check for httplib response from glance_http. The
- # object can't be used here because importing httplib breaks httplib2.
- # If another object from a class not imported were passed here as
- # resp this could possibly fail
- if str(type(resp)) == "<type 'instance'>":
- ctype = resp.getheader('content-type')
- else:
- try:
- ctype = resp['content-type']
- # NOTE(mtreinish): Keystone delete user responses doesn't have a
- # content-type header. (They don't have a body) So just pretend it
- # is set.
- except KeyError:
- ctype = 'application/json'
-
- # It is not an error response
- if resp.status < 400:
- return
-
- JSON_ENC = ['application/json', 'application/json; charset=utf-8']
- # NOTE(mtreinish): This is for compatibility with Glance and swift
- # APIs. These are the return content types that Glance api v1
- # (and occasionally swift) are using.
- TXT_ENC = ['text/plain', 'text/html', 'text/html; charset=utf-8',
- 'text/plain; charset=utf-8']
-
- if ctype.lower() in JSON_ENC:
- parse_resp = True
- elif ctype.lower() in TXT_ENC:
- parse_resp = False
- else:
- raise exceptions.InvalidContentType(str(resp.status))
-
- if resp.status == 401 or resp.status == 403:
- raise exceptions.Unauthorized(resp_body)
-
- if resp.status == 404:
- raise exceptions.NotFound(resp_body)
-
- if resp.status == 400:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- raise exceptions.BadRequest(resp_body)
-
- if resp.status == 409:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- raise exceptions.Conflict(resp_body)
-
- if resp.status == 413:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- if self.is_absolute_limit(resp, resp_body):
- raise exceptions.OverLimit(resp_body)
- else:
- raise exceptions.RateLimitExceeded(resp_body)
-
- if resp.status == 415:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- raise exceptions.InvalidContentType(resp_body)
-
- if resp.status == 422:
- if parse_resp:
- resp_body = self._parse_resp(resp_body)
- raise exceptions.UnprocessableEntity(resp_body)
-
- if resp.status in (500, 501):
- message = resp_body
- if parse_resp:
- try:
- resp_body = self._parse_resp(resp_body)
- except ValueError:
- # If response body is a non-json string message.
- # Use resp_body as is and raise InvalidResponseBody
- # exception.
- raise exceptions.InvalidHTTPResponseBody(message)
- else:
- if isinstance(resp_body, dict):
- # I'm seeing both computeFault
- # and cloudServersFault come back.
- # Will file a bug to fix, but leave as is for now.
- if 'cloudServersFault' in resp_body:
- message = resp_body['cloudServersFault']['message']
- elif 'computeFault' in resp_body:
- message = resp_body['computeFault']['message']
- elif 'error' in resp_body:
- message = resp_body['error']['message']
- elif 'message' in resp_body:
- message = resp_body['message']
- else:
- message = resp_body
-
- if resp.status == 501:
- raise exceptions.NotImplemented(message)
- else:
- raise exceptions.ServerFault(message)
-
- if resp.status >= 400:
- raise exceptions.UnexpectedResponseCode(str(resp.status))
-
- def is_absolute_limit(self, resp, resp_body):
- if (not isinstance(resp_body, collections.Mapping) or
- 'retry-after' not in resp):
- return True
- over_limit = resp_body.get('overLimit', None)
- if not over_limit:
- return True
- return 'exceed' in over_limit.get('message', 'blabla')
-
- def wait_for_resource_deletion(self, id):
- """Waits for a resource to be deleted."""
- start_time = int(time.time())
- while True:
- if self.is_resource_deleted(id):
- return
- if int(time.time()) - start_time >= self.build_timeout:
- message = ('Failed to delete %(resource_type)s %(id)s within '
- 'the required time (%(timeout)s s).' %
- {'resource_type': self.resource_type, 'id': id,
- 'timeout': self.build_timeout})
- caller = misc_utils.find_test_caller()
- if caller:
- message = '(%s) %s' % (caller, message)
- raise exceptions.TimeoutException(message)
- time.sleep(self.build_interval)
-
- def is_resource_deleted(self, id):
- """
- Subclasses override with specific deletion detection.
- """
- message = ('"%s" does not implement is_resource_deleted'
- % self.__class__.__name__)
- raise NotImplementedError(message)
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'resource'
-
- @classmethod
- def validate_response(cls, schema, resp, body):
- # Only check the response if the status code is a success code
- # TODO(cyeoh): Eventually we should be able to verify that a failure
- # code if it exists is something that we expect. This is explicitly
- # declared in the V3 API and so we should be able to export this in
- # the response schema. For now we'll ignore it.
- if resp.status in HTTP_SUCCESS:
- cls.expected_success(schema['status_code'], resp.status)
-
- # Check the body of a response
- body_schema = schema.get('response_body')
- if body_schema:
- try:
- jsonschema.validate(body, body_schema)
- except jsonschema.ValidationError as ex:
- msg = ("HTTP response body is invalid (%s)") % ex
- raise exceptions.InvalidHTTPResponseBody(msg)
- else:
- if body:
- msg = ("HTTP response body should not exist (%s)") % body
- raise exceptions.InvalidHTTPResponseBody(msg)
-
- # Check the header of a response
- header_schema = schema.get('response_header')
- if header_schema:
- try:
- jsonschema.validate(resp, header_schema)
- except jsonschema.ValidationError as ex:
- msg = ("HTTP response header is invalid (%s)") % ex
- raise exceptions.InvalidHTTPResponseHeader(msg)
diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py
index c32a7d0..45a07f1 100644
--- a/tempest/common/service_client.py
+++ b/tempest/common/service_client.py
@@ -12,8 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.common import rest_client
+from tempest_lib.common import rest_client
+from tempest_lib import exceptions as lib_exceptions
+
from tempest import config
+from tempest import exceptions
CONF = config.CONF
@@ -21,13 +24,21 @@
class ServiceClient(rest_client.RestClient):
def __init__(self, auth_provider, service, region,
- endpoint_type=None, build_interval=None, build_timeout=None):
+ endpoint_type=None, build_interval=None, build_timeout=None,
+ disable_ssl_certificate_validation=None, ca_certs=None,
+ trace_requests=None):
+
+ # TODO(oomichi): This params setting should be removed after all
+ # service clients pass these values, and we can make ServiceClient
+ # free from CONF values.
+ dscv = (disable_ssl_certificate_validation or
+ CONF.identity.disable_ssl_certificate_validation)
params = {
- 'disable_ssl_certificate_validation':
- CONF.identity.disable_ssl_certificate_validation,
- 'ca_certs': CONF.identity.ca_certificates_file,
- 'trace_requests': CONF.debug.trace_requests
+ 'disable_ssl_certificate_validation': dscv,
+ 'ca_certs': ca_certs or CONF.identity.ca_certificates_file,
+ 'trace_requests': trace_requests or CONF.debug.trace_requests
}
+
if endpoint_type is not None:
params.update({'endpoint_type': endpoint_type})
if build_interval is not None:
@@ -37,6 +48,42 @@
super(ServiceClient, self).__init__(auth_provider, service, region,
**params)
+ def request(self, method, url, extra_headers=False, headers=None,
+ body=None):
+ # TODO(oomichi): This translation is just for avoiding a single
+ # huge patch to migrate rest_client module to tempest-lib.
+ # Ideally(in the future), we need to remove this translation and
+ # replace each API tests with tempest-lib's exceptions.
+ try:
+ return super(ServiceClient, self).request(
+ method, url,
+ extra_headers=extra_headers,
+ headers=headers, body=body)
+ except lib_exceptions.Unauthorized as ex:
+ raise exceptions.Unauthorized(ex)
+ except lib_exceptions.NotFound as ex:
+ raise exceptions.NotFound(ex)
+ except lib_exceptions.BadRequest as ex:
+ raise exceptions.BadRequest(ex)
+ except lib_exceptions.Conflict as ex:
+ raise exceptions.Conflict(ex)
+ except lib_exceptions.OverLimit as ex:
+ raise exceptions.OverLimit(ex)
+ except lib_exceptions.RateLimitExceeded as ex:
+ raise exceptions.RateLimitExceeded(ex)
+ except lib_exceptions.InvalidContentType as ex:
+ raise exceptions.InvalidContentType(ex)
+ except lib_exceptions.UnprocessableEntity as ex:
+ raise exceptions.UnprocessableEntity(ex)
+ except lib_exceptions.InvalidHTTPResponseBody as ex:
+ raise exceptions.InvalidHTTPResponseBody(ex)
+ except lib_exceptions.NotImplemented as ex:
+ raise exceptions.NotImplemented(ex)
+ except lib_exceptions.ServerFault as ex:
+ raise exceptions.ServerFault(ex)
+ except lib_exceptions.UnexpectedResponseCode as ex:
+ raise exceptions.UnexpectedResponseCode(ex)
+
class ResponseBody(dict):
"""Class that wraps an http response and dict body into a single value.
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index d8bfef8..6e61c55 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -97,6 +97,10 @@
cmd = "/bin/ip addr | awk '/ether/ {print $2}'"
return self.exec_command(cmd)
+ def get_nic_name(self, address):
+ cmd = "/bin/ip -o addr | awk '/%s/ {print $2}'" % address
+ return self.exec_command(cmd)
+
def get_ip_list(self):
cmd = "/bin/ip address"
return self.exec_command(cmd)
@@ -116,3 +120,47 @@
# Get pid(s) of a process/program
cmd = "ps -ef | grep %s | grep -v 'grep' | awk {'print $1'}" % pr_name
return self.exec_command(cmd).split('\n')
+
+ def get_dns_servers(self):
+ cmd = 'cat /etc/resolv.conf'
+ resolve_file = self.exec_command(cmd).strip().split('\n')
+ entries = (l.split() for l in resolve_file)
+ dns_servers = [l[1] for l in entries
+ if len(l) and l[0] == 'nameserver']
+ return dns_servers
+
+ def send_signal(self, pid, signum):
+ cmd = 'sudo /bin/kill -{sig} {pid}'.format(pid=pid, sig=signum)
+ return self.exec_command(cmd)
+
+ def _renew_lease_udhcpc(self, fixed_ip=None):
+ """Renews DHCP lease via udhcpc client. """
+ file_path = '/var/run/udhcpc.'
+ nic_name = self.get_nic_name(fixed_ip)
+ nic_name = nic_name.strip().lower()
+ pid = self.exec_command('cat {path}{nic}.pid'.
+ format(path=file_path, nic=nic_name))
+ pid = pid.strip()
+ self.send_signal(pid, 'USR1')
+
+ def _renew_lease_dhclient(self, fixed_ip=None):
+ """Renews DHCP lease via dhclient client. """
+ cmd = "sudo /sbin/dhclient -r && /sbin/dhclient"
+ self.exec_command(cmd)
+
+ def renew_lease(self, fixed_ip=None):
+ """Wrapper method for renewing DHCP lease via given client
+
+ Supporting:
+ * udhcpc
+ * dhclient
+ """
+ # TODO(yfried): add support for dhcpcd
+ suported_clients = ['udhcpc', 'dhclient']
+ dhcp_client = CONF.scenario.dhcp_client
+ if dhcp_client not in suported_clients:
+ raise exceptions.InvalidConfiguration('%s DHCP client unsupported'
+ % dhcp_client)
+ if dhcp_client == 'udhcpc' and not fixed_ip:
+ raise ValueError("need to set 'fixed_ip' for udhcpc client")
+ return getattr(self, '_renew_lease_' + dhcp_client)(fixed_ip=fixed_ip)
\ No newline at end of file
diff --git a/tempest/config.py b/tempest/config.py
index 1c0dabb..dd693e5 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -59,6 +59,9 @@
"It requires at least `2 * CONC` distinct accounts "
"configured in `test_accounts_file`, with CONC == the "
"number of concurrent test processes."),
+ cfg.ListOpt('tempest_roles',
+ help="Roles to assign to all users created by tempest",
+ default=[])
]
identity_group = cfg.OptGroup(name='identity',
@@ -857,7 +860,14 @@
'large_ops_number',
default=0,
help="specifies how many resources to request at once. Used "
- "for large operations testing.")
+ "for large operations testing."),
+ # TODO(yfried): add support for dhcpcd
+ cfg.StrOpt('dhcp_client',
+ default='udhcpc',
+ choices=["udhcpc", "dhclient"],
+ help='DHCP client used by images to renew DCHP lease. '
+ 'If left empty, update operation will be skipped. '
+ 'Supported clients: "udhcpc", "dhclient"')
]
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 9b2b4d4..86f488a 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -51,10 +51,6 @@
pass
-class RFCViolation(RestClientException):
- message = "RFC Violation"
-
-
class InvalidConfiguration(TempestException):
message = "Invalid Configuration"
@@ -63,18 +59,6 @@
message = "Invalid Credentials"
-class InvalidHttpSuccessCode(RestClientException):
- message = "The success code is different than the expected one"
-
-
-class NotFound(RestClientException):
- message = "Object not found"
-
-
-class Unauthorized(RestClientException):
- message = 'Unauthorized'
-
-
class InvalidServiceTag(TempestException):
message = "Invalid service tag"
@@ -123,15 +107,7 @@
"'%(resource_status_reason)s'")
-class BadRequest(RestClientException):
- message = "Bad request"
-
-
-class UnprocessableEntity(RestClientException):
- message = "Unprocessable entity"
-
-
-class AuthenticationFailure(RestClientException):
+class AuthenticationFailure(TempestException):
message = ("Authentication with user %(user)s and password "
"%(password)s failed auth using tenant %(tenant)s.")
@@ -140,22 +116,6 @@
message = "Endpoint not found"
-class RateLimitExceeded(RestClientException):
- message = "Rate limit exceeded"
-
-
-class OverLimit(RestClientException):
- message = "Quota exceeded"
-
-
-class ServerFault(RestClientException):
- message = "Got server fault"
-
-
-class NotImplemented(RestClientException):
- message = "Got NotImplemented error"
-
-
class ImageFault(TempestException):
message = "Got image fault"
@@ -164,10 +124,6 @@
message = "Got identity error"
-class Conflict(RestClientException):
- message = "An object with that identifier already exists"
-
-
class SSHTimeout(TempestException):
message = ("Connection to the %(host)s via SSH timed out.\n"
"User: %(user)s, Password: %(password)s")
@@ -187,6 +143,50 @@
message = "%(num)d cleanUp operation failed"
+class RFCViolation(RestClientException):
+ message = "RFC Violation"
+
+
+class InvalidHttpSuccessCode(RestClientException):
+ message = "The success code is different than the expected one"
+
+
+class NotFound(RestClientException):
+ message = "Object not found"
+
+
+class Unauthorized(RestClientException):
+ message = 'Unauthorized'
+
+
+class BadRequest(RestClientException):
+ message = "Bad request"
+
+
+class UnprocessableEntity(RestClientException):
+ message = "Unprocessable entity"
+
+
+class RateLimitExceeded(RestClientException):
+ message = "Rate limit exceeded"
+
+
+class OverLimit(RestClientException):
+ message = "Quota exceeded"
+
+
+class ServerFault(RestClientException):
+ message = "Got server fault"
+
+
+class NotImplemented(RestClientException):
+ message = "Got NotImplemented error"
+
+
+class Conflict(RestClientException):
+ message = "An object with that identifier already exists"
+
+
class ResponseWithNonEmptyBody(RFCViolation):
message = ("RFC Violation! Response with %(status)d HTTP Status Code "
"MUST NOT have a body")
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 71697c4..1c53f45 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -210,7 +210,7 @@
imageRef=None, volume_type=None, wait_on_delete=True):
if name is None:
name = data_utils.rand_name(self.__class__.__name__)
- _, volume = self.volumes_client.create_volume(
+ volume = self.volumes_client.create_volume(
size=size, display_name=name, snapshot_id=snapshot_id,
imageRef=imageRef, volume_type=volume_type)
@@ -230,7 +230,7 @@
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
# The volume retrieved on creation has a non-up-to-date status.
# Retrieval after it becomes active ensures correct details.
- _, volume = self.volumes_client.get_volume(volume['id'])
+ volume = self.volumes_client.get_volume(volume['id'])
return volume
def _create_loginable_secgroup_rule(self, secgroup_id=None):
@@ -416,19 +416,19 @@
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')
+ volume = self.servers_client.attach_volume(
+ self.server['id'], self.volume['id'], '/dev/vdb')[1]
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
- _, self.volume = self.volumes_client.get_volume(volume['id'])
+ self.volume = self.volumes_client.get_volume(volume['id'])
def nova_volume_detach(self):
self.servers_client.detach_volume(self.server['id'], self.volume['id'])
self.volumes_client.wait_for_volume_status(self.volume['id'],
'available')
- _, volume = self.volumes_client.get_volume(self.volume['id'])
+ volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual('available', volume['status'])
def rebuild_server(self, server_id, image=None,
@@ -1012,12 +1012,16 @@
router.update(admin_state_up=admin_state_up)
self.assertEqual(admin_state_up, router.admin_state_up)
- def create_networks(self, client=None, tenant_id=None):
+ def create_networks(self, client=None, tenant_id=None,
+ dns_nameservers=None):
"""Create a network with a subnet connected to a router.
The baremetal driver is a special case since all nodes are
on the same shared network.
+ :param client: network client to create resources with.
+ :param tenant_id: id of tenant to create resources in.
+ :param dns_nameservers: list of dns servers to send to subnet.
:returns: network, subnet, router
"""
if CONF.baremetal.driver_enabled:
@@ -1033,7 +1037,12 @@
else:
network = self._create_network(client=client, tenant_id=tenant_id)
router = self._get_router(client=client, tenant_id=tenant_id)
- subnet = self._create_subnet(network=network, client=client)
+
+ subnet_kwargs = dict(network=network, client=client)
+ # use explicit check because empty list is a valid option
+ if dns_nameservers is not None:
+ subnet_kwargs['dns_nameservers'] = dns_nameservers
+ subnet = self._create_subnet(**subnet_kwargs)
subnet.add_to_router(router.id)
return network, subnet, router
@@ -1216,7 +1225,7 @@
name = 'generic'
randomized_name = data_utils.rand_name('scenario-type-' + name + '-')
LOG.debug("Creating a volume type: %s", randomized_name)
- _, body = client.create_volume_type(
+ body = client.create_volume_type(
randomized_name)
self.assertIn('id', body)
self.addCleanup(client.delete_volume_type, body['id'])
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index f09f00c..18b759e 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -52,13 +52,13 @@
# create the stack
self.template = self._load_template(__file__, self.template_name)
- _, stack = self.client.create_stack(
+ stack = self.client.create_stack(
name=self.stack_name,
template=self.template,
parameters=self.parameters)
stack = stack['stack']
- _, self.stack = self.client.get_stack(stack['id'])
+ self.stack = self.client.get_stack(stack['id'])
self.stack_identifier = '%s/%s' % (self.stack_name, self.stack['id'])
self.addCleanup(self.delete_wrapper,
self.orchestration_client.delete_stack,
@@ -77,7 +77,7 @@
self.client.wait_for_resource_status(
sid, 'SmokeServer', 'CREATE_COMPLETE')
- _, server_resource = self.client.get_resource(sid, 'SmokeServer')
+ server_resource = self.client.get_resource(sid, 'SmokeServer')
server_id = server_resource['physical_resource_id']
_, server = self.servers_client.get_server(server_id)
server_ip =\
@@ -104,7 +104,7 @@
self.client.wait_for_stack_status(sid, 'CREATE_COMPLETE')
- _, stack = self.client.get_stack(sid)
+ stack = self.client.get_stack(sid)
# This is an assert of great significance, as it means the following
# has happened:
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
index 75769ce..469ac4a 100644
--- a/tempest/scenario/test_aggregates_basic_ops.py
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -43,7 +43,7 @@
return cls.admin_credentials()
def _create_aggregate(self, **kwargs):
- _, aggregate = self.aggregates_client.create_aggregate(**kwargs)
+ aggregate = self.aggregates_client.create_aggregate(**kwargs)
self.addCleanup(self._delete_aggregate, aggregate)
aggregate_name = kwargs['name']
availability_zone = kwargs['availability_zone']
@@ -55,23 +55,23 @@
self.aggregates_client.delete_aggregate(aggregate['id'])
def _get_host_name(self):
- _, hosts = self.hosts_client.list_hosts()
+ hosts = self.hosts_client.list_hosts()
self.assertTrue(len(hosts) >= 1)
computes = [x for x in hosts if x['service'] == 'compute']
return computes[0]['host_name']
def _add_host(self, aggregate_id, host):
- _, aggregate = self.aggregates_client.add_host(aggregate_id, host)
+ aggregate = self.aggregates_client.add_host(aggregate_id, host)
self.addCleanup(self._remove_host, aggregate['id'], host)
self.assertIn(host, aggregate['hosts'])
def _remove_host(self, aggregate_id, host):
- _, aggregate = self.aggregates_client.remove_host(aggregate_id, host)
+ aggregate = self.aggregates_client.remove_host(aggregate_id, host)
self.assertNotIn(host, aggregate['hosts'])
def _check_aggregate_details(self, aggregate, aggregate_name, azone,
hosts, metadata):
- _, aggregate = self.aggregates_client.get_aggregate(aggregate['id'])
+ aggregate = self.aggregates_client.get_aggregate(aggregate['id'])
self.assertEqual(aggregate_name, aggregate['name'])
self.assertEqual(azone, aggregate['availability_zone'])
self.assertEqual(hosts, aggregate['hosts'])
@@ -81,15 +81,15 @@
aggregate['metadata'][meta_key])
def _set_aggregate_metadata(self, aggregate, meta):
- _, aggregate = self.aggregates_client.set_metadata(aggregate['id'],
- meta)
+ aggregate = self.aggregates_client.set_metadata(aggregate['id'],
+ meta)
for key, value in meta.items():
self.assertEqual(meta[key], aggregate['metadata'][key])
def _update_aggregate(self, aggregate, aggregate_name,
availability_zone):
- _, aggregate = self.aggregates_client.update_aggregate(
+ aggregate = self.aggregates_client.update_aggregate(
aggregate['id'], name=aggregate_name,
availability_zone=availability_zone)
self.assertEqual(aggregate['name'], aggregate_name)
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 16a65c9..5ea48e0 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -68,21 +68,21 @@
self.volume = self.create_volume()
def cinder_list(self):
- _, volumes = self.volumes_client.list_volumes()
+ volumes = self.volumes_client.list_volumes()
self.assertIn(self.volume['id'], [x['id'] for x in volumes])
def cinder_show(self):
- _, volume = self.volumes_client.get_volume(self.volume['id'])
+ volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual(self.volume, volume)
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)
+ volume = self.servers_client.attach_volume(
+ self.server['id'], self.volume['id'], volume_device_path)[1]
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
- _, self.volume = self.volumes_client.get_volume(volume['id'])
+ self.volume = self.volumes_client.get_volume(volume['id'])
def nova_reboot(self):
self.servers_client.reboot(self.server['id'], 'SOFT')
@@ -98,7 +98,7 @@
self.volumes_client.wait_for_volume_status(self.volume['id'],
'available')
- _, volume = self.volumes_client.get_volume(self.volume['id'])
+ volume = self.volumes_client.get_volume(self.volume['id'])
self.assertEqual('available', volume['status'])
def create_and_add_security_group(self):
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 30c3b9d..2cfec14 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -100,10 +100,10 @@
self.keypairs = {}
self.servers = []
- def _setup_network_and_servers(self):
+ def _setup_network_and_servers(self, **kwargs):
self.security_group = \
self._create_security_group(tenant_id=self.tenant_id)
- self.network, self.subnet, self.router = self.create_networks()
+ self.network, self.subnet, self.router = self.create_networks(**kwargs)
self.check_networks()
name = data_utils.rand_name('server-smoke')
@@ -425,3 +425,62 @@
self.check_public_network_connectivity(
should_connect=True, msg="after updating "
"admin_state_up of router to True")
+
+ def _check_dns_server(self, ssh_client, dns_servers):
+ servers = ssh_client.get_dns_servers()
+ self.assertEqual(set(dns_servers), set(servers),
+ 'Looking for servers: {trgt_serv}. '
+ 'Retrieved DNS nameservers: {act_serv} '
+ 'From host: {host}.'
+ .format(host=ssh_client.ssh_client.host,
+ act_serv=servers,
+ trgt_serv=dns_servers))
+
+ @testtools.skipUnless(CONF.scenario.dhcp_client,
+ "DHCP client is not available.")
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_subnet_details(self):
+ """Tests that subnet's extra configuration details are affecting
+ the VMs
+
+ NOTE: Neutron subnets push data to servers via dhcp-agent, so any
+ update in subnet requires server to actively renew its DHCP lease.
+
+ 1. Configure subnet with dns nameserver
+ 2. retrieve the VM's configured dns and verify it matches the one
+ configured for the subnet.
+ 3. update subnet's dns
+ 4. retrieve the VM's configured dns and verify it matches the new one
+ configured for the subnet.
+
+ TODO(yfried): add host_routes
+
+ any resolution check would be testing either:
+ * l3 forwarding (tested in test_network_basic_ops)
+ * Name resolution of an external DNS nameserver - out of scope for
+ Tempest
+ """
+ # this test check only updates (no actual resolution) so using
+ # arbitrary ip addresses as nameservers, instead of parsing CONF
+ initial_dns_server = '1.2.3.4'
+ alt_dns_server = '9.8.7.6'
+ self._setup_network_and_servers(dns_nameservers=[initial_dns_server])
+ self.check_public_network_connectivity(should_connect=True)
+
+ floating_ip, server = self.floating_ip_tuple
+ ip_address = floating_ip.floating_ip_address
+ private_key = self._get_server_key(server)
+ ssh_client = self._ssh_to_server(ip_address, private_key)
+
+ self._check_dns_server(ssh_client, [initial_dns_server])
+
+ self.subnet.update(dns_nameservers=[alt_dns_server])
+ # asserts that Neutron DB has updated the nameservers
+ self.assertEqual([alt_dns_server], self.subnet.dns_nameservers,
+ "Failed to update subnet's nameservers")
+
+ # server needs to renew its dhcp lease in order to get the new dns
+ # definitions from subnet
+ ssh_client.renew_lease(fixed_ip=floating_ip['fixed_ip_address'])
+ self._check_dns_server(ssh_client, [alt_dns_server])
diff --git a/tempest/services/compute/json/agents_client.py b/tempest/services/compute/json/agents_client.py
index eacd367..95d7880 100644
--- a/tempest/services/compute/json/agents_client.py
+++ b/tempest/services/compute/json/agents_client.py
@@ -17,6 +17,7 @@
from tempest.api_schema.response.compute import agents as common_schema
from tempest.api_schema.response.compute.v2 import agents as schema
+from tempest.common import service_client
from tempest.services.compute.json import base
@@ -33,7 +34,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(common_schema.list_agents, resp, body)
- return resp, body['agents']
+ return service_client.ResponseBodyList(resp, body['agents'])
def create_agent(self, **kwargs):
"""Create an agent build."""
@@ -41,16 +42,16 @@
resp, body = self.post('os-agents', post_body)
body = json.loads(body)
self.validate_response(schema.create_agent, resp, body)
- return resp, body['agent']
+ return service_client.ResponseBody(resp, body['agent'])
def delete_agent(self, agent_id):
"""Delete an existing agent build."""
resp, body = self.delete("os-agents/%s" % str(agent_id))
self.validate_response(schema.delete_agent, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def update_agent(self, agent_id, **kwargs):
"""Update an agent build."""
put_body = json.dumps({'para': kwargs})
resp, body = self.put('os-agents/%s' % str(agent_id), put_body)
- return resp, self._parse_resp(body)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index 1539259..47dd401 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -17,6 +17,7 @@
from tempest.api_schema.response.compute import aggregates as schema
from tempest.api_schema.response.compute.v2 import aggregates as v2_schema
+from tempest.common import service_client
from tempest import exceptions
from tempest.services.compute.json import base
@@ -28,14 +29,14 @@
resp, body = self.get("os-aggregates")
body = json.loads(body)
self.validate_response(schema.list_aggregates, resp, body)
- return resp, body['aggregates']
+ return service_client.ResponseBodyList(resp, body['aggregates'])
def get_aggregate(self, aggregate_id):
"""Get details of the given aggregate."""
resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
body = json.loads(body)
self.validate_response(schema.get_aggregate, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
def create_aggregate(self, **kwargs):
"""Creates a new aggregate."""
@@ -44,7 +45,7 @@
body = json.loads(body)
self.validate_response(v2_schema.create_aggregate, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
def update_aggregate(self, aggregate_id, name, availability_zone=None):
"""Update a aggregate."""
@@ -57,13 +58,13 @@
body = json.loads(body)
self.validate_response(schema.update_aggregate, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
def delete_aggregate(self, aggregate_id):
"""Deletes the given aggregate."""
resp, body = self.delete("os-aggregates/%s" % str(aggregate_id))
self.validate_response(v2_schema.delete_aggregate, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
try:
@@ -87,7 +88,7 @@
post_body)
body = json.loads(body)
self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
def remove_host(self, aggregate_id, host):
"""Removes a host from the given aggregate."""
@@ -99,7 +100,7 @@
post_body)
body = json.loads(body)
self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
def set_metadata(self, aggregate_id, meta):
"""Replaces the aggregate's existing metadata with new metadata."""
@@ -111,4 +112,4 @@
post_body)
body = json.loads(body)
self.validate_response(schema.aggregate_set_metadata, resp, body)
- return resp, body['aggregate']
+ return service_client.ResponseBody(resp, body['aggregate'])
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index 5d306f9..f4e1f12 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -17,6 +17,7 @@
from tempest.api_schema.response.compute import hosts as schema
from tempest.api_schema.response.compute.v2 import hosts as v2_schema
+from tempest.common import service_client
from tempest.services.compute.json import base
@@ -32,7 +33,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_hosts, resp, body)
- return resp, body['hosts']
+ return service_client.ResponseBodyList(resp, body['hosts'])
def show_host_detail(self, hostname):
"""Show detail information for the host."""
@@ -40,7 +41,7 @@
resp, body = self.get("os-hosts/%s" % str(hostname))
body = json.loads(body)
self.validate_response(schema.show_host_detail, resp, body)
- return resp, body['host']
+ return service_client.ResponseBodyList(resp, body['host'])
def update_host(self, hostname, **kwargs):
"""Update a host."""
@@ -55,7 +56,7 @@
resp, body = self.put("os-hosts/%s" % str(hostname), request_body)
body = json.loads(body)
self.validate_response(v2_schema.update_host, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def startup_host(self, hostname):
"""Startup a host."""
@@ -63,7 +64,7 @@
resp, body = self.get("os-hosts/%s/startup" % str(hostname))
body = json.loads(body)
self.validate_response(v2_schema.startup_host, resp, body)
- return resp, body['host']
+ return service_client.ResponseBody(resp, body['host'])
def shutdown_host(self, hostname):
"""Shutdown a host."""
@@ -71,7 +72,7 @@
resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
body = json.loads(body)
self.validate_response(v2_schema.shutdown_host, resp, body)
- return resp, body['host']
+ return service_client.ResponseBody(resp, body['host'])
def reboot_host(self, hostname):
"""reboot a host."""
@@ -79,4 +80,4 @@
resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
body = json.loads(body)
self.validate_response(v2_schema.reboot_host, resp, body)
- return resp, body['host']
+ return service_client.ResponseBody(resp, body['host'])
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
index 52b50c8..37be874 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/json/hypervisor_client.py
@@ -17,6 +17,7 @@
from tempest.api_schema.response.compute import hypervisors as common_schema
from tempest.api_schema.response.compute.v2 import hypervisors as v2schema
+from tempest.common import service_client
from tempest.services.compute.json import base
@@ -28,7 +29,7 @@
body = json.loads(body)
self.validate_response(common_schema.common_hypervisors_detail,
resp, body)
- return resp, body['hypervisors']
+ return service_client.ResponseBodyList(resp, body['hypervisors'])
def get_hypervisor_list_details(self):
"""Show detailed hypervisors information."""
@@ -36,7 +37,7 @@
body = json.loads(body)
self.validate_response(common_schema.common_list_hypervisors_detail,
resp, body)
- return resp, body['hypervisors']
+ return service_client.ResponseBodyList(resp, body['hypervisors'])
def get_hypervisor_show_details(self, hyper_id):
"""Display the details of the specified hypervisor."""
@@ -44,28 +45,28 @@
body = json.loads(body)
self.validate_response(common_schema.common_show_hypervisor,
resp, body)
- return resp, body['hypervisor']
+ return service_client.ResponseBody(resp, body['hypervisor'])
def get_hypervisor_servers(self, hyper_name):
"""List instances belonging to the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
body = json.loads(body)
self.validate_response(v2schema.hypervisors_servers, resp, body)
- return resp, body['hypervisors']
+ return service_client.ResponseBodyList(resp, body['hypervisors'])
def get_hypervisor_stats(self):
"""Get hypervisor statistics over all compute nodes."""
resp, body = self.get('os-hypervisors/statistics')
body = json.loads(body)
self.validate_response(common_schema.hypervisor_statistics, resp, body)
- return resp, body['hypervisor_statistics']
+ return service_client.ResponseBody(resp, body['hypervisor_statistics'])
def get_hypervisor_uptime(self, hyper_id):
"""Display the uptime of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
body = json.loads(body)
self.validate_response(common_schema.hypervisor_uptime, resp, body)
- return resp, body['hypervisor']
+ return service_client.ResponseBody(resp, body['hypervisor'])
def search_hypervisor(self, hyper_name):
"""Search specified hypervisor."""
@@ -73,4 +74,4 @@
body = json.loads(body)
self.validate_response(common_schema.common_hypervisors_detail,
resp, body)
- return resp, body['hypervisors']
+ return service_client.ResponseBodyList(resp, body['hypervisors'])
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 8d73c37..52662fa 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -18,6 +18,7 @@
import urllib
from tempest.api_schema.response.compute import services as schema
+from tempest.common import service_client
from tempest.services.compute.json import base
@@ -31,7 +32,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_services, resp, body)
- return resp, body['services']
+ return service_client.ResponseBodyList(resp, body['services'])
def enable_service(self, host_name, binary):
"""
@@ -43,7 +44,7 @@
resp, body = self.put('os-services/enable', post_body)
body = json.loads(body)
self.validate_response(schema.enable_service, resp, body)
- return resp, body['service']
+ return service_client.ResponseBody(resp, body['service'])
def disable_service(self, host_name, binary):
"""
@@ -54,4 +55,4 @@
post_body = json.dumps({'binary': binary, 'host': host_name})
resp, body = self.put('os-services/disable', post_body)
body = json.loads(body)
- return resp, body['service']
+ return service_client.ResponseBody(resp, body['service'])
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
index 513d2cf..4d45515 100644
--- a/tempest/services/network/resources.py
+++ b/tempest/services/network/resources.py
@@ -82,8 +82,10 @@
self._router_ids = set()
def update(self, *args, **kwargs):
- result = self.client.update_subnet(subnet=self.id, *args, **kwargs)
- super(DeletableSubnet, self).update(**result['subnet'])
+ result = self.client.update_subnet(self.id,
+ *args,
+ **kwargs)
+ return super(DeletableSubnet, self).update(**result['subnet'])
def add_to_router(self, router_id):
self._router_ids.add(router_id)
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index d23d934..c813977 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -19,23 +19,11 @@
import urllib
from tempest.common import service_client
-from tempest import config
from tempest import exceptions
-CONF = config.CONF
-
class OrchestrationClient(service_client.ServiceClient):
- def __init__(self, auth_provider):
- super(OrchestrationClient, self).__init__(
- auth_provider,
- CONF.orchestration.catalog_type,
- CONF.orchestration.region or CONF.identity.region,
- endpoint_type=CONF.orchestration.endpoint_type,
- build_interval=CONF.orchestration.build_interval,
- build_timeout=CONF.orchestration.build_timeout)
-
def list_stacks(self, params=None):
"""Lists all stacks for a user."""
@@ -46,7 +34,7 @@
resp, body = self.get(uri)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['stacks']
+ return service_client.ResponseBodyList(resp, body['stacks'])
def create_stack(self, name, disable_rollback=True, parameters=None,
timeout_mins=60, template=None, template_url=None,
@@ -66,7 +54,7 @@
resp, body = self.post(uri, headers=headers, body=body)
self.expected_success(201, resp.status)
body = json.loads(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def update_stack(self, stack_identifier, name, disable_rollback=True,
parameters=None, timeout_mins=60, template=None,
@@ -85,7 +73,7 @@
uri = "stacks/%s" % stack_identifier
resp, body = self.put(uri, headers=headers, body=body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def _prepare_update_create(self, name, disable_rollback=True,
parameters=None, timeout_mins=60,
@@ -121,7 +109,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['stack']
+ return service_client.ResponseBody(resp, body['stack'])
def suspend_stack(self, stack_identifier):
"""Suspend a stack."""
@@ -129,7 +117,7 @@
body = {'suspend': None}
resp, body = self.post(url, json.dumps(body))
self.expected_success(200, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp)
def resume_stack(self, stack_identifier):
"""Resume a stack."""
@@ -137,7 +125,7 @@
body = {'resume': None}
resp, body = self.post(url, json.dumps(body))
self.expected_success(200, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp)
def list_resources(self, stack_identifier):
"""Returns the details of a single resource."""
@@ -145,7 +133,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['resources']
+ return service_client.ResponseBodyList(resp, body['resources'])
def get_resource(self, stack_identifier, resource_name):
"""Returns the details of a single resource."""
@@ -153,13 +141,13 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['resource']
+ return service_client.ResponseBody(resp, body['resource'])
def delete_stack(self, stack_identifier):
"""Deletes the specified Stack."""
resp, _ = self.delete("stacks/%s" % str(stack_identifier))
self.expected_success(204, resp.status)
- return resp
+ return service_client.ResponseBody(resp)
def wait_for_resource_status(self, stack_identifier, resource_name,
status, failure_pattern='^.*_FAILED$'):
@@ -169,7 +157,7 @@
while True:
try:
- resp, body = self.get_resource(
+ body = self.get_resource(
stack_identifier, resource_name)
except exceptions.NotFound:
# ignore this, as the resource may not have
@@ -205,7 +193,7 @@
while True:
try:
- resp, body = self.get_stack(stack_identifier)
+ body = self.get_stack(stack_identifier)
except exceptions.NotFound:
if status == 'DELETE_COMPLETE':
return
@@ -234,7 +222,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def list_events(self, stack_identifier):
"""Returns list of all events for a stack."""
@@ -242,7 +230,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['events']
+ return service_client.ResponseBodyList(resp, body['events'])
def list_resource_events(self, stack_identifier, resource_name):
"""Returns list of all events for a resource from stack."""
@@ -251,7 +239,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['events']
+ return service_client.ResponseBodyList(resp, body['events'])
def show_event(self, stack_identifier, resource_name, event_id):
"""Returns the details of a single stack's event."""
@@ -260,7 +248,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['event']
+ return service_client.ResponseBody(resp, body['event'])
def show_template(self, stack_identifier):
"""Returns the template for the stack."""
@@ -268,7 +256,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def _validate_template(self, post_body):
"""Returns the validation request result."""
@@ -276,7 +264,7 @@
resp, body = self.post('validate', post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def validate_template(self, template, parameters=None):
"""Returns the validation result for a template with parameters."""
@@ -303,21 +291,21 @@
resp, body = self.get('resource_types')
self.expected_success(200, resp.status)
body = json.loads(body)
- return body['resource_types']
+ return service_client.ResponseBodyList(resp, body['resource_types'])
def get_resource_type(self, resource_type_name):
"""Return the schema of a resource type."""
url = 'resource_types/%s' % resource_type_name
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return json.loads(body)
+ return service_client.ResponseBody(resp, json.loads(body))
def get_resource_type_template(self, resource_type_name):
"""Return the template of a resource type."""
url = 'resource_types/%s/template' % resource_type_name
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return json.loads(body)
+ return service_client.ResponseBody(resp, json.loads(body))
def create_software_config(self, name=None, config=None, group=None,
inputs=None, outputs=None, options=None):
@@ -328,7 +316,7 @@
resp, body = self.post(url, headers=headers, body=body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def get_software_config(self, conf_id):
"""Returns a software configuration resource."""
@@ -336,13 +324,14 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def delete_software_config(self, conf_id):
"""Deletes a specific software configuration."""
url = 'software_configs/%s' % str(conf_id)
resp, _ = self.delete(url)
self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp)
def create_software_deploy(self, server_id=None, config_id=None,
action=None, status=None,
@@ -357,7 +346,7 @@
resp, body = self.post(url, headers=headers, body=body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def update_software_deploy(self, deploy_id=None, server_id=None,
config_id=None, action=None, status=None,
@@ -372,7 +361,7 @@
resp, body = self.put(url, headers=headers, body=body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def get_software_deploy_list(self):
"""Returns a list of all deployments."""
@@ -380,7 +369,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def get_software_deploy(self, deploy_id):
"""Returns a specific software deployment."""
@@ -388,7 +377,7 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def get_software_deploy_meta(self, server_id):
"""Return a config metadata for a specific server."""
@@ -396,13 +385,14 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
- return body
+ return service_client.ResponseBody(resp, body)
def delete_software_deploy(self, deploy_id):
"""Deletes a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, _ = self.delete(url)
self.expected_success(204, resp.status)
+ return service_client.ResponseBody(resp)
def _prep_software_config_create(self, name=None, conf=None, group=None,
inputs=None, outputs=None, options=None):
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index e7add30..cf566f2 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -16,6 +16,7 @@
import json
import urllib
+from tempest.common import service_client
from tempest.services.volume.json import base
@@ -34,7 +35,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['hosts']
+ return service_client.ResponseBodyList(resp, body['hosts'])
class VolumeHostsClientJSON(BaseVolumeHostsClientJSON):
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index f08cb64..88df69f 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -16,6 +16,7 @@
import urllib
+from tempest.common import service_client
from tempest.openstack.common import jsonutils
from tempest.services.volume.json import base
@@ -33,7 +34,7 @@
url = 'os-quota-sets/%s/defaults' % tenant_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
def get_quota_set(self, tenant_id, params=None):
"""List the quota set for a tenant."""
@@ -44,14 +45,13 @@
resp, body = self.get(url)
self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
def get_quota_usage(self, tenant_id):
"""List the quota set for a tenant."""
- resp, body = self.get_quota_set(tenant_id, params={'usage': True})
- self.expected_success(200, resp.status)
- return resp, body
+ body = self.get_quota_set(tenant_id, params={'usage': True})
+ return body
def update_quota_set(self, tenant_id, gigabytes=None, volumes=None,
snapshots=None):
@@ -69,12 +69,13 @@
post_body = jsonutils.dumps({'quota_set': post_body})
resp, body = self.put('os-quota-sets/%s' % tenant_id, post_body)
self.expected_success(200, resp.status)
- return resp, self._parse_resp(body)
+ return service_client.ResponseBody(resp, self._parse_resp(body))
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""
resp, body = self.delete('os-quota-sets/%s' % tenant_id)
self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
class VolumeQuotasClientJSON(BaseVolumeQuotasClientJSON):
diff --git a/tempest/services/volume/json/admin/volume_services_client.py b/tempest/services/volume/json/admin/volume_services_client.py
index 5d4f9db..d258f3d 100644
--- a/tempest/services/volume/json/admin/volume_services_client.py
+++ b/tempest/services/volume/json/admin/volume_services_client.py
@@ -16,6 +16,7 @@
import json
import urllib
+from tempest.common import service_client
from tempest.services.volume.json import base
@@ -29,7 +30,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['services']
+ return service_client.ResponseBodyList(resp, body['services'])
class VolumesServicesClientJSON(BaseVolumesServicesClientJSON):
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 171ad35..b3b4ae6 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -16,6 +16,7 @@
import json
import urllib
+from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@@ -34,8 +35,7 @@
if resource['type'] == "volume-type":
self.get_volume_type(resource['id'])
elif resource['type'] == "encryption-type":
- resp, body = self.get_encryption_type(resource['id'])
- assert 200 == resp.status
+ body = self.get_encryption_type(resource['id'])
if not body:
return True
else:
@@ -59,7 +59,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volume_types']
+ return service_client.ResponseBodyList(resp, body['volume_types'])
def get_volume_type(self, volume_id):
"""Returns the details of a single volume_type."""
@@ -67,7 +67,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volume_type']
+ return service_client.ResponseBody(resp, body['volume_type'])
def create_volume_type(self, name, **kwargs):
"""
@@ -85,12 +85,13 @@
resp, body = self.post('types', post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volume_type']
+ return service_client.ResponseBody(resp, body['volume_type'])
def delete_volume_type(self, volume_id):
"""Deletes the Specified Volume_type."""
resp, body = self.delete("types/%s" % str(volume_id))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def list_volume_types_extra_specs(self, vol_type_id, params=None):
"""List all the volume_types extra specs created."""
@@ -101,7 +102,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['extra_specs']
+ return service_client.ResponseBody(resp, body['extra_specs'])
def get_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
"""Returns the details of a single volume_type extra spec."""
@@ -110,7 +111,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
"""
@@ -123,13 +124,14 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['extra_specs']
+ return service_client.ResponseBody(resp, body['extra_specs'])
def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
"""Deletes the Specified Volume_type extra spec."""
resp, body = self.delete("types/%s/extra_specs/%s" % (
(str(vol_id)), str(extra_spec_name)))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
extra_spec):
@@ -146,7 +148,7 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def get_encryption_type(self, vol_type_id):
"""
@@ -157,7 +159,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_encryption_type(self, vol_type_id, **kwargs):
"""
@@ -176,13 +178,14 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['encryption']
+ return service_client.ResponseBody(resp, body['encryption'])
def delete_encryption_type(self, vol_type_id):
"""Delete the encryption type for the specified volume-type."""
resp, body = self.delete(
"/types/%s/encryption/provider" % str(vol_type_id))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
class VolumeTypesClientJSON(BaseVolumeTypesClientJSON):
diff --git a/tempest/services/volume/json/availability_zone_client.py b/tempest/services/volume/json/availability_zone_client.py
index 9f2c570..8a0257e 100644
--- a/tempest/services/volume/json/availability_zone_client.py
+++ b/tempest/services/volume/json/availability_zone_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.common import service_client
from tempest.services.volume.json import base
@@ -24,7 +25,7 @@
resp, body = self.get('os-availability-zone')
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['availabilityZoneInfo']
+ return service_client.ResponseBody(resp, body['availabilityZoneInfo'])
class VolumeAvailabilityZoneClientJSON(BaseVolumeAvailabilityZoneClientJSON):
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index e2ba822..102e823 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -16,6 +16,7 @@
import json
import time
+from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@@ -39,7 +40,7 @@
resp, body = self.post('backups', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return resp, body['backup']
+ return service_client.ResponseBody(resp, body['backup'])
def restore_backup(self, backup_id, volume_id=None):
"""Restore volume from backup."""
@@ -48,13 +49,13 @@
resp, body = self.post('backups/%s/restore' % (backup_id), post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return resp, body['restore']
+ return service_client.ResponseBody(resp, body['restore'])
def delete_backup(self, backup_id):
"""Delete a backup of volume."""
resp, body = self.delete('backups/%s' % (str(backup_id)))
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def get_backup(self, backup_id):
"""Returns the details of a single backup."""
@@ -62,7 +63,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['backup']
+ return service_client.ResponseBody(resp, body['backup'])
def list_backups_with_detail(self):
"""Information for all the tenant's backups."""
@@ -70,17 +71,17 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['backups']
+ return service_client.ResponseBodyList(resp, body['backups'])
def wait_for_backup_status(self, backup_id, status):
"""Waits for a Backup to reach a given status."""
- resp, body = self.get_backup(backup_id)
+ body = self.get_backup(backup_id)
backup_status = body['status']
start = int(time.time())
while backup_status != status:
time.sleep(self.build_interval)
- resp, body = self.get_backup(backup_id)
+ body = self.get_backup(backup_id)
backup_status = body['status']
if backup_status == 'error':
raise exceptions.VolumeBackupException(backup_id=backup_id)
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index 13b91c3..ae79dad 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -15,6 +15,7 @@
import json
+from tempest.common import service_client
from tempest.services.volume.json import base
@@ -25,7 +26,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['extensions']
+ return service_client.ResponseBodyList(resp, body['extensions'])
class ExtensionsClientJSON(BaseExtensionsClientJSON):
diff --git a/tempest/services/volume/json/qos_client.py b/tempest/services/volume/json/qos_client.py
index 9c13cac..32555eb 100644
--- a/tempest/services/volume/json/qos_client.py
+++ b/tempest/services/volume/json/qos_client.py
@@ -15,6 +15,7 @@
import json
import time
+from tempest.common import service_client
from tempest import exceptions
from tempest.services.volume.json import base
@@ -46,18 +47,15 @@
start_time = int(time.time())
while True:
if operation == 'qos-key-unset':
- resp, body = self.get_qos(qos_id)
- self.expected_success(200, resp.status)
+ body = self.get_qos(qos_id)
if not any(key in body['specs'] for key in args):
return
elif operation == 'disassociate':
- resp, body = self.get_association_qos(qos_id)
- self.expected_success(200, resp.status)
+ body = self.get_association_qos(qos_id)
if not any(args in body[i]['id'] for i in range(0, len(body))):
return
elif operation == 'disassociate-all':
- resp, body = self.get_association_qos(qos_id)
- self.expected_success(200, resp.status)
+ body = self.get_association_qos(qos_id)
if not body:
return
else:
@@ -80,13 +78,14 @@
resp, body = self.post('qos-specs', post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
- return resp, body['qos_specs']
+ return service_client.ResponseBody(resp, body['qos_specs'])
def delete_qos(self, qos_id, force=False):
"""Delete the specified QoS specification."""
resp, body = self.delete(
"qos-specs/%s?force=%s" % (str(qos_id), force))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def list_qos(self):
"""List all the QoS specifications created."""
@@ -94,7 +93,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['qos_specs']
+ return service_client.ResponseBodyList(resp, body['qos_specs'])
def get_qos(self, qos_id):
"""Get the specified QoS specification."""
@@ -102,7 +101,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['qos_specs']
+ return service_client.ResponseBody(resp, body['qos_specs'])
def set_qos_key(self, qos_id, **kwargs):
"""Set the specified keys/values of QoS specification.
@@ -113,7 +112,7 @@
resp, body = self.put('qos-specs/%s' % qos_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['qos_specs']
+ return service_client.ResponseBody(resp, body['qos_specs'])
def unset_qos_key(self, qos_id, keys):
"""Unset the specified keys of QoS specification.
@@ -121,15 +120,17 @@
keys : it is the array of the keys to unset
"""
put_body = json.dumps({'keys': keys})
- resp, _ = self.put('qos-specs/%s/delete_keys' % qos_id, put_body)
+ resp, body = self.put('qos-specs/%s/delete_keys' % qos_id, put_body)
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def associate_qos(self, qos_id, vol_type_id):
"""Associate the specified QoS with specified volume-type."""
url = "qos-specs/%s/associate" % str(qos_id)
url += "?vol_type_id=%s" % vol_type_id
- resp, _ = self.get(url)
+ resp, body = self.get(url)
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def get_association_qos(self, qos_id):
"""Get the association of the specified QoS specification."""
@@ -137,20 +138,22 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['qos_associations']
+ return service_client.ResponseBodyList(resp, body['qos_associations'])
def disassociate_qos(self, qos_id, vol_type_id):
"""Disassociate the specified QoS with specified volume-type."""
url = "qos-specs/%s/disassociate" % str(qos_id)
url += "?vol_type_id=%s" % vol_type_id
- resp, _ = self.get(url)
+ resp, body = self.get(url)
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def disassociate_all_qos(self, qos_id):
"""Disassociate the specified QoS with all associations."""
url = "qos-specs/%s/disassociate_all" % str(qos_id)
- resp, _ = self.get(url)
+ resp, body = self.get(url)
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
class QosSpecsClientJSON(BaseQosSpecsClientJSON):
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index 349d1b0..cd115df 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -14,6 +14,7 @@
import time
import urllib
+from tempest.common import service_client
from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.services.volume.json import base
@@ -36,7 +37,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['snapshots']
+ return service_client.ResponseBodyList(resp, body['snapshots'])
def list_snapshots_with_detail(self, params=None):
"""List the details of all snapshots."""
@@ -47,7 +48,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['snapshots']
+ return service_client.ResponseBodyList(resp, body['snapshots'])
def get_snapshot(self, snapshot_id):
"""Returns the details of a single snapshot."""
@@ -55,7 +56,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['snapshot']
+ return service_client.ResponseBody(resp, body['snapshot'])
def create_snapshot(self, volume_id, **kwargs):
"""
@@ -71,7 +72,7 @@
resp, body = self.post('snapshots', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
- return resp, body['snapshot']
+ return service_client.ResponseBody(resp, body['snapshot'])
def update_snapshot(self, snapshot_id, **kwargs):
"""Updates a snapshot."""
@@ -79,11 +80,11 @@
resp, body = self.put('snapshots/%s' % snapshot_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['snapshot']
+ return service_client.ResponseBody(resp, body['snapshot'])
# NOTE(afazekas): just for the wait function
def _get_snapshot_status(self, snapshot_id):
- resp, body = self.get_snapshot(snapshot_id)
+ body = self.get_snapshot(snapshot_id)
status = body['status']
# NOTE(afazekas): snapshot can reach an "error"
# state in a "normal" lifecycle
@@ -122,6 +123,7 @@
"""Delete Snapshot."""
resp, body = self.delete("snapshots/%s" % str(snapshot_id))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
try:
@@ -140,7 +142,7 @@
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def update_snapshot_status(self, snapshot_id, status, progress):
"""Update the specified snapshot's status."""
@@ -152,7 +154,7 @@
url = 'snapshots/%s/action' % str(snapshot_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_snapshot_metadata(self, snapshot_id, metadata):
"""Create metadata for the snapshot."""
@@ -161,7 +163,7 @@
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def get_snapshot_metadata(self, snapshot_id):
"""Get metadata of the snapshot."""
@@ -169,7 +171,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def update_snapshot_metadata(self, snapshot_id, metadata):
"""Update metadata for the snapshot."""
@@ -178,7 +180,7 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
"""Update metadata item for the snapshot."""
@@ -187,20 +189,21 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['meta']
+ return service_client.ResponseBody(resp, body['meta'])
def delete_snapshot_metadata_item(self, snapshot_id, id):
"""Delete metadata item for the snapshot."""
url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
resp, body = self.delete(url)
self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
def force_delete_snapshot(self, snapshot_id):
"""Force Delete Snapshot."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
class SnapshotsClientJSON(BaseSnapshotsClientJSON):
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index f19718e..c0f81fe 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,6 +17,7 @@
import time
import urllib
+from tempest.common import service_client
from tempest import config
from tempest import exceptions
from tempest.services.volume.json import base
@@ -44,7 +45,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def list_volumes_with_detail(self, params=None):
"""List the details of all volumes."""
@@ -55,7 +56,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
@@ -63,7 +64,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def create_volume(self, size=None, **kwargs):
"""
@@ -87,7 +88,7 @@
resp, body = self.post('volumes', post_body)
body = json.loads(body)
self.expected_success(self.create_resp, resp.status)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def update_volume(self, volume_id, **kwargs):
"""Updates the Specified Volume."""
@@ -95,12 +96,13 @@
resp, body = self.put('volumes/%s' % volume_id, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- 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("volumes/%s" % str(volume_id))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def upload_volume(self, volume_id, image_name, disk_format):
"""Uploads a volume in Glance."""
@@ -113,7 +115,8 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return resp, body['os-volume_upload_image']
+ return service_client.ResponseBody(resp,
+ body['os-volume_upload_image'])
def attach_volume(self, volume_id, instance_uuid, mountpoint):
"""Attaches a volume to a given instance on a given mountpoint."""
@@ -125,7 +128,7 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def detach_volume(self, volume_id):
"""Detaches a volume from an instance."""
@@ -134,7 +137,7 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def reserve_volume(self, volume_id):
"""Reserves a volume."""
@@ -143,7 +146,7 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def unreserve_volume(self, volume_id):
"""Restore a reserved volume ."""
@@ -152,17 +155,17 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- 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)
@@ -197,14 +200,14 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def reset_volume_status(self, volume_id, status):
"""Reset the Specified Volume's Status."""
post_body = json.dumps({'os-reset_status': {"status": status}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def volume_begin_detaching(self, volume_id):
"""Volume Begin Detaching."""
@@ -212,7 +215,7 @@
post_body = json.dumps({'os-begin_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def volume_roll_detaching(self, volume_id):
"""Volume Roll Detaching."""
@@ -220,7 +223,7 @@
post_body = json.dumps({'os-roll_detaching': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_volume_transfer(self, vol_id, display_name=None):
"""Create a volume transfer."""
@@ -233,7 +236,7 @@
resp, body = self.post('os-volume-transfer', post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return resp, body['transfer']
+ return service_client.ResponseBody(resp, body['transfer'])
def get_volume_transfer(self, transfer_id):
"""Returns the details of a volume transfer."""
@@ -241,7 +244,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['transfer']
+ return service_client.ResponseBody(resp, body['transfer'])
def list_volume_transfers(self, params=None):
"""List all the volume transfers created."""
@@ -251,12 +254,13 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['transfers']
+ return service_client.ResponseBodyList(resp, body['transfers'])
def delete_volume_transfer(self, transfer_id):
"""Delete a volume transfer."""
resp, body = self.delete("os-volume-transfer/%s" % str(transfer_id))
self.expected_success(202, resp.status)
+ return service_client.ResponseBody(resp, body)
def accept_volume_transfer(self, transfer_id, transfer_auth_key):
"""Accept a volume transfer."""
@@ -268,7 +272,7 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.expected_success(202, resp.status)
- return resp, body['transfer']
+ return service_client.ResponseBody(resp, body['transfer'])
def update_volume_readonly(self, volume_id, readonly):
"""Update the Specified Volume readonly."""
@@ -279,14 +283,14 @@
url = 'volumes/%s/action' % (volume_id)
resp, body = self.post(url, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def force_delete_volume(self, volume_id):
"""Force Delete Volume."""
post_body = json.dumps({'os-force_delete': {}})
resp, body = self.post('volumes/%s/action' % volume_id, post_body)
self.expected_success(202, resp.status)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_volume_metadata(self, volume_id, metadata):
"""Create metadata for the volume."""
@@ -295,7 +299,7 @@
resp, body = self.post(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def get_volume_metadata(self, volume_id):
"""Get metadata of the volume."""
@@ -303,7 +307,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def update_volume_metadata(self, volume_id, metadata):
"""Update metadata for the volume."""
@@ -312,7 +316,7 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['metadata']
+ return service_client.ResponseBody(resp, body['metadata'])
def update_volume_metadata_item(self, volume_id, id, meta_item):
"""Update metadata item for the volume."""
@@ -321,13 +325,14 @@
resp, body = self.put(url, put_body)
body = json.loads(body)
self.expected_success(200, resp.status)
- return resp, body['meta']
+ return service_client.ResponseBody(resp, body['meta'])
def delete_volume_metadata_item(self, volume_id, id):
"""Delete metadata item for the volume."""
url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
resp, body = self.delete(url)
self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
class VolumesClientJSON(BaseVolumesClientJSON):
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index a8adc7e..1abe29a 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -243,9 +243,9 @@
def test_verify_extensions_cinder(self):
def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
+ return {'extensions': [{'alias': 'fake1'},
+ {'alias': 'fake2'},
+ {'alias': 'not_fake'}]}
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@@ -265,9 +265,9 @@
def test_verify_extensions_cinder_all(self):
def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
+ return {'extensions': [{'alias': 'fake1'},
+ {'alias': 'fake2'},
+ {'alias': 'not_fake'}]}
fake_os = mock.MagicMock()
fake_os.volumes_extension_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
diff --git a/tempest/tests/fake_auth_provider.py b/tempest/tests/fake_auth_provider.py
index 44c331e..bc68d26 100644
--- a/tempest/tests/fake_auth_provider.py
+++ b/tempest/tests/fake_auth_provider.py
@@ -13,16 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.tests import fake_credentials
-
-
-def get_default_credentials(credential_type, fill_in=True):
- return fake_credentials.FakeCredentials()
-
-
-def get_credentials(credential_type=None, fill_in=True, **kwargs):
- return fake_credentials.FakeCredentials()
-
class FakeAuthProvider(object):
diff --git a/tempest/tests/test_auth.py b/tempest/tests/test_auth.py
index fc05198..a191781 100644
--- a/tempest/tests/test_auth.py
+++ b/tempest/tests/test_auth.py
@@ -24,13 +24,20 @@
from tempest.services.identity.json import identity_client as v2_client
from tempest.services.identity.v3.json import identity_client as v3_client
from tempest.tests import base
-from tempest.tests import fake_auth_provider
from tempest.tests import fake_config
from tempest.tests import fake_credentials
from tempest.tests import fake_http
from tempest.tests import fake_identity
+def fake_get_default_credentials(credential_type, fill_in=True):
+ return fake_credentials.FakeCredentials()
+
+
+def fake_get_credentials(credential_type=None, fill_in=True, **kwargs):
+ return fake_credentials.FakeCredentials()
+
+
class BaseAuthTestsSetUp(base.TestCase):
_auth_provider_class = None
credentials = fake_credentials.FakeCredentials()
@@ -46,10 +53,9 @@
self.useFixture(fake_config.ConfigFixture())
self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
self.fake_http = fake_http.fake_httplib2(return_type=200)
- self.stubs.Set(auth, 'get_credentials',
- fake_auth_provider.get_credentials)
+ self.stubs.Set(auth, 'get_credentials', fake_get_credentials)
self.stubs.Set(auth, 'get_default_credentials',
- fake_auth_provider.get_default_credentials)
+ fake_get_default_credentials)
self.auth_provider = self._auth(self.credentials)
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
deleted file mode 100644
index e42fab7..0000000
--- a/tempest/tests/test_rest_client.py
+++ /dev/null
@@ -1,475 +0,0 @@
-# Copyright 2013 IBM Corp.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import json
-
-import httplib2
-from oslotest import mockpatch
-
-from tempest.common import rest_client
-from tempest import config
-from tempest import exceptions
-from tempest.tests import base
-from tempest.tests import fake_auth_provider
-from tempest.tests import fake_config
-from tempest.tests import fake_http
-
-
-class BaseRestClientTestClass(base.TestCase):
-
- url = 'fake_endpoint'
-
- def setUp(self):
- super(BaseRestClientTestClass, self).setUp()
- self.useFixture(fake_config.ConfigFixture())
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
- self.rest_client = rest_client.RestClient(
- fake_auth_provider.FakeAuthProvider(), None, None)
- self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_log_request'))
-
-
-class TestRestClientHTTPMethods(BaseRestClientTestClass):
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2()
- super(TestRestClientHTTPMethods, self).setUp()
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_error_checker'))
-
- def test_post(self):
- __, return_dict = self.rest_client.post(self.url, {}, {})
- self.assertEqual('POST', return_dict['method'])
-
- def test_get(self):
- __, return_dict = self.rest_client.get(self.url)
- self.assertEqual('GET', return_dict['method'])
-
- def test_delete(self):
- __, return_dict = self.rest_client.delete(self.url)
- self.assertEqual('DELETE', return_dict['method'])
-
- def test_patch(self):
- __, return_dict = self.rest_client.patch(self.url, {}, {})
- self.assertEqual('PATCH', return_dict['method'])
-
- def test_put(self):
- __, return_dict = self.rest_client.put(self.url, {}, {})
- self.assertEqual('PUT', return_dict['method'])
-
- def test_head(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
- __, return_dict = self.rest_client.head(self.url)
- self.assertEqual('HEAD', return_dict['method'])
-
- def test_copy(self):
- __, return_dict = self.rest_client.copy(self.url)
- self.assertEqual('COPY', return_dict['method'])
-
-
-class TestRestClientNotFoundHandling(BaseRestClientTestClass):
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2(404)
- super(TestRestClientNotFoundHandling, self).setUp()
-
- def test_post(self):
- self.assertRaises(exceptions.NotFound, self.rest_client.post,
- self.url, {}, {})
-
-
-class TestRestClientHeadersJSON(TestRestClientHTTPMethods):
- TYPE = "json"
-
- def _verify_headers(self, resp):
- self.assertEqual(self.rest_client._get_type(), self.TYPE)
- resp = dict((k.lower(), v) for k, v in resp.iteritems())
- self.assertEqual(self.header_value, resp['accept'])
- self.assertEqual(self.header_value, resp['content-type'])
-
- def setUp(self):
- super(TestRestClientHeadersJSON, self).setUp()
- self.rest_client.TYPE = self.TYPE
- self.header_value = 'application/%s' % self.rest_client._get_type()
-
- def test_post(self):
- resp, __ = self.rest_client.post(self.url, {})
- self._verify_headers(resp)
-
- def test_get(self):
- resp, __ = self.rest_client.get(self.url)
- self._verify_headers(resp)
-
- def test_delete(self):
- resp, __ = self.rest_client.delete(self.url)
- self._verify_headers(resp)
-
- def test_patch(self):
- resp, __ = self.rest_client.patch(self.url, {})
- self._verify_headers(resp)
-
- def test_put(self):
- resp, __ = self.rest_client.put(self.url, {})
- self._verify_headers(resp)
-
- def test_head(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
- resp, __ = self.rest_client.head(self.url)
- self._verify_headers(resp)
-
- def test_copy(self):
- resp, __ = self.rest_client.copy(self.url)
- self._verify_headers(resp)
-
-
-class TestRestClientUpdateHeaders(BaseRestClientTestClass):
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2()
- super(TestRestClientUpdateHeaders, self).setUp()
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- '_error_checker'))
- self.headers = {'X-Configuration-Session': 'session_id'}
-
- def test_post_update_headers(self):
- __, return_dict = self.rest_client.post(self.url, {},
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_get_update_headers(self):
- __, return_dict = self.rest_client.get(self.url,
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_delete_update_headers(self):
- __, return_dict = self.rest_client.delete(self.url,
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_patch_update_headers(self):
- __, return_dict = self.rest_client.patch(self.url, {},
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_put_update_headers(self):
- __, return_dict = self.rest_client.put(self.url, {},
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_head_update_headers(self):
- self.useFixture(mockpatch.PatchObject(self.rest_client,
- 'response_checker'))
-
- __, return_dict = self.rest_client.head(self.url,
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
- def test_copy_update_headers(self):
- __, return_dict = self.rest_client.copy(self.url,
- extra_headers=True,
- headers=self.headers)
-
- self.assertDictContainsSubset(
- {'X-Configuration-Session': 'session_id',
- 'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
- )
-
-
-class TestRestClientParseRespJSON(BaseRestClientTestClass):
- TYPE = "json"
-
- keys = ["fake_key1", "fake_key2"]
- values = ["fake_value1", "fake_value2"]
- item_expected = dict((key, value) for (key, value) in zip(keys, values))
- list_expected = {"body_list": [
- {keys[0]: values[0]},
- {keys[1]: values[1]},
- ]}
- dict_expected = {"body_dict": {
- keys[0]: values[0],
- keys[1]: values[1],
- }}
-
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2()
- super(TestRestClientParseRespJSON, self).setUp()
- self.rest_client.TYPE = self.TYPE
-
- def test_parse_resp_body_item(self):
- body = self.rest_client._parse_resp(json.dumps(self.item_expected))
- self.assertEqual(self.item_expected, body)
-
- def test_parse_resp_body_list(self):
- body = self.rest_client._parse_resp(json.dumps(self.list_expected))
- self.assertEqual(self.list_expected["body_list"], body)
-
- def test_parse_resp_body_dict(self):
- body = self.rest_client._parse_resp(json.dumps(self.dict_expected))
- self.assertEqual(self.dict_expected["body_dict"], body)
-
- def test_parse_resp_two_top_keys(self):
- dict_two_keys = self.dict_expected.copy()
- dict_two_keys.update({"second_key": ""})
- body = self.rest_client._parse_resp(json.dumps(dict_two_keys))
- self.assertEqual(dict_two_keys, body)
-
- def test_parse_resp_one_top_key_without_list_or_dict(self):
- data = {"one_top_key": "not_list_or_dict_value"}
- body = self.rest_client._parse_resp(json.dumps(data))
- self.assertEqual(data, body)
-
-
-class TestRestClientErrorCheckerJSON(base.TestCase):
- c_type = "application/json"
-
- def set_data(self, r_code, enc=None, r_body=None):
- if enc is None:
- enc = self.c_type
- resp_dict = {'status': r_code, 'content-type': enc}
- resp = httplib2.Response(resp_dict)
- data = {
- "method": "fake_method",
- "url": "fake_url",
- "headers": "fake_headers",
- "body": "fake_body",
- "resp": resp,
- "resp_body": '{"resp_body": "fake_resp_body"}',
- }
- if r_body is not None:
- data.update({"resp_body": r_body})
- return data
-
- def setUp(self):
- super(TestRestClientErrorCheckerJSON, self).setUp()
- self.useFixture(fake_config.ConfigFixture())
- self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
- self.rest_client = rest_client.RestClient(
- fake_auth_provider.FakeAuthProvider(), None, None)
-
- def test_response_less_than_400(self):
- self.rest_client._error_checker(**self.set_data("399"))
-
- def test_response_400(self):
- self.assertRaises(exceptions.BadRequest,
- self.rest_client._error_checker,
- **self.set_data("400"))
-
- def test_response_401(self):
- self.assertRaises(exceptions.Unauthorized,
- self.rest_client._error_checker,
- **self.set_data("401"))
-
- def test_response_403(self):
- self.assertRaises(exceptions.Unauthorized,
- self.rest_client._error_checker,
- **self.set_data("403"))
-
- def test_response_404(self):
- self.assertRaises(exceptions.NotFound,
- self.rest_client._error_checker,
- **self.set_data("404"))
-
- def test_response_409(self):
- self.assertRaises(exceptions.Conflict,
- self.rest_client._error_checker,
- **self.set_data("409"))
-
- def test_response_413(self):
- self.assertRaises(exceptions.OverLimit,
- self.rest_client._error_checker,
- **self.set_data("413"))
-
- def test_response_415(self):
- self.assertRaises(exceptions.InvalidContentType,
- self.rest_client._error_checker,
- **self.set_data("415"))
-
- def test_response_422(self):
- self.assertRaises(exceptions.UnprocessableEntity,
- self.rest_client._error_checker,
- **self.set_data("422"))
-
- def test_response_500_with_text(self):
- # _parse_resp is expected to return 'str'
- self.assertRaises(exceptions.ServerFault,
- self.rest_client._error_checker,
- **self.set_data("500"))
-
- def test_response_501_with_text(self):
- self.assertRaises(exceptions.NotImplemented,
- self.rest_client._error_checker,
- **self.set_data("501"))
-
- def test_response_500_with_dict(self):
- r_body = '{"resp_body": {"err": "fake_resp_body"}}'
- self.assertRaises(exceptions.ServerFault,
- self.rest_client._error_checker,
- **self.set_data("500", r_body=r_body))
-
- def test_response_501_with_dict(self):
- r_body = '{"resp_body": {"err": "fake_resp_body"}}'
- self.assertRaises(exceptions.NotImplemented,
- self.rest_client._error_checker,
- **self.set_data("501", r_body=r_body))
-
- def test_response_bigger_than_400(self):
- # Any response code, that bigger than 400, and not in
- # (401, 403, 404, 409, 413, 422, 500, 501)
- self.assertRaises(exceptions.UnexpectedResponseCode,
- self.rest_client._error_checker,
- **self.set_data("402"))
-
-
-class TestRestClientErrorCheckerTEXT(TestRestClientErrorCheckerJSON):
- c_type = "text/plain"
-
- def test_fake_content_type(self):
- # This test is required only in one exemplar
- # Any response code, that bigger than 400, and not in
- # (401, 403, 404, 409, 413, 422, 500, 501)
- self.assertRaises(exceptions.InvalidContentType,
- self.rest_client._error_checker,
- **self.set_data("405", enc="fake_enc"))
-
-
-class TestRestClientUtils(BaseRestClientTestClass):
-
- def _is_resource_deleted(self, resource_id):
- if not isinstance(self.retry_pass, int):
- return False
- if self.retry_count >= self.retry_pass:
- return True
- self.retry_count = self.retry_count + 1
- return False
-
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2()
- super(TestRestClientUtils, self).setUp()
- self.retry_count = 0
- self.retry_pass = None
- self.original_deleted_method = self.rest_client.is_resource_deleted
- self.rest_client.is_resource_deleted = self._is_resource_deleted
-
- def test_wait_for_resource_deletion(self):
- self.retry_pass = 2
- # Ensure timeout long enough for loop execution to hit retry count
- self.rest_client.build_timeout = 500
- sleep_mock = self.patch('time.sleep')
- self.rest_client.wait_for_resource_deletion('1234')
- self.assertEqual(len(sleep_mock.mock_calls), 2)
-
- def test_wait_for_resource_deletion_not_deleted(self):
- self.patch('time.sleep')
- # Set timeout to be very quick to force exception faster
- self.rest_client.build_timeout = 1
- self.assertRaises(exceptions.TimeoutException,
- self.rest_client.wait_for_resource_deletion,
- '1234')
-
- def test_wait_for_deletion_with_unimplemented_deleted_method(self):
- self.rest_client.is_resource_deleted = self.original_deleted_method
- self.assertRaises(NotImplementedError,
- self.rest_client.wait_for_resource_deletion,
- '1234')
-
-
-class TestExpectedSuccess(BaseRestClientTestClass):
-
- def setUp(self):
- self.fake_http = fake_http.fake_httplib2()
- super(TestExpectedSuccess, self).setUp()
-
- def test_expected_succes_int_match(self):
- expected_code = 202
- read_code = 202
- resp = self.rest_client.expected_success(expected_code, read_code)
- # Assert None resp on success
- self.assertFalse(resp)
-
- def test_expected_succes_int_no_match(self):
- expected_code = 204
- read_code = 202
- self.assertRaises(exceptions.InvalidHttpSuccessCode,
- self.rest_client.expected_success,
- expected_code, read_code)
-
- def test_expected_succes_list_match(self):
- expected_code = [202, 204]
- read_code = 202
- resp = self.rest_client.expected_success(expected_code, read_code)
- # Assert None resp on success
- self.assertFalse(resp)
-
- def test_expected_succes_list_no_match(self):
- expected_code = [202, 204]
- read_code = 200
- self.assertRaises(exceptions.InvalidHttpSuccessCode,
- self.rest_client.expected_success,
- expected_code, read_code)
-
- def test_non_success_expected_int(self):
- expected_code = 404
- read_code = 202
- self.assertRaises(AssertionError, self.rest_client.expected_success,
- expected_code, read_code)
-
- def test_non_success_expected_list(self):
- expected_code = [404, 202]
- read_code = 202
- self.assertRaises(AssertionError, self.rest_client.expected_success,
- expected_code, read_code)
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
index f6779c6..58a8060 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/test_tenant_isolation.py
@@ -110,7 +110,7 @@
return_value={'router': {'id': id, 'name': name}}))
return router_fix
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_primary_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
iso_creds = isolated_creds.IsolatedCreds('test class',
@@ -126,7 +126,7 @@
self.assertEqual(primary_creds.tenant_id, '1234')
self.assertEqual(primary_creds.user_id, '1234')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_admin_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
iso_creds = isolated_creds.IsolatedCreds('test class',
@@ -151,7 +151,7 @@
self.assertEqual(admin_creds.tenant_id, '1234')
self.assertEqual(admin_creds.user_id, '1234')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_all_cred_cleanup(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
iso_creds = isolated_creds.IsolatedCreds('test class',
@@ -195,7 +195,7 @@
self.assertIn('12345', args)
self.assertIn('123456', args)
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_alt_creds(self, MockRestClient):
cfg.CONF.set_default('neutron', False, 'service_available')
iso_creds = isolated_creds.IsolatedCreds('test class',
@@ -211,7 +211,7 @@
self.assertEqual(alt_creds.tenant_id, '1234')
self.assertEqual(alt_creds.user_id, '1234')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_creation(self, MockRestClient):
iso_creds = isolated_creds.IsolatedCreds('test class',
password='fake_password')
@@ -237,7 +237,7 @@
self.assertEqual(router['id'], '1234')
self.assertEqual(router['name'], 'fake_router')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_cleanup(self, MockRestClient):
def side_effect(**args):
return {"security_groups": [{"tenant_id": args['tenant_id'],
@@ -360,7 +360,7 @@
self.assertIn('12345', args)
self.assertIn('123456', args)
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_alt_creation(self, MockRestClient):
iso_creds = isolated_creds.IsolatedCreds('test class',
password='fake_password')
@@ -386,7 +386,7 @@
self.assertEqual(router['id'], '1234')
self.assertEqual(router['name'], 'fake_alt_router')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_network_admin_creation(self, MockRestClient):
iso_creds = isolated_creds.IsolatedCreds('test class',
password='fake_password')
@@ -412,7 +412,7 @@
self.assertEqual(router['id'], '1234')
self.assertEqual(router['name'], 'fake_admin_router')
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_no_network_resources(self, MockRestClient):
net_dict = {
'network': False,
@@ -448,7 +448,7 @@
self.assertIsNone(subnet)
self.assertIsNone(router)
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_router_without_network(self, MockRestClient):
net_dict = {
'network': False,
@@ -466,7 +466,7 @@
self.assertRaises(exceptions.InvalidConfiguration,
iso_creds.get_primary_creds)
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_subnet_without_network(self, MockRestClient):
net_dict = {
'network': False,
@@ -484,7 +484,7 @@
self.assertRaises(exceptions.InvalidConfiguration,
iso_creds.get_primary_creds)
- @mock.patch('tempest.common.rest_client.RestClient')
+ @mock.patch('tempest_lib.common.rest_client.RestClient')
def test_dhcp_without_subnet(self, MockRestClient):
net_dict = {
'network': False,