Merge "Remove novaclient CLI tests"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 0eeb738..bc4198f 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -779,6 +779,10 @@
# value)
#dns_servers = 8.8.8.8,8.8.4.4
+# vnic_type to use when Launching instances with pre-configured ports.
+# Supported ports are: ['normal','direct','macvtap'] (string value)
+#port_vnic_type = <None>
+
[network-feature-enabled]
diff --git a/tempest/api/baremetal/admin/base.py b/tempest/api/baremetal/admin/base.py
index 3b12b8e..1e9b308 100644
--- a/tempest/api/baremetal/admin/base.py
+++ b/tempest/api/baremetal/admin/base.py
@@ -11,11 +11,11 @@
# under the License.
import functools
+from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions as exc
from tempest import test
CONF = config.CONF
@@ -83,7 +83,7 @@
uuids = cls.created_objects[resource]
delete_method = getattr(cls.client, 'delete_%s' % resource)
for u in uuids:
- delete_method(u, ignore_errors=exc.NotFound)
+ delete_method(u, ignore_errors=lib_exc.NotFound)
finally:
super(BaseBaremetalTest, cls).resource_cleanup()
diff --git a/tempest/api/baremetal/admin/test_chassis.py b/tempest/api/baremetal/admin/test_chassis.py
index 6f83412..1cf22ae 100644
--- a/tempest/api/baremetal/admin/test_chassis.py
+++ b/tempest/api/baremetal/admin/test_chassis.py
@@ -11,9 +11,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.baremetal.admin import base
from tempest.common.utils import data_utils
-from tempest import exceptions as exc
from tempest import test
@@ -63,7 +64,7 @@
uuid = body['uuid']
self.delete_chassis(uuid)
- self.assertRaises(exc.NotFound, self.client.show_chassis, uuid)
+ self.assertRaises(lib_exc.NotFound, self.client.show_chassis, uuid)
@test.attr(type='smoke')
def test_update_chassis(self):
diff --git a/tempest/api/baremetal/admin/test_nodes.py b/tempest/api/baremetal/admin/test_nodes.py
index 41c12c6..96f4b43 100644
--- a/tempest/api/baremetal/admin/test_nodes.py
+++ b/tempest/api/baremetal/admin/test_nodes.py
@@ -11,11 +11,11 @@
# under the License.
import six
+from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
from tempest.common.utils import data_utils
from tempest.common import waiters
-from tempest import exceptions as exc
from tempest import test
@@ -62,7 +62,8 @@
self.delete_node(node['uuid'])
- self.assertRaises(exc.NotFound, self.client.show_node, node['uuid'])
+ self.assertRaises(lib_exc.NotFound, self.client.show_node,
+ node['uuid'])
@test.attr(type='smoke')
def test_show_node(self):
diff --git a/tempest/api/baremetal/admin/test_ports.py b/tempest/api/baremetal/admin/test_ports.py
index 89447e0..0076dee 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -11,10 +11,10 @@
# under the License.
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
from tempest.api.baremetal.admin import base
from tempest.common.utils import data_utils
-from tempest import exceptions as exc
from tempest import test
@@ -81,7 +81,8 @@
self.delete_port(port['uuid'])
- self.assertRaises(exc.NotFound, self.client.show_port, port['uuid'])
+ self.assertRaises(lib_exc.NotFound, self.client.show_port,
+ port['uuid'])
@test.attr(type='smoke')
def test_show_port(self):
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index 8080eb6..dd19edc 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.baremetal.admin import base
from tempest.common.utils import data_utils
from tempest import exceptions as exc
@@ -47,7 +49,7 @@
@test.attr(type=['negative', 'smoke'])
def test_show_port_nonexistent_uuid(self):
- self.assertRaises(exc.NotFound, self.client.show_port,
+ self.assertRaises(lib_exc.NotFound, self.client.show_port,
data_utils.rand_uuid())
@test.attr(type=['negative', 'smoke'])
@@ -62,7 +64,7 @@
uuid = data_utils.rand_uuid()
self.create_port(node_id=node_id, address=address, uuid=uuid)
- self.assertRaises(exc.Conflict, self.create_port, node_id=node_id,
+ self.assertRaises(lib_exc.Conflict, self.create_port, node_id=node_id,
address=address, uuid=uuid)
@test.attr(type=['negative', 'smoke'])
@@ -99,7 +101,7 @@
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
- self.assertRaises(exc.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.create_port, node_id=node_id,
address=address)
@@ -134,7 +136,7 @@
patch = [{'path': '/extra/key',
'op': 'replace',
'value': 'new-value'}]
- self.assertRaises(exc.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
@@ -190,7 +192,7 @@
patch = [{'path': '/address',
'op': 'replace',
'value': address1}]
- self.assertRaises(exc.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
diff --git a/tempest/api/compute/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py
index 425ce13..b28b9e0 100644
--- a/tempest/api/compute/admin/test_agents.py
+++ b/tempest/api/compute/admin/test_agents.py
@@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.openstack.common import log
from tempest import test
@@ -43,7 +44,7 @@
def tearDown(self):
try:
self.client.delete_agent(self.agent_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
except Exception:
LOG.exception('Exception raised deleting agent %s', self.agent_id)
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index a866ede..dd40145 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -45,7 +46,7 @@
try:
self.client.delete_aggregate(aggregate_id)
# if aggregate not found, it depict it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@test.attr(type='gate')
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index a450e5d..48f6f94 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
@@ -43,7 +45,7 @@
def test_aggregate_create_as_user(self):
# Regular user is not allowed to create an aggregate.
aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.create_aggregate,
name=aggregate_name)
@@ -69,7 +71,7 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.create_aggregate,
name=aggregate_name)
@@ -80,14 +82,14 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.delete_aggregate,
aggregate['id'])
@test.attr(type=['negative', 'gate'])
def test_aggregate_list_as_user(self):
# Regular user is not allowed to list aggregates.
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.list_aggregates)
@test.attr(type=['negative', 'gate'])
@@ -97,20 +99,20 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.get_aggregate,
aggregate['id'])
@test.attr(type=['negative', 'gate'])
def test_aggregate_delete_with_invalid_id(self):
# Delete an aggregate with invalid id should raise exceptions.
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_aggregate, -1)
@test.attr(type=['negative', 'gate'])
def test_aggregate_get_details_with_invalid_id(self):
# Get aggregate details with invalid id should raise exceptions.
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_aggregate, -1)
@test.attr(type=['negative', 'gate'])
@@ -127,7 +129,7 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.NotFound, self.client.add_host,
+ self.assertRaises(lib_exc.NotFound, self.client.add_host,
aggregate['id'], non_exist_host)
@test.attr(type=['negative', 'gate'])
@@ -137,7 +139,7 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.add_host,
aggregate['id'], self.host)
@@ -151,7 +153,7 @@
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,
+ self.assertRaises(lib_exc.Conflict, self.client.add_host,
aggregate['id'], self.host)
@test.attr(type=['negative', 'gate'])
@@ -164,7 +166,7 @@
self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.remove_host,
aggregate['id'], self.host)
@@ -175,5 +177,5 @@
aggregate = self.client.create_aggregate(name=aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
- self.assertRaises(exceptions.NotFound, self.client.remove_host,
+ self.assertRaises(lib_exc.NotFound, self.client.remove_host,
aggregate['id'], non_exist_host)
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index d062b0c..546aa3b 100644
--- a/tempest/api/compute/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -33,5 +34,5 @@
# List of availability zones and available services with
# non-administrator user
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_availability_zone_list_detail)
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index e7022db..bb5fa8c 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest import config
from tempest import exceptions
@@ -43,14 +45,14 @@
@test.attr(type=['negative', 'gate'])
@test.services('network')
def test_list_fixed_ip_details_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.get_fixed_ip_details, self.ip)
@test.attr(type=['negative', 'gate'])
@test.services('network')
def test_set_reserve_with_non_admin_user(self):
body = {"reserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.reserve_fixed_ip,
self.ip, body)
@@ -58,7 +60,7 @@
@test.services('network')
def test_set_unreserve_with_non_admin_user(self):
body = {"unreserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.reserve_fixed_ip,
self.ip, body)
@@ -71,7 +73,7 @@
# NOTE(eliqiao): in Juno, the exception is NotFound, but in master, we
# change the error code to BadRequest, both exceptions should be
# accepted by tempest
- self.assertRaises((exceptions.NotFound, exceptions.BadRequest),
+ self.assertRaises((lib_exc.NotFound, exceptions.BadRequest),
self.client.reserve_fixed_ip,
"my.invalid.ip", body)
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index 4ba9eb2..5031432 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import uuid
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -53,7 +53,7 @@
new_flavor_id,
is_public='True')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_flavor_access,
new_flavor_id)
@@ -68,7 +68,7 @@
new_flavor_id,
is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.add_flavor_access,
new_flavor['id'],
self.tenant_id)
@@ -88,7 +88,7 @@
self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
self.addCleanup(self.client.remove_flavor_access,
new_flavor['id'], self.tenant_id)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.remove_flavor_access,
new_flavor['id'],
self.tenant_id)
@@ -112,7 +112,7 @@
# An exception should be raised when adding flavor access to the same
# tenant
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.add_flavor_access,
new_flavor['id'],
self.tenant_id)
@@ -130,7 +130,7 @@
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
# An exception should be raised when flavor access is not found
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.remove_flavor_access,
new_flavor['id'],
str(uuid.uuid4()))
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index 2663e25..e414973 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -61,7 +63,7 @@
def test_flavor_non_admin_set_keys(self):
# Test to SET flavor extra spec as a user without admin privileges.
specs = {"key1": "value1", "key2": "value2"}
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.set_flavor_extra_spec,
self.flavor['id'],
specs)
@@ -73,7 +75,7 @@
body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
self.assertEqual(body['key1'], 'value1')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.
update_flavor_extra_spec,
self.flavor['id'],
@@ -85,7 +87,7 @@
specs = {"key1": "value1", "key2": "value2"}
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.unset_flavor_extra_spec,
self.flavor['id'],
'key1')
@@ -93,14 +95,14 @@
@test.attr(type=['negative', 'gate'])
def test_flavor_unset_nonexistent_key(self):
nonexistent_key = data_utils.rand_name('flavor_key')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.unset_flavor_extra_spec,
self.flavor['id'],
nonexistent_key)
@test.attr(type=['negative', 'gate'])
def test_flavor_get_nonexistent_key(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.flavors_client.get_flavor_extra_spec_with_key,
self.flavor['id'],
"nonexistent_key")
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index 86125fb..34d8e3f 100644
--- a/tempest/api/compute/admin/test_flavors_negative.py
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -15,11 +15,12 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.api_schema.request.compute.v2 import flavors
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
@@ -88,7 +89,7 @@
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = str(uuid.uuid4())
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.create_flavor,
flavor_name, self.ram, self.vcpus, self.disk,
new_flavor_id, ephemeral=self.ephemeral,
@@ -97,7 +98,7 @@
@test.attr(type=['negative', 'gate'])
def test_delete_flavor_as_user(self):
# only admin user can delete a flavor
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.user_client.delete_flavor,
self.flavor_ref_alt)
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index fc918a3..20429b1 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -38,20 +40,20 @@
@test.attr(type=['negative', 'gate'])
def test_list_hosts_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_hosts)
@test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_nonexistent_hostname(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.show_host_detail, nonexitent_hostname)
@test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_non_admin_user(self):
hostname = self._get_host_name()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.show_host_detail,
hostname)
@@ -59,7 +61,7 @@
def test_update_host_with_non_admin_user(self):
hostname = self._get_host_name()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.update_host,
hostname,
status='enable',
@@ -112,7 +114,7 @@
def test_update_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_host,
nonexitent_hostname,
status='enable',
@@ -122,7 +124,7 @@
def test_startup_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.startup_host,
nonexitent_hostname)
@@ -130,7 +132,7 @@
def test_startup_host_with_non_admin_user(self):
hostname = self._get_host_name()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.startup_host,
hostname)
@@ -138,7 +140,7 @@
def test_shutdown_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.shutdown_host,
nonexitent_hostname)
@@ -146,7 +148,7 @@
def test_shutdown_host_with_non_admin_user(self):
hostname = self._get_host_name()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.shutdown_host,
hostname)
@@ -154,7 +156,7 @@
def test_reboot_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.reboot_host,
nonexitent_hostname)
@@ -162,6 +164,6 @@
def test_reboot_host_with_non_admin_user(self):
hostname = self._get_host_name()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.reboot_host,
hostname)
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index a137a61..a9c1cb1 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import uuid
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -43,7 +43,7 @@
nonexistent_hypervisor_id = str(uuid.uuid4())
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.client.get_hypervisor_show_details,
nonexistent_hypervisor_id)
@@ -53,7 +53,7 @@
self.assertTrue(len(hypers) > 0)
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_show_details,
hypers[0]['id'])
@@ -63,7 +63,7 @@
self.assertTrue(len(hypers) > 0)
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_servers,
hypers[0]['id'])
@@ -72,14 +72,14 @@
nonexistent_hypervisor_id = str(uuid.uuid4())
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.client.get_hypervisor_servers,
nonexistent_hypervisor_id)
@test.attr(type=['negative', 'gate'])
def test_get_hypervisor_stats_with_non_admin_user(self):
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_stats)
@test.attr(type=['negative', 'gate'])
@@ -87,7 +87,7 @@
nonexistent_hypervisor_id = str(uuid.uuid4())
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.client.get_hypervisor_uptime,
nonexistent_hypervisor_id)
@@ -97,7 +97,7 @@
self.assertTrue(len(hypers) > 0)
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_uptime,
hypers[0]['id'])
@@ -105,14 +105,14 @@
def test_get_hypervisor_list_with_non_admin_user(self):
# List of hypervisor and available services with non admin user
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_list)
@test.attr(type=['negative', 'gate'])
def test_get_hypervisor_list_details_with_non_admin_user(self):
# List of hypervisor details and available services with non admin user
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.get_hypervisor_list_details)
@test.attr(type=['negative', 'gate'])
@@ -120,7 +120,7 @@
nonexistent_hypervisor_name = data_utils.rand_name('test_hypervisor')
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.client.search_hypervisor,
nonexistent_hypervisor_name)
@@ -130,6 +130,6 @@
self.assertTrue(len(hypers) > 0)
self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.non_adm_client.search_hypervisor,
hypers[0]['hypervisor_hostname'])
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
index c4905d9..1e03bd0 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
@@ -16,6 +16,8 @@
import datetime
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest import exceptions
from tempest import test
@@ -31,11 +33,11 @@
@test.attr(type=['negative', 'gate'])
def test_instance_usage_audit_logs_with_nonadmin_user(self):
# the instance_usage_audit_logs API just can be accessed by admin user
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.instance_usages_audit_log_client.
list_instance_usage_audit_logs)
now = datetime.datetime.now()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.instance_usages_audit_log_client.
get_instance_usage_audit_log,
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 7cefe90..2fb7be6 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -13,11 +13,11 @@
# under the License.
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -39,7 +39,7 @@
@test.attr(type=['negative', 'gate'])
def test_update_quota_normal_user(self):
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.update_quota_set,
self.demo_tenant_id,
ram=0)
@@ -59,7 +59,7 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
cores=default_vcpu_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.create_test_server)
@test.attr(type=['negative', 'gate'])
@@ -75,7 +75,7 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
ram=default_mem_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.create_test_server)
@test.attr(type=['negative', 'gate'])
@@ -90,7 +90,7 @@
instances=instances_quota)
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
instances=default_instances_quota)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.create_test_server)
@decorators.skip_because(bug="1186354",
@@ -116,7 +116,7 @@
# Check we cannot create anymore
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.sg_client.create_security_group,
"sg-overlimit", "sg-desc")
@@ -155,6 +155,6 @@
# Check we cannot create SG rule anymore
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
- self.assertRaises((exceptions.OverLimit, exceptions.Unauthorized),
+ self.assertRaises((lib_exc.OverLimit, lib_exc.Unauthorized),
self.sg_client.create_security_group_rule,
secgroup_id, ip_protocol, 1025, 1025)
diff --git a/tempest/api/compute/admin/test_security_group_default_rules.py b/tempest/api/compute/admin/test_security_group_default_rules.py
index 563d517..31103df 100644
--- a/tempest/api/compute/admin/test_security_group_default_rules.py
+++ b/tempest/api/compute/admin/test_security_group_default_rules.py
@@ -12,11 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -59,7 +59,7 @@
rule = self._create_security_group_default_rules(ip_protocol)
# Delete Security Group default rule
self.adm_client.delete_security_group_default_rule(rule['id'])
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.adm_client.get_security_group_default_rule,
rule['id'])
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 0dddc76..0d4731d 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -14,6 +14,7 @@
import uuid
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
@@ -50,7 +51,7 @@
while True:
try:
self.flavors_client.get_flavor_details(flavor_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
break
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
@@ -71,7 +72,7 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
@@ -92,7 +93,7 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
@@ -111,20 +112,20 @@
@test.attr(type=['negative', 'gate'])
def test_reset_state_server_nonexistent_server(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.reset_state, '999')
@test.attr(type=['negative', 'gate'])
def test_get_server_diagnostics_by_non_admin(self):
# Non-admin user can not view server diagnostics according to policy
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_adm_client.get_server_diagnostics,
self.s1_id)
@test.attr(type=['negative', 'gate'])
def test_migrate_non_existent_server(self):
# migrate a non existent server
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.migrate_server,
str(uuid.uuid4()))
@@ -143,6 +144,6 @@
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(server_id, 'SUSPENDED')
# migrate an suspended server should fail
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.migrate_server,
server_id)
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index bb19a39..39d0ee1 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -31,7 +32,7 @@
@test.attr(type=['negative', 'gate'])
def test_list_services_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_services)
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
index 8c31d7c..b371f2d 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -14,6 +14,7 @@
# under the License.
import datetime
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest import exceptions
@@ -42,7 +43,7 @@
# Get usage for a specific tenant empty
params = {'start': self.start,
'end': self.end}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.adm_client.get_tenant_usage,
'', params)
@@ -61,5 +62,5 @@
params = {'start': self.start,
'end': self.end,
'detailed': int(bool(True))}
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.list_tenant_usages, params)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 3e80bf2..4ad6c1d 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import time
from tempest import clients
@@ -107,7 +108,7 @@
for server in cls.servers:
try:
cls.servers_client.delete_server(server['id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# Something else already cleaned up the server, nothing to be
# worried about
pass
@@ -147,7 +148,7 @@
for image_id in cls.images:
try:
cls.images_client.delete_image(image_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# The image may have already been deleted which is OK.
pass
except Exception:
@@ -160,7 +161,7 @@
for sg in cls.security_groups:
try:
cls.security_groups_client.delete_security_group(sg['id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# The security group may have already been deleted which is OK.
pass
except Exception as exc:
@@ -174,7 +175,7 @@
for server_group_id in cls.server_groups:
try:
cls.servers_client.delete_server_group(server_group_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# The server-group may have already been deleted which is OK.
pass
except Exception:
@@ -274,7 +275,7 @@
# 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)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn("Unable to delete volume '%s' since it was not found. "
"Maybe it was already deleted?" % volume_id)
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index e6f4fb0..089ee5a 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -17,7 +17,6 @@
from tempest.api.compute.floating_ips import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -51,7 +50,7 @@
try:
self.client.delete_floating_ip(floating_ip_id)
# if not found, it depicts it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@test.attr(type='gate')
@@ -136,8 +135,8 @@
self.new_server_id)
# Make sure no longer associated with old server
- self.assertRaises((exceptions.NotFound,
+ self.assertRaises((lib_exc.NotFound,
lib_exc.UnprocessableEntity,
- exceptions.Conflict),
+ lib_exc.Conflict),
self.client.disassociate_floating_ip_from_server,
self.floating_ip, self.server_id)
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
index b08df97..b4ea175 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute.floating_ips import base
from tempest.common.utils import data_utils
from tempest import config
@@ -52,7 +54,7 @@
def test_allocate_floating_ip_from_nonexistent_pool(self):
# Negative test:Allocation of a new floating IP from a nonexistent_pool
# to a project should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.create_floating_ip,
"non_exist_pool")
@@ -63,7 +65,7 @@
# from project should fail
# Deleting the non existent floating IP
- self.assertRaises(exceptions.NotFound, self.client.delete_floating_ip,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_floating_ip,
self.non_exist_id)
@test.attr(type=['negative', 'gate'])
@@ -72,7 +74,7 @@
# Negative test:Association of a non existent floating IP
# to specific server should fail
# Associating non existent floating IP
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.associate_floating_ip_to_server,
"0.0.0.0", self.server_id)
@@ -81,7 +83,7 @@
def test_dissociate_nonexistent_floating_ip(self):
# Negative test:Dissociation of a non existent floating IP should fail
# Dissociating non existent floating IP
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.disassociate_floating_ip_from_server,
"0.0.0.0", self.server_id)
@@ -90,6 +92,6 @@
def test_associate_ip_to_server_without_passing_floating_ip(self):
# Negative test:Association of empty floating IP to specific server
# should raise NotFound or BadRequest(In case of Nova V2.1) exception.
- self.assertRaises((exceptions.NotFound, exceptions.BadRequest),
+ self.assertRaises((lib_exc.NotFound, exceptions.BadRequest),
self.client.associate_floating_ip_to_server,
'', self.server_id)
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
index c343018..b3ff132 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -15,10 +15,11 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -41,5 +42,5 @@
non_exist_id = str(uuid.uuid4())
else:
non_exist_id = data_utils.rand_int_id(start=999)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_floating_ip_details, non_exist_id)
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 73412ff..0013714 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -30,21 +31,21 @@
def test_list_nonexistent_image_metadata(self):
# Negative test: List on nonexistent image
# metadata should not happen
- self.assertRaises(exceptions.NotFound, self.client.list_image_metadata,
+ self.assertRaises(lib_exc.NotFound, self.client.list_image_metadata,
data_utils.rand_uuid())
@test.attr(type=['negative', 'gate'])
def test_update_nonexistent_image_metadata(self):
# Negative test:An update should not happen for a non-existent image
meta = {'os_distro': 'alt1', 'os_version': 'alt2'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_image_metadata,
data_utils.rand_uuid(), meta)
@test.attr(type=['negative', 'gate'])
def test_get_nonexistent_image_metadata_item(self):
# Negative test: Get on non-existent image should not happen
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_image_metadata_item,
data_utils.rand_uuid(), 'os_version')
@@ -52,7 +53,7 @@
def test_set_nonexistent_image_metadata(self):
# Negative test: Metadata should not be set to a non-existent image
meta = {'os_distro': 'alt1', 'os_version': 'alt2'}
- self.assertRaises(exceptions.NotFound, self.client.set_image_metadata,
+ self.assertRaises(lib_exc.NotFound, self.client.set_image_metadata,
data_utils.rand_uuid(), meta)
@test.attr(type=['negative', 'gate'])
@@ -60,7 +61,7 @@
# Negative test: Metadata item should not be set to a
# nonexistent image
meta = {'os_distro': 'alt'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.set_image_metadata_item,
data_utils.rand_uuid(), 'os_distro',
meta)
@@ -69,6 +70,6 @@
def test_delete_nonexistent_image_metadata_item(self):
# Negative test: Shouldn't be able to delete metadata
# item from non-existent image
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_image_metadata_item,
data_utils.rand_uuid(), 'os_distro')
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 58fc20d..cf127ee 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -49,7 +50,7 @@
# Create a new image after server is deleted
name = data_utils.rand_name('image')
meta = {'image_type': 'test'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.create_image_from_server,
server['id'], name=name, meta=meta)
@@ -61,7 +62,7 @@
meta = {'image_type': 'test'}
resp = {}
resp['status'] = None
- self.assertRaises(exceptions.NotFound, self.create_image_from_server,
+ self.assertRaises(lib_exc.NotFound, self.create_image_from_server,
'!@#$%^&*()', name=name, meta=meta)
@test.attr(type=['negative', 'gate'])
@@ -84,7 +85,7 @@
# Return an error if Image ID passed is 35 characters or less
snapshot_name = data_utils.rand_name('test-snap-')
test_uuid = ('a' * 35)
- self.assertRaises(exceptions.NotFound, self.client.create_image,
+ self.assertRaises(lib_exc.NotFound, self.client.create_image,
test_uuid, snapshot_name)
@test.attr(type=['negative', 'gate'])
@@ -92,13 +93,13 @@
# Return an error if Image ID passed is 37 characters or more
snapshot_name = data_utils.rand_name('test-snap-')
test_uuid = ('a' * 37)
- self.assertRaises(exceptions.NotFound, self.client.create_image,
+ self.assertRaises(lib_exc.NotFound, self.client.create_image,
test_uuid, snapshot_name)
@test.attr(type=['negative', 'gate'])
def test_delete_image_with_invalid_image_id(self):
# An image should not be deleted with invalid image id
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
'!@$%^&*()')
@test.attr(type=['negative', 'gate'])
@@ -106,28 +107,28 @@
# Return an error while trying to delete a non-existent image
non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
non_existent_image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_image_blank_id(self):
# Return an error while trying to delete an image with blank Id
- self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image, '')
@test.attr(type=['negative', 'gate'])
def test_delete_image_non_hex_string_id(self):
# Return an error while trying to delete an image with non hex id
image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_image_negative_image_id(self):
# Return an error while trying to delete an image with negative id
- self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image, -1)
@test.attr(type=['negative', 'gate'])
def test_delete_image_id_is_over_35_character_limit(self):
# Return an error while trying to delete image with id over limit
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
'11a22b9-12a9-5555-cc11-00ab112223fa-3fac')
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 46cec9b..63f5b9e 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
@@ -102,7 +104,7 @@
# Create second snapshot
alt_snapshot_name = data_utils.rand_name('test-snap-')
- self.assertRaises(exceptions.Conflict, self.client.create_image,
+ self.assertRaises(lib_exc.Conflict, self.client.create_image,
self.server_id, alt_snapshot_name)
@test.attr(type=['negative', 'gate'])
@@ -127,4 +129,4 @@
self.client.delete_image(image_id)
self.image_ids.remove(image_id)
- self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
+ self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
index a8f2ae7..77c9459 100644
--- a/tempest/api/compute/images/test_list_image_filters_negative.py
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -35,5 +36,5 @@
def test_get_nonexistent_image(self):
# Check raises a NotFound
nonexistent_image = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.get_image,
+ self.assertRaises(lib_exc.NotFound, self.client.get_image,
nonexistent_image)
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 4e06d6c..1586405 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -43,7 +45,7 @@
def test_keypair_delete_nonexistent_key(self):
# Non-existent key deletion should throw a proper error
k_name = data_utils.rand_name("keypair-non-existent-")
- self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_keypair,
k_name)
@test.attr(type=['negative', 'gate'])
@@ -68,7 +70,7 @@
k_name = data_utils.rand_name('keypair-')
self.client.create_keypair(k_name)
# Now try the same keyname to create another key
- self.assertRaises(exceptions.Conflict, self._create_keypair,
+ self.assertRaises(lib_exc.Conflict, self._create_keypair,
k_name)
self.client.delete_keypair(k_name)
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index d537d83..9776db3 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
-from tempest import exceptions
from tempest import test
@@ -51,5 +52,5 @@
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.create_test_server, meta=meta_data)
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index d97c404..c8da63f 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute.security_groups import base
from tempest.common.utils import data_utils
from tempest import config
@@ -46,7 +48,7 @@
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -158,6 +160,6 @@
# Negative test: Deletion of Security Group rule should be FAIL
# with non existent id
non_existent_rule_id = not_existing_id()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_security_group_rule,
non_existent_rule_id)
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index ee9f78b..a083406 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -14,6 +14,7 @@
# under the License.
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute.security_groups import base
@@ -53,7 +54,7 @@
# Negative test:Should not be able to GET the details
# of non-existent Security Group
non_exist_id = self._generate_a_non_existent_security_group_id()
- self.assertRaises(exceptions.NotFound, self.client.get_security_group,
+ self.assertRaises(lib_exc.NotFound, self.client.get_security_group,
non_exist_id)
@decorators.skip_because(bug="1161411",
@@ -132,7 +133,7 @@
def test_delete_nonexistent_security_group(self):
# Negative test:Deletion of a non-existent Security Group should fail
non_exist_id = self._generate_a_non_existent_security_group_id()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_security_group, non_exist_id)
@test.attr(type=['negative', 'smoke'])
@@ -140,7 +141,7 @@
def test_delete_security_group_without_passing_id(self):
# Negative test:Deletion of a Security Group with out passing ID
# should Fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_security_group, '')
@testtools.skipIf(CONF.service_available.neutron,
@@ -194,7 +195,7 @@
non_exist_id = self._generate_a_non_existent_security_group_id()
s_name = data_utils.rand_name('sg-')
s_description = data_utils.rand_name('description-')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_security_group,
non_exist_id, name=s_name,
description=s_description)
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 9d1ea9e..7ccec8e 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -124,12 +124,12 @@
device = '/dev/%s' % CONF.compute.volume_device_name
resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, volume = volumes_client.create_volume(1)
+ volume = volumes_client.create_volume(1)
self.addCleanup(volumes_client.delete_volume, volume['id'])
volumes_client.wait_for_volume_status(volume['id'], 'available')
- resp, body = self.client.attach_volume(server['id'],
- volume['id'],
- device=device)
+ self.client.attach_volume(server['id'],
+ volume['id'],
+ device=device)
volumes_client.wait_for_volume_status(volume['id'], 'in-use')
resp, _ = self.client.delete_server(server['id'])
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index e92f04c..116191c 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -32,12 +33,12 @@
def test_list_instance_actions_non_existent_server(self):
# List actions of the non-existent server id
non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_instance_actions,
non_existent_server_id)
@test.attr(type=['negative', 'gate'])
def test_get_instance_action_invalid_request(self):
# Get the action details of the provided server with invalid request
- self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
+ self.assertRaises(lib_exc.NotFound, self.client.get_instance_action,
self.server_id, '999')
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 375f441..cb90873 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -14,12 +14,12 @@
# under the License.
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
from tempest.api import utils
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -48,13 +48,13 @@
# not exist, fail early since the tests won't work...
try:
cls.images_client.get_image(cls.image_ref)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
raise RuntimeError("Image %s (image_ref) was not found!" %
cls.image_ref)
try:
cls.images_client.get_image(cls.image_ref_alt)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
raise RuntimeError("Image %s (image_ref_alt) was not found!" %
cls.image_ref_alt)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 9edaede..f948a3a 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -18,13 +18,13 @@
import urlparse
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -262,7 +262,7 @@
if oldest_backup_exist:
try:
self.os.image_client.delete_image(oldest_backup)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
else:
LOG.warning("Deletion of oldest backup %s should not have "
@@ -464,7 +464,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(server['status'], 'ACTIVE')
# Locked server is not allowed to be stopped by non-admin user
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.servers_client.stop, self.server_id)
resp, server = self.servers_client.unlock_server(self.server_id)
self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index 3087e59..77a041a 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -32,13 +33,13 @@
@test.services('network')
def test_list_server_addresses_invalid_server_id(self):
# List addresses request should fail if server id not in system
- self.assertRaises(exceptions.NotFound, self.client.list_addresses,
+ self.assertRaises(lib_exc.NotFound, self.client.list_addresses,
'999')
@test.attr(type=['negative', 'gate'])
@test.services('network')
def test_list_server_addresses_by_network_neg(self):
# List addresses by network should fail if network name not valid
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_addresses_by_network,
self.server['id'], 'invalid')
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index e193677..7fe95dd 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -40,7 +42,7 @@
for sz in [256, 257, 511, 1023]:
key = "k" * sz
meta = {key: 'data1'}
- self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
+ self.assertRaises((exceptions.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=meta)
@@ -58,7 +60,7 @@
def test_server_metadata_non_existent_server(self):
# GET on a non-existent server should not succeed
non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_server_metadata_item,
non_existent_server_id,
'test2')
@@ -67,7 +69,7 @@
def test_list_server_metadata_non_existent_server(self):
# List metadata on a non-existent server should not succeed
non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_server_metadata,
non_existent_server_id)
@@ -85,7 +87,7 @@
# Set metadata on a non-existent server should not succeed
non_existent_server_id = data_utils.rand_uuid()
meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.set_server_metadata,
non_existent_server_id,
meta)
@@ -95,7 +97,7 @@
# An update should not happen for a non-existent server
non_existent_server_id = data_utils.rand_uuid()
meta = {'key1': 'value1', 'key2': 'value2'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_server_metadata,
non_existent_server_id,
meta)
@@ -112,7 +114,7 @@
def test_delete_metadata_non_existent_server(self):
# Should not be able to delete metadata item from a non-existent server
non_existent_server_id = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_server_metadata_item,
non_existent_server_id,
'd')
@@ -130,14 +132,14 @@
req_metadata = {}
for num in range(1, quota_metadata + 2):
req_metadata['key' + str(num)] = 'val' + str(num)
- self.assertRaises((exceptions.OverLimit, exceptions.Unauthorized),
+ self.assertRaises((lib_exc.OverLimit, lib_exc.Unauthorized),
self.client.set_server_metadata,
self.server_id, req_metadata)
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised while exceeding metadata items limit for
# tenant.
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.client.update_server_metadata,
self.server_id, req_metadata)
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index c6d48bc..bd3ebb0 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -14,9 +14,9 @@
# under the License.
import base64
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -44,7 +44,7 @@
'contents': base64.b64encode(file_contents)})
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
- self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit),
self.create_test_server, personality=personality)
@test.attr(type='gate')
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index f1e2f7f..6780455 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -12,12 +12,13 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -49,7 +50,7 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
def _create_volume(self):
- resp, volume = self.volumes_extensions_client.create_volume(
+ volume = self.volumes_extensions_client.create_volume(
1, display_name=data_utils.rand_name(
self.__class__.__name__ + '_volume'))
self.addCleanup(self.delete_volume, volume['id'])
@@ -81,26 +82,26 @@
self.addCleanup(self._unpause, self.server_id)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.servers_client.rescue_server,
self.server_id)
@test.attr(type=['negative', 'gate'])
def test_rescued_vm_reboot(self):
- self.assertRaises(exceptions.Conflict, self.servers_client.reboot,
+ self.assertRaises(lib_exc.Conflict, self.servers_client.reboot,
self.rescue_id, 'HARD')
@test.attr(type=['negative', 'gate'])
def test_rescue_non_existent_server(self):
# Rescue a non-existing server
non_existent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.servers_client.rescue_server,
non_existent_server)
@test.attr(type=['negative', 'gate'])
def test_rescued_vm_rebuild(self):
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.servers_client.rebuild,
self.rescue_id,
self.image_ref_alt)
@@ -117,7 +118,7 @@
self.addCleanup(self._unrescue, self.server_id)
# Attach the volume to the server
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.servers_client.attach_volume,
self.server_id,
volume['id'],
@@ -144,7 +145,7 @@
self.addCleanup(self._unrescue, self.server_id)
# Detach the volume from the server expecting failure
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.servers_client.detach_volume,
self.server_id,
volume['id'])
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index b703cfe..845a71e 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -15,6 +15,7 @@
import sys
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
@@ -108,7 +109,7 @@
def test_resize_nonexistent_server(self):
# Resize a non-existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.resize,
nonexistent_server, self.flavor_ref)
@@ -133,7 +134,7 @@
def test_reboot_non_existent_server(self):
# Reboot a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.reboot,
+ self.assertRaises(lib_exc.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -143,7 +144,7 @@
# Pause a paused server.
self.client.pause_server(self.server_id)
self.client.wait_for_server_status(self.server_id, 'PAUSED')
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.pause_server,
self.server_id)
self.client.unpause_server(self.server_id)
@@ -155,17 +156,17 @@
self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.rebuild,
server['id'], self.image_ref_alt)
- self.assertRaises(exceptions.NotFound, self.client.reboot,
+ self.assertRaises(lib_exc.NotFound, self.client.reboot,
server['id'], 'SOFT')
@test.attr(type=['negative', 'gate'])
def test_rebuild_non_existent_server(self):
# Rebuild a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.rebuild,
nonexistent_server,
self.image_ref_alt)
@@ -210,7 +211,7 @@
# Pass really long metadata while creating a server
metadata = {'a': 'b' * 260}
- self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
+ self.assertRaises((exceptions.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=metadata)
@@ -221,7 +222,7 @@
server_name = data_utils.rand_name('server')
new_name = data_utils.rand_name('server') + '_updated'
- self.assertRaises(exceptions.NotFound, self.client.update_server,
+ self.assertRaises(lib_exc.NotFound, self.client.update_server,
server_name, name=new_name)
@test.attr(type=['negative', 'gate'])
@@ -239,7 +240,7 @@
# Update name of a server that belongs to another tenant
new_name = self.server_id + '_new'
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.update_server, self.server_id,
name=new_name)
@@ -258,13 +259,13 @@
# Delete a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.delete_server,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_server,
nonexistent_server)
@test.attr(type=['negative', 'gate'])
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.delete_server,
self.server_id)
@@ -272,13 +273,13 @@
def test_delete_server_pass_negative_id(self):
# Pass an invalid string parameter to delete server
- self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
+ self.assertRaises(lib_exc.NotFound, self.client.delete_server, -1)
@test.attr(type=['negative', 'gate'])
def test_delete_server_pass_id_exceeding_length_limit(self):
# Pass a server ID that exceeds length limit to delete server
- self.assertRaises(exceptions.NotFound, self.client.delete_server,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_server,
sys.maxint + 1)
@test.attr(type=['negative', 'gate'])
@@ -294,14 +295,14 @@
def test_get_non_existent_server(self):
# Get a non existent server details
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.get_server,
+ self.assertRaises(lib_exc.NotFound, self.client.get_server,
nonexistent_server)
@test.attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.servers_client.stop,
+ self.assertRaises(lib_exc.NotFound, self.servers_client.stop,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -310,7 +311,7 @@
def test_pause_non_existent_server(self):
# pause a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.pause_server,
+ self.assertRaises(lib_exc.NotFound, self.client.pause_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -319,7 +320,7 @@
def test_unpause_non_existent_server(self):
# unpause a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.unpause_server,
+ self.assertRaises(lib_exc.NotFound, self.client.unpause_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -327,7 +328,7 @@
@test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.unpause_server,
self.server_id)
@@ -337,7 +338,7 @@
def test_suspend_non_existent_server(self):
# suspend a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.suspend_server,
+ self.assertRaises(lib_exc.NotFound, self.client.suspend_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -348,7 +349,7 @@
resp, _ = self.client.suspend_server(self.server_id)
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'SUSPENDED')
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.suspend_server,
self.server_id)
self.client.resume_server(self.server_id)
@@ -359,7 +360,7 @@
def test_resume_non_existent_server(self):
# resume a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.resume_server,
+ self.assertRaises(lib_exc.NotFound, self.client.resume_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -367,7 +368,7 @@
@test.attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
# resume an active server.
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.resume_server,
self.server_id)
@@ -375,7 +376,7 @@
def test_get_console_output_of_non_existent_server(self):
# get the console output for a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_console_output,
nonexistent_server, 10)
@@ -383,7 +384,7 @@
def test_force_delete_nonexistent_server_id(self):
# force-delete a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.force_delete_server,
nonexistent_server)
@@ -391,14 +392,14 @@
def test_restore_nonexistent_server_id(self):
# restore-delete a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.restore_soft_deleted_server,
nonexistent_server)
@test.attr(type=['negative', 'gate'])
def test_restore_server_invalid_state(self):
# we can only restore-delete a server in 'soft-delete' state
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.restore_soft_deleted_server,
self.server_id)
@@ -408,7 +409,7 @@
def test_shelve_non_existent_server(self):
# shelve a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.shelve_server,
+ self.assertRaises(lib_exc.NotFound, self.client.shelve_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
@@ -435,7 +436,7 @@
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.shelve_server,
self.server_id)
@@ -447,7 +448,7 @@
def test_unshelve_non_existent_server(self):
# unshelve a non existent server
nonexistent_server = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
+ self.assertRaises(lib_exc.NotFound, self.client.unshelve_server,
nonexistent_server)
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
@@ -455,6 +456,6 @@
@test.attr(type=['negative', 'gate'])
def test_unshelve_server_invalid_state(self):
# unshelve an active server.
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.unshelve_server,
self.server_id)
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
index e81ccc6..d66b7ba 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -15,8 +15,9 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -35,6 +36,6 @@
# Negative test: Should not be able to GET virtual interfaces
# for an invalid server_id
invalid_server_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_virtual_interfaces,
invalid_server_id)
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index cdbaee8..16b7ed2 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -15,6 +15,8 @@
import StringIO
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
@@ -93,32 +95,32 @@
@test.attr(type='gate')
def test_get_server_for_alt_account_fails(self):
# A GET request for a server on another user's account should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.get_server,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.get_server,
self.server['id'])
@test.attr(type='gate')
def test_delete_server_for_alt_account_fails(self):
# A DELETE request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.delete_server,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.delete_server,
self.server['id'])
@test.attr(type='gate')
def test_update_server_for_alt_account_fails(self):
# An update server request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.update_server,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.update_server,
self.server['id'], name='test')
@test.attr(type='gate')
def test_list_server_addresses_for_alt_account_fails(self):
# A list addresses request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.list_addresses,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.list_addresses,
self.server['id'])
@test.attr(type='gate')
def test_list_server_addresses_by_network_for_alt_account_fails(self):
# A list address/network request for another user's server should fail
server_id = self.server['id']
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.list_addresses_by_network, server_id,
'public')
@@ -135,31 +137,31 @@
@test.attr(type='gate')
def test_change_password_for_alt_account_fails(self):
# A change password request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.change_password,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.change_password,
self.server['id'], 'newpass')
@test.attr(type='gate')
def test_reboot_server_for_alt_account_fails(self):
# A reboot request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.reboot,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.reboot,
self.server['id'], 'HARD')
@test.attr(type='gate')
def test_rebuild_server_for_alt_account_fails(self):
# A rebuild request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.rebuild,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.rebuild,
self.server['id'], self.image_ref_alt)
@test.attr(type='gate')
def test_resize_server_for_alt_account_fails(self):
# A resize request for another user's server should fail
- self.assertRaises(exceptions.NotFound, self.alt_client.resize,
+ self.assertRaises(lib_exc.NotFound, self.alt_client.resize,
self.server['id'], self.flavor_ref_alt)
@test.attr(type='gate')
def test_create_image_for_alt_account_fails(self):
# A create image request for another user's server should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.create_image,
self.server['id'], 'testImage')
@@ -208,27 +210,27 @@
@test.attr(type='gate')
def test_get_keypair_of_alt_account_fails(self):
# A GET request for another user's keypair should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_keypairs_client.get_keypair,
self.keypairname)
@test.attr(type='gate')
def test_delete_keypair_of_alt_account_fails(self):
# A DELETE request for another user's keypair should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_keypairs_client.delete_keypair,
self.keypairname)
@test.attr(type='gate')
def test_get_image_for_alt_account_fails(self):
# A GET request for an image on another user's account should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.get_image, self.image['id'])
@test.attr(type='gate')
def test_delete_image_for_alt_account_fails(self):
# A DELETE request for another user's image should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.delete_image,
self.image['id'])
@@ -260,14 +262,14 @@
@test.attr(type='gate')
def test_get_security_group_of_alt_account_fails(self):
# A GET request for another user's security group should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_security_client.get_security_group,
self.security_group['id'])
@test.attr(type='gate')
def test_delete_security_group_of_alt_account_fails(self):
# A DELETE request for another user's security group should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_security_client.delete_security_group,
self.security_group['id'])
@@ -305,7 +307,7 @@
def test_delete_security_group_rule_of_alt_account_fails(self):
# A DELETE request for another user's security group rule
# should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_security_client.delete_security_group_rule,
self.rule['id'])
@@ -313,7 +315,7 @@
def test_set_metadata_of_alt_account_server_fails(self):
# A set metadata for another user's server should fail
req_metadata = {'meta1': 'data1', 'meta2': 'data2'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.set_server_metadata,
self.server['id'],
req_metadata)
@@ -322,7 +324,7 @@
def test_set_metadata_of_alt_account_image_fails(self):
# A set metadata for another user's image should fail
req_metadata = {'meta1': 'value1', 'meta2': 'value2'}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.set_image_metadata,
self.image['id'], req_metadata)
@@ -333,7 +335,7 @@
self.client.set_server_metadata(self.server['id'], req_metadata)
self.addCleanup(self.client.delete_server_metadata_item,
self.server['id'], 'meta1')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.get_server_metadata_item,
self.server['id'], 'meta1')
@@ -345,7 +347,7 @@
self.image['id'], 'meta1')
self.images_client.set_image_metadata(self.image['id'],
req_metadata)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.get_image_metadata_item,
self.image['id'], 'meta1')
@@ -356,7 +358,7 @@
self.addCleanup(self.client.delete_server_metadata_item,
self.server['id'], 'meta1')
self.client.set_server_metadata(self.server['id'], req_metadata)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.delete_server_metadata_item,
self.server['id'], 'meta1')
@@ -368,13 +370,13 @@
self.image['id'], 'meta1')
self.images_client.set_image_metadata(self.image['id'],
req_metadata)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_images_client.delete_image_metadata_item,
self.image['id'], 'meta1')
@test.attr(type='gate')
def test_get_console_output_of_alt_account_server_fails(self):
# A Get Console Output for another user's server should fail
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_client.get_console_output,
self.server['id'], 10)
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 7fef52f..40b93a8 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -68,7 +68,7 @@
'available')
# Attach the volume to the server
- _, self.attachment = self.servers_client.attach_volume(
+ self.attachment = self.servers_client.attach_volume(
self.server['id'],
self.volume['id'],
device='/dev/%s' % self.device)
@@ -116,13 +116,13 @@
# Create Server, Volume and attach that Volume to Server
self._create_and_attach()
# List Volume attachment of the server
- _, body = self.servers_client.list_volume_attachments(
+ body = self.servers_client.list_volume_attachments(
self.server['id'])
self.assertEqual(1, len(body))
self.assertIn(self.attachment, body)
# Get Volume attachment of the server
- _, body = self.servers_client.get_volume_attachment(
+ body = self.servers_client.get_volume_attachment(
self.server['id'],
self.attachment['id'])
self.assertEqual(self.server['id'], body['serverId'])
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index d441427..53f5ac0 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -41,11 +41,10 @@
v_name = data_utils.rand_name('Volume-%s-') % self._interface
metadata = {'Type': 'work'}
# Create volume
- resp, volume = self.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
+ volume = self.client.create_volume(size=1,
+ display_name=v_name,
+ metadata=metadata)
self.addCleanup(self.delete_volume, volume['id'])
- self.assertEqual(200, resp.status)
self.assertIn('id', volume)
self.assertIn('displayName', volume)
self.assertEqual(volume['displayName'], v_name,
@@ -56,8 +55,7 @@
# Wait for Volume status to become ACTIVE
self.client.wait_for_volume_status(volume['id'], 'available')
# GET Volume
- resp, fetched_volume = self.client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
+ fetched_volume = self.client.get_volume(volume['id'])
# Verification of details of fetched Volume
self.assertEqual(v_name,
fetched_volume['displayName'],
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index 6bf9519..c0ac99b 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -45,11 +45,11 @@
v_name = data_utils.rand_name('volume-%s' % cls._interface)
metadata = {'Type': 'work'}
try:
- resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=metadata)
+ volume = cls.client.create_volume(size=1,
+ display_name=v_name,
+ metadata=metadata)
cls.client.wait_for_volume_status(volume['id'], 'available')
- resp, volume = cls.client.get_volume(volume['id'])
+ volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
except Exception:
@@ -79,8 +79,7 @@
def test_volume_list(self):
# Should return the list of Volumes
# Fetch all Volumes
- resp, fetched_list = self.client.list_volumes()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_volumes()
# Now check if all the Volumes created in setup are in fetched list
missing_volumes = [
v for v in self.volume_list if v not in fetched_list
@@ -95,8 +94,7 @@
def test_volume_list_with_details(self):
# Should return the list of Volumes with details
# Fetch all Volumes
- resp, fetched_list = self.client.list_volumes_with_detail()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_volumes_with_detail()
# Now check if all the Volumes created in setup are in fetched list
missing_volumes = [
v for v in self.volume_list if v not in fetched_list
@@ -111,8 +109,7 @@
def test_volume_list_param_limit(self):
# Return the list of volumes based on limit set
params = {'limit': 2}
- resp, fetched_vol_list = self.client.list_volumes(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes(params=params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volumes by limit set")
@@ -121,9 +118,7 @@
def test_volume_list_with_detail_param_limit(self):
# Return the list of volumes with details based on limit set.
params = {'limit': 2}
- resp, fetched_vol_list = \
- self.client.list_volumes_with_detail(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes_with_detail(params=params)
self.assertEqual(len(fetched_vol_list), params['limit'],
"Failed to list volume details by limit set")
@@ -132,10 +127,9 @@
def test_volume_list_param_offset_and_limit(self):
# Return the list of volumes based on offset and limit set.
# get all volumes list
- response, all_vol_list = self.client.list_volumes()
+ all_vol_list = self.client.list_volumes()
params = {'offset': 1, 'limit': 1}
- resp, fetched_vol_list = self.client.list_volumes(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes(params=params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
@@ -150,11 +144,9 @@
def test_volume_list_with_detail_param_offset_and_limit(self):
# Return the list of volumes details based on offset and limit set.
# get all volumes list
- response, all_vol_list = self.client.list_volumes_with_detail()
+ all_vol_list = self.client.list_volumes_with_detail()
params = {'offset': 1, 'limit': 1}
- resp, fetched_vol_list = \
- self.client.list_volumes_with_detail(params=params)
- self.assertEqual(200, resp.status)
+ fetched_vol_list = self.client.list_volumes_with_detail(params=params)
# Validating length of the fetched volumes
self.assertEqual(len(fetched_vol_list), params['limit'],
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index f0f9879..53253c9 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import config
@@ -39,7 +41,7 @@
# Negative: Should not be able to get details of nonexistent volume
# Creating a nonexistent volume id
# Trying to GET a non existent volume
- self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@test.attr(type=['negative', 'gate'])
@@ -47,7 +49,7 @@
# Negative: Should not be able to delete nonexistent Volume
# Creating nonexistent volume id
# Trying to DELETE a non existent volume
- self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
@test.attr(type=['negative', 'gate'])
@@ -79,22 +81,22 @@
@test.attr(type=['negative', 'gate'])
def test_get_invalid_volume_id(self):
# Negative: Should not be able to get volume with invalid id
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_volume, '#$%%&^&^')
@test.attr(type=['negative', 'gate'])
def test_get_volume_without_passing_volume_id(self):
# Negative: Should not be able to get volume when empty ID is passed
- self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
+ self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
@test.attr(type=['negative', 'gate'])
def test_delete_invalid_volume_id(self):
# Negative: Should not be able to delete volume when invalid ID is
# passed
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_volume, '!@#$%^&*()')
@test.attr(type=['negative', 'gate'])
def test_delete_volume_without_passing_volume_id(self):
# Negative: Should not be able to delete volume when empty ID is passed
- self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
+ self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index 2ec1017..bb3a7c8 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -12,8 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest import config
-from tempest import exceptions
import tempest.test
@@ -24,14 +25,25 @@
_interface = 'json'
@classmethod
- def resource_setup(cls):
- super(BaseDataProcessingTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(BaseDataProcessingTest, cls).skip_checks()
if not CONF.service_available.sahara:
raise cls.skipException('Sahara support is required')
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseDataProcessingTest, cls).setup_credentials()
cls.os = cls.get_client_manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseDataProcessingTest, cls).setup_clients()
cls.client = cls.os.data_processing_client
+ @classmethod
+ def resource_setup(cls):
+ super(BaseDataProcessingTest, cls).resource_setup()
+
cls.flavor_ref = CONF.compute.flavor_ref
# add lists for watched resources
@@ -63,7 +75,7 @@
for resource_id in resource_id_list:
try:
method(resource_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# ignore errors while auto removing created resource
pass
@@ -77,12 +89,12 @@
object. All resources created in this method will be automatically
removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_node_group_template(name, plugin_name,
- hadoop_version,
- node_processes,
- flavor_id,
- node_configs,
- **kwargs)
+ resp_body = cls.client.create_node_group_template(name, plugin_name,
+ hadoop_version,
+ node_processes,
+ flavor_id,
+ node_configs,
+ **kwargs)
# store id of created node group template
cls._node_group_templates.append(resp_body['id'])
@@ -97,11 +109,11 @@
object. All resources created in this method will be automatically
removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_cluster_template(name, plugin_name,
- hadoop_version,
- node_groups,
- cluster_configs,
- **kwargs)
+ resp_body = cls.client.create_cluster_template(name, plugin_name,
+ hadoop_version,
+ node_groups,
+ cluster_configs,
+ **kwargs)
# store id of created cluster template
cls._cluster_templates.append(resp_body['id'])
@@ -115,7 +127,7 @@
object. All resources created in this method will be automatically
removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_data_source(name, type, url, **kwargs)
+ resp_body = cls.client.create_data_source(name, type, url, **kwargs)
# store id of created data source
cls._data_sources.append(resp_body['id'])
@@ -128,7 +140,7 @@
It returns created object. All resources created in this method will
be automatically removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_job_binary_internal(name, data)
+ resp_body = cls.client.create_job_binary_internal(name, data)
# store id of created job binary internal
cls._job_binary_internals.append(resp_body['id'])
@@ -142,7 +154,7 @@
object. All resources created in this method will be automatically
removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_job_binary(name, url, extra, **kwargs)
+ resp_body = cls.client.create_job_binary(name, url, extra, **kwargs)
# store id of created job binary
cls._job_binaries.append(resp_body['id'])
@@ -156,8 +168,8 @@
object. All resources created in this method will be automatically
removed in tearDownClass method.
"""
- _, resp_body = cls.client.create_job(name,
- job_type, mains, libs, **kwargs)
+ resp_body = cls.client.create_job(name,
+ job_type, mains, libs, **kwargs)
# store id of created job
cls._jobs.append(resp_body['id'])
diff --git a/tempest/api/data_processing/test_cluster_templates.py b/tempest/api/data_processing/test_cluster_templates.py
index 537f90c..422ea5b 100644
--- a/tempest/api/data_processing/test_cluster_templates.py
+++ b/tempest/api/data_processing/test_cluster_templates.py
@@ -120,7 +120,7 @@
template_info = self._create_cluster_template()
# check for cluster template in list
- _, templates = self.client.list_cluster_templates()
+ templates = self.client.list_cluster_templates()
templates_info = [(template['id'], template['name'])
for template in templates]
self.assertIn(template_info, templates_info)
@@ -130,7 +130,7 @@
template_id, template_name = self._create_cluster_template()
# check cluster template fetch by id
- _, template = self.client.get_cluster_template(template_id)
+ template = self.client.get_cluster_template(template_id)
self.assertEqual(template_name, template['name'])
self.assertDictContainsSubset(self.cluster_template, template)
diff --git a/tempest/api/data_processing/test_data_sources.py b/tempest/api/data_processing/test_data_sources.py
index 3650751..a50f44b 100644
--- a/tempest/api/data_processing/test_data_sources.py
+++ b/tempest/api/data_processing/test_data_sources.py
@@ -68,13 +68,13 @@
def _list_data_sources(self, source_info):
# check for data source in list
- _, sources = self.client.list_data_sources()
+ sources = self.client.list_data_sources()
sources_info = [(source['id'], source['name']) for source in sources]
self.assertIn(source_info, sources_info)
def _get_data_source(self, source_id, source_name, source_body):
# check data source fetch by id
- _, source = self.client.get_data_source(source_id)
+ source = self.client.get_data_source(source_id)
self.assertEqual(source_name, source['name'])
self.assertDictContainsSubset(source_body, source)
diff --git a/tempest/api/data_processing/test_job_binaries.py b/tempest/api/data_processing/test_job_binaries.py
index d006991..2f6d998 100644
--- a/tempest/api/data_processing/test_job_binaries.py
+++ b/tempest/api/data_processing/test_job_binaries.py
@@ -78,7 +78,7 @@
binary_info = self._create_job_binary(self.swift_job_binary_with_extra)
# check for job binary in list
- _, binaries = self.client.list_job_binaries()
+ binaries = self.client.list_job_binaries()
binaries_info = [(binary['id'], binary['name']) for binary in binaries]
self.assertIn(binary_info, binaries_info)
@@ -88,7 +88,7 @@
self._create_job_binary(self.swift_job_binary_with_extra))
# check job binary fetch by id
- _, binary = self.client.get_job_binary(binary_id)
+ binary = self.client.get_job_binary(binary_id)
self.assertEqual(binary_name, binary['name'])
self.assertDictContainsSubset(self.swift_job_binary, binary)
@@ -109,7 +109,7 @@
binary_info = self._create_job_binary(self.internal_db_job_binary)
# check for job binary in list
- _, binaries = self.client.list_job_binaries()
+ binaries = self.client.list_job_binaries()
binaries_info = [(binary['id'], binary['name']) for binary in binaries]
self.assertIn(binary_info, binaries_info)
@@ -119,7 +119,7 @@
self._create_job_binary(self.internal_db_job_binary))
# check job binary fetch by id
- _, binary = self.client.get_job_binary(binary_id)
+ binary = self.client.get_job_binary(binary_id)
self.assertEqual(binary_name, binary['name'])
self.assertDictContainsSubset(self.internal_db_job_binary, binary)
diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/tempest/api/data_processing/test_job_binary_internals.py
index 7e99867..b8121a0 100644
--- a/tempest/api/data_processing/test_job_binary_internals.py
+++ b/tempest/api/data_processing/test_job_binary_internals.py
@@ -55,7 +55,7 @@
binary_info = self._create_job_binary_internal()
# check for job binary internal in list
- _, binaries = self.client.list_job_binary_internals()
+ binaries = self.client.list_job_binary_internals()
binaries_info = [(binary['id'], binary['name']) for binary in binaries]
self.assertIn(binary_info, binaries_info)
@@ -64,7 +64,7 @@
binary_id, binary_name = self._create_job_binary_internal()
# check job binary internal fetch by id
- _, binary = self.client.get_job_binary_internal(binary_id)
+ binary = self.client.get_job_binary_internal(binary_id)
self.assertEqual(binary_name, binary['name'])
@test.attr(type='smoke')
diff --git a/tempest/api/data_processing/test_jobs.py b/tempest/api/data_processing/test_jobs.py
index 5af2eef..a7beb0e 100644
--- a/tempest/api/data_processing/test_jobs.py
+++ b/tempest/api/data_processing/test_jobs.py
@@ -69,7 +69,7 @@
job_info = self._create_job()
# check for job in list
- _, jobs = self.client.list_jobs()
+ jobs = self.client.list_jobs()
jobs_info = [(job['id'], job['name']) for job in jobs]
self.assertIn(job_info, jobs_info)
@@ -78,7 +78,7 @@
job_id, job_name = self._create_job()
# check job fetch by id
- _, job = self.client.get_job(job_id)
+ job = self.client.get_job(job_id)
self.assertEqual(job_name, job['name'])
@test.attr(type='smoke')
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
index f3f59fc..d37e910 100644
--- a/tempest/api/data_processing/test_node_group_templates.py
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -69,7 +69,7 @@
template_info = self._create_node_group_template()
# check for node group template in list
- _, templates = self.client.list_node_group_templates()
+ templates = self.client.list_node_group_templates()
templates_info = [(template['id'], template['name'])
for template in templates]
self.assertIn(template_info, templates_info)
@@ -79,7 +79,7 @@
template_id, template_name = self._create_node_group_template()
# check node group template fetch by id
- _, template = self.client.get_node_group_template(template_id)
+ template = self.client.get_node_group_template(template_id)
self.assertEqual(template_name, template['name'])
self.assertDictContainsSubset(self.node_group_template, template)
diff --git a/tempest/api/data_processing/test_plugins.py b/tempest/api/data_processing/test_plugins.py
index 4b4ec48..8c9b720 100644
--- a/tempest/api/data_processing/test_plugins.py
+++ b/tempest/api/data_processing/test_plugins.py
@@ -25,7 +25,7 @@
It ensures main plugins availability.
"""
- _, plugins = self.client.list_plugins()
+ plugins = self.client.list_plugins()
plugins_names = [plugin['name'] for plugin in plugins]
for enabled_plugin in CONF.data_processing_feature_enabled.plugins:
self.assertIn(enabled_plugin, plugins_names)
@@ -39,12 +39,12 @@
@test.attr(type='smoke')
def test_plugin_get(self):
for plugin_name in self._list_all_plugin_names():
- _, plugin = self.client.get_plugin(plugin_name)
+ plugin = self.client.get_plugin(plugin_name)
self.assertEqual(plugin_name, plugin['name'])
for plugin_version in plugin['versions']:
- _, detailed_plugin = self.client.get_plugin(plugin_name,
- plugin_version)
+ detailed_plugin = self.client.get_plugin(plugin_name,
+ plugin_version)
self.assertEqual(plugin_name, detailed_plugin['name'])
# check that required image tags contains name and version
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
index 9f14cce..c6acacf 100644
--- a/tempest/api/database/flavors/test_flavors_negative.py
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.database import base
-from tempest import exceptions
from tempest import test
@@ -28,5 +29,5 @@
@test.attr(type=['negative', 'gate'])
def test_get_non_existent_db_flavor(self):
# flavor details are not returned for non-existent flavors
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_db_flavor_details, -1)
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 58f726a..789e8b6 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import uuid
from tempest.api.identity import base
@@ -35,7 +36,7 @@
@test.attr(type=['negative', 'gate'])
def test_list_roles_by_unauthorized_user(self):
# Non-administrator user should not be able to list roles
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_roles)
@test.attr(type=['negative', 'gate'])
@@ -43,7 +44,7 @@
# Request to list roles without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.list_roles)
+ self.assertRaises(lib_exc.Unauthorized, self.client.list_roles)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative', 'gate'])
@@ -55,7 +56,7 @@
def test_create_role_by_unauthorized_user(self):
# Non-administrator user should not be able to create role
role_name = data_utils.rand_name(name='role-')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.create_role, role_name)
@test.attr(type=['negative', 'gate'])
@@ -64,7 +65,7 @@
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
role_name = data_utils.rand_name(name='role-')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.create_role, role_name)
self.client.auth_provider.clear_auth()
@@ -75,7 +76,7 @@
body = self.client.create_role(role_name)
role1_id = body.get('id')
self.addCleanup(self.client.delete_role, role1_id)
- self.assertRaises(exceptions.Conflict, self.client.create_role,
+ self.assertRaises(lib_exc.Conflict, self.client.create_role,
role_name)
@test.attr(type=['negative', 'gate'])
@@ -85,7 +86,7 @@
body = self.client.create_role(role_name)
self.data.roles.append(body)
role_id = body.get('id')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.delete_role, role_id)
@test.attr(type=['negative', 'gate'])
@@ -97,7 +98,7 @@
role_id = body.get('id')
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.delete_role,
role_id)
self.client.auth_provider.clear_auth()
@@ -106,7 +107,7 @@
def test_delete_role_non_existent(self):
# Attempt to delete a non existent role should fail
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.delete_role,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_role,
non_existent_role)
@test.attr(type=['negative', 'gate'])
@@ -114,7 +115,7 @@
# Non-administrator user should not be authorized to
# assign a role to user
(user, tenant, role) = self._get_role_params()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.assign_user_role,
tenant['id'], user['id'], role['id'])
@@ -124,7 +125,7 @@
(user, tenant, role) = self._get_role_params()
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.assign_user_role, tenant['id'],
user['id'], role['id'])
self.client.auth_provider.clear_auth()
@@ -134,7 +135,7 @@
# Attempt to assign a non existent role to user should fail
(user, tenant, role) = self._get_role_params()
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.assign_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.assign_user_role,
tenant['id'], user['id'], non_existent_role)
@test.attr(type=['negative', 'gate'])
@@ -142,7 +143,7 @@
# Attempt to assign a role on a non existent tenant should fail
(user, tenant, role) = self._get_role_params()
non_existent_tenant = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.assign_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.assign_user_role,
non_existent_tenant, user['id'], role['id'])
@test.attr(type=['negative', 'gate'])
@@ -150,7 +151,7 @@
# Duplicate user role should not get assigned
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- self.assertRaises(exceptions.Conflict, self.client.assign_user_role,
+ self.assertRaises(lib_exc.Conflict, self.client.assign_user_role,
tenant['id'], user['id'], role['id'])
@test.attr(type=['negative', 'gate'])
@@ -161,7 +162,7 @@
self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.remove_user_role,
tenant['id'], user['id'], role['id'])
@@ -174,7 +175,7 @@
role['id'])
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.remove_user_role, tenant['id'],
user['id'], role['id'])
self.client.auth_provider.clear_auth()
@@ -187,7 +188,7 @@
user['id'],
role['id'])
non_existent_role = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.remove_user_role,
tenant['id'], user['id'], non_existent_role)
@test.attr(type=['negative', 'gate'])
@@ -198,7 +199,7 @@
user['id'],
role['id'])
non_existent_tenant = str(uuid.uuid4().hex)
- self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
+ self.assertRaises(lib_exc.NotFound, self.client.remove_user_role,
non_existent_tenant, user['id'], role['id'])
@test.attr(type=['negative', 'gate'])
@@ -207,7 +208,7 @@
# a user's roles
(user, tenant, role) = self._get_role_params()
self.client.assign_user_role(tenant['id'], user['id'], role['id'])
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_user_roles, tenant['id'],
user['id'])
@@ -218,7 +219,7 @@
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
try:
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.client.list_user_roles, tenant['id'],
user['id'])
finally:
diff --git a/tempest/api/identity/admin/test_services.py b/tempest/api/identity/admin/test_services.py
index 03d6e35..30e0058 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -14,10 +14,10 @@
# under the License.
from six import moves
+from tempest_lib import exceptions as lib_exc
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -28,7 +28,7 @@
# Deleting the service created in this method
self.client.delete_service(service_id)
# Checking whether service is deleted successfully
- self.assertRaises(exceptions.NotFound, self.client.get_service,
+ self.assertRaises(lib_exc.NotFound, self.client.get_service,
service_id)
@test.attr(type='smoke')
diff --git a/tempest/api/identity/admin/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py
index 75f0152..a4bf263 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import uuid
from tempest.api.identity import base
@@ -27,7 +28,7 @@
@test.attr(type=['negative', 'gate'])
def test_list_tenants_by_unauthorized_user(self):
# Non-administrator user should not be able to list tenants
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_tenants)
@test.attr(type=['negative', 'gate'])
@@ -35,7 +36,7 @@
# Request to list tenants without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.list_tenants)
+ self.assertRaises(lib_exc.Unauthorized, self.client.list_tenants)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative', 'gate'])
@@ -44,7 +45,7 @@
tenant_name = data_utils.rand_name(name='tenant-')
tenant = self.client.create_tenant(tenant_name)
self.data.tenants.append(tenant)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.delete_tenant, tenant['id'])
@test.attr(type=['negative', 'gate'])
@@ -55,14 +56,14 @@
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.delete_tenant,
+ self.assertRaises(lib_exc.Unauthorized, self.client.delete_tenant,
tenant['id'])
self.client.auth_provider.clear_auth()
@test.attr(type=['negative', 'gate'])
def test_delete_non_existent_tenant(self):
# Attempt to delete a non existent tenant should fail
- self.assertRaises(exceptions.NotFound, self.client.delete_tenant,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_tenant,
str(uuid.uuid4().hex))
@test.attr(type=['negative', 'gate'])
@@ -76,14 +77,14 @@
self.addCleanup(self.client.delete_tenant, tenant1_id)
self.addCleanup(self.data.tenants.remove, tenant)
- self.assertRaises(exceptions.Conflict, self.client.create_tenant,
+ self.assertRaises(lib_exc.Conflict, self.client.create_tenant,
tenant_name)
@test.attr(type=['negative', 'gate'])
def test_create_tenant_by_unauthorized_user(self):
# Non-administrator user should not be authorized to create a tenant
tenant_name = data_utils.rand_name(name='tenant-')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.create_tenant, tenant_name)
@test.attr(type=['negative', 'gate'])
@@ -92,7 +93,7 @@
tenant_name = data_utils.rand_name(name='tenant-')
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.create_tenant,
+ self.assertRaises(lib_exc.Unauthorized, self.client.create_tenant,
tenant_name)
self.client.auth_provider.clear_auth()
@@ -112,7 +113,7 @@
@test.attr(type=['negative', 'gate'])
def test_update_non_existent_tenant(self):
# Attempt to update a non existent tenant should fail
- self.assertRaises(exceptions.NotFound, self.client.update_tenant,
+ self.assertRaises(lib_exc.NotFound, self.client.update_tenant,
str(uuid.uuid4().hex))
@test.attr(type=['negative', 'gate'])
@@ -121,7 +122,7 @@
tenant_name = data_utils.rand_name(name='tenant-')
tenant = self.client.create_tenant(tenant_name)
self.data.tenants.append(tenant)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.update_tenant, tenant['id'])
@test.attr(type=['negative', 'gate'])
@@ -132,6 +133,6 @@
self.data.tenants.append(tenant)
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.update_tenant,
+ self.assertRaises(lib_exc.Unauthorized, self.client.update_tenant,
tenant['id'])
self.client.auth_provider.clear_auth()
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index c039da6..33a2f35 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import uuid
from tempest.api.identity import base
@@ -35,7 +36,7 @@
def test_create_user_by_unauthorized_user(self):
# Non-administrator should not be authorized to create a user
self.data.setup_test_tenant()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.create_user, self.alt_user,
self.alt_password, self.data.tenant['id'],
self.alt_email)
@@ -60,14 +61,14 @@
def test_create_user_with_duplicate_name(self):
# Duplicate user should not be created
self.data.setup_test_user()
- self.assertRaises(exceptions.Conflict, self.client.create_user,
+ self.assertRaises(lib_exc.Conflict, self.client.create_user,
self.data.test_user, self.data.test_password,
self.data.tenant['id'], self.data.test_email)
@test.attr(type=['negative', 'gate'])
def test_create_user_for_non_existent_tenant(self):
# Attempt to create a user in a non-existent tenant should fail
- self.assertRaises(exceptions.NotFound, self.client.create_user,
+ self.assertRaises(lib_exc.NotFound, self.client.create_user,
self.alt_user, self.alt_password, '49ffgg99999',
self.alt_email)
@@ -79,7 +80,7 @@
token = self.client.auth_provider.get_token()
# Delete the token from database
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.create_user,
+ self.assertRaises(lib_exc.Unauthorized, self.client.create_user,
self.alt_user, self.alt_password,
self.data.tenant['id'], self.alt_email)
@@ -101,7 +102,7 @@
# Attempt to update a user non-existent user should fail
user_name = data_utils.rand_name('user-')
non_existent_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.update_user,
+ self.assertRaises(lib_exc.NotFound, self.client.update_user,
non_existent_id, name=user_name)
@test.attr(type=['negative', 'gate'])
@@ -112,7 +113,7 @@
token = self.client.auth_provider.get_token()
# Delete the token from database
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.update_user,
+ self.assertRaises(lib_exc.Unauthorized, self.client.update_user,
self.alt_user)
# Unset the token to allow further tests to generate a new token
@@ -122,21 +123,21 @@
def test_update_user_by_unauthorized_user(self):
# Non-administrator should not be authorized to update user
self.data.setup_test_tenant()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.update_user, self.alt_user)
@test.attr(type=['negative', 'gate'])
def test_delete_users_by_unauthorized_user(self):
# Non-administrator user should not be authorized to delete a user
self.data.setup_test_user()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.delete_user,
self.data.user['id'])
@test.attr(type=['negative', 'gate'])
def test_delete_non_existent_user(self):
# Attempt to delete a non-existent user should fail
- self.assertRaises(exceptions.NotFound, self.client.delete_user,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_user,
'junk12345123')
@test.attr(type=['negative', 'gate'])
@@ -147,7 +148,7 @@
token = self.client.auth_provider.get_token()
# Delete the token from database
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.delete_user,
+ self.assertRaises(lib_exc.Unauthorized, self.client.delete_user,
self.alt_user)
# Unset the token to allow further tests to generate a new token
@@ -158,7 +159,7 @@
# Disabled user's token should not get authenticated
self.data.setup_test_user()
self.disable_user(self.data.test_user)
- self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
+ self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
self.data.test_user,
self.data.test_password,
self.data.test_tenant)
@@ -168,7 +169,7 @@
# User's token for a disabled tenant should not be authenticated
self.data.setup_test_user()
self.disable_tenant(self.data.test_tenant)
- self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
+ self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
self.data.test_user,
self.data.test_password,
self.data.test_tenant)
@@ -177,7 +178,7 @@
def test_authentication_with_invalid_tenant(self):
# User's token for an invalid tenant should not be authenticated
self.data.setup_test_user()
- self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
+ self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
self.data.test_user,
self.data.test_password,
'junktenant1234')
@@ -186,7 +187,7 @@
def test_authentication_with_invalid_username(self):
# Non-existent user's token should not get authenticated
self.data.setup_test_user()
- self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
+ self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
'junkuser123', self.data.test_password,
self.data.test_tenant)
@@ -194,7 +195,7 @@
def test_authentication_with_invalid_password(self):
# User's token with invalid password should not be authenticated
self.data.setup_test_user()
- self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
+ self.assertRaises(lib_exc.Unauthorized, self.token_client.auth,
self.data.test_user, 'junkpass1234',
self.data.test_tenant)
@@ -202,7 +203,7 @@
def test_get_users_by_unauthorized_user(self):
# Non-administrator user should not be authorized to get user list
self.data.setup_test_user()
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.get_users)
@test.attr(type=['negative', 'gate'])
@@ -210,7 +211,7 @@
# Request to get list of users without a valid token should fail
token = self.client.auth_provider.get_token()
self.client.delete_token(token)
- self.assertRaises(exceptions.Unauthorized, self.client.get_users)
+ self.assertRaises(lib_exc.Unauthorized, self.client.get_users)
self.client.auth_provider.clear_auth()
@test.attr(type=['negative', 'gate'])
@@ -225,5 +226,5 @@
invalid_id.append('!@#()$%^&*?<>{}[]')
# List the users with invalid tenant id
for invalid in invalid_id:
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_users_for_tenant, invalid)
diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
index f5e832b..23a16d1 100644
--- a/tempest/api/identity/admin/v3/test_projects_negative.py
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -25,7 +27,7 @@
@test.attr(type=['negative', 'gate'])
def test_list_projects_by_unauthorized_user(self):
# Non-admin user should not be able to list projects
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.non_admin_client.list_projects)
@test.attr(type=['negative', 'gate'])
@@ -36,14 +38,14 @@
self.data.projects.append(project)
self.assertRaises(
- exceptions.Conflict, self.client.create_project, project_name)
+ lib_exc.Conflict, self.client.create_project, project_name)
@test.attr(type=['negative', 'gate'])
def test_create_project_by_unauthorized_user(self):
# Non-admin user should not be authorized to create a project
project_name = data_utils.rand_name('project-')
self.assertRaises(
- exceptions.Unauthorized, self.non_admin_client.create_project,
+ lib_exc.Unauthorized, self.non_admin_client.create_project,
project_name)
@test.attr(type=['negative', 'gate'])
@@ -66,11 +68,11 @@
project = self.client.create_project(project_name)
self.data.projects.append(project)
self.assertRaises(
- exceptions.Unauthorized, self.non_admin_client.delete_project,
+ lib_exc.Unauthorized, self.non_admin_client.delete_project,
project['id'])
@test.attr(type=['negative', 'gate'])
def test_delete_non_existent_project(self):
# Attempt to delete a non existent project should fail
- self.assertRaises(exceptions.NotFound, self.client.delete_project,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_project,
data_utils.rand_uuid_hex())
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index c71cbf3..2ca3538 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -40,7 +41,7 @@
def _delete_region(self, region_id):
self.client.delete_region(region_id)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_region, region_id)
@test.attr(type='gate')
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 9e45b50..c060094 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -26,7 +27,7 @@
# Used for deleting the services created in this class
self.service_client.delete_service(service_id)
# Checking whether service is deleted successfully
- self.assertRaises(exceptions.NotFound, self.service_client.get_service,
+ self.assertRaises(lib_exc.NotFound, self.service_client.get_service,
service_id)
@test.attr(type='smoke')
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index f0acfdf..de142e0 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -44,7 +45,7 @@
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
self.client.delete_token(subject_token)
- self.assertRaises(exceptions.NotFound, self.client.get_token,
+ self.assertRaises(lib_exc.NotFound, self.client.get_token,
subject_token)
@test.attr(type='gate')
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index cd28e96..be527d0 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -13,9 +13,11 @@
import datetime
import re
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.identity import base
-from tempest import auth
from tempest import clients
+from tempest.common import cred_provider
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -87,7 +89,7 @@
self.assertIsNotNone(self.trustee_user_id)
# Initialize a new client with the trustor credentials
- creds = auth.get_credentials(
+ creds = cred_provider.get_credentials(
username=self.trustor_username,
password=self.trustor_password,
tenant_name=self.trustor_project_name)
@@ -166,19 +168,19 @@
self.trust_id, self.delegated_role_id)
# And that we don't find not_delegated_role
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.trustor_client.get_trust_role,
self.trust_id,
self.not_delegated_role_id)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.trustor_client.check_trust_role,
self.trust_id,
self.not_delegated_role_id)
def delete_trust(self):
self.trustor_client.delete_trust(self.trust_id)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.trustor_client.get_trust,
self.trust_id)
self.trust_id = None
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 08bfd4f..e428071 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
-from tempest import auth
from tempest import clients
+from tempest.common import cred_provider
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -149,11 +149,11 @@
@property
def test_credentials(self):
- return auth.get_credentials(username=self.test_user,
- user_id=self.user['id'],
- password=self.test_password,
- tenant_name=self.test_tenant,
- tenant_id=self.tenant['id'])
+ return cred_provider.get_credentials(username=self.test_user,
+ user_id=self.user['id'],
+ password=self.test_password,
+ tenant_name=self.test_tenant,
+ tenant_id=self.tenant['id'])
def setup_test_user(self):
"""Set up a test user."""
@@ -226,7 +226,7 @@
func(item['id'], **kwargs)
else:
func(item['id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
except Exception:
LOG.exception("Unexpected exception occurred in %s deletion."
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 12f3fdd..4d33d37 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -13,12 +13,12 @@
# under the License.
import cStringIO as StringIO
+from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common import credentials
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -48,7 +48,7 @@
for image_id in cls.created_images:
try:
cls.client.delete_image(image_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
for image_id in cls.created_images:
diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py
index aac63b4..1622791 100644
--- a/tempest/api/image/v1/test_image_members_negative.py
+++ b/tempest/api/image/v1/test_image_members_negative.py
@@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -25,14 +25,14 @@
def test_add_member_with_non_existing_image(self):
# Add member with non existing image.
non_exist_image = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.add_member,
+ self.assertRaises(lib_exc.NotFound, self.client.add_member,
self.alt_tenant_id, non_exist_image)
@test.attr(type=['negative', 'gate'])
def test_delete_member_with_non_existing_image(self):
# Delete member with non existing image.
non_exist_image = data_utils.rand_uuid()
- self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_member,
self.alt_tenant_id, non_exist_image)
@test.attr(type=['negative', 'gate'])
@@ -40,13 +40,13 @@
# Delete member with non existing tenant.
image_id = self._create_image()
non_exist_tenant = data_utils.rand_uuid_hex()
- self.assertRaises(exceptions.NotFound, self.client.delete_member,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_member,
non_exist_tenant, image_id)
@test.attr(type=['negative', 'gate'])
def test_get_image_without_membership(self):
# Image is hidden from another tenants.
image_id = self._create_image()
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.alt_img_cli.get_image,
image_id)
diff --git a/tempest/api/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py
index 66556e0..b144a83 100644
--- a/tempest/api/image/v1/test_images_negative.py
+++ b/tempest/api/image/v1/test_images_negative.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.image import base
from tempest import exceptions
from tempest import test
@@ -35,7 +37,7 @@
@test.attr(type=['negative', 'gate'])
def test_delete_image_with_invalid_image_id(self):
# An image should not be deleted with invalid image id
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
'!@$%^&*()')
@test.attr(type=['negative', 'gate'])
@@ -43,28 +45,28 @@
# Return an error while trying to delete a non-existent image
non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
non_existent_image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_image_blank_id(self):
# Return an error while trying to delete an image with blank Id
- self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image, '')
@test.attr(type=['negative', 'gate'])
def test_delete_image_non_hex_string_id(self):
# Return an error while trying to delete an image with non hex id
image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_image_negative_image_id(self):
# Return an error while trying to delete an image with negative id
- self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image, -1)
@test.attr(type=['negative', 'gate'])
def test_delete_image_id_is_over_35_character_limit(self):
# Return an error while trying to delete image with id over limit
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
'11a22b9-12a9-5555-cc11-00ab112223fa-3fac')
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index 1f8e3d0..9965286 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.image import base
from tempest import exceptions
from tempest import test
@@ -35,7 +37,7 @@
self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.os_img_client.update_member_status,
image_id, self.alt_tenant_id, 'accepted')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index fc781b1..d32fc3b 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -16,6 +16,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.image import base
from tempest import exceptions
from tempest import test
@@ -39,14 +41,14 @@
def test_get_non_existent_image(self):
# get the non-existent image
non_existent_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.get_image,
+ self.assertRaises(lib_exc.NotFound, self.client.get_image,
non_existent_id)
@test.attr(type=['negative', 'gate'])
def test_get_image_null_id(self):
# get image with image_id = NULL
image_id = ""
- self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
+ self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
@test.attr(type=['negative', 'gate'])
def test_get_delete_deleted_image(self):
@@ -60,24 +62,24 @@
self.client.wait_for_resource_deletion(image_id)
# get the deleted image
- self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
+ self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
# delete the deleted image
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_non_existing_image(self):
# delete non-existent image
non_existent_image_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
non_existent_image_id)
@test.attr(type=['negative', 'gate'])
def test_delete_image_null_id(self):
# delete image with image_id=NULL
image_id = ""
- self.assertRaises(exceptions.NotFound, self.client.delete_image,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image,
image_id)
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py
index aa0a214..5b18862 100644
--- a/tempest/api/image/v2/test_images_tags_negative.py
+++ b/tempest/api/image/v2/test_images_tags_negative.py
@@ -14,9 +14,10 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.image import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -27,7 +28,7 @@
# Update tag with non existing image.
tag = data_utils.rand_name('tag-')
non_exist_image = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.add_image_tag,
+ self.assertRaises(lib_exc.NotFound, self.client.add_image_tag,
non_exist_image, tag)
@test.attr(type=['negative', 'gate'])
@@ -40,5 +41,5 @@
image_id = body['id']
tag = data_utils.rand_name('non-exist-tag-')
self.addCleanup(self.client.delete_image, image_id)
- self.assertRaises(exceptions.NotFound, self.client.delete_image_tag,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_image_tag,
image_id, tag)
diff --git a/tempest/api/messaging/test_queues.py b/tempest/api/messaging/test_queues.py
index accbd17..04ba8a3 100644
--- a/tempest/api/messaging/test_queues.py
+++ b/tempest/api/messaging/test_queues.py
@@ -16,11 +16,11 @@
import logging
from six import moves
+from tempest_lib import exceptions as lib_exc
from testtools import matchers
from tempest.api.messaging import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -42,7 +42,7 @@
self.assertEqual('', body)
self.delete_queue(queue_name)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_queue,
queue_name)
diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py
index 7dbb347..8eb6888 100644
--- a/tempest/api/network/admin/test_external_networks_negative.py
+++ b/tempest/api/network/admin/test_external_networks_negative.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -47,7 +48,7 @@
fixed_ips = [{'ip_address': floating_ip_address}]
# create a port which will internally create an instance-ip
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
client.create_port,
network_id=CONF.network.public_network_id,
fixed_ips=fixed_ips)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 10cda53..520bec7 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -14,6 +14,7 @@
# under the License.
import netaddr
+from tempest_lib import exceptions as lib_exc
from tempest import clients
from tempest.common.utils import data_utils
@@ -177,7 +178,7 @@
try:
delete_callable(*args, **kwargs)
# if resource is not found, this means it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@classmethod
@@ -399,7 +400,7 @@
try:
cls.client.remove_router_interface_with_subnet_id(
router['id'], i['fixed_ips'][0]['subnet_id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
cls.client.delete_router(router['id'])
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 1257699..f7a6fb7 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -16,6 +16,8 @@
import netaddr
import random
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
@@ -348,7 +350,7 @@
fixed_ips=[
{'subnet_id': subnet['id'],
'ip_address': ip}])
- self.assertRaisesRegexp(exceptions.Conflict,
+ self.assertRaisesRegexp(lib_exc.Conflict,
"object with that identifier already exists",
self.create_port,
self.network,
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index 82f0519..7e91ba2 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
@@ -49,7 +51,7 @@
@test.attr(type=['negative', 'smoke'])
def test_create_floatingip_with_port_ext_net_unreachable(self):
- self.assertRaises(exceptions.NotFound, self.client.create_floatingip,
+ self.assertRaises(lib_exc.NotFound, self.client.create_floatingip,
floating_network_id=self.ext_net_id,
port_id=self.port['id'],
fixed_ip_address=self.port['fixed_ips'][0]
@@ -72,7 +74,7 @@
floating_ip = body['floatingip']
self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
# Associate floating IP to the other port
- self.assertRaises(exceptions.NotFound, self.client.update_floatingip,
+ self.assertRaises(lib_exc.NotFound, self.client.update_floatingip,
floating_ip['id'], port_id=self.port['id'],
fixed_ip_address=self.port['fixed_ips'][0]
['ip_address'])
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 8104567..b0318c9 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
@@ -63,7 +65,7 @@
try:
self.client.delete_firewall_policy(policy_id)
# if policy is not found, this means it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
def _try_delete_rule(self, rule_id):
@@ -71,7 +73,7 @@
try:
self.client.delete_firewall_rule(rule_id)
# if rule is not found, this means it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
def _try_delete_firewall(self, fw_id):
@@ -79,7 +81,7 @@
try:
self.client.delete_firewall(fw_id)
# if firewall is not found, this means it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
self.client.wait_for_resource_deletion('firewall', fw_id)
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 65aeb24..a5f9667 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -15,12 +15,12 @@
import itertools
import netaddr
+from tempest_lib import exceptions as lib_exc
from tempest.api.network import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -280,7 +280,7 @@
try:
self.client.delete_network(net_id)
# if network is not found, this means it was deleted in the test
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@test.attr(type='smoke')
@@ -300,7 +300,7 @@
body = self.client.delete_network(net_id)
# Verify that the subnet got automatically deleted.
- self.assertRaises(exceptions.NotFound, self.client.show_subnet,
+ self.assertRaises(lib_exc.NotFound, self.client.show_subnet,
subnet_id)
# Since create_subnet adds the subnet to the delete list, and it is
@@ -614,7 +614,7 @@
self.assertNotIn(subnet_slaac['id'], subnet_ids,
"Subnet wasn't deleted")
self.assertRaisesRegexp(
- exceptions.Conflict,
+ lib_exc.Conflict,
"There are one or more ports still in use on the network",
self.client.delete_network,
slaac_network['id'])
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index bc3ab68..b694728 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -14,9 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -26,29 +27,29 @@
@test.attr(type=['negative', 'smoke'])
def test_show_non_existent_network(self):
non_exist_id = data_utils.rand_name('network')
- self.assertRaises(exceptions.NotFound, self.client.show_network,
+ self.assertRaises(lib_exc.NotFound, self.client.show_network,
non_exist_id)
@test.attr(type=['negative', 'smoke'])
def test_show_non_existent_subnet(self):
non_exist_id = data_utils.rand_name('subnet')
- self.assertRaises(exceptions.NotFound, self.client.show_subnet,
+ self.assertRaises(lib_exc.NotFound, self.client.show_subnet,
non_exist_id)
@test.attr(type=['negative', 'smoke'])
def test_show_non_existent_port(self):
non_exist_id = data_utils.rand_name('port')
- self.assertRaises(exceptions.NotFound, self.client.show_port,
+ self.assertRaises(lib_exc.NotFound, self.client.show_port,
non_exist_id)
@test.attr(type=['negative', 'smoke'])
def test_update_non_existent_network(self):
non_exist_id = data_utils.rand_name('network')
- self.assertRaises(exceptions.NotFound, self.client.update_network,
+ self.assertRaises(lib_exc.NotFound, self.client.update_network,
non_exist_id, name="new_name")
@test.attr(type=['negative', 'smoke'])
def test_delete_non_existent_network(self):
non_exist_id = data_utils.rand_name('network')
- self.assertRaises(exceptions.NotFound, self.client.delete_network,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_network,
non_exist_id)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index d571e92..32dcf74 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -14,6 +14,7 @@
# under the License.
import netaddr
+from tempest_lib import exceptions as lib_exc
from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
@@ -42,7 +43,7 @@
@test.attr(type=['negative', 'smoke'])
def test_router_add_gateway_invalid_network_returns_404(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.update_router,
self.router['id'],
external_gateway_info={
@@ -79,26 +80,26 @@
def test_router_remove_interface_in_use_returns_409(self):
self.client.add_router_interface_with_subnet_id(
self.router['id'], self.subnet['id'])
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.delete_router,
self.router['id'])
@test.attr(type=['negative', 'smoke'])
def test_show_non_existent_router_returns_404(self):
router = data_utils.rand_name('non_exist_router')
- self.assertRaises(exceptions.NotFound, self.client.show_router,
+ self.assertRaises(lib_exc.NotFound, self.client.show_router,
router)
@test.attr(type=['negative', 'smoke'])
def test_update_non_existent_router_returns_404(self):
router = data_utils.rand_name('non_exist_router')
- self.assertRaises(exceptions.NotFound, self.client.update_router,
+ self.assertRaises(lib_exc.NotFound, self.client.update_router,
router, name="new_name")
@test.attr(type=['negative', 'smoke'])
def test_delete_non_existent_router_returns_404(self):
router = data_utils.rand_name('non_exist_router')
- self.assertRaises(exceptions.NotFound, self.client.delete_router,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_router,
router)
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index fb51e30..0398c66 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base_security_groups as base
from tempest import config
from tempest import exceptions
@@ -37,20 +39,20 @@
@test.attr(type=['negative', 'gate'])
def test_show_non_existent_security_group(self):
non_exist_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.show_security_group,
+ self.assertRaises(lib_exc.NotFound, self.client.show_security_group,
non_exist_id)
@test.attr(type=['negative', 'gate'])
def test_show_non_existent_security_group_rule(self):
non_exist_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.show_security_group_rule,
non_exist_id)
@test.attr(type=['negative', 'gate'])
def test_delete_non_existent_security_group(self):
non_exist_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_security_group,
non_exist_id
)
@@ -88,7 +90,7 @@
group_ids = ['bad_group_id', non_exist_id]
for remote_group_id in group_ids:
self.assertRaises(
- exceptions.NotFound, self.client.create_security_group_rule,
+ lib_exc.NotFound, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol='tcp', direction='ingress', ethertype=self.ethertype,
remote_group_id=remote_group_id)
@@ -152,7 +154,7 @@
def test_create_additional_default_security_group_fails(self):
# Create security group named 'default', it should be failed.
name = 'default'
- self.assertRaises(exceptions.Conflict,
+ self.assertRaises(lib_exc.Conflict,
self.client.create_security_group,
name=name)
@@ -175,7 +177,7 @@
# Try creating the same security group rule, it should fail
self.assertRaises(
- exceptions.Conflict, self.client.create_security_group_rule,
+ lib_exc.Conflict, self.client.create_security_group_rule,
security_group_id=body['security_group']['id'],
protocol='tcp', direction='ingress', ethertype=self.ethertype,
port_range_min=min_port, port_range_max=max_port)
@@ -184,7 +186,7 @@
def test_create_security_group_rule_with_non_existent_security_group(self):
# Create security group rules with not existing security group.
non_existent_sg = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.create_security_group_rule,
security_group_id=non_existent_sg,
direction='ingress', ethertype=self.ethertype)
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 56e1a05..9ff406c 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -74,7 +75,7 @@
try:
self.client.delete_ipsecpolicy(ipsec_policy_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
def _assertExpected(self, expected, actual):
@@ -304,7 +305,7 @@
self._assertExpected(new_ipsec, updated_ipsec_policy)
# Verification of ipsec policy delete
self.client.delete_ipsecpolicy(ipsecpolicy['id'])
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.delete_ipsecpolicy, ipsecpolicy['id'])
@test.attr(type='smoke')
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index 36c9f5a..79a1960 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
from tempest.api.identity import base
from tempest import clients
from tempest.common import credentials
from tempest.common import custom_matchers
from tempest import config
-from tempest import exceptions
import tempest.test
CONF = config.CONF
@@ -93,10 +93,10 @@
for obj in objlist:
try:
object_client.delete_object(cont, obj['name'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
container_client.delete_container(cont)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
def assertHeaders(self, resp, target, method):
@@ -126,7 +126,7 @@
return next(r['id'] for r in roles if r['name'] == role_name)
except StopIteration:
msg = "Role name '%s' is not found" % role_name
- raise exceptions.NotFound(msg)
+ raise lib_exc.NotFound(msg)
def _assign_role(self, role_id):
self.client.assign_user_role(self.tenant['id'],
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index 5a0be54..0e136bf 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -15,12 +15,12 @@
# under the License.
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -85,12 +85,12 @@
"""
# Not able to remove quota
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.account_client.create_account_metadata,
{"Quota-Bytes": ""})
# Not able to modify quota
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.account_client.create_account_metadata,
{"Quota-Bytes": "100"})
@@ -100,6 +100,6 @@
def test_upload_large_object(self):
object_name = data_utils.rand_name(name="TestObject")
data = data_utils.arbitrary_string(30)
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.object_client.create_object,
self.container_name, object_name, data)
diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py
index ef04387..9acf668 100644
--- a/tempest/api/object_storage/test_account_services_negative.py
+++ b/tempest/api/object_storage/test_account_services_negative.py
@@ -14,9 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest import clients
-from tempest import exceptions
from tempest import test
@@ -44,6 +45,6 @@
params = {'format': 'json'}
# list containers with non-authorized user token
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.account_client.list_account_containers,
params=params)
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index 138d25a..7fe472c 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -14,10 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -47,7 +48,7 @@
request_part='headers',
auth_data=None
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.create_object,
self.container_name, object_name, 'data', headers={})
@@ -63,7 +64,7 @@
request_part='headers',
auth_data=None
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.delete_object,
self.container_name, object_name)
@@ -77,7 +78,7 @@
request_part='headers',
auth_data=self.test_auth_data
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.create_object,
self.container_name, object_name, 'data', headers={})
@@ -94,7 +95,7 @@
request_part='headers',
auth_data=self.test_auth_data
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.get_object,
self.container_name, object_name)
@@ -111,7 +112,7 @@
request_part='headers',
auth_data=self.test_auth_data
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.delete_object,
self.container_name, object_name)
@@ -134,7 +135,7 @@
request_part='headers',
auth_data=self.test_auth_data
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.get_object,
self.container_name, object_name)
@@ -153,7 +154,7 @@
auth_data=self.test_auth_data
)
object_name = data_utils.rand_name(name='Object')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.create_object,
self.container_name,
object_name, 'data', headers={})
@@ -175,7 +176,7 @@
auth_data=self.test_auth_data
)
object_name = data_utils.rand_name(name='Object')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.create_object,
self.container_name,
object_name, 'data', headers={})
@@ -201,7 +202,7 @@
request_part='headers',
auth_data=self.test_auth_data
)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.delete_object,
self.container_name,
object_name)
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index 46944ed..12ec6d2 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -75,7 +76,7 @@
nbefore = self._get_bytes_used()
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.object_client.create_object,
self.container_name, object_name, data)
@@ -93,7 +94,7 @@
nbefore = self._get_object_count()
self.assertEqual(nbefore, QUOTA_COUNT)
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.object_client.create_object,
self.container_name, "OverQuotaObject", "")
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index a8e5f9a..8a61911 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -14,10 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -161,5 +162,5 @@
# Request non-existing object
self.assertRaises(
- exceptions.NotFound, self.object_client.get_object,
+ lib_exc.NotFound, self.object_client.get_object,
self.container_name, "notexisting")
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index 5fa209d..be5d50e 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
import time
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -66,7 +66,7 @@
time.sleep(sleepy_time + 3)
# object should not be there anymore
- self.assertRaises(exceptions.NotFound, self.object_client.get_object,
+ self.assertRaises(lib_exc.NotFound, self.object_client.get_object,
self.container_name, self.object_name)
@test.attr(type='gate')
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index 32f5917..cdd9d2c 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -18,9 +18,10 @@
import time
import urlparse
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -117,7 +118,7 @@
url = "%s/%s" % (self.container_name, self.object_name)
exc = self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.object_client.post,
url, body, headers=headers)
self.assertIn('FormPost: Form Expired', str(exc))
@@ -133,7 +134,7 @@
url = "%s/%s" % (self.container_name, self.object_name)
exc = self.assertRaises(
- exceptions.Unauthorized,
+ lib_exc.Unauthorized,
self.object_client.post,
url, body, headers=headers)
self.assertIn('FormPost: Invalid Signature', str(exc))
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index 6622349..7b85201 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -15,10 +15,11 @@
import hashlib
import json
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
# Each segment, except for the final one, must be at least 1 megabyte
@@ -39,7 +40,7 @@
self.object_client.delete_object(
self.container_name,
obj)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
self.container_client.delete_container(self.container_name)
super(ObjectSloTest, self).tearDown()
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
index b752348..ca34293 100644
--- a/tempest/api/object_storage/test_object_temp_url_negative.py
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -19,9 +19,10 @@
import time
import urlparse
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -104,5 +105,5 @@
# temp URL is valid for 1 seconds, let's wait 2
time.sleep(2)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.object_client.get, url)
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 97777db..2a99630 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -12,12 +12,12 @@
import os.path
+from tempest_lib import exceptions as lib_exc
import yaml
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -84,14 +84,14 @@
for stack_identifier in cls.stacks:
try:
cls.client.delete_stack(stack_identifier)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
for stack_identifier in cls.stacks:
try:
cls.client.wait_for_stack_status(
stack_identifier, 'DELETE_COMPLETE')
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@classmethod
@@ -125,7 +125,7 @@
for image_id in cls.images:
try:
cls.images_v2_client.delete_image(image_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@classmethod
diff --git a/tempest/api/orchestration/stacks/test_soft_conf.py b/tempest/api/orchestration/stacks/test_soft_conf.py
index 8903d4c..220054e 100644
--- a/tempest/api/orchestration/stacks/test_soft_conf.py
+++ b/tempest/api/orchestration/stacks/test_soft_conf.py
@@ -10,10 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest import test
@@ -70,14 +71,14 @@
self.client.delete_software_deploy(deploy_id)
# Testing that it is really gone
self.assertRaises(
- exceptions.NotFound, self.client.get_software_deploy,
+ lib_exc.NotFound, self.client.get_software_deploy,
self.deployment_id)
def _config_delete(self, config_id):
self.client.delete_software_config(config_id)
# Testing that it is really gone
self.assertRaises(
- exceptions.NotFound, self.client.get_software_config, config_id)
+ lib_exc.NotFound, self.client.get_software_config, config_id)
@test.attr(type='smoke')
def test_get_software_config(self):
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index 6fddb21..322bdf1 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -12,10 +12,11 @@
import logging
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
@@ -73,7 +74,7 @@
# Delete the stack and ensure the volume is gone
self.client.delete_stack(stack_identifier)
self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.volumes_client.get_volume,
volume_id)
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 8885187..dc7a8f5 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -12,6 +12,8 @@
import time
+from tempest_lib import exceptions as lib_exc
+
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -80,7 +82,7 @@
for resource_id in list_of_ids:
try:
method(resource_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@classmethod
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index 97eb4eb..2457438 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -10,9 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.telemetry import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -70,7 +71,7 @@
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Delete alarm and verify if deleted
self.telemetry_client.delete_alarm(alarm_id)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.telemetry_client.get_alarm, alarm_id)
@test.attr(type="gate")
@@ -101,5 +102,5 @@
self.assertDictContainsSubset(rule, body['combination_rule'])
# Verify alarm delete
self.telemetry_client.delete_alarm(alarm_id)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.telemetry_client.get_alarm, alarm_id)
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index 5cf6af0..d5eb05a 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.py
@@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
-from tempest import exceptions
from tempest import test
@@ -42,13 +43,13 @@
@test.attr(type='negative')
def test_quota_volumes(self):
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.volumes_client.create_volume,
size=1)
@test.attr(type='negative')
def test_quota_volume_snapshots(self):
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.snapshots_client.create_snapshot,
self.volume['id'])
@@ -65,7 +66,7 @@
self.quotas_client.update_quota_set(
self.demo_tenant_id,
**new_quota_set)
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.volumes_client.create_volume,
size=1)
@@ -73,7 +74,7 @@
self.quotas_client.update_quota_set(
self.demo_tenant_id,
**self.shared_quota_set)
- self.assertRaises(exceptions.OverLimit,
+ self.assertRaises(lib_exc.OverLimit,
self.snapshots_client.create_snapshot,
self.volume['id'])
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 fff0199..2e2cfd2 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
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -83,7 +85,7 @@
# type id.
extra_specs = {"spec2": "val1"}
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.volume_types_client.create_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs)
@@ -109,7 +111,7 @@
# type id.
extra_specs = {"spec1": "val1"}
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.volume_types_client.delete_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs.keys()[0])
@@ -117,7 +119,7 @@
def test_list_nonexistent_volume_type_id(self):
# Should not list volume type extra spec for nonexistent type id.
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.volume_types_client.list_volume_types_extra_specs,
str(uuid.uuid4()))
@@ -126,7 +128,7 @@
# Should not get volume type extra spec for nonexistent type id.
extra_specs = {"spec1": "val1"}
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.volume_types_client.get_volume_type_extra_specs,
str(uuid.uuid4()), extra_specs.keys()[0])
@@ -135,7 +137,7 @@
# Should not get volume type extra spec for nonexistent extra spec
# id.
self.assertRaises(
- exceptions.NotFound,
+ lib_exc.NotFound,
self.volume_types_client.get_volume_type_extra_specs,
self.volume_type['id'], str(uuid.uuid4()))
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 4144270..18d54fa 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
from tempest import exceptions
from tempest import test
@@ -29,7 +31,7 @@
self.name_field = self.special_fields['name_field']
params = {self.name_field: str(uuid.uuid4()),
'volume_type': str(uuid.uuid4())}
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.volumes_client.create_volume, size=1,
**params)
@@ -42,14 +44,14 @@
@test.attr(type='gate')
def test_get_nonexistent_type_id(self):
# Should not be able to get volume type with nonexistent type id.
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.volume_types_client.get_volume_type,
str(uuid.uuid4()))
@test.attr(type='gate')
def test_delete_nonexistent_type_id(self):
# Should not be able to delete volume type with nonexistent type id.
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.volume_types_client.delete_volume_type,
str(uuid.uuid4()))
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 127a216..a1858de 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import exceptions as lib_exc
+
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
@@ -208,13 +210,13 @@
for qos_id in cls.qos_specs:
try:
cls.volume_qos_client.delete_qos(qos_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# The qos_specs may have already been deleted which is OK.
pass
for qos_id in cls.qos_specs:
try:
cls.volume_qos_client.wait_for_resource_deletion(qos_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# The qos_specs may have already been deleted which is OK.
pass
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 6d9c438..2a49210 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -37,15 +37,6 @@
self.client.delete_volume(volume_id)
self.client.wait_for_resource_deletion(volume_id)
- def _is_true(self, val):
- # NOTE(jdg): Temporary conversion method to get cinder patch
- # merged. Then we'll make this strict again and
- # specifically check "true" or "false"
- if val in ['true', 'True', True]:
- return True
- else:
- return False
-
def _volume_create_get_update_delete(self, **kwargs):
# Create a volume, Get it's details and Delete the volume
volume = {}
@@ -79,13 +70,10 @@
'The fetched Volume metadata misses data '
'from the created Volume')
- # NOTE(jdg): Revert back to strict true/false checking
- # after fix for bug #1227837 merges
- boot_flag = self._is_true(fetched_volume['bootable'])
if 'imageRef' in kwargs:
- self.assertEqual(boot_flag, True)
+ self.assertEqual('true', fetched_volume['bootable'])
if 'imageRef' not in kwargs:
- self.assertEqual(boot_flag, False)
+ self.assertEqual('false', fetched_volume['bootable'])
# Update Volume
# Test volume update when display_name is same with original value
@@ -125,13 +113,10 @@
self.descrip_field: volume[self.descrip_field]}
self.client.update_volume(new_volume['id'], **params)
- # NOTE(jdg): Revert back to strict true/false checking
- # after fix for bug #1227837 merges
- boot_flag = self._is_true(updated_volume['bootable'])
if 'imageRef' in kwargs:
- self.assertEqual(boot_flag, True)
+ self.assertEqual('true', updated_volume['bootable'])
if 'imageRef' not in kwargs:
- self.assertEqual(boot_flag, False)
+ self.assertEqual('false', updated_volume['bootable'])
@test.attr(type='smoke')
def test_volume_create_get_update_delete(self):
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index dc8d8e2..57fcaee 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -15,6 +15,8 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import exceptions
@@ -37,13 +39,13 @@
@test.attr(type=['negative', 'gate'])
def test_volume_get_nonexistent_volume_id(self):
# Should not be able to get a non-existent volume
- self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@test.attr(type=['negative', 'gate'])
def test_volume_delete_nonexistent_volume_id(self):
# Should not be able to delete a non-existent Volume
- self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
@test.attr(type=['negative', 'gate'])
@@ -85,7 +87,7 @@
# Should not be able to create volume with non-existent volume type
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.create_volume,
size='1', volume_type=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
@@ -94,7 +96,7 @@
# Should not be able to create volume with non-existent snapshot
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.create_volume,
size='1', snapshot_id=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
@@ -103,7 +105,7 @@
# Should not be able to create volume with non-existent source volume
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.create_volume,
size='1', source_volid=str(uuid.uuid4()),
display_name=v_name, metadata=metadata)
@@ -111,7 +113,7 @@
def test_update_volume_with_nonexistent_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.update_volume,
volume_id=str(uuid.uuid4()), display_name=v_name,
metadata=metadata)
@@ -119,7 +121,7 @@
def test_update_volume_with_invalid_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.update_volume,
volume_id='#$%%&^&^', display_name=v_name,
metadata=metadata)
@@ -127,31 +129,31 @@
def test_update_volume_with_empty_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.update_volume,
volume_id='', display_name=v_name,
metadata=metadata)
@test.attr(type=['negative', 'gate'])
def test_get_invalid_volume_id(self):
# Should not be able to get volume with invalid id
- self.assertRaises(exceptions.NotFound, self.client.get_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.get_volume,
'#$%%&^&^')
@test.attr(type=['negative', 'gate'])
def test_get_volume_without_passing_volume_id(self):
# Should not be able to get volume when empty ID is passed
- self.assertRaises(exceptions.NotFound, self.client.get_volume, '')
+ self.assertRaises(lib_exc.NotFound, self.client.get_volume, '')
@test.attr(type=['negative', 'gate'])
def test_delete_invalid_volume_id(self):
# Should not be able to delete volume when invalid ID is passed
- self.assertRaises(exceptions.NotFound, self.client.delete_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
'!@#$%^&*()')
@test.attr(type=['negative', 'gate'])
def test_delete_volume_without_passing_volume_id(self):
# Should not be able to delete volume when empty ID is passed
- self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
+ self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')
@test.attr(type=['negative', 'gate'])
@test.services('compute')
@@ -162,7 +164,7 @@
self.flavor_ref)
self.addCleanup(self.servers_client.delete_server, server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.attach_volume,
str(uuid.uuid4()),
server['id'],
@@ -170,7 +172,7 @@
@test.attr(type=['negative', 'gate'])
def test_detach_volumes_with_invalid_volume_id(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.detach_volume,
'xxx')
@@ -199,25 +201,25 @@
def test_volume_extend_with_nonexistent_volume_id(self):
# Extend volume size when volume is nonexistent.
extend_size = int(self.volume['size']) + 1
- self.assertRaises(exceptions.NotFound, self.client.extend_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
str(uuid.uuid4()), extend_size)
@test.attr(type=['negative', 'gate'])
def test_volume_extend_without_passing_volume_id(self):
# Extend volume size when passing volume id is None.
extend_size = int(self.volume['size']) + 1
- self.assertRaises(exceptions.NotFound, self.client.extend_volume,
+ self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
None, extend_size)
@test.attr(type=['negative', 'gate'])
def test_reserve_volume_with_nonexistent_volume_id(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.reserve_volume,
str(uuid.uuid4()))
@test.attr(type=['negative', 'gate'])
def test_unreserve_volume_with_nonexistent_volume_id(self):
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.unreserve_volume,
str(uuid.uuid4()))
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 179eb09..d667dfd 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -70,7 +70,7 @@
self.addCleanup(self.servers_client.delete_server, server['id'])
self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
mountpoint = '/dev/%s' % CONF.compute.volume_device_name
- _, body = self.servers_client.attach_volume(
+ self.servers_client.attach_volume(
server['id'], self.volume_origin['id'], mountpoint)
self.volumes_client.wait_for_volume_status(self.volume_origin['id'],
'in-use')
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 2d7b6de..8b68ea9 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -12,10 +12,11 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -34,7 +35,7 @@
def test_create_snapshot_with_nonexistent_volume_id(self):
# Create a snapshot with nonexistent volume id
s_name = data_utils.rand_name('snap')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.snapshots_client.create_snapshot,
str(uuid.uuid4()), display_name=s_name)
@@ -42,7 +43,7 @@
def test_create_snapshot_without_passing_volume_id(self):
# Create a snapshot without passing volume id
s_name = data_utils.rand_name('snap')
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.snapshots_client.create_snapshot,
None, display_name=s_name)
diff --git a/tempest/auth.py b/tempest/auth.py
index 6a92b5f..9645a2e 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -44,7 +44,6 @@
:param interface: 'json' or 'xml'. Applicable for tempest client only
(deprecated: only json now supported)
"""
- credentials = self._convert_credentials(credentials)
if self.check_credentials(credentials):
self.credentials = credentials
else:
@@ -54,13 +53,6 @@
self.alt_auth_data = None
self.alt_part = None
- def _convert_credentials(self, credentials):
- # Support dict credentials for backwards compatibility
- if isinstance(credentials, dict):
- return get_credentials(**credentials)
- else:
- return credentials
-
def __str__(self):
return "Creds :{creds}, interface: {interface}, " \
"cached auth data: {cache}".format(
@@ -440,44 +432,38 @@
datetime.datetime.utcnow()
-def get_default_credentials(credential_type, fill_in=True):
- """
- Returns configured credentials of the specified type
- based on the configured auth_version
- """
- return get_credentials(fill_in=fill_in, credential_type=credential_type)
+def is_identity_version_supported(identity_version):
+ return identity_version in IDENTITY_VERSION
-def get_credentials(credential_type=None, fill_in=True, **kwargs):
+def get_credentials(fill_in=True, identity_version='v2', **kwargs):
"""
Builds a credentials object based on the configured auth_version
- :param credential_type (string): requests credentials from tempest
- configuration file. Valid values are defined in
- Credentials.TYPE.
- :param kwargs (dict): take into account only if credential_type is
- not specified or None. Dict of credential key/value pairs
+ :param fill_in (boolean): obtain a token and fill in all credential
+ details provided by the identity service. When fill_in is not
+ specified, credentials are not validated. Validation can be invoked
+ by invoking ``is_valid()``
+ :param identity_version (string): identity API version is used to
+ select the matching auth provider and credentials class
+ :param kwargs (dict): Dict of credential key/value pairs
Examples:
Returns credentials from the provided parameters:
>>> get_credentials(username='foo', password='bar')
- Returns credentials from tempest configuration:
- >>> get_credentials(credential_type='user')
+ Returns credentials including IDs:
+ >>> get_credentials(username='foo', password='bar', fill_in=True)
"""
- if CONF.identity.auth_version == 'v2':
- credential_class = KeystoneV2Credentials
- auth_provider_class = KeystoneV2AuthProvider
- elif CONF.identity.auth_version == 'v3':
- credential_class = KeystoneV3Credentials
- auth_provider_class = KeystoneV3AuthProvider
- else:
- raise exceptions.InvalidConfiguration('Unsupported auth version')
- if credential_type is not None:
- creds = credential_class.get_default(credential_type)
- else:
- creds = credential_class(**kwargs)
+ if not is_identity_version_supported(identity_version):
+ raise exceptions.InvalidIdentityVersion(
+ identity_version=identity_version)
+
+ credential_class, auth_provider_class = IDENTITY_VERSION.get(
+ identity_version)
+
+ creds = credential_class(**kwargs)
# Fill in the credentials fields that were not specified
if fill_in:
auth_provider = auth_provider_class(creds)
@@ -490,18 +476,9 @@
Set of credentials for accessing OpenStack services
ATTRIBUTES: list of valid class attributes representing credentials.
-
- TYPES: types of credentials available in the configuration file.
- For each key there's a tuple (section, prefix) to match the
- configuration options.
"""
ATTRIBUTES = []
- TYPES = {
- 'identity_admin': ('identity', 'admin'),
- 'user': ('identity', None),
- 'alt_user': ('identity', 'alt')
- }
def __init__(self, **kwargs):
"""
@@ -554,21 +531,8 @@
except AttributeError:
return default
- @classmethod
- def get_default(cls, credentials_type):
- if credentials_type not in cls.TYPES:
- raise exceptions.InvalidCredentials()
- creds = cls._get_default(credentials_type)
- if not creds.is_valid():
- msg = ("The %s credentials are incorrectly set in the config file."
- " Double check that all required values are assigned" %
- credentials_type)
- raise exceptions.InvalidConfiguration(msg)
- return creds
-
- @classmethod
- def _get_default(cls, credentials_type):
- raise NotImplementedError
+ def get_init_attributes(self):
+ return self._initial.keys()
def is_valid(self):
raise NotImplementedError
@@ -584,21 +548,8 @@
class KeystoneV2Credentials(Credentials):
- CONF_ATTRIBUTES = ['username', 'password', 'tenant_name']
- ATTRIBUTES = ['user_id', 'tenant_id']
- ATTRIBUTES.extend(CONF_ATTRIBUTES)
-
- @classmethod
- def _get_default(cls, credentials_type='user'):
- params = {}
- section, prefix = cls.TYPES[credentials_type]
- for attr in cls.CONF_ATTRIBUTES:
- _section = getattr(CONF, section)
- if prefix is None:
- params[attr] = getattr(_section, attr)
- else:
- params[attr] = getattr(_section, prefix + "_" + attr)
- return cls(**params)
+ ATTRIBUTES = ['username', 'password', 'tenant_name', 'user_id',
+ 'tenant_id']
def is_valid(self):
"""
@@ -608,16 +559,15 @@
return None not in (self.username, self.password)
-class KeystoneV3Credentials(KeystoneV2Credentials):
+class KeystoneV3Credentials(Credentials):
"""
Credentials suitable for the Keystone Identity V3 API
"""
- CONF_ATTRIBUTES = ['domain_name', 'password', 'tenant_name', 'username']
- ATTRIBUTES = ['project_domain_id', 'project_domain_name', 'project_id',
+ ATTRIBUTES = ['domain_name', 'password', 'tenant_name', 'username',
+ 'project_domain_id', 'project_domain_name', 'project_id',
'project_name', 'tenant_id', 'tenant_name', 'user_domain_id',
'user_domain_name', 'user_id']
- ATTRIBUTES.extend(CONF_ATTRIBUTES)
def __init__(self, **kwargs):
"""
@@ -685,3 +635,7 @@
self.project_id is not None,
self.project_name is not None and valid_project_domain])
return all([self.password is not None, valid_user, valid_project])
+
+
+IDENTITY_VERSION = {'v2': (KeystoneV2Credentials, KeystoneV2AuthProvider),
+ 'v3': (KeystoneV3Credentials, KeystoneV3AuthProvider)}
diff --git a/tempest/clients.py b/tempest/clients.py
index 03928ba..cbc6571 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -15,7 +15,7 @@
import copy
-from tempest import auth
+from tempest.common import cred_provider
from tempest.common import negative_rest_client
from tempest import config
from tempest import manager
@@ -378,6 +378,7 @@
def __init__(self, interface='json', service=None):
super(AdminManager, self).__init__(
- credentials=auth.get_default_credentials('identity_admin'),
+ credentials=cred_provider.get_configured_credentials(
+ 'identity_admin'),
interface=interface,
service=service)
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index 28992b9..c52704a 100755
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -54,9 +54,9 @@
import json
import sys
-from tempest import auth
from tempest import clients
from tempest.cmd import cleanup_service
+from tempest.common import cred_provider
from tempest import config
from tempest.openstack.common import log as logging
@@ -159,7 +159,8 @@
kwargs = {"username": CONF.identity.admin_username,
"password": CONF.identity.admin_password,
"tenant_name": tenant['name']}
- mgr = clients.Manager(credentials=auth.get_credentials(**kwargs))
+ mgr = clients.Manager(credentials=cred_provider.get_credentials(
+ **kwargs))
kwargs = {'data': tenant_data,
'is_dry_run': is_dry_run,
'saved_state_json': None,
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 889b2dd..4af2108 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -110,6 +110,7 @@
import unittest
import netaddr
+from tempest_lib import exceptions as lib_exc
import yaml
import tempest.auth
@@ -297,7 +298,7 @@
USERS[user]['tenant_id'],
USERS[user]['id'],
role['id'])
- except exceptions.Conflict:
+ except lib_exc.Conflict:
# don't care if it's already assigned
pass
@@ -313,14 +314,14 @@
for u in users:
try:
tenant = admin.identity.get_tenant_by_name(u['tenant'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.error("Tenant: %s - not found" % u['tenant'])
continue
try:
admin.identity.get_user_by_username(tenant['id'], u['name'])
LOG.warn("User '%s' already exists in this environment"
% u['name'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
admin.identity.create_user(
u['name'], u['pass'], tenant['id'],
"%s@%s" % (u['name'], tenant['id']),
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index 66285e4..dd8d498 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -17,7 +17,6 @@
import yaml
-from tempest import auth
from tempest.common import cred_provider
from tempest import config
from tempest import exceptions
@@ -109,9 +108,9 @@
def get_hash(self, creds):
for _hash in self.hash_dict:
- # Comparing on the attributes that are expected in the YAML
+ # Comparing on the attributes that were read from the YAML
if all([getattr(creds, k) == self.hash_dict[_hash][k] for k in
- creds.CONF_ATTRIBUTES]):
+ creds.get_init_attributes()]):
return _hash
raise AttributeError('Invalid credentials %s' % creds)
@@ -123,7 +122,7 @@
if self.isolated_creds.get('primary'):
return self.isolated_creds.get('primary')
creds = self._get_creds()
- primary_credential = auth.get_credentials(**creds)
+ primary_credential = cred_provider.get_credentials(**creds)
self.isolated_creds['primary'] = primary_credential
return primary_credential
@@ -131,7 +130,7 @@
if self.isolated_creds.get('alt'):
return self.isolated_creds.get('alt')
creds = self._get_creds()
- alt_credential = auth.get_credentials(**creds)
+ alt_credential = cred_provider.get_credentials(**creds)
self.isolated_creds['alt'] = alt_credential
return alt_credential
@@ -189,9 +188,10 @@
return self.isolated_creds.get('primary')
if not self.use_default_creds:
creds = self.get_creds(0)
- primary_credential = auth.get_credentials(**creds)
+ primary_credential = cred_provider.get_credentials(**creds)
else:
- primary_credential = auth.get_default_credentials('user')
+ primary_credential = cred_provider.get_configured_credentials(
+ 'user')
self.isolated_creds['primary'] = primary_credential
return primary_credential
@@ -200,9 +200,10 @@
return self.isolated_creds.get('alt')
if not self.use_default_creds:
creds = self.get_creds(1)
- alt_credential = auth.get_credentials(**creds)
+ alt_credential = cred_provider.get_credentials(**creds)
else:
- alt_credential = auth.get_default_credentials('alt_user')
+ alt_credential = cred_provider.get_configured_credentials(
+ 'alt_user')
self.isolated_creds['alt'] = alt_credential
return alt_credential
@@ -210,4 +211,5 @@
self.isolated_creds = {}
def get_admin_creds(self):
- return auth.get_default_credentials("identity_admin", fill_in=False)
+ return cred_provider.get_configured_credentials(
+ "identity_admin", fill_in=False)
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index c5be0c0..b9ca3aa 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -16,12 +16,64 @@
import six
+from tempest import auth
from tempest import config
+from tempest import exceptions
from tempest.openstack.common import log as logging
CONF = config.CONF
LOG = logging.getLogger(__name__)
+# Type of credentials available from configuration
+CREDENTIAL_TYPES = {
+ 'identity_admin': ('identity', 'admin'),
+ 'user': ('identity', None),
+ 'alt_user': ('identity', 'alt')
+}
+
+
+# Read credentials from configuration, builds a Credentials object
+# based on the specified or configured version
+def get_configured_credentials(credential_type, fill_in=True,
+ identity_version=None):
+ identity_version = identity_version or CONF.identity.auth_version
+ if identity_version not in ('v2', 'v3'):
+ raise exceptions.InvalidConfiguration(
+ 'Unsupported auth version: %s' % identity_version)
+ if credential_type not in CREDENTIAL_TYPES:
+ raise exceptions.InvalidCredentials()
+ conf_attributes = ['username', 'password', 'tenant_name']
+ if identity_version == 'v3':
+ conf_attributes.append('domain_name')
+ # Read the parts of credentials from config
+ params = {}
+ section, prefix = CREDENTIAL_TYPES[credential_type]
+ for attr in conf_attributes:
+ _section = getattr(CONF, section)
+ if prefix is None:
+ params[attr] = getattr(_section, attr)
+ else:
+ params[attr] = getattr(_section, prefix + "_" + attr)
+ # Build and validate credentials. We are reading configured credentials,
+ # so validate them even if fill_in is False
+ credentials = get_credentials(fill_in=fill_in, **params)
+ if not fill_in:
+ if not credentials.is_valid():
+ msg = ("The %s credentials are incorrectly set in the config file."
+ " Double check that all required values are assigned" %
+ credential_type)
+ raise exceptions.InvalidConfiguration(msg)
+ return credentials
+
+
+# Wrapper around auth.get_credentials to use the configured identity version
+# is none is specified
+def get_credentials(fill_in=True, identity_version=None, **kwargs):
+ identity_version = identity_version or CONF.identity.auth_version
+ return auth.get_credentials(fill_in=fill_in,
+ identity_version=identity_version,
+ **kwargs)
+
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index a663931..3572a1d 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -13,8 +13,8 @@
# under the License.
import netaddr
+from tempest_lib import exceptions as lib_exc
-from tempest import auth
from tempest import clients
from tempest.common import cred_provider
from tempest.common.utils import data_utils
@@ -81,7 +81,7 @@
role = next(r for r in roles if r['name'] == role_name)
except StopIteration:
msg = 'No "%s" role found' % role_name
- raise exceptions.NotFound(msg)
+ raise lib_exc.NotFound(msg)
self.identity_admin_client.assign_user_role(tenant['id'], user['id'],
role['id'])
@@ -129,7 +129,7 @@
return self._get_credentials(user, tenant)
def _get_credentials(self, user, tenant):
- return auth.get_credentials(
+ return cred_provider.get_credentials(
username=user['name'], user_id=user['id'],
tenant_name=tenant['name'], tenant_id=tenant['id'],
password=self.password)
@@ -282,7 +282,7 @@
net_client = self.network_admin_client
try:
net_client.delete_router(router_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' %
router_name)
@@ -290,7 +290,7 @@
net_client = self.network_admin_client
try:
net_client.delete_subnet(subnet_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn('subnet with name: %s not found for delete' %
subnet_name)
@@ -298,7 +298,7 @@
net_client = self.network_admin_client
try:
net_client.delete_network(network_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn('network with name: %s not found for delete' %
network_name)
@@ -310,7 +310,7 @@
for secgroup in secgroups_to_delete:
try:
net_client.delete_security_group(secgroup['id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn('Security group %s, id %s not found for clean-up' %
(secgroup['name'], secgroup['id']))
@@ -326,7 +326,7 @@
try:
net_client.remove_router_interface_with_subnet_id(
router['id'], subnet['id'])
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' %
router['name'])
self._clear_isolated_router(router['id'], router['name'])
@@ -344,12 +344,12 @@
for creds in self.isolated_creds.itervalues():
try:
self._delete_user(creds.user_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn("user with name: %s not found for delete" %
creds.username)
try:
self._delete_tenant(creds.tenant_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
LOG.warn("tenant with name: %s not found for delete" %
creds.tenant_name)
diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py
index 69e25e2..9aeb243 100644
--- a/tempest/common/service_client.py
+++ b/tempest/common/service_client.py
@@ -59,22 +59,14 @@
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)
# TODO(oomichi): This is just a workaround for failing gate tests
# when separating Forbidden from Unauthorized in tempest-lib.
# We will need to remove this translation and replace negative tests
# with lib_exceptions.Forbidden in the future.
except lib_exceptions.Forbidden as ex:
- raise exceptions.Unauthorized(ex)
+ raise lib_exceptions.Unauthorized(ex)
class ResponseBody(dict):
diff --git a/tempest/config.py b/tempest/config.py
index c60434a..4588b20 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -455,7 +455,13 @@
cfg.ListOpt('dns_servers',
default=["8.8.8.8", "8.8.4.4"],
help="List of dns servers which should be used"
- " for subnet creation")
+ " for subnet creation"),
+ cfg.StrOpt('port_vnic_type',
+ choices=[None, 'normal', 'direct', 'macvtap'],
+ help="vnic_type to use when Launching instances"
+ " with pre-configured ports."
+ " Supported ports are:"
+ " ['normal','direct','macvtap']"),
]
network_feature_group = cfg.OptGroup(name='network-feature-enabled',
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 7ddeeff..09f7016 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -63,6 +63,10 @@
message = "Invalid service tag"
+class InvalidIdentityVersion(TempestException):
+ message = "Invalid version %(identity_version) of the identity service"
+
+
class TimeoutException(TempestException):
message = "Request timed out"
@@ -151,26 +155,10 @@
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 OverLimit(RestClientException):
- message = "Quota exceeded"
-
-
-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/manager.py b/tempest/manager.py
index 538b619..2b00e89 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -14,6 +14,7 @@
# under the License.
from tempest import auth
+from tempest.common import cred_provider
from tempest import config
from tempest import exceptions
@@ -39,7 +40,7 @@
"""
self.auth_version = CONF.identity.auth_version
if credentials is None:
- self.credentials = auth.get_default_credentials('user')
+ self.credentials = cred_provider.get_configured_credentials('user')
else:
self.credentials = credentials
# Check if passed or default credentials are valid
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index b1f5cce..7da7b12 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -19,9 +19,10 @@
import netaddr
import six
+from tempest_lib import exceptions as lib_exc
-from tempest import auth
from tempest import clients
+from tempest.common import cred_provider
from tempest.common import credentials
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
@@ -110,7 +111,7 @@
# Tempest clients return dicts, so there is no common delete
# method available. Using a callable instead
delete_thing(*args, **kwargs)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# If the resource is already missing, mission accomplished.
pass
@@ -417,7 +418,7 @@
def nova_volume_attach(self):
# TODO(andreaf) Device should be here CONF.compute.volume_device_name
volume = self.servers_client.attach_volume(
- self.server['id'], self.volume['id'], '/dev/vdb')[1]
+ self.server['id'], self.volume['id'], '/dev/vdb')
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
@@ -628,7 +629,7 @@
try:
result = client.create_subnet(**subnet)
break
- except exceptions.Conflict as e:
+ except lib_exc.Conflict as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
@@ -639,14 +640,15 @@
self.addCleanup(self.delete_wrapper, subnet.delete)
return subnet
- def _create_port(self, network, client=None, namestart='port-quotatest'):
+ def _create_port(self, network_id, client=None, namestart='port-quotatest',
+ **kwargs):
if not client:
client = self.network_client
name = data_utils.rand_name(namestart)
result = client.create_port(
name=name,
- network_id=network.id,
- tenant_id=network.tenant_id)
+ network_id=network_id,
+ **kwargs)
self.assertIsNotNone(result, 'Unable to allocate port')
port = net_resources.DeletablePort(client=client,
**result['port'])
@@ -915,7 +917,7 @@
try:
sg_rule = self._create_security_group_rule(
client=client, secgroup=secgroup, **ruleset)
- except exceptions.Conflict as ex:
+ except lib_exc.Conflict as ex:
# if rule already exist - skip rule and continue
msg = 'Security group rule already exists'
if msg not in ex._error_string:
@@ -1047,6 +1049,66 @@
subnet.add_to_router(router.id)
return network, subnet, router
+ def create_server(self, name=None, image=None, flavor=None,
+ wait_on_boot=True, wait_on_delete=True,
+ create_kwargs=None):
+ vnic_type = CONF.network.port_vnic_type
+
+ # If vnic_type is configured create port for
+ # every network
+ if vnic_type:
+ ports = []
+ networks = []
+ create_port_body = {'binding:vnic_type': vnic_type,
+ 'namestart': 'port-smoke'}
+ if create_kwargs:
+ net_client = create_kwargs.get("network_client",
+ self.network_client)
+
+ # Convert security group names to security group ids
+ # to pass to create_port
+ if create_kwargs.get('security_groups'):
+ security_groups = net_client.list_security_groups().get(
+ 'security_groups')
+ sec_dict = dict([(s['name'], s['id'])
+ for s in security_groups])
+
+ sec_groups_names = [s['name'] for s in create_kwargs[
+ 'security_groups']]
+ security_groups_ids = [sec_dict[s]
+ for s in sec_groups_names]
+
+ if security_groups_ids:
+ create_port_body[
+ 'security_groups'] = security_groups_ids
+ networks = create_kwargs.get('networks')
+ else:
+ net_client = self.network_client
+ # If there are no networks passed to us we look up
+ # for the tenant's private networks and create a port
+ # if there is only one private network. The same behaviour
+ # as we would expect when passing the call to the clients
+ # with no networks
+ if not networks:
+ networks = net_client.list_networks(filters={
+ 'router:external': False})
+ self.assertEqual(1, len(networks),
+ "There is more than one"
+ " network for the tenant")
+ for net in networks:
+ net_id = net['uuid']
+ port = self._create_port(network_id=net_id,
+ client=net_client,
+ **create_port_body)
+ ports.append({'port': port.id})
+ if ports:
+ create_kwargs['networks'] = ports
+
+ return super(NetworkScenarioTest, self).create_server(
+ name=name, image=image, flavor=flavor,
+ wait_on_boot=wait_on_boot, wait_on_delete=wait_on_delete,
+ create_kwargs=create_kwargs)
+
# power/provision states as of icehouse
class BaremetalPowerStates(object):
@@ -1124,7 +1186,7 @@
node = None
try:
node = self.get_node(instance_id=instance_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
return node is not None
@@ -1259,8 +1321,9 @@
@classmethod
def credentials(cls):
- admin_creds = auth.get_default_credentials('identity_admin')
- creds = auth.get_default_credentials('user')
+ admin_creds = cred_provider.get_configured_credentials(
+ 'identity_admin')
+ creds = cred_provider.get_configured_credentials('user')
admin_creds.tenant_name = creds.tenant_name
return admin_creds
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index 35f6689..1313050 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -65,7 +65,7 @@
def check_login_page(self):
response = urllib2.urlopen(CONF.dashboard.dashboard_url)
- self.assertIn("Log In", response.read())
+ self.assertIn("id_username", response.read())
def user_login(self, username, password):
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 99a2023..ac766ea 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-from tempest_lib import exceptions
+from tempest_lib import exceptions as lib_exc
from tempest.common.utils import data_utils
from tempest import config
@@ -54,7 +54,7 @@
function, args, kwargs = cls._cleanup_resources.pop(-1)
try:
function(*args, **kwargs)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
super(TestLargeOpsScenario, cls).resource_cleanup()
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 5ea48e0..4624038 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -78,7 +78,7 @@
def nova_volume_attach(self):
volume_device_path = '/dev/' + CONF.compute.volume_device_name
volume = self.servers_client.attach_volume(
- self.server['id'], self.volume['id'], volume_device_path)[1]
+ self.server['id'], self.volume['id'], volume_device_path)
self.assertEqual(self.volume['id'], volume['id'])
self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
# Refresh the volume after the attachment
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index fc174cd..ae326c4 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -381,6 +381,9 @@
@testtools.skipUnless(CONF.compute_feature_enabled.interface_attach,
'NIC hotplug not available')
+ @testtools.skipIf(CONF.network.port_vnic_type in ['direct', 'macvtap'],
+ 'NIC hotplug not supported for '
+ 'vnic_type direct or macvtap')
@test.attr(type='smoke')
@test.services('compute', 'network')
def test_hotplug_nic(self):
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 83739fd..55ab18f 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -238,7 +238,8 @@
],
'key_name': tenant.keypair['name'],
'security_groups': security_groups_names,
- 'tenant_id': tenant.creds.tenant_id
+ 'tenant_id': tenant.creds.tenant_id,
+ 'network_client': tenant.manager.network_client
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
self.assertEqual(
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 16f5283..e97f089 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -16,6 +16,7 @@
import time
from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.common.utils import data_utils
@@ -85,7 +86,7 @@
try:
while self.snapshots_client.get_snapshot(snapshot['id']):
time.sleep(1)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
self.addCleanup(cleaner)
self._wait_for_volume_status(volume, 'available')
@@ -102,7 +103,7 @@
def _attach_volume(self, server, volume):
# TODO(andreaf) we should use device from config instead if vdb
- _, attached_volume = self.servers_client.attach_volume(
+ attached_volume = self.servers_client.attach_volume(
server['id'], volume['id'], device='/dev/vdb')
self.assertEqual(volume['id'], attached_volume['id'])
self._wait_for_volume_status(attached_volume, 'in-use')
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index f997a65..061f5c8 100644
--- a/tempest/scenario/utils.py
+++ b/tempest/scenario/utils.py
@@ -21,8 +21,8 @@
import testscenarios
import testtools
-from tempest import auth
from tempest import clients
+from tempest.common import cred_provider
from tempest.common.utils import misc
from tempest import config
from tempest import exceptions
@@ -101,7 +101,7 @@
def __init__(self):
os = clients.Manager(
- auth.get_default_credentials('user', fill_in=False))
+ cred_provider.get_configured_credentials('user', fill_in=False))
self.images_client = os.images_client
self.flavors_client = os.flavors_client
self.image_pattern = CONF.input_scenario.image_regex
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index f581e89..50d0779 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -15,6 +15,7 @@
import ConfigParser
import contextlib
+from tempest_lib import exceptions as lib_exc
import types
import urlparse
@@ -65,7 +66,7 @@
ec2_cred = keystone.ec2.create(keystone.auth_user_id,
keystone.auth_tenant_id)
if not all((ec2_cred, ec2_cred.access, ec2_cred.secret)):
- raise exceptions.NotFound("Unable to get access and secret keys")
+ raise lib_exc.NotFound("Unable to get access and secret keys")
return ec2_cred
def _config_boto_timeout(self, timeout, retries):
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index 94ea713..10955fd 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -15,10 +15,11 @@
import json
+from tempest_lib import exceptions as lib_exc
+
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
class AggregatesClientJSON(service_client.ServiceClient):
@@ -68,7 +69,7 @@
def is_resource_deleted(self, id):
try:
self.get_aggregate(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 9c586e3..d06386e 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -16,9 +16,10 @@
import json
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api_schema.response.compute.v2 import floating_ips as schema
from tempest.common import service_client
-from tempest import exceptions
class FloatingIPsClientJSON(service_client.ServiceClient):
@@ -40,7 +41,7 @@
resp, body = self.get(url)
body = json.loads(body)
if resp.status == 404:
- raise exceptions.NotFound(body)
+ raise lib_exc.NotFound(body)
self.validate_response(schema.floating_ip, resp, body)
return resp, body['floating_ip']
@@ -92,7 +93,7 @@
def is_resource_deleted(self, id):
try:
self.get_floating_ip_details(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index a5755da..0ceb6d1 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -16,10 +16,11 @@
import json
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api_schema.response.compute.v2 import images as schema
from tempest.common import service_client
from tempest.common import waiters
-from tempest import exceptions
class ImagesClientJSON(service_client.ServiceClient):
@@ -131,7 +132,7 @@
def is_resource_deleted(self, id):
try:
self.get_image(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 410ad60..5aefa7b 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -16,9 +16,10 @@
import json
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api_schema.response.compute.v2 import security_groups as schema
from tempest.common import service_client
-from tempest import exceptions
class SecurityGroupsClientJSON(service_client.ServiceClient):
@@ -128,12 +129,12 @@
for sg in body['security_groups']:
if sg['id'] == security_group_id:
return service_client.ResponseBodyList(resp, sg['rules'])
- raise exceptions.NotFound('No such Security Group')
+ raise lib_exc.NotFound('No such Security Group')
def is_resource_deleted(self, id):
try:
self.get_security_group(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index cbe1ca8..fe3d02b 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -18,6 +18,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api_schema.response.compute import servers as common_schema
from tempest.api_schema.response.compute.v2 import servers as schema
from tempest.common import service_client
@@ -183,7 +185,7 @@
while True:
try:
resp, body = self.get_server(server_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return
server_status = body['status']
@@ -364,14 +366,14 @@
post_body)
body = json.loads(body)
self.validate_response(schema.attach_volume, resp, body)
- return resp, body['volumeAttachment']
+ return service_client.ResponseBody(resp, body['volumeAttachment'])
def detach_volume(self, server_id, volume_id):
"""Detaches a volume from a server instance."""
resp, body = self.delete('servers/%s/os-volume_attachments/%s' %
(server_id, volume_id))
self.validate_response(schema.detach_volume, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def get_volume_attachment(self, server_id, attach_id):
"""Return details about the given volume attachment."""
@@ -379,7 +381,7 @@
str(server_id), attach_id))
body = json.loads(body)
self.validate_response(schema.get_volume_attachment, resp, body)
- return resp, body['volumeAttachment']
+ return service_client.ResponseBody(resp, body['volumeAttachment'])
def list_volume_attachments(self, server_id):
"""Returns the list of volume attachments for a given instance."""
@@ -387,7 +389,7 @@
str(server_id)))
body = json.loads(body)
self.validate_response(schema.list_volume_attachments, resp, body)
- return resp, body['volumeAttachments']
+ return service_client.ResponseBodyList(resp, body['volumeAttachments'])
def add_security_group(self, server_id, name):
"""Adds a security group to the server."""
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index 61d0b23..a9cada8 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -17,6 +17,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.api_schema.response.compute.v2 import volumes as schema
from tempest.common import service_client
from tempest import exceptions
@@ -33,7 +35,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_volumes, resp, body)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def list_volumes_with_detail(self, params=None):
"""List all the details of volumes."""
@@ -44,7 +46,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_volumes, resp, body)
- return resp, body['volumes']
+ return service_client.ResponseBodyList(resp, body['volumes'])
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
@@ -52,7 +54,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.create_get_volume, resp, body)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def create_volume(self, size, **kwargs):
"""
@@ -71,23 +73,23 @@
resp, body = self.post('os-volumes', post_body)
body = json.loads(body)
self.validate_response(schema.create_get_volume, resp, body)
- return resp, body['volume']
+ return service_client.ResponseBody(resp, body['volume'])
def delete_volume(self, volume_id):
"""Deletes the Specified Volume."""
resp, body = self.delete("os-volumes/%s" % str(volume_id))
self.validate_response(schema.delete_volume, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def wait_for_volume_status(self, volume_id, status):
"""Waits for a Volume to reach a given status."""
- resp, body = self.get_volume(volume_id)
+ body = self.get_volume(volume_id)
volume_status = body['status']
start = int(time.time())
while volume_status != status:
time.sleep(self.build_interval)
- resp, body = self.get_volume(volume_id)
+ body = self.get_volume(volume_id)
volume_status = body['status']
if volume_status == 'error':
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
@@ -102,7 +104,7 @@
def is_resource_deleted(self, id):
try:
self.get_volume(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
index 55b6be6..8879373 100644
--- a/tempest/services/data_processing/v1_1/client.py
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -33,7 +33,17 @@
"""Make a request using specified request_func and check response
status code.
- It returns pair: resp and response body.
+ It returns a ResponseBody.
+ """
+ resp, body = request_func(uri)
+ self.expected_success(resp_status, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def _request_and_check_resp_data(self, request_func, uri, resp_status):
+ """Make a request using specified request_func and check response
+ status code.
+
+ It returns pair: resp and response data.
"""
resp, body = request_func(uri)
self.expected_success(resp_status, resp.status)
@@ -44,20 +54,35 @@
"""Make a request using specified request_func, check response status
code and parse response body.
- It returns pair: resp and parsed resource(s) body.
+ It returns a ResponseBody.
"""
headers = {'Content-Type': 'application/json'}
resp, body = request_func(uri, headers=headers, *args, **kwargs)
self.expected_success(resp_status, resp.status)
body = json.loads(body)
- return resp, body[resource_name]
+ return service_client.ResponseBody(resp, body[resource_name])
+
+ def _request_check_and_parse_resp_list(self, request_func, uri,
+ resp_status, resource_name,
+ *args, **kwargs):
+ """Make a request using specified request_func, check response status
+ code and parse response body.
+
+ It returns a ResponseBodyList.
+ """
+ headers = {'Content-Type': 'application/json'}
+ resp, body = request_func(uri, headers=headers, *args, **kwargs)
+ self.expected_success(resp_status, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBodyList(resp, body[resource_name])
def list_node_group_templates(self):
"""List all node group templates for a user."""
uri = 'node-group-templates'
- return self._request_check_and_parse_resp(self.get, uri,
- 200, 'node_group_templates')
+ return self._request_check_and_parse_resp_list(self.get, uri,
+ 200,
+ 'node_group_templates')
def get_node_group_template(self, tmpl_id):
"""Returns the details of a single node group template."""
@@ -98,8 +123,8 @@
"""List all enabled plugins."""
uri = 'plugins'
- return self._request_check_and_parse_resp(self.get,
- uri, 200, 'plugins')
+ return self._request_check_and_parse_resp_list(self.get,
+ uri, 200, 'plugins')
def get_plugin(self, plugin_name, plugin_version=None):
"""Returns the details of a single plugin."""
@@ -113,8 +138,9 @@
"""List all cluster templates for a user."""
uri = 'cluster-templates'
- return self._request_check_and_parse_resp(self.get, uri,
- 200, 'cluster_templates')
+ return self._request_check_and_parse_resp_list(self.get, uri,
+ 200,
+ 'cluster_templates')
def get_cluster_template(self, tmpl_id):
"""Returns the details of a single cluster template."""
@@ -154,8 +180,9 @@
"""List all data sources for a user."""
uri = 'data-sources'
- return self._request_check_and_parse_resp(self.get,
- uri, 200, 'data_sources')
+ return self._request_check_and_parse_resp_list(self.get,
+ uri, 200,
+ 'data_sources')
def get_data_source(self, source_id):
"""Returns the details of a single data source."""
@@ -191,8 +218,8 @@
"""List all job binary internals for a user."""
uri = 'job-binary-internals'
- return self._request_check_and_parse_resp(self.get,
- uri, 200, 'binaries')
+ return self._request_check_and_parse_resp_list(self.get,
+ uri, 200, 'binaries')
def get_job_binary_internal(self, job_binary_id):
"""Returns the details of a single job binary internal."""
@@ -218,14 +245,14 @@
"""Returns data of a single job binary internal."""
uri = 'job-binary-internals/%s/data' % job_binary_id
- return self._request_and_check_resp(self.get, uri, 200)
+ return self._request_and_check_resp_data(self.get, uri, 200)
def list_job_binaries(self):
"""List all job binaries for a user."""
uri = 'job-binaries'
- return self._request_check_and_parse_resp(self.get,
- uri, 200, 'binaries')
+ return self._request_check_and_parse_resp_list(self.get,
+ uri, 200, 'binaries')
def get_job_binary(self, job_binary_id):
"""Returns the details of a single job binary."""
@@ -261,13 +288,14 @@
"""Returns data of a single job binary."""
uri = 'job-binaries/%s/data' % job_binary_id
- return self._request_and_check_resp(self.get, uri, 200)
+ return self._request_and_check_resp_data(self.get, uri, 200)
def list_jobs(self):
"""List all jobs for a user."""
uri = 'jobs'
- return self._request_check_and_parse_resp(self.get, uri, 200, 'jobs')
+ return self._request_check_and_parse_resp_list(self.get,
+ uri, 200, 'jobs')
def get_job(self, job_id):
"""Returns the details of a single job."""
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index d4f57e0..6fbb3a9 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -11,10 +11,10 @@
# under the License.
import json
+from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
from tempest import config
-from tempest import exceptions
CONF = config.CONF
@@ -134,7 +134,7 @@
for tenant in tenants:
if tenant['name'] == tenant_name:
return tenant
- raise exceptions.NotFound('No such tenant')
+ raise lib_exc.NotFound('No such tenant')
def update_tenant(self, tenant_id, **kwargs):
"""Updates a tenant."""
@@ -227,7 +227,7 @@
for user in users:
if user['name'] == username:
return user
- raise exceptions.NotFound('No such user')
+ raise lib_exc.NotFound('No such user')
def create_service(self, name, type, **kwargs):
"""Create a service."""
diff --git a/tempest/services/identity/json/token_client.py b/tempest/services/identity/json/token_client.py
index 93936bc..1e8b31e 100644
--- a/tempest/services/identity/json/token_client.py
+++ b/tempest/services/identity/json/token_client.py
@@ -13,6 +13,7 @@
# under the License.
import json
+from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
from tempest import config
@@ -87,7 +88,7 @@
if resp.status in [401, 403]:
resp_body = json.loads(resp_body)
- raise exceptions.Unauthorized(resp_body['error']['message'])
+ raise lib_exc.Unauthorized(resp_body['error']['message'])
elif resp.status not in [200, 201]:
raise exceptions.IdentityError(
'Unexpected status code {0}'.format(resp.status))
diff --git a/tempest/services/identity/v3/json/token_client.py b/tempest/services/identity/v3/json/token_client.py
index 14c4a0a..1467d7c 100644
--- a/tempest/services/identity/v3/json/token_client.py
+++ b/tempest/services/identity/v3/json/token_client.py
@@ -13,6 +13,7 @@
# under the License.
import json
+from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
from tempest import config
@@ -112,7 +113,7 @@
if resp.status in [401, 403]:
resp_body = json.loads(resp_body)
- raise exceptions.Unauthorized(resp_body['error']['message'])
+ raise lib_exc.Unauthorized(resp_body['error']['message'])
elif resp.status not in [200, 201, 204]:
raise exceptions.IdentityError(
'Unexpected status code {0}'.format(resp.status))
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index a7b8f63..0c05118 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -20,6 +20,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import glance_http
from tempest.common import service_client
from tempest.common.utils import misc as misc_utils
@@ -243,7 +245,7 @@
def is_resource_deleted(self, id):
try:
self.get_image_meta(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 4b1d52d..4cddc59 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -17,11 +17,11 @@
import urllib
import jsonschema
+from tempest_lib import exceptions as lib_exc
from tempest.common import glance_http
from tempest.common import service_client
from tempest import config
-from tempest import exceptions
CONF = config.CONF
@@ -120,7 +120,7 @@
def is_resource_deleted(self, id):
try:
self.get_image(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index e92708c..5106225 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -14,6 +14,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import service_client
from tempest.common.utils import misc
from tempest import exceptions
@@ -211,7 +213,7 @@
getattr(self, method)(id)
except AttributeError:
raise Exception("Unknown resource type %s " % resource_type)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index c813977..1a4c5d9 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -18,6 +18,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import service_client
from tempest import exceptions
@@ -159,7 +161,7 @@
try:
body = self.get_resource(
stack_identifier, resource_name)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
# ignore this, as the resource may not have
# been created yet
pass
@@ -194,7 +196,7 @@
while True:
try:
body = self.get_stack(stack_identifier)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
if status == 'DELETE_COMPLETE':
return
stack_name = body['stack_name']
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 6049eb6..c905155 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -19,7 +19,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.common import service_client
-from tempest import exceptions
class BaseVolumeTypesClientJSON(service_client.ServiceClient):
@@ -42,7 +41,7 @@
else:
msg = (" resource value is either not defined or incorrect.")
raise lib_exc.UnprocessableEntity(msg)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/volume/json/qos_client.py b/tempest/services/volume/json/qos_client.py
index 6aa56f7..14ff506 100644
--- a/tempest/services/volume/json/qos_client.py
+++ b/tempest/services/volume/json/qos_client.py
@@ -27,7 +27,7 @@
def is_resource_deleted(self, qos_id):
try:
self.get_qos(qos_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index 100b34c..8430b63 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -14,6 +14,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import service_client
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -127,7 +129,7 @@
def is_resource_deleted(self, id):
try:
self.get_snapshot(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index d834905..b906cec 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,6 +17,8 @@
import time
import urllib
+from tempest_lib import exceptions as lib_exc
+
from tempest.common import service_client
from tempest import config
from tempest import exceptions
@@ -181,7 +183,7 @@
def is_resource_deleted(self, id):
try:
self.get_volume(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index b52eca9..9bc55fa 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -95,7 +95,7 @@
except Exception:
pass
- _, vols = admin_manager.volumes_client.list_volumes({"all_tenants": True})
+ vols = admin_manager.volumes_client.list_volumes({"all_tenants": True})
LOG.info("Cleanup::remove %s volumes" % len(vols))
for v in vols:
try:
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index 49fac3d..1c27815 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -19,8 +19,8 @@
from six import moves
-from tempest import auth
from tempest import clients
+from tempest.common import cred_provider
from tempest.common import ssh
from tempest.common.utils import data_utils
from tempest import config
@@ -148,9 +148,9 @@
password,
tenant['id'],
"email")
- creds = auth.get_credentials(username=username,
- password=password,
- tenant_name=tenant_name)
+ creds = cred_provider.get_credentials(username=username,
+ password=password,
+ tenant_name=tenant_name)
manager = clients.Manager(credentials=creds)
test_obj = importutils.import_class(test['action'])
diff --git a/tempest/tests/common/test_cred_provider.py b/tempest/tests/common/test_cred_provider.py
new file mode 100644
index 0000000..160ecaa
--- /dev/null
+++ b/tempest/tests/common/test_cred_provider.py
@@ -0,0 +1,97 @@
+# Copyright 2015 Hewlett-Packard Development Company, L.P.
+#
+# 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.
+
+from oslo.config import cfg
+
+from tempest import auth
+from tempest.common import cred_provider
+from tempest.common import tempest_fixtures as fixtures
+from tempest.services.identity.json import token_client as v2_client
+from tempest.services.identity.v3.json import token_client as v3_client
+from tempest.tests import fake_identity
+# Note: eventually the auth module will move to tempest-lib, and so wil its
+# unit tests. *CredentialsTests will be imported from tempest-lib then.
+from tempest.tests import test_credentials as test_creds
+
+
+class ConfiguredV2CredentialsTests(test_creds.CredentialsTests):
+ attributes = {
+ 'username': 'fake_username',
+ 'password': 'fake_password',
+ 'tenant_name': 'fake_tenant_name'
+ }
+
+ identity_response = fake_identity._fake_v2_response
+ credentials_class = auth.KeystoneV2Credentials
+ tokenclient_class = v2_client.TokenClientJSON
+ identity_version = 'v2'
+
+ def setUp(self):
+ super(ConfiguredV2CredentialsTests, self).setUp()
+ self.stubs.Set(self.tokenclient_class, 'raw_request',
+ self.identity_response)
+
+ def _verify_credentials(self, credentials_class, filled=True,
+ identity_version=None):
+ for ctype in cred_provider.CREDENTIAL_TYPES:
+ if identity_version is None:
+ creds = cred_provider.get_configured_credentials(
+ credential_type=ctype, fill_in=filled)
+ else:
+ creds = cred_provider.get_configured_credentials(
+ credential_type=ctype, fill_in=filled,
+ identity_version=identity_version)
+ self._check(creds, credentials_class, filled)
+
+ def test_get_configured_credentials(self):
+ self.useFixture(fixtures.LockFixture('auth_version'))
+ self._verify_credentials(credentials_class=self.credentials_class)
+
+ def test_get_configured_credentials_unfilled(self):
+ self.useFixture(fixtures.LockFixture('auth_version'))
+ self._verify_credentials(credentials_class=self.credentials_class,
+ filled=False)
+
+ def test_get_configured_credentials_version(self):
+ # version specified and not loaded from config
+ self.useFixture(fixtures.LockFixture('auth_version'))
+ self._verify_credentials(credentials_class=self.credentials_class,
+ identity_version=self.identity_version)
+
+ def test_is_valid(self):
+ creds = self._get_credentials()
+ self.assertTrue(creds.is_valid())
+
+
+class ConfiguredV3CredentialsTests(ConfiguredV2CredentialsTests):
+ attributes = {
+ 'username': 'fake_username',
+ 'password': 'fake_password',
+ 'project_name': 'fake_project_name',
+ 'user_domain_name': 'fake_domain_name'
+ }
+
+ credentials_class = auth.KeystoneV3Credentials
+ identity_response = fake_identity._fake_v3_response
+ tokenclient_class = v3_client.V3TokenClientJSON
+ identity_version = 'v3'
+
+ def setUp(self):
+ super(ConfiguredV3CredentialsTests, self).setUp()
+ # Additional config items reset by cfg fixture after each test
+ cfg.CONF.set_default('auth_version', 'v3', group='identity')
+ # Identity group items
+ for prefix in ['', 'alt_', 'admin_']:
+ cfg.CONF.set_default(prefix + 'domain_name', 'fake_domain_name',
+ group='identity')
diff --git a/tempest/tests/test_auth.py b/tempest/tests/test_auth.py
index 90bb8a7..0317ad6 100644
--- a/tempest/tests/test_auth.py
+++ b/tempest/tests/test_auth.py
@@ -30,11 +30,7 @@
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):
+def fake_get_credentials(fill_in=True, identity_version='v2', **kwargs):
return fake_credentials.FakeCredentials()
@@ -54,8 +50,6 @@
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_get_credentials)
- self.stubs.Set(auth, 'get_default_credentials',
- fake_get_default_credentials)
self.auth_provider = self._auth(self.credentials)
@@ -87,11 +81,6 @@
def test_check_credentials_bad_type(self):
self.assertFalse(self.auth_provider.check_credentials([]))
- def test_instantiate_with_dict(self):
- # Dict credentials are only supported for backward compatibility
- auth_provider = self._auth(credentials={})
- self.assertIsInstance(auth_provider.credentials, auth.Credentials)
-
def test_auth_data_property_when_cache_exists(self):
self.auth_provider.cache = 'foo'
self.useFixture(mockpatch.PatchObject(self.auth_provider,
diff --git a/tempest/tests/test_credentials.py b/tempest/tests/test_credentials.py
index 6e447d6..7621f6e 100644
--- a/tempest/tests/test_credentials.py
+++ b/tempest/tests/test_credentials.py
@@ -15,8 +15,6 @@
import copy
-from oslo.config import cfg
-
from tempest import auth
from tempest.common import tempest_fixtures as fixtures
from tempest import config
@@ -37,6 +35,18 @@
attributes = self.attributes
return self.credentials_class(**attributes)
+ def _check(self, credentials, credentials_class, filled):
+ # Check the right version of credentials has been returned
+ self.assertIsInstance(credentials, credentials_class)
+ # Check the id attributes are filled in
+ attributes = [x for x in credentials.ATTRIBUTES if (
+ '_id' in x and x != 'domain_id')]
+ for attr in attributes:
+ if filled:
+ self.assertIsNotNone(getattr(credentials, attr))
+ else:
+ self.assertIsNone(getattr(credentials, attr))
+
def setUp(self):
super(CredentialsTests, self).setUp()
self.useFixture(fake_config.ConfigFixture())
@@ -51,18 +61,6 @@
self._get_credentials,
attributes=dict(invalid='fake'))
- def test_default(self):
- self.useFixture(fixtures.LockFixture('auth_version'))
- for ctype in self.credentials_class.TYPES:
- self.assertRaises(NotImplementedError,
- self.credentials_class.get_default,
- credentials_type=ctype)
-
- def test_invalid_default(self):
- self.assertRaises(exceptions.InvalidCredentials,
- auth.Credentials.get_default,
- credentials_type='invalid_type')
-
def test_is_valid(self):
creds = self._get_credentials()
self.assertRaises(NotImplementedError, creds.is_valid)
@@ -78,39 +76,18 @@
identity_response = fake_identity._fake_v2_response
credentials_class = auth.KeystoneV2Credentials
tokenclient_class = v2_client.TokenClientJSON
+ identity_version = 'v2'
def setUp(self):
super(KeystoneV2CredentialsTests, self).setUp()
self.stubs.Set(self.tokenclient_class, 'raw_request',
self.identity_response)
- def _verify_credentials(self, credentials_class, filled=True,
- creds_dict=None):
-
- def _check(credentials):
- # Check the right version of credentials has been returned
- self.assertIsInstance(credentials, credentials_class)
- # Check the id attributes are filled in
- attributes = [x for x in credentials.ATTRIBUTES if (
- '_id' in x and x != 'domain_id')]
- for attr in attributes:
- if filled:
- self.assertIsNotNone(getattr(credentials, attr))
- else:
- self.assertIsNone(getattr(credentials, attr))
-
- if creds_dict is None:
- for ctype in auth.Credentials.TYPES:
- creds = auth.get_default_credentials(credential_type=ctype,
- fill_in=filled)
- _check(creds)
- else:
- creds = auth.get_credentials(fill_in=filled, **creds_dict)
- _check(creds)
-
- def test_get_default_credentials(self):
- self.useFixture(fixtures.LockFixture('auth_version'))
- self._verify_credentials(credentials_class=self.credentials_class)
+ def _verify_credentials(self, credentials_class, creds_dict, filled=True):
+ creds = auth.get_credentials(fill_in=filled,
+ identity_version=self.identity_version,
+ **creds_dict)
+ self._check(creds, credentials_class, filled)
def test_get_credentials(self):
self.useFixture(fixtures.LockFixture('auth_version'))
@@ -120,8 +97,8 @@
def test_get_credentials_not_filled(self):
self.useFixture(fixtures.LockFixture('auth_version'))
self._verify_credentials(credentials_class=self.credentials_class,
- filled=False,
- creds_dict=self.attributes)
+ creds_dict=self.attributes,
+ filled=False)
def test_is_valid(self):
creds = self._get_credentials()
@@ -144,15 +121,6 @@
# credential requirements
self._test_is_not_valid('tenant_name')
- def test_default(self):
- self.useFixture(fixtures.LockFixture('auth_version'))
- for ctype in self.credentials_class.TYPES:
- creds = self.credentials_class.get_default(credentials_type=ctype)
- for attr in self.attributes.keys():
- # Default configuration values related to credentials
- # are defined as fake_* in fake_config.py
- self.assertEqual(getattr(creds, attr), 'fake_' + attr)
-
def test_reset_all_attributes(self):
creds = self._get_credentials()
initial_creds = copy.deepcopy(creds)
@@ -189,28 +157,7 @@
credentials_class = auth.KeystoneV3Credentials
identity_response = fake_identity._fake_v3_response
tokenclient_class = v3_client.V3TokenClientJSON
-
- def setUp(self):
- super(KeystoneV3CredentialsTests, self).setUp()
- # Additional config items reset by cfg fixture after each test
- cfg.CONF.set_default('auth_version', 'v3', group='identity')
- # Identity group items
- for prefix in ['', 'alt_', 'admin_']:
- cfg.CONF.set_default(prefix + 'domain_name', 'fake_domain_name',
- group='identity')
-
- def test_default(self):
- self.useFixture(fixtures.LockFixture('auth_version'))
- for ctype in self.credentials_class.TYPES:
- creds = self.credentials_class.get_default(credentials_type=ctype)
- for attr in self.attributes.keys():
- if attr == 'project_name':
- config_value = 'fake_tenant_name'
- elif attr == 'user_domain_name':
- config_value = 'fake_domain_name'
- else:
- config_value = 'fake_' + attr
- self.assertEqual(getattr(creds, attr), config_value)
+ identity_version = 'v3'
def test_is_not_valid(self):
# NOTE(mtreinish) For a Keystone V3 credential object a project name