Merge "Adding api tests for dvr routers"
diff --git a/HACKING.rst b/HACKING.rst
index 607682b..81a7c2c 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -13,6 +13,7 @@
- [T104] Scenario tests require a services decorator
- [T105] Tests cannot use setUpClass/tearDownClass
- [T106] vim configuration should not be kept in source files.
+- [T107] Check that a service tag isn't in the module path
- [N322] Method's default argument shouldn't be mutable
Test Data/Configuration
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 949302f..bc4198f 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -439,6 +439,9 @@
# running instances? (boolean value)
#snapshot = true
+# Does the test environment have the ec2 api running? (boolean value)
+#ec2_api = true
+
[dashboard]
@@ -776,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/requirements.txt b/requirements.txt
index 94c6fb0..ebb23c3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -11,7 +11,7 @@
netaddr>=0.7.12
python-ceilometerclient>=1.0.6
python-glanceclient>=0.15.0
-python-keystoneclient>=1.0.0
+python-keystoneclient>=1.1.0
python-novaclient>=2.18.0
python-neutronclient>=2.3.6,<3
python-cinderclient>=1.1.0
@@ -25,4 +25,4 @@
iso8601>=0.1.9
fixtures>=0.3.14
testscenarios>=0.4
-tempest-lib>=0.1.0
+tempest-lib>=0.2.0
diff --git a/tempest/api/baremetal/admin/base.py b/tempest/api/baremetal/admin/base.py
index 3b12b8e..4f5c6c8 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
@@ -53,9 +53,8 @@
"""Base class for Baremetal API tests."""
@classmethod
- def resource_setup(cls):
- super(BaseBaremetalTest, cls).resource_setup()
-
+ def skip_checks(cls):
+ super(BaseBaremetalTest, cls).skip_checks()
if not CONF.service_available.ironic:
skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
raise cls.skipException(skip_msg)
@@ -65,10 +64,22 @@
'testing.' %
(cls.__name__, CONF.baremetal.driver))
raise cls.skipException(skip_msg)
- cls.driver = CONF.baremetal.driver
- mgr = clients.AdminManager()
- cls.client = mgr.baremetal_client
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseBaremetalTest, cls).setup_credentials()
+ cls.mgr = clients.AdminManager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseBaremetalTest, cls).setup_clients()
+ cls.client = cls.mgr.baremetal_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseBaremetalTest, cls).resource_setup()
+
+ cls.driver = CONF.baremetal.driver
cls.power_timeout = CONF.baremetal.power_timeout
cls.created_objects = {}
for resource in RESOURCE_TYPES:
@@ -83,7 +94,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 4aedaa4..0076dee 100644
--- a/tempest/api/baremetal/admin/test_ports.py
+++ b/tempest/api/baremetal/admin/test_ports.py
@@ -10,9 +10,11 @@
# License for the specific language governing permissions and limitations
# 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
@@ -57,7 +59,7 @@
_, body = self.client.show_port(uuid)
self._assertExpected(port, body)
- @test.skip_because(bug='1398350')
+ @decorators.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_create_port_with_extra(self):
node_id = self.node['uuid']
@@ -79,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):
@@ -231,7 +234,7 @@
_, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
- @test.skip_because(bug='1398350')
+ @decorators.skip_because(bug='1398350')
@test.attr(type='smoke')
def test_update_port_mixed_ops(self):
node_id = self.node['uuid']
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index 8080eb6..8dbdedf 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.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.baremetal.admin import base
from tempest.common.utils import data_utils
-from tempest import exceptions as exc
from tempest import test
@@ -30,29 +31,29 @@
node_id = self.node['uuid']
address = 'malformed:mac'
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_port, node_id=node_id, address=address)
@test.attr(type=['negative', 'smoke'])
def test_create_port_nonexsistent_node_id(self):
node_id = str(data_utils.rand_uuid())
address = data_utils.rand_mac_address()
- self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id,
- address=address)
+ self.assertRaises(lib_exc.BadRequest, self.create_port,
+ node_id=node_id, address=address)
@test.attr(type=['negative', 'smoke'])
def test_show_port_malformed_uuid(self):
- self.assertRaises(exc.BadRequest, self.client.show_port,
+ self.assertRaises(lib_exc.BadRequest, self.client.show_port,
'malformed:uuid')
@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'])
def test_show_port_by_mac_not_allowed(self):
- self.assertRaises(exc.BadRequest, self.client.show_port,
+ self.assertRaises(lib_exc.BadRequest, self.client.show_port,
data_utils.rand_mac_address())
@test.attr(type=['negative', 'smoke'])
@@ -62,22 +63,22 @@
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'])
def test_create_port_no_mandatory_field_node_id(self):
address = data_utils.rand_mac_address()
- self.assertRaises(exc.BadRequest, self.create_port, node_id=None,
+ self.assertRaises(lib_exc.BadRequest, self.create_port, node_id=None,
address=address)
@test.attr(type=['negative', 'smoke'])
def test_create_port_no_mandatory_field_mac(self):
node_id = self.node['uuid']
- self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id,
- address=None)
+ self.assertRaises(lib_exc.BadRequest, self.create_port,
+ node_id=node_id, address=None)
@test.attr(type=['negative', 'smoke'])
def test_create_port_malformed_port_uuid(self):
@@ -85,13 +86,13 @@
address = data_utils.rand_mac_address()
uuid = 'malformed:uuid'
- self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id,
- address=address, uuid=uuid)
+ self.assertRaises(lib_exc.BadRequest, self.create_port,
+ node_id=node_id, address=address, uuid=uuid)
@test.attr(type=['negative', 'smoke'])
def test_create_port_malformed_node_id(self):
address = data_utils.rand_mac_address()
- self.assertRaises(exc.BadRequest, self.create_port,
+ self.assertRaises(lib_exc.BadRequest, self.create_port,
node_id='malformed:nodeid', address=address)
@test.attr(type=['negative', 'smoke'])
@@ -99,7 +100,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)
@@ -115,7 +116,7 @@
'op': 'replace',
'value': 'new-value'}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, address,
patch)
@@ -134,7 +135,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'])
@@ -145,7 +146,7 @@
self.create_port(node_id=node_id, address=address)
new_address = data_utils.rand_mac_address()
- self.assertRaises(exc.BadRequest, self.client.update_port,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port,
uuid='malformed:uuid',
patch=[{'path': '/address', 'op': 'replace',
'value': new_address}])
@@ -158,7 +159,7 @@
_, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
[{'path': '/nonexistent', ' op': 'add',
'value': 'value'}])
@@ -173,7 +174,7 @@
patch = [{'path': '/node_uuid',
'op': 'replace',
'value': 'malformed:node_uuid'}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
@@ -190,7 +191,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'])
@@ -204,7 +205,7 @@
patch = [{'path': '/node_uuid',
'op': 'replace',
'value': data_utils.rand_uuid()}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
@@ -219,7 +220,7 @@
'op': 'replace',
'value': 'malformed:mac'}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
@@ -232,7 +233,7 @@
patch = [{'path': '/nonexistent', ' op': 'replace', 'value': 'value'}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, port_id, patch)
@test.attr(type=['negative', 'smoke'])
@@ -243,7 +244,7 @@
_, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
[{'path': '/address', 'op': 'remove'}])
@test.attr(type=['negative', 'smoke'])
@@ -254,7 +255,7 @@
_, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
[{'path': '/uuid', 'op': 'remove'}])
@test.attr(type=['negative', 'smoke'])
@@ -265,7 +266,7 @@
_, port = self.create_port(node_id=node_id, address=address)
port_id = port['uuid']
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
[{'path': '/nonexistent', 'op': 'remove'}])
@test.attr(type=['negative', 'smoke'])
@@ -274,7 +275,7 @@
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
- self.assertRaises(exc.BadRequest, self.client.delete_port, address)
+ self.assertRaises(lib_exc.BadRequest, self.client.delete_port, address)
@test.attr(type=['negative', 'smoke'])
def test_update_port_mixed_ops_integrity(self):
@@ -304,7 +305,7 @@
'op': 'replace',
'value': 'value'}]
- self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
patch)
# patch should not be applied
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..2bf2b82 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')
@@ -203,8 +204,8 @@
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
server_name = data_utils.rand_name('test_server_')
admin_servers_client = self.os_adm.servers_client
- resp, server = self.create_test_server(name=server_name,
- availability_zone=az_name,
- wait_until='ACTIVE')
- resp, body = admin_servers_client.get_server(server['id'])
+ server = self.create_test_server(name=server_name,
+ availability_zone=az_name,
+ wait_until='ACTIVE')
+ body = admin_servers_client.get_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index a450e5d..fd44f7f 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.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
@@ -43,14 +44,14 @@
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)
@test.attr(type=['negative', 'gate'])
def test_aggregate_create_aggregate_name_length_less_than_1(self):
# the length of aggregate name should >= 1 and <=255
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_aggregate,
name='')
@@ -58,7 +59,7 @@
def test_aggregate_create_aggregate_name_length_exceeds_255(self):
# the length of aggregate name should >= 1 and <=255
aggregate_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_aggregate,
name=aggregate_name)
@@ -69,7 +70,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 +81,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 +98,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 +128,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 +138,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 +152,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 +165,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 +176,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.py b/tempest/api/compute/admin/test_availability_zone.py
index e88fecb..909f0a5 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -31,14 +31,11 @@
@test.attr(type='gate')
def test_get_availability_zone_list(self):
# List of availability zone
- resp, availability_zone = self.client.get_availability_zone_list()
- self.assertEqual(200, resp.status)
+ availability_zone = self.client.get_availability_zone_list()
self.assertTrue(len(availability_zone) > 0)
@test.attr(type='gate')
def test_get_availability_zone_list_detail(self):
# List of availability zones and available services
- resp, availability_zone = \
- self.client.get_availability_zone_list_detail()
- self.assertEqual(200, resp.status)
+ availability_zone = self.client.get_availability_zone_list_detail()
self.assertTrue(len(availability_zone) > 0)
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_baremetal_nodes.py b/tempest/api/compute/admin/test_baremetal_nodes.py
new file mode 100644
index 0000000..d894de6
--- /dev/null
+++ b/tempest/api/compute/admin/test_baremetal_nodes.py
@@ -0,0 +1,43 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
+
+
+class BaremetalNodesAdminTestJSON(base.BaseV2ComputeAdminTest):
+ """
+ Tests Baremetal API
+ """
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaremetalNodesAdminTestJSON, cls).resource_setup()
+ if not CONF.service_available.ironic:
+ skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
+ raise cls.skipException(skip_msg)
+ cls.client = cls.os_adm.baremetal_nodes_client
+
+ @test.attr(type='smoke')
+ def test_list_baremetal_nodes(self):
+ # List all baremetal nodes.
+ baremetal_nodes = self.client.list_baremetal_nodes()
+ self.assertNotEmpty(baremetal_nodes, "No baremetal nodes found.")
+
+ for node in baremetal_nodes:
+ baremetal_node = self.client.get_baremetal_node(node['id'])
+ self.assertEqual(node['id'], baremetal_node['id'])
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index d1d13a0..078fe08 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -29,8 +29,8 @@
msg = ("%s skipped as neutron is available" % cls.__name__)
raise cls.skipException(msg)
cls.client = cls.os_adm.fixed_ips_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- resp, server = cls.servers_client.get_server(server['id'])
+ server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.servers_client.get_server(server['id'])
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
@@ -42,19 +42,17 @@
@test.attr(type='gate')
@test.services('network')
def test_list_fixed_ip_details(self):
- resp, fixed_ip = self.client.get_fixed_ip_details(self.ip)
+ fixed_ip = self.client.get_fixed_ip_details(self.ip)
self.assertEqual(fixed_ip['address'], self.ip)
@test.attr(type='gate')
@test.services('network')
def test_set_reserve(self):
body = {"reserve": "None"}
- resp, body = self.client.reserve_fixed_ip(self.ip, body)
- self.assertEqual(resp.status, 202)
+ self.client.reserve_fixed_ip(self.ip, body)
@test.attr(type='gate')
@test.services('network')
def test_set_unreserve(self):
body = {"unreserve": "None"}
- resp, body = self.client.reserve_fixed_ip(self.ip, body)
- self.assertEqual(resp.status, 202)
+ self.client.reserve_fixed_ip(self.ip, body)
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index e7022db..f717291 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.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 import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -30,8 +31,8 @@
raise cls.skipException(msg)
cls.client = cls.os_adm.fixed_ips_client
cls.non_admin_client = cls.fixed_ips_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- resp, server = cls.servers_client.get_server(server['id'])
+ server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.servers_client.get_server(server['id'])
for ip_set in server['addresses']:
for ip in server['addresses'][ip_set]:
if ip['OS-EXT-IPS:type'] == 'fixed':
@@ -43,14 +44,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 +59,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 +72,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, lib_exc.BadRequest),
self.client.reserve_fixed_ip,
"my.invalid.ip", body)
@@ -79,6 +80,6 @@
@test.services('network')
def test_fixed_ip_with_invalid_action(self):
body = {"invalid_action": "None"}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.reserve_fixed_ip,
self.ip, body)
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 1953040..8d5c5e3 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.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
@@ -45,8 +45,7 @@
cls.rxtx = 2
def flavor_clean_up(self, flavor_id):
- resp, body = self.client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 202)
+ self.client.delete_flavor(flavor_id)
self.client.wait_for_resource_deletion(flavor_id)
def _create_flavor(self, flavor_id):
@@ -55,15 +54,14 @@
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(flavor['name'], flavor_name)
self.assertEqual(flavor['vcpus'], self.vcpus)
self.assertEqual(flavor['disk'], self.disk)
@@ -75,8 +73,7 @@
self.assertEqual(flavor['os-flavor-access:is_public'], True)
# Verify flavor is retrieved
- resp, flavor = self.client.get_flavor_details(flavor['id'])
- self.assertEqual(resp.status, 200)
+ flavor = self.client.get_flavor_details(flavor['id'])
self.assertEqual(flavor['name'], flavor_name)
return flavor['id']
@@ -109,18 +106,17 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
self.addCleanup(self.flavor_clean_up, flavor['id'])
flag = False
# Verify flavor is retrieved
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.client.list_flavors_with_detail()
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -142,12 +138,11 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id)
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id)
self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(flavor['name'], flavor_name)
self.assertEqual(flavor['ram'], self.ram)
self.assertEqual(flavor['vcpus'], self.vcpus)
@@ -156,14 +151,12 @@
verify_flavor_response_extension(flavor)
# Verify flavor is retrieved
- resp, flavor = self.client.get_flavor_details(new_flavor_id)
- self.assertEqual(resp.status, 200)
+ flavor = self.client.get_flavor_details(new_flavor_id)
self.assertEqual(flavor['name'], flavor_name)
verify_flavor_response_extension(flavor)
# Check if flavor is present in list
- resp, flavors = self.user_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.user_client.list_flavors_with_detail()
for flavor in flavors:
if flavor['name'] == flavor_name:
verify_flavor_response_extension(flavor)
@@ -180,16 +173,15 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="False")
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="False")
self.addCleanup(self.flavor_clean_up, flavor['id'])
# Verify flavor is retrieved
flag = False
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.client.list_flavors_with_detail()
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -197,8 +189,7 @@
# Verify flavor is not retrieved with other user
flag = False
- resp, flavors = self.user_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.user_client.list_flavors_with_detail()
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -211,16 +202,15 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="False")
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="False")
self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
# Verify flavor is not used by other user
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.os.servers_client.create_server,
'test', self.image_ref, flavor['id'])
@@ -232,17 +222,16 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
# Create the flavor
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public="True")
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public="True")
self.addCleanup(self.flavor_clean_up, flavor['id'])
flag = False
self.new_client = self.flavors_client
# Verify flavor is retrieved with new user
- resp, flavors = self.new_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.new_client.list_flavors_with_detail()
for flavor in flavors:
if flavor['name'] == flavor_name:
flag = True
@@ -256,19 +245,19 @@
flavor_name_public = data_utils.rand_name(self.flavor_name_prefix)
# Create a non public flavor
- resp, flavor = self.client.create_flavor(flavor_name_not_public,
- self.ram, self.vcpus,
- self.disk,
- flavor_id_not_public,
- is_public="False")
+ flavor = self.client.create_flavor(flavor_name_not_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_not_public,
+ is_public="False")
self.addCleanup(self.flavor_clean_up, flavor['id'])
# Create a public flavor
- resp, flavor = self.client.create_flavor(flavor_name_public,
- self.ram, self.vcpus,
- self.disk,
- flavor_id_public,
- is_public="True")
+ flavor = self.client.create_flavor(flavor_name_public,
+ self.ram, self.vcpus,
+ self.disk,
+ flavor_id_public,
+ is_public="True")
self.addCleanup(self.flavor_clean_up, flavor['id'])
def _flavor_lookup(flavors, flavor_name):
@@ -280,8 +269,7 @@
def _test_string_variations(variations, flavor_name):
for string in variations:
params = {'is_public': string}
- r, flavors = self.client.list_flavors_with_detail(params)
- self.assertEqual(r.status, 200)
+ flavors = self.client.list_flavors_with_detail(params)
flavor = _flavor_lookup(flavors, flavor_name)
self.assertIsNotNone(flavor)
@@ -297,12 +285,11 @@
new_flavor_id = data_utils.rand_int_id(start=1000)
ram = "1024"
- resp, flavor = self.client.create_flavor(flavor_name,
- ram, self.vcpus,
- self.disk,
- new_flavor_id)
+ flavor = self.client.create_flavor(flavor_name,
+ ram, self.vcpus,
+ self.disk,
+ new_flavor_id)
self.addCleanup(self.flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(flavor['name'], flavor_name)
self.assertEqual(flavor['vcpus'], self.vcpus)
self.assertEqual(flavor['disk'], self.disk)
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 19707d0..8a33ce7 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -49,15 +49,13 @@
# private flavor will return an empty access list
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
- resp, flavor_access = self.client.list_flavor_access(new_flavor_id)
- self.assertEqual(resp.status, 200)
+ flavor_access = self.client.list_flavor_access(new_flavor_id)
self.assertEqual(len(flavor_access), 0, str(flavor_access))
@test.attr(type='gate')
@@ -65,34 +63,30 @@
# Test to add and remove flavor access to a given tenant.
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
# Add flavor access to a tenant.
resp_body = {
"tenant_id": str(self.tenant_id),
"flavor_id": str(new_flavor['id']),
}
- add_resp, add_body = \
+ add_body = \
self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
- self.assertEqual(add_resp.status, 200)
self.assertIn(resp_body, add_body)
# The flavor is present in list.
- resp, flavors = self.flavors_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.flavors_client.list_flavors_with_detail()
self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
# Remove flavor access from a tenant.
- remove_resp, remove_body = \
+ remove_body = \
self.client.remove_flavor_access(new_flavor['id'], self.tenant_id)
- self.assertEqual(remove_resp.status, 200)
self.assertNotIn(resp_body, remove_body)
# The flavor is not present in list.
- resp, flavors = self.flavors_client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.flavors_client.list_flavors_with_detail()
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index c49652d..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
@@ -47,14 +47,13 @@
# Test to list flavor access with exceptions by querying public flavor
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='True')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='True')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.list_flavor_access,
new_flavor_id)
@@ -63,13 +62,13 @@
# Test to add flavor access as a user without admin privileges.
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ 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)
@@ -79,17 +78,17 @@
# Test to remove flavor access as a user without admin privileges.
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
# Add flavor access to a tenant.
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)
@@ -99,11 +98,11 @@
# Create a new flavor.
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
# Add flavor access to a tenant.
@@ -113,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)
@@ -123,15 +122,15 @@
# Create a new flavor.
flavor_name = data_utils.rand_name(self.flavor_name_prefix)
new_flavor_id = data_utils.rand_int_id(start=1000)
- resp, new_flavor = self.client.create_flavor(flavor_name,
- self.ram, self.vcpus,
- self.disk,
- new_flavor_id,
- is_public='False')
+ new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
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.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 5157d2e..55c3358 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -43,16 +43,16 @@
swap = 1024
rxtx = 1
# Create a flavor so as to set/get/unset extra specs
- resp, cls.flavor = cls.client.create_flavor(flavor_name,
- ram, vcpus,
- disk,
- cls.new_flavor_id,
- ephemeral=ephemeral,
- swap=swap, rxtx=rxtx)
+ cls.flavor = cls.client.create_flavor(flavor_name,
+ ram, vcpus,
+ disk,
+ cls.new_flavor_id,
+ ephemeral=ephemeral,
+ swap=swap, rxtx=rxtx)
@classmethod
def resource_cleanup(cls):
- resp, body = cls.client.delete_flavor(cls.flavor['id'])
+ cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
super(FlavorsExtraSpecsTestJSON, cls).resource_cleanup()
@@ -63,47 +63,34 @@
# Assigning extra specs values that are to be set
specs = {"key1": "value1", "key2": "value2"}
# SET extra specs to the flavor created in setUp
- set_resp, set_body = \
+ set_body = \
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- self.assertEqual(set_resp.status, 200)
self.assertEqual(set_body, specs)
# GET extra specs and verify
- get_resp, get_body = \
- self.client.get_flavor_extra_spec(self.flavor['id'])
- self.assertEqual(get_resp.status, 200)
+ get_body = self.client.get_flavor_extra_spec(self.flavor['id'])
self.assertEqual(get_body, specs)
# UPDATE the value of the extra specs key1
- update_resp, update_body = \
+ update_body = \
self.client.update_flavor_extra_spec(self.flavor['id'],
"key1",
key1="value")
- self.assertEqual(update_resp.status, 200)
self.assertEqual({"key1": "value"}, update_body)
# GET extra specs and verify the value of the key2
# is the same as before
- get_resp, get_body = \
- self.client.get_flavor_extra_spec(self.flavor['id'])
- self.assertEqual(get_resp.status, 200)
+ get_body = self.client.get_flavor_extra_spec(self.flavor['id'])
self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
# UNSET extra specs that were set in this test
- unset_resp, _ = \
- self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
- self.assertEqual(unset_resp.status, 200)
- unset_resp, _ = \
- self.client.unset_flavor_extra_spec(self.flavor['id'], "key2")
- self.assertEqual(unset_resp.status, 200)
+ self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
+ self.client.unset_flavor_extra_spec(self.flavor['id'], "key2")
@test.attr(type='gate')
def test_flavor_non_admin_get_all_keys(self):
specs = {"key1": "value1", "key2": "value2"}
- set_resp, set_body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
- resp, body = self.flavors_client.get_flavor_extra_spec(
- self.flavor['id'])
- self.assertEqual(resp.status, 200)
+ self.client.set_flavor_extra_spec(self.flavor['id'], specs)
+ body = self.flavors_client.get_flavor_extra_spec(self.flavor['id'])
for key in specs:
self.assertEqual(body[key], specs[key])
@@ -111,13 +98,10 @@
@test.attr(type='gate')
def test_flavor_non_admin_get_specific_key(self):
specs = {"key1": "value1", "key2": "value2"}
- resp, body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
+ body = self.client.set_flavor_extra_spec(self.flavor['id'], specs)
self.assertEqual(body['key1'], 'value1')
self.assertIn('key2', body)
- resp, body = self.flavors_client.get_flavor_extra_spec_with_key(
+ body = self.flavors_client.get_flavor_extra_spec_with_key(
self.flavor['id'], 'key1')
- self.assertEqual(resp.status, 200)
self.assertEqual(body['key1'], 'value1')
self.assertNotIn('key2', body)
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 20860c8..c22602a 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_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.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -44,16 +45,16 @@
swap = 1024
rxtx = 1
# Create a flavor
- resp, cls.flavor = cls.client.create_flavor(flavor_name,
- ram, vcpus,
- disk,
- cls.new_flavor_id,
- ephemeral=ephemeral,
- swap=swap, rxtx=rxtx)
+ cls.flavor = cls.client.create_flavor(flavor_name,
+ ram, vcpus,
+ disk,
+ cls.new_flavor_id,
+ ephemeral=ephemeral,
+ swap=swap, rxtx=rxtx)
@classmethod
def resource_cleanup(cls):
- resp, body = cls.client.delete_flavor(cls.flavor['id'])
+ cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
super(FlavorsExtraSpecsNegativeTestJSON, cls).resource_cleanup()
@@ -61,7 +62,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)
@@ -70,11 +71,10 @@
def test_flavor_non_admin_update_specific_key(self):
# non admin user is not allowed to update flavor extra spec
specs = {"key1": "value1", "key2": "value2"}
- resp, body = self.client.set_flavor_extra_spec(
+ body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
self.assertEqual(body['key1'], 'value1')
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises(lib_exc.Unauthorized,
self.flavors_client.
update_flavor_extra_spec,
self.flavor['id'],
@@ -84,10 +84,9 @@
@test.attr(type=['negative', 'gate'])
def test_flavor_non_admin_unset_keys(self):
specs = {"key1": "value1", "key2": "value2"}
- set_resp, set_body = self.client.set_flavor_extra_spec(
- self.flavor['id'], specs)
+ 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')
@@ -95,14 +94,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")
@@ -110,7 +109,7 @@
@test.attr(type=['negative', 'gate'])
def test_flavor_update_mismatch_key(self):
# the key will be updated should be match the key in the body
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_flavor_extra_spec,
self.flavor['id'],
"key2",
@@ -119,7 +118,7 @@
@test.attr(type=['negative', 'gate'])
def test_flavor_update_more_key(self):
# there should be just one item in the request body
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_flavor_extra_spec,
self.flavor['id'],
"key1",
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index fb27360..d1060c5 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
@@ -59,27 +60,23 @@
# no need to specify flavor_id, we can get the flavor_id from a
# response of create_flavor() call.
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram,
- self.vcpus, self.disk,
- None,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
+ flavor = self.client.create_flavor(flavor_name,
+ self.ram,
+ self.vcpus, self.disk,
+ None,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
# Delete the flavor
new_flavor_id = flavor['id']
- resp_delete, body = self.client.delete_flavor(new_flavor_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(202, resp_delete.status)
+ self.client.delete_flavor(new_flavor_id)
# Deleted flavors can be seen via detailed GET
- resp, flavor = self.client.get_flavor_details(new_flavor_id)
- self.assertEqual(resp.status, 200)
+ flavor = self.client.get_flavor_details(new_flavor_id)
self.assertEqual(flavor['name'], flavor_name)
# Deleted flavors should not show up in a list however
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
+ flavors = self.client.list_flavors_with_detail()
flag = True
for flavor in flavors:
if flavor['name'] == flavor_name:
@@ -92,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,
@@ -101,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)
@@ -109,6 +106,5 @@
@test.SimpleNegativeAutoTest
class FlavorCreateNegativeTestJSON(base.BaseV2ComputeAdminTest,
test.NegativeAutoTest):
- _interface = 'json'
_service = CONF.compute.catalog_type
_schema = flavors.flavor_create
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index c1263ea..e01245e 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -40,7 +40,7 @@
@classmethod
def verify_unallocated_floating_ip_range(cls, ip_range):
# Verify whether configure floating IP range is not already allocated.
- _, body = cls.client.list_floating_ips_bulk()
+ body = cls.client.list_floating_ips_bulk()
allocated_ips_list = map(lambda x: x['address'], body)
for ip_addr in netaddr.IPNetwork(ip_range).iter_hosts():
if str(ip_addr) in allocated_ips_list:
@@ -65,18 +65,14 @@
# anywhere. Using the below mentioned interface which is not ever
# expected to be used. Clean Up has been done for created IP range
interface = 'eth0'
- resp, body = self.client.create_floating_ips_bulk(self.ip_range,
- pool,
- interface)
-
- self.assertEqual(200, resp.status)
+ body = self.client.create_floating_ips_bulk(self.ip_range,
+ pool,
+ interface)
self.addCleanup(self._delete_floating_ips_bulk, self.ip_range)
self.assertEqual(self.ip_range, body['ip_range'])
- resp, ips_list = self.client.list_floating_ips_bulk()
- self.assertEqual(200, resp.status)
+ ips_list = self.client.list_floating_ips_bulk()
self.assertNotEqual(0, len(ips_list))
for ip in netaddr.IPNetwork(self.ip_range).iter_hosts():
self.assertIn(str(ip), map(lambda x: x['address'], ips_list))
- resp, body = self.client.delete_floating_ips_bulk(self.ip_range)
- self.assertEqual(200, resp.status)
- self.assertEqual(self.ip_range, body)
+ body = self.client.delete_floating_ips_bulk(self.ip_range)
+ self.assertEqual(self.ip_range, body.data)
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index fc918a3..8d70c44 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.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 import test
@@ -38,20 +39,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 +60,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',
@@ -70,7 +71,7 @@
# only 'status' and 'maintenance_mode' are the valid params.
hostname = self._get_host_name()
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
hostname,
status='enable',
@@ -82,7 +83,7 @@
# 'status' can only be 'enable' or 'disable'
hostname = self._get_host_name()
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
hostname,
status='invalid',
@@ -93,7 +94,7 @@
# 'maintenance_mode' can only be 'enable' or 'disable'
hostname = self._get_host_name()
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
hostname,
status='enable',
@@ -104,7 +105,7 @@
# 'status' or 'maintenance_mode' needed for host update
hostname = self._get_host_name()
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_host,
hostname)
@@ -112,7 +113,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 +123,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 +131,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 +139,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 +147,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 +155,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 +163,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.py b/tempest/api/compute/admin/test_instance_usage_audit_log.py
index f7b5e43..16ce93c 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -30,8 +30,7 @@
@test.attr(type='gate')
def test_list_instance_usage_audit_logs(self):
# list instance usage audit logs
- resp, body = self.adm_client.list_instance_usage_audit_logs()
- self.assertEqual(200, resp.status)
+ body = self.adm_client.list_instance_usage_audit_logs()
expected_items = ['total_errors', 'total_instances', 'log',
'num_hosts_running', 'num_hosts_done',
'num_hosts', 'hosts_not_run', 'overall_status',
@@ -44,10 +43,9 @@
def test_get_instance_usage_audit_log(self):
# Get instance usage audit log before specified time
now = datetime.datetime.now()
- resp, body = self.adm_client.get_instance_usage_audit_log(
+ body = self.adm_client.get_instance_usage_audit_log(
urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S")))
- self.assertEqual(200, resp.status)
expected_items = ['total_errors', 'total_instances', 'log',
'num_hosts_running', 'num_hosts_done', 'num_hosts',
'hosts_not_run', 'overall_status', 'period_ending',
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..5453ff4 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,8 +16,9 @@
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,17 +32,17 @@
@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")))
@test.attr(type=['negative', 'gate'])
def test_get_instance_usage_audit_logs_with_invalid_time(self):
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.adm_client.get_instance_usage_audit_log,
"invalid_time")
diff --git a/tempest/api/compute/admin/test_migrations.py b/tempest/api/compute/admin/test_migrations.py
index 7ba05ef..c51ad61 100644
--- a/tempest/api/compute/admin/test_migrations.py
+++ b/tempest/api/compute/admin/test_migrations.py
@@ -31,15 +31,14 @@
@test.attr(type='gate')
def test_list_migrations(self):
# Admin can get the migrations list
- resp, _ = self.client.list_migrations()
- self.assertEqual(200, resp.status)
+ self.client.list_migrations()
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize not available.')
@test.attr(type='gate')
def test_list_migrations_in_flavor_resize_situation(self):
# Admin can get the migrations list which contains the resized server
- resp, server = self.create_test_server(wait_until="ACTIVE")
+ server = self.create_test_server(wait_until="ACTIVE")
server_id = server['id']
resp, _ = self.servers_client.resize(server_id, self.flavor_ref_alt)
@@ -48,8 +47,7 @@
self.servers_client.confirm_resize(server_id)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
- resp, body = self.client.list_migrations()
- self.assertEqual(200, resp.status)
+ body = self.client.list_migrations()
instance_uuids = [x['instance_uuid'] for x in body]
self.assertIn(server_id, instance_uuids)
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index fc70fdb..b0fcf94 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -54,9 +54,8 @@
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.adm_client.get_default_quota_set(
+ quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
- self.assertEqual(200, resp.status)
self.assertEqual(quota_set['id'], self.demo_tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -64,7 +63,7 @@
@test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
- resp, default_quota_set = self.adm_client.get_default_quota_set(
+ default_quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
new_quota_set = {'injected_file_content_bytes': 20480,
'metadata_items': 256, 'injected_files': 10,
@@ -73,7 +72,7 @@
'instances': 20, 'security_group_rules': 20,
'cores': 2, 'security_groups': 20}
# Update limits for all quota resources
- resp, quota_set = self.adm_client.update_quota_set(
+ quota_set = self.adm_client.update_quota_set(
self.demo_tenant_id,
force=True,
**new_quota_set)
@@ -88,7 +87,6 @@
default_quota_set.pop('server_group_members')
self.addCleanup(self.adm_client.update_quota_set,
self.demo_tenant_id, **default_quota_set)
- self.assertEqual(200, resp.status)
for quota in new_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -105,8 +103,7 @@
self.addCleanup(identity_client.delete_tenant, tenant_id)
self.adm_client.update_quota_set(tenant_id, ram='5120')
- resp, quota_set = self.adm_client.get_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
+ quota_set = self.adm_client.get_quota_set(tenant_id)
self.assertEqual(5120, quota_set['ram'])
# Verify that GET shows the updated quota set of user
@@ -123,9 +120,8 @@
self.adm_client.update_quota_set(tenant_id,
user_id=user_id,
ram='2048')
- resp, quota_set = self.adm_client.get_quota_set(tenant_id,
- user_id=user_id)
- self.assertEqual(200, resp.status)
+ quota_set = self.adm_client.get_quota_set(tenant_id,
+ user_id=user_id)
self.assertEqual(2048, quota_set['ram'])
@test.attr(type='gate')
@@ -138,17 +134,14 @@
description=tenant_desc)
tenant_id = tenant['id']
self.addCleanup(identity_client.delete_tenant, tenant_id)
- resp, quota_set_default = self.adm_client.get_quota_set(tenant_id)
+ quota_set_default = self.adm_client.get_quota_set(tenant_id)
ram_default = quota_set_default['ram']
- resp, body = self.adm_client.update_quota_set(tenant_id, ram='5120')
- self.assertEqual(200, resp.status)
+ self.adm_client.update_quota_set(tenant_id, ram='5120')
- resp, body = self.adm_client.delete_quota_set(tenant_id)
- self.assertEqual(202, resp.status)
+ self.adm_client.delete_quota_set(tenant_id)
- resp, quota_set_new = self.adm_client.get_quota_set(tenant_id)
- self.assertEqual(200, resp.status)
+ quota_set_new = self.adm_client.get_quota_set(tenant_id)
self.assertEqual(ram_default, quota_set_new['ram'])
@@ -169,9 +162,8 @@
def _restore_default_quotas(self, original_defaults):
LOG.debug("restoring quota class defaults")
- resp, body = self.adm_client.update_quota_class_set(
+ self.adm_client.update_quota_class_set(
'default', **original_defaults)
- self.assertEqual(200, resp.status)
# NOTE(sdague): this test is problematic as it changes
# global state, and possibly needs to be part of a set of
@@ -179,8 +171,7 @@
# 'danger' flag.
def test_update_default_quotas(self):
LOG.debug("get the current 'default' quota class values")
- resp, body = self.adm_client.get_quota_class_set('default')
- self.assertEqual(200, resp.status)
+ body = self.adm_client.get_quota_class_set('default')
self.assertIn('id', body)
self.assertEqual('default', body.pop('id'))
# restore the defaults when the test is done
@@ -192,9 +183,8 @@
# to a very small number which causes issues.
body[quota] = default + 100
LOG.debug("update limits for the default quota class set")
- resp, update_body = self.adm_client.update_quota_class_set('default',
- **body)
- self.assertEqual(200, resp.status)
+ update_body = self.adm_client.update_quota_class_set('default',
+ **body)
LOG.debug("assert that the response has all of the changed values")
self.assertThat(update_body.items(),
matchers.ContainsAll(body.items()))
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 532f195..2fb7be6 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -12,10 +12,12 @@
# License for the specific language governing permissions and limitations
# 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
@@ -37,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)
@@ -47,23 +49,23 @@
@test.attr(type=['negative', 'gate'])
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_vcpu_quota = quota_set['cores']
vcpu_quota = 0 # Set the quota to zero to conserve resources
- resp, quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- cores=vcpu_quota)
+ quota_set = self.adm_client.update_quota_set(self.demo_tenant_id,
+ force=True,
+ cores=vcpu_quota)
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'])
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_mem_quota = quota_set['ram']
mem_quota = 0 # Set the quota to zero to conserve resources
@@ -73,13 +75,13 @@
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'])
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_instances_quota = quota_set['instances']
instances_quota = 0 # Set quota to zero to disallow server creation
@@ -88,21 +90,21 @@
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)
- @test.skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
@test.attr(type='gate')
@test.services('network')
def test_security_groups_exceed_limit(self):
# Negative test: Creation Security Groups over limit should FAIL
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_sg_quota = quota_set['security_groups']
sg_quota = 0 # Set the quota to zero to conserve resources
- resp, quota_set =\
+ quota_set =\
self.adm_client.update_quota_set(self.demo_tenant_id,
force=True,
security_groups=sg_quota)
@@ -114,23 +116,23 @@
# 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")
- @test.skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1186354",
+ condition=CONF.service_available.neutron)
@test.attr(type=['negative', 'gate'])
@test.services('network')
def test_security_groups_rules_exceed_limit(self):
# Negative test: Creation of Security Group Rules should FAIL
# when we reach limit maxSecurityGroupRules
- resp, quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
+ quota_set = self.adm_client.get_quota_set(self.demo_tenant_id)
default_sg_rules_quota = quota_set['security_group_rules']
sg_rules_quota = 0 # Set the quota to zero to conserve resources
- resp, quota_set =\
+ quota_set =\
self.adm_client.update_quota_set(
self.demo_tenant_id,
force=True,
@@ -142,7 +144,7 @@
s_name = data_utils.rand_name('securitygroup-')
s_description = data_utils.rand_name('description-')
- resp, securitygroup =\
+ securitygroup =\
self.sg_client.create_security_group(s_name, s_description)
self.addCleanup(self.sg_client.delete_security_group,
securitygroup['id'])
@@ -153,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 4c0bd47..a0606cd 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
@@ -30,17 +30,21 @@
@testtools.skipIf(CONF.service_available.neutron,
"Skip as this functionality is not yet "
"implemented in Neutron. Related Bug#1311500")
- def resource_setup(cls):
+ def setup_credentials(cls):
# A network and a subnet will be created for these tests
cls.set_network_resources(network=True, subnet=True)
- super(SecurityGroupDefaultRulesTest, cls).resource_setup()
+ super(SecurityGroupDefaultRulesTest, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(SecurityGroupDefaultRulesTest, cls).setup_clients()
cls.adm_client = cls.os_adm.security_group_default_rules_client
def _create_security_group_default_rules(self, ip_protocol='tcp',
from_port=22, to_port=22,
cidr='10.10.0.0/24'):
# Create Security Group default rule
- _, rule = self.adm_client.create_security_default_group_rule(
+ rule = self.adm_client.create_security_default_group_rule(
ip_protocol,
from_port,
to_port,
@@ -59,7 +63,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'])
@@ -68,7 +72,7 @@
ip_protocol = 'udp'
from_port = 80
to_port = 80
- _, rule = self.adm_client.create_security_default_group_rule(
+ rule = self.adm_client.create_security_default_group_rule(
ip_protocol,
from_port,
to_port)
@@ -83,7 +87,7 @@
from_port = 10
to_port = 10
cidr = ''
- _, rule = self.adm_client.create_security_default_group_rule(
+ rule = self.adm_client.create_security_default_group_rule(
ip_protocol,
from_port,
to_port,
@@ -105,7 +109,7 @@
cidr)
self.addCleanup(self.adm_client.delete_security_group_default_rule,
rule['id'])
- _, rules = self.adm_client.list_security_group_default_rules()
+ rules = self.adm_client.list_security_group_default_rules()
self.assertNotEqual(0, len(rules))
self.assertIn(rule, rules)
@@ -121,6 +125,6 @@
cidr)
self.addCleanup(self.adm_client.delete_security_group_default_rule,
rule['id'])
- _, fetched_rule = self.adm_client.get_security_group_default_rule(
+ fetched_rule = self.adm_client.get_security_group_default_rule(
rule['id'])
self.assertEqual(rule, fetched_rule)
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index b4615f2..82cb26e 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -33,11 +33,9 @@
def _delete_security_group(self, securitygroup_id, admin=True):
if admin:
- resp, _ = self.adm_client.delete_security_group(securitygroup_id)
+ self.adm_client.delete_security_group(securitygroup_id)
else:
- resp, _ = self.client.delete_security_group(securitygroup_id)
-
- self.assertEqual(202, resp.status)
+ self.client.delete_security_group(securitygroup_id)
@testtools.skipIf(CONF.service_available.neutron,
"Skipped because neutron do not support all_tenants"
@@ -52,9 +50,8 @@
for i in range(2):
name = data_utils.rand_name('securitygroup-')
description = data_utils.rand_name('description-')
- resp, securitygroup = (self.client
- .create_security_group(name, description))
- self.assertEqual(200, resp.status)
+ securitygroup = (self.client
+ .create_security_group(name, description))
self.addCleanup(self._delete_security_group,
securitygroup['id'], admin=False)
security_group_list.append(securitygroup)
@@ -64,18 +61,16 @@
for i in range(2):
name = data_utils.rand_name('securitygroup-')
description = data_utils.rand_name('description-')
- resp, adm_securitygroup = (self.adm_client
- .create_security_group(name,
- description))
- self.assertEqual(200, resp.status)
+ adm_securitygroup = (self.adm_client
+ .create_security_group(name,
+ description))
self.addCleanup(self._delete_security_group,
adm_securitygroup['id'])
security_group_list.append(adm_securitygroup)
# Fetch all security groups based on 'all_tenants' search filter
param = {'all_tenants': 'true'}
- resp, fetched_list = self.adm_client.list_security_groups(params=param)
- self.assertEqual(200, resp.status)
+ fetched_list = self.adm_client.list_security_groups(params=param)
sec_group_id_list = map(lambda sg: sg['id'], fetched_list)
# Now check if all created Security Groups are present in fetched list
for sec_group in security_group_list:
@@ -83,8 +78,7 @@
# Fetch all security groups for non-admin user with 'all_tenants'
# search filter
- resp, fetched_list = self.client.list_security_groups(params=param)
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_security_groups(params=param)
# Now check if all created Security Groups are present in fetched list
for sec_group in fetched_list:
self.assertEqual(sec_group['tenant_id'], client_tenant_id,
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 5210077..6110b89 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import test
@@ -33,13 +35,13 @@
cls.flavors_client = cls.os_adm.flavors_client
cls.s1_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
+ server = cls.create_test_server(name=cls.s1_name,
+ wait_until='ACTIVE')
cls.s1_id = server['id']
cls.s2_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s2_name,
- wait_until='ACTIVE')
+ server = cls.create_test_server(name=cls.s2_name,
+ wait_until='ACTIVE')
cls.s2_id = server['id']
@test.attr(type='gate')
@@ -59,7 +61,7 @@
# Reset server's state to 'active'
resp, server = self.client.reset_state(self.s1_id, state='active')
# Verify server's state
- resp, server = self.client.get_server(self.s1_id)
+ server = self.client.get_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
servers = body['servers']
# Verify error server in list result
@@ -102,12 +104,10 @@
name = data_utils.rand_name('server')
flavor = self.flavor_ref
image_id = self.image_ref
- resp, test_server = self.client.create_server(
- name, image_id, flavor)
- self.assertEqual('202', resp['status'])
+ test_server = self.client.create_server(name, image_id, flavor)
self.addCleanup(self.client.delete_server, test_server['id'])
self.client.wait_for_server_status(test_server['id'], 'ACTIVE')
- resp, server = self.client.get_server(test_server['id'])
+ server = self.client.get_server(test_server['id'])
self.assertEqual(server['status'], 'ACTIVE')
hostname = server[self._host_key]
params = {'host': hostname}
@@ -130,7 +130,7 @@
self.assertEqual(202, resp.status)
# Verify server's state
- resp, server = self.client.get_server(self.s1_id)
+ server = self.client.get_server(self.s1_id)
self.assertEqual(server['status'], 'ERROR')
# Reset server's state to 'active'
@@ -138,11 +138,11 @@
self.assertEqual(202, resp.status)
# Verify server's state
- resp, server = self.client.get_server(self.s1_id)
+ server = self.client.get_server(self.s1_id)
self.assertEqual(server['status'], 'ACTIVE')
@test.attr(type='gate')
- @test.skip_because(bug="1240043")
+ @decorators.skip_because(bug="1240043")
def test_get_server_diagnostics_by_admin(self):
# Retrieve server diagnostics by admin user
resp, diagnostic = self.client.get_server_diagnostics(self.s1_id)
@@ -177,14 +177,14 @@
'ACTIVE',
raise_on_error=False)
# Verify the server properties after rebuilding
- resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
+ server = self.non_admin_client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(self.image_ref_alt, rebuilt_image_id)
@test.attr(type='gate')
def test_reset_network_inject_network_info(self):
# Reset Network of a Server
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, server_body = self.client.reset_network(server['id'])
self.assertEqual(202, resp.status)
# Inject the Network Info into Server
@@ -197,6 +197,5 @@
hints = {
'same_host': self.s1_id
}
- resp, server = self.create_test_server(sched_hints=hints,
- wait_until='ACTIVE')
- self.assertEqual('202', resp['status'])
+ self.create_test_server(sched_hints=hints,
+ wait_until='ACTIVE')
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 2f0af72..7fd87f6 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -14,13 +14,13 @@
import uuid
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -41,16 +41,16 @@
cls.tenant_id = cls.client.tenant_id
cls.s1_name = data_utils.rand_name('server')
- resp, server = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
+ server = cls.create_test_server(name=cls.s1_name,
+ wait_until='ACTIVE')
cls.s1_id = server['id']
def _get_unused_flavor_id(self):
flavor_id = data_utils.rand_int_id(start=1000)
while True:
try:
- resp, body = self.flavors_client.get_flavor_details(flavor_id)
- except exceptions.NotFound:
+ self.flavors_client.get_flavor_details(flavor_id)
+ except lib_exc.NotFound:
break
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
@@ -63,16 +63,15 @@
self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
- resp, quota_set = self.quotas_client.get_default_quota_set(
- self.tenant_id)
+ quota_set = self.quotas_client.get_default_quota_set(self.tenant_id)
ram = int(quota_set['ram']) + 1
vcpus = 8
disk = 10
- resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
- ram, vcpus, disk,
- flavor_id)
+ flavor_ref = self.flavors_client.create_flavor(flavor_name,
+ 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'])
@@ -86,47 +85,46 @@
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
ram = 512
- resp, quota_set = self.quotas_client.get_default_quota_set(
- self.tenant_id)
+ quota_set = self.quotas_client.get_default_quota_set(self.tenant_id)
vcpus = int(quota_set['cores']) + 1
disk = 10
- resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
- ram, vcpus, disk,
- flavor_id)
+ flavor_ref = self.flavors_client.create_flavor(flavor_name,
+ 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'])
@test.attr(type=['negative', 'gate'])
def test_reset_state_server_invalid_state(self):
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.reset_state, self.s1_id,
state='invalid')
@test.attr(type=['negative', 'gate'])
def test_reset_state_server_invalid_type(self):
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.reset_state, self.s1_id,
state=1)
@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()))
@@ -137,14 +135,13 @@
@test.attr(type=['negative', 'gate'])
def test_migrate_server_invalid_state(self):
# create server.
- resp, server = self.create_test_server(wait_until='ACTIVE')
- self.assertEqual(202, resp.status)
+ server = self.create_test_server(wait_until='ACTIVE')
server_id = server['id']
# suspend the server.
resp, _ = self.client.suspend_server(server_id)
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.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index f6553b3..6775d1f 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -30,7 +30,7 @@
cls.tenant_id = cls.client.tenant_id
# Create a server in the demo tenant
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.create_test_server(wait_until='ACTIVE')
time.sleep(2)
now = datetime.datetime.now()
@@ -48,8 +48,7 @@
params = {'start': self.start,
'end': self.end,
'detailed': int(bool(True))}
- resp, tenant_usage = self.adm_client.list_tenant_usages(params)
- self.assertEqual(200, resp.status)
+ tenant_usage = self.adm_client.list_tenant_usages(params)
self.assertEqual(len(tenant_usage), 8)
@test.attr(type='gate')
@@ -57,10 +56,9 @@
# Get usage for a specific tenant
params = {'start': self.start,
'end': self.end}
- resp, tenant_usage = self.adm_client.get_tenant_usage(
+ tenant_usage = self.adm_client.get_tenant_usage(
self.tenant_id, params)
- self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
@test.attr(type='gate')
@@ -68,8 +66,7 @@
# Get usage for a specific tenant with non admin user
params = {'start': self.start,
'end': self.end}
- resp, tenant_usage = self.client.get_tenant_usage(
+ tenant_usage = self.client.get_tenant_usage(
self.tenant_id, params)
- self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
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..0d88f6c 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -14,9 +14,9 @@
# under the License.
import datetime
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -42,7 +42,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)
@@ -51,7 +51,7 @@
# Get usage for tenant with invalid date
params = {'start': self.end,
'end': self.start}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.adm_client.get_tenant_usage,
self.client.tenant_id, params)
@@ -61,5 +61,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 c245eb4..c448975 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -13,9 +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 import clients
+from tempest.common import credentials
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -35,15 +37,60 @@
force_tenant_isolation = False
@classmethod
- def resource_setup(cls):
- cls.set_network_resources()
- super(BaseComputeTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(BaseComputeTest, cls).skip_checks()
+ if cls._api_version != 2:
+ msg = ("Unexpected API version is specified (%s)" %
+ cls._api_version)
+ raise exceptions.InvalidConfiguration(message=msg)
+ @classmethod
+ def setup_credentials(cls):
+ cls.set_network_resources()
+ super(BaseComputeTest, cls).setup_credentials()
# TODO(andreaf) WE should care also for the alt_manager here
# but only once client lazy load in the manager is done
cls.os = cls.get_client_manager()
+ # Note that we put this here and not in skip_checks because in
+ # the case of preprovisioned users we won't know if we can get
+ # two distinct users until we go and lock them
cls.multi_user = cls.check_multi_user()
+ @classmethod
+ def setup_clients(cls):
+ super(BaseComputeTest, cls).setup_clients()
+ cls.servers_client = cls.os.servers_client
+ cls.flavors_client = cls.os.flavors_client
+ cls.images_client = cls.os.images_client
+ cls.extensions_client = cls.os.extensions_client
+ cls.floating_ips_client = cls.os.floating_ips_client
+ cls.keypairs_client = cls.os.keypairs_client
+ cls.security_groups_client = cls.os.security_groups_client
+ cls.quotas_client = cls.os.quotas_client
+ # NOTE(mriedem): os-quota-class-sets is v2 API only
+ cls.quota_classes_client = cls.os.quota_classes_client
+ # NOTE(mriedem): os-networks is v2 API only
+ cls.networks_client = cls.os.networks_client
+ cls.limits_client = cls.os.limits_client
+ cls.volumes_extensions_client = cls.os.volumes_extensions_client
+ cls.volumes_client = cls.os.volumes_client
+ cls.interfaces_client = cls.os.interfaces_client
+ cls.fixed_ips_client = cls.os.fixed_ips_client
+ cls.availability_zone_client = cls.os.availability_zone_client
+ cls.agents_client = cls.os.agents_client
+ cls.aggregates_client = cls.os.aggregates_client
+ cls.services_client = cls.os.services_client
+ cls.instance_usages_audit_log_client = (
+ cls.os.instance_usages_audit_log_client)
+ cls.hypervisor_client = cls.os.hypervisor_client
+ cls.certificates_client = cls.os.certificates_client
+ cls.migrations_client = cls.os.migrations_client
+ cls.security_group_default_rules_client = (
+ cls.os.security_group_default_rules_client)
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseComputeTest, cls).resource_setup()
cls.build_interval = CONF.compute.build_interval
cls.build_timeout = CONF.compute.build_timeout
cls.ssh_user = CONF.compute.ssh_user
@@ -58,39 +105,13 @@
cls.security_groups = []
cls.server_groups = []
- if cls._api_version == 2:
- cls.servers_client = cls.os.servers_client
- cls.flavors_client = cls.os.flavors_client
- cls.images_client = cls.os.images_client
- cls.extensions_client = cls.os.extensions_client
- cls.floating_ips_client = cls.os.floating_ips_client
- cls.keypairs_client = cls.os.keypairs_client
- cls.security_groups_client = cls.os.security_groups_client
- cls.quotas_client = cls.os.quotas_client
- # NOTE(mriedem): os-quota-class-sets is v2 API only
- cls.quota_classes_client = cls.os.quota_classes_client
- # NOTE(mriedem): os-networks is v2 API only
- cls.networks_client = cls.os.networks_client
- cls.limits_client = cls.os.limits_client
- cls.volumes_extensions_client = cls.os.volumes_extensions_client
- cls.volumes_client = cls.os.volumes_client
- cls.interfaces_client = cls.os.interfaces_client
- cls.fixed_ips_client = cls.os.fixed_ips_client
- cls.availability_zone_client = cls.os.availability_zone_client
- cls.agents_client = cls.os.agents_client
- cls.aggregates_client = cls.os.aggregates_client
- cls.services_client = cls.os.services_client
- cls.instance_usages_audit_log_client = \
- cls.os.instance_usages_audit_log_client
- cls.hypervisor_client = cls.os.hypervisor_client
- cls.certificates_client = cls.os.certificates_client
- cls.migrations_client = cls.os.migrations_client
- cls.security_group_default_rules_client = (
- cls.os.security_group_default_rules_client)
- else:
- msg = ("Unexpected API version is specified (%s)" %
- cls._api_version)
- raise exceptions.InvalidConfiguration(message=msg)
+ @classmethod
+ def resource_cleanup(cls):
+ cls.clear_images()
+ cls.clear_servers()
+ cls.clear_security_groups()
+ cls.clear_server_groups()
+ super(BaseComputeTest, cls).resource_cleanup()
@classmethod
def check_multi_user(cls):
@@ -107,7 +128,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 +168,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:
@@ -159,9 +180,8 @@
str(sg['id']) for sg in cls.security_groups))
for sg in cls.security_groups:
try:
- resp, body =\
- cls.security_groups_client.delete_security_group(sg['id'])
- except exceptions.NotFound:
+ cls.security_groups_client.delete_security_group(sg['id'])
+ except lib_exc.NotFound:
# The security group may have already been deleted which is OK.
pass
except Exception as exc:
@@ -175,7 +195,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:
@@ -183,14 +203,6 @@
server_group_id)
@classmethod
- def resource_cleanup(cls):
- cls.clear_images()
- cls.clear_servers()
- cls.clear_security_groups()
- cls.clear_server_groups()
- super(BaseComputeTest, cls).resource_cleanup()
-
- @classmethod
def create_test_server(cls, **kwargs):
"""Wrapper utility that returns a test server."""
name = data_utils.rand_name(cls.__name__ + "-instance")
@@ -199,7 +211,7 @@
flavor = kwargs.get('flavor', cls.flavor_ref)
image_id = kwargs.get('image_id', cls.image_ref)
- resp, body = cls.servers_client.create_server(
+ body = cls.servers_client.create_server(
name, image_id, flavor, **kwargs)
# handle the case of multiple servers
@@ -227,7 +239,7 @@
cls.servers.extend(servers)
- return resp, body
+ return body
@classmethod
def create_security_group(cls, name=None, description=None):
@@ -235,12 +247,12 @@
name = data_utils.rand_name(cls.__name__ + "-securitygroup")
if description is None:
description = data_utils.rand_name('description-')
- resp, body = \
+ body = \
cls.security_groups_client.create_security_group(name,
description)
cls.security_groups.append(body)
- return resp, body
+ return body
@classmethod
def create_test_server_group(cls, name="", policy=None):
@@ -275,7 +287,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)
@@ -317,7 +329,7 @@
cls.servers_client.wait_for_server_termination(server_id)
except Exception:
LOG.exception('Failed to delete server %s' % server_id)
- resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
+ server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
cls.password = server['adminPass']
return server['id']
@@ -329,24 +341,27 @@
class BaseV2ComputeTest(BaseComputeTest):
_api_version = 2
- _interface = "json"
class BaseComputeAdminTest(BaseComputeTest):
"""Base test case class for Compute Admin API tests."""
- _interface = "json"
@classmethod
- def resource_setup(cls):
- super(BaseComputeAdminTest, cls).resource_setup()
- try:
- creds = cls.isolated_creds.get_admin_creds()
- cls.os_adm = clients.Manager(
- credentials=creds, interface=cls._interface)
- except NotImplementedError:
- msg = ("Missing Compute Admin API credentials in configuration.")
+ def skip_checks(cls):
+ if not credentials.is_admin_available():
+ msg = ("Missing Identity Admin API credentials in configuration.")
raise cls.skipException(msg)
+ super(BaseComputeAdminTest, cls).skip_checks()
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseComputeAdminTest, cls).setup_credentials()
+ creds = cls.isolated_creds.get_admin_creds()
+ cls.os_adm = clients.Manager(credentials=creds)
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseComputeAdminTest, cls).setup_clients()
cls.availability_zone_admin_client = (
cls.os_adm.availability_zone_client)
diff --git a/tempest/api/compute/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 15ccf53..321a0a1 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -24,14 +24,13 @@
@test.attr(type='gate')
def test_create_root_certificate(self):
# create certificates
- resp, body = self.certificates_client.create_certificate()
+ body = self.certificates_client.create_certificate()
self.assertIn('data', body)
self.assertIn('private_key', body)
@test.attr(type='gate')
def test_get_root_certificate(self):
# get the root certificate
- resp, body = self.certificates_client.get_certificate('root')
- self.assertEqual(200, resp.status)
+ body = self.certificates_client.get_certificate('root')
self.assertIn('data', body)
self.assertIn('private_key', body)
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 992f86a..c91ce17 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -31,8 +31,8 @@
@test.attr(type='smoke')
def test_list_flavors(self):
# List of all flavors should contain the expected flavor
- resp, flavors = self.client.list_flavors()
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavors = self.client.list_flavors()
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_min_detail = {'id': flavor['id'], 'links': flavor['links'],
'name': flavor['name']}
self.assertIn(flavor_min_detail, flavors)
@@ -40,88 +40,88 @@
@test.attr(type='smoke')
def test_list_flavors_with_detail(self):
# Detailed list of all flavors should contain the expected flavor
- resp, flavors = self.client.list_flavors_with_detail()
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavors = self.client.list_flavors_with_detail()
+ flavor = self.client.get_flavor_details(self.flavor_ref)
self.assertIn(flavor, flavors)
@test.attr(type='smoke')
def test_get_flavor(self):
# The expected flavor details should be returned
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
self.assertEqual(self.flavor_ref, flavor['id'])
@test.attr(type='gate')
def test_list_flavors_limit_results(self):
# Only the expected number of flavors should be returned
params = {'limit': 1}
- resp, flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(params)
self.assertEqual(1, len(flavors))
@test.attr(type='gate')
def test_list_flavors_detailed_limit_results(self):
# Only the expected number of flavors (detailed) should be returned
params = {'limit': 1}
- resp, flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors_with_detail(params)
self.assertEqual(1, len(flavors))
@test.attr(type='gate')
def test_list_flavors_using_marker(self):
# The list of flavors should start from the provided marker
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {'marker': flavor_id}
- resp, flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
@test.attr(type='gate')
def test_list_flavors_detailed_using_marker(self):
# The list of flavors should start from the provided marker
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {'marker': flavor_id}
- resp, flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors_with_detail(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
'The list of flavors did not start after the marker.')
@test.attr(type='gate')
def test_list_flavors_detailed_filter_by_min_disk(self):
# The detailed list of flavors should be filtered by disk space
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_disk: flavor['disk'] + 1}
- resp, flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors_with_detail(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.attr(type='gate')
def test_list_flavors_detailed_filter_by_min_ram(self):
# The detailed list of flavors should be filtered by RAM
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_ram: flavor['ram'] + 1}
- resp, flavors = self.client.list_flavors_with_detail(params)
+ flavors = self.client.list_flavors_with_detail(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.attr(type='gate')
def test_list_flavors_filter_by_min_disk(self):
# The list of flavors should be filtered by disk space
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_disk: flavor['disk'] + 1}
- resp, flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
@test.attr(type='gate')
def test_list_flavors_filter_by_min_ram(self):
# The list of flavors should be filtered by RAM
- resp, flavor = self.client.get_flavor_details(self.flavor_ref)
+ flavor = self.client.get_flavor_details(self.flavor_ref)
flavor_id = flavor['id']
params = {self._min_ram: flavor['ram'] + 1}
- resp, flavors = self.client.list_flavors(params)
+ flavors = self.client.list_flavors(params)
self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py
index 19b6a50..142eaec 100644
--- a/tempest/api/compute/floating_ips/base.py
+++ b/tempest/api/compute/floating_ips/base.py
@@ -19,8 +19,8 @@
class BaseFloatingIPsTest(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
# Floating IP actions might need a full network configuration
cls.set_network_resources(network=True, subnet=True,
router=True, dhcp=True)
- super(BaseFloatingIPsTest, cls).resource_setup()
+ super(BaseFloatingIPsTest, cls).setup_credentials()
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..46a6ddb 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
@@ -26,16 +25,20 @@
floating_ip = None
@classmethod
+ def setup_clients(cls):
+ super(FloatingIPsTestJSON, cls).setup_clients()
+ cls.client = cls.floating_ips_client
+
+ @classmethod
def resource_setup(cls):
super(FloatingIPsTestJSON, cls).resource_setup()
- cls.client = cls.floating_ips_client
cls.floating_ip_id = None
# Server creation
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
# Floating IP creation
- resp, body = cls.client.create_floating_ip()
+ body = cls.client.create_floating_ip()
cls.floating_ip_id = body['id']
cls.floating_ip = body['ip']
@@ -43,7 +46,7 @@
def resource_cleanup(cls):
# Deleting the floating IP which is created in this method
if cls.floating_ip_id:
- resp, body = cls.client.delete_floating_ip(cls.floating_ip_id)
+ cls.client.delete_floating_ip(cls.floating_ip_id)
super(FloatingIPsTestJSON, cls).resource_cleanup()
def _try_delete_floating_ip(self, floating_ip_id):
@@ -51,7 +54,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')
@@ -59,15 +62,14 @@
def test_allocate_floating_ip(self):
# Positive test:Allocation of a new floating IP to a project
# should be successful
- resp, body = self.client.create_floating_ip()
+ body = self.client.create_floating_ip()
floating_ip_id_allocated = body['id']
self.addCleanup(self.client.delete_floating_ip,
floating_ip_id_allocated)
- self.assertEqual(200, resp.status)
- resp, floating_ip_details = \
+ floating_ip_details = \
self.client.get_floating_ip_details(floating_ip_id_allocated)
# Checking if the details of allocated IP is in list of floating IP
- resp, body = self.client.list_floating_ips()
+ body = self.client.list_floating_ips()
self.assertIn(floating_ip_details, body)
@test.attr(type='gate')
@@ -76,14 +78,10 @@
# Positive test:Deletion of valid floating IP from project
# should be successful
# Creating the floating IP that is to be deleted in this method
- resp, floating_ip_body = self.client.create_floating_ip()
+ floating_ip_body = self.client.create_floating_ip()
self.addCleanup(self._try_delete_floating_ip, floating_ip_body['id'])
- # Storing the details of floating IP before deleting it
- cli_resp = self.client.get_floating_ip_details(floating_ip_body['id'])
- resp, floating_ip_details = cli_resp
# Deleting the floating IP from the project
- resp, body = self.client.delete_floating_ip(floating_ip_body['id'])
- self.assertEqual(202, resp.status)
+ self.client.delete_floating_ip(floating_ip_body['id'])
# Check it was really deleted.
self.client.wait_for_resource_deletion(floating_ip_body['id'])
@@ -94,20 +92,18 @@
# to a specific server should be successful
# Association of floating IP to fixed IP address
- resp, body = self.client.associate_floating_ip_to_server(
+ self.client.associate_floating_ip_to_server(
self.floating_ip,
self.server_id)
- self.assertEqual(202, resp.status)
# Check instance_id in the floating_ip body
- resp, body = self.client.get_floating_ip_details(self.floating_ip_id)
+ body = self.client.get_floating_ip_details(self.floating_ip_id)
self.assertEqual(self.server_id, body['instance_id'])
# Disassociation of floating IP that was associated in this method
- resp, body = self.client.disassociate_floating_ip_from_server(
+ self.client.disassociate_floating_ip_from_server(
self.floating_ip,
self.server_id)
- self.assertEqual(202, resp.status)
@test.attr(type='gate')
@test.services('network')
@@ -116,28 +112,27 @@
# to specific server should change the association of the Floating IP
# Create server so as to use for Multiple association
new_name = data_utils.rand_name('floating_server')
- resp, body = self.create_test_server(name=new_name)
+ body = self.create_test_server(name=new_name)
self.servers_client.wait_for_server_status(body['id'], 'ACTIVE')
self.new_server_id = body['id']
+ self.addCleanup(self.servers_client.delete_server, self.new_server_id)
# Associating floating IP for the first time
- resp, _ = self.client.associate_floating_ip_to_server(
+ self.client.associate_floating_ip_to_server(
self.floating_ip,
self.server_id)
# Associating floating IP for the second time
- resp, body = self.client.associate_floating_ip_to_server(
+ self.client.associate_floating_ip_to_server(
self.floating_ip,
self.new_server_id)
- self.addCleanup(self.servers_client.delete_server, self.new_server_id)
- if (resp['status'] is not None):
- self.addCleanup(self.client.disassociate_floating_ip_from_server,
- self.floating_ip,
- self.new_server_id)
+ self.addCleanup(self.client.disassociate_floating_ip_from_server,
+ self.floating_ip,
+ 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..fa3fa16 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,10 +15,11 @@
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
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -28,16 +29,20 @@
server_id = None
@classmethod
- def resource_setup(cls):
- super(FloatingIPsNegativeTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(FloatingIPsNegativeTestJSON, cls).setup_clients()
cls.client = cls.floating_ips_client
+ @classmethod
+ def resource_setup(cls):
+ super(FloatingIPsNegativeTestJSON, cls).resource_setup()
+
# Server creation
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
# Generating a nonexistent floatingIP id
cls.floating_ip_ids = []
- resp, body = cls.client.list_floating_ips()
+ body = cls.client.list_floating_ips()
for i in range(len(body)):
cls.floating_ip_ids.append(body[i]['id'])
while True:
@@ -52,7 +57,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 +68,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 +77,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 +86,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 +95,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, lib_exc.BadRequest),
self.client.associate_floating_ip_to_server,
'', self.server_id)
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index 7af9ca7..25f13fc 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -20,13 +20,17 @@
class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
@classmethod
+ def setup_clients(cls):
+ super(FloatingIPDetailsTestJSON, cls).setup_clients()
+ cls.client = cls.floating_ips_client
+
+ @classmethod
def resource_setup(cls):
super(FloatingIPDetailsTestJSON, cls).resource_setup()
- cls.client = cls.floating_ips_client
cls.floating_ip = []
cls.floating_ip_id = []
for i in range(3):
- resp, body = cls.client.create_floating_ip()
+ body = cls.client.create_floating_ip()
cls.floating_ip.append(body)
cls.floating_ip_id.append(body['id'])
@@ -40,8 +44,7 @@
@test.services('network')
def test_list_floating_ips(self):
# Positive test:Should return the list of floating IPs
- resp, body = self.client.list_floating_ips()
- self.assertEqual(200, resp.status)
+ body = self.client.list_floating_ips()
floating_ips = body
self.assertNotEqual(0, len(floating_ips),
"Expected floating IPs. Got zero.")
@@ -53,16 +56,14 @@
def test_get_floating_ip_details(self):
# Positive test:Should be able to GET the details of floatingIP
# Creating a floating IP for which details are to be checked
- resp, body = self.client.create_floating_ip()
+ body = self.client.create_floating_ip()
floating_ip_id = body['id']
self.addCleanup(self.client.delete_floating_ip,
floating_ip_id)
floating_ip_instance_id = body['instance_id']
floating_ip_ip = body['ip']
floating_ip_fixed_ip = body['fixed_ip']
- resp, body = \
- self.client.get_floating_ip_details(floating_ip_id)
- self.assertEqual(200, resp.status)
+ body = self.client.get_floating_ip_details(floating_ip_id)
# Comparing the details of floating IP
self.assertEqual(floating_ip_instance_id,
body['instance_id'])
@@ -75,7 +76,6 @@
@test.services('network')
def test_list_floating_ip_pools(self):
# Positive test:Should return the list of floating IP Pools
- resp, floating_ip_pools = self.client.list_floating_ip_pools()
- self.assertEqual(200, resp.status)
+ floating_ip_pools = self.client.list_floating_ip_pools()
self.assertNotEqual(0, len(floating_ip_pools),
"Expected floating IP Pools. Got zero.")
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..d1d3517 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
@@ -27,8 +28,8 @@
class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
- super(FloatingIPDetailsNegativeTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(FloatingIPDetailsNegativeTestJSON, cls).setup_clients()
cls.client = cls.floating_ips_client
@test.attr(type=['negative', 'gate'])
@@ -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.py b/tempest/api/compute/images/test_images.py
index dc27a70..2508fe1 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -40,7 +40,7 @@
@test.attr(type='gate')
def test_delete_saving_image(self):
snapshot_name = data_utils.rand_name('test-snap-')
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
self.addCleanup(self.servers_client.delete_server, server['id'])
image = self.create_image_from_server(server['id'],
name=snapshot_name,
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 58fc20d..55184d9 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
@@ -41,7 +42,7 @@
@test.attr(type=['negative', 'gate'])
def test_create_image_from_deleted_server(self):
# An image should not be created if the server instance is removed
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
# Delete server before trying to create server
self.servers_client.delete_server(server['id'])
@@ -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,12 +62,12 @@
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'])
def test_create_image_from_stopped_server(self):
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
self.servers_client.stop(server['id'])
self.servers_client.wait_for_server_status(server['id'],
'SHUTOFF')
@@ -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.py b/tempest/api/compute/images/test_images_oneserver.py
index 6156c5a..12aa886 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -59,11 +59,11 @@
% cls.__name__)
raise cls.skipException(skip_msg)
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
def _get_default_flavor_disk_size(self, flavor_id):
- resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
+ flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
@test.attr(type='smoke')
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 46cec9b..7f15ad1 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_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.compute 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
@@ -67,7 +68,7 @@
% cls.__name__)
raise cls.skipException(skip_msg)
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
cls.image_ids = []
@@ -77,7 +78,7 @@
# Return an error when creating image with invalid metadata
snapshot_name = data_utils.rand_name('test-snap-')
meta = {'': ''}
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
self.server_id, snapshot_name, meta)
@test.attr(type=['negative', 'gate'])
@@ -85,7 +86,7 @@
# Return an error when creating image with meta data over 256 chars
snapshot_name = data_utils.rand_name('test-snap-')
meta = {'a' * 260: 'b' * 260}
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
self.server_id, snapshot_name, meta)
@test.attr(type=['negative', 'gate'])
@@ -102,7 +103,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'])
@@ -110,7 +111,7 @@
# Return an error if snapshot name over 256 characters is passed
snapshot_name = data_utils.rand_name('a' * 260)
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
self.server_id, snapshot_name)
@test.attr(type=['negative', 'gate'])
@@ -127,4 +128,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.py b/tempest/api/compute/images/test_list_image_filters.py
index 742c2dd..a2e5f56 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -69,8 +69,8 @@
return
# Create instances and snapshots via nova
- resp, cls.server1 = cls.create_test_server()
- resp, cls.server2 = cls.create_test_server(wait_until='ACTIVE')
+ cls.server1 = cls.create_test_server()
+ cls.server2 = cls.create_test_server(wait_until='ACTIVE')
# NOTE(sdague) this is faster than doing the sync wait_util on both
cls.servers_client.wait_for_server_status(cls.server1['id'],
'ACTIVE')
@@ -172,8 +172,6 @@
# Verify only the expected number of results are returned
params = {'limit': '1'}
images = self.client.list_images(params)
- # when _interface='xml', one element for images_links in images
- # ref: Question #224349
self.assertEqual(1, len([x for x in images if 'id' in x]))
@test.attr(type='gate')
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.py b/tempest/api/compute/keypairs/test_keypairs.py
index ce10fbe..d7884ab 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -28,12 +28,12 @@
cls.client = cls.keypairs_client
def _delete_keypair(self, keypair_name):
- resp, _ = self.client.delete_keypair(keypair_name)
+ self.client.delete_keypair(keypair_name)
def _create_keypair(self, keypair_name, pub_key=None):
- resp, body = self.client.create_keypair(keypair_name, pub_key)
+ body = self.client.create_keypair(keypair_name, pub_key)
self.addCleanup(self._delete_keypair, keypair_name)
- return resp, body
+ return body
@test.attr(type='gate')
def test_keypairs_create_list_delete(self):
@@ -42,7 +42,7 @@
key_list = list()
for i in range(3):
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self._create_keypair(k_name)
+ keypair = self._create_keypair(k_name)
# Need to pop these keys so that our compare doesn't fail later,
# as the keypair dicts from list API doesn't have them.
keypair.pop('private_key')
@@ -50,8 +50,7 @@
key_list.append(keypair)
# Fetch all keypairs and verify the list
# has all created keypairs
- resp, fetched_list = self.client.list_keypairs()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_keypairs()
# We need to remove the extra 'keypair' element in the
# returned dict. See comment in keypairs_client.list_keypairs()
new_list = list()
@@ -68,7 +67,7 @@
def test_keypair_create_delete(self):
# Keypair should be created, verified and deleted
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self._create_keypair(k_name)
+ keypair = self._create_keypair(k_name)
private_key = keypair['private_key']
key_name = keypair['name']
self.assertEqual(key_name, k_name,
@@ -81,9 +80,8 @@
def test_get_keypair_detail(self):
# Keypair should be created, Got details by name and deleted
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self._create_keypair(k_name)
- resp, keypair_detail = self.client.get_keypair(k_name)
- self.assertEqual(200, resp.status)
+ self._create_keypair(k_name)
+ keypair_detail = self.client.get_keypair(k_name)
self.assertIn('name', keypair_detail)
self.assertIn('public_key', keypair_detail)
self.assertEqual(keypair_detail['name'], k_name,
@@ -106,7 +104,7 @@
"LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
"XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
"snSA8wzBx3A/8y9Pp1B nova@ubuntu")
- resp, keypair = self._create_keypair(k_name, pub_key)
+ keypair = self._create_keypair(k_name, pub_key)
self.assertFalse('private_key' in keypair,
"Field private_key is not empty!")
key_name = keypair['name']
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 2cc6f00..ea25527 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_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.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -36,14 +37,14 @@
# Keypair should not be created with a non RSA public key
k_name = data_utils.rand_name('keypair-')
pub_key = "ssh-rsa JUNK nova@ubuntu"
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self._create_keypair, k_name, pub_key)
@test.attr(type=['negative', 'gate'])
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'])
@@ -51,7 +52,7 @@
# Keypair should not be created with an empty public key
k_name = data_utils.rand_name("keypair-")
pub_key = ' '
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ self.assertRaises(lib_exc.BadRequest, self._create_keypair,
k_name, pub_key)
@test.attr(type=['negative', 'gate'])
@@ -59,37 +60,35 @@
# Keypair should not be created when public key bits are too long
k_name = data_utils.rand_name("keypair-")
pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ self.assertRaises(lib_exc.BadRequest, self._create_keypair,
k_name, pub_key)
@test.attr(type=['negative', 'gate'])
def test_create_keypair_with_duplicate_name(self):
# Keypairs with duplicate names should not be created
k_name = data_utils.rand_name('keypair-')
- resp, _ = self.client.create_keypair(k_name)
- self.assertEqual(200, resp.status)
+ 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)
- resp, _ = self.client.delete_keypair(k_name)
- self.assertEqual(202, resp.status)
+ self.client.delete_keypair(k_name)
@test.attr(type=['negative', 'gate'])
def test_create_keypair_with_empty_name_string(self):
# Keypairs with name being an empty string should not be created
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ self.assertRaises(lib_exc.BadRequest, self._create_keypair,
'')
@test.attr(type=['negative', 'gate'])
def test_create_keypair_with_long_keynames(self):
# Keypairs with name longer than 255 chars should not be created
k_name = 'keypair-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ self.assertRaises(lib_exc.BadRequest, self._create_keypair,
k_name)
@test.attr(type=['negative', 'gate'])
def test_create_keypair_invalid_name(self):
# Keypairs with name being an invalid name should not be created
k_name = 'key_/.\@:'
- self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ self.assertRaises(lib_exc.BadRequest, self._create_keypair,
k_name)
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index 4420ac7..de6eecb 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -20,14 +20,14 @@
class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
- super(AbsoluteLimitsTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(AbsoluteLimitsTestJSON, cls).setup_clients()
cls.client = cls.limits_client
@test.attr(type='gate')
def test_absLimits_get(self):
# To check if all limits are present in the response
- resp, absolute_limits = self.client.get_absolute_limits()
+ absolute_limits = self.client.get_absolute_limits()
expected_elements = ['maxImageMeta', 'maxPersonality',
'maxPersonalitySize',
'maxServerMeta', 'maxTotalCores',
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index d537d83..d82a2e5 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
@@ -27,8 +28,8 @@
super(AbsoluteLimitsNegativeTestJSON, self).setUp()
@classmethod
- def resource_setup(cls):
- super(AbsoluteLimitsNegativeTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(AbsoluteLimitsNegativeTestJSON, cls).setup_clients()
cls.client = cls.limits_client
cls.server_client = cls.servers_client
@@ -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/base.py b/tempest/api/compute/security_groups/base.py
index 05cad9a..f70f6d3 100644
--- a/tempest/api/compute/security_groups/base.py
+++ b/tempest/api/compute/security_groups/base.py
@@ -19,7 +19,7 @@
class BaseSecurityGroupsTest(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
# A network and a subnet will be created for these tests
cls.set_network_resources(network=True, subnet=True)
- super(BaseSecurityGroupsTest, cls).resource_setup()
+ super(BaseSecurityGroupsTest, cls).setup_credentials()
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index be06213..1871c73 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -23,9 +23,13 @@
class SecurityGroupRulesTestJSON(base.BaseSecurityGroupsTest):
@classmethod
+ def setup_clients(cls):
+ super(SecurityGroupRulesTestJSON, cls).setup_clients()
+ cls.client = cls.security_groups_client
+
+ @classmethod
def resource_setup(cls):
super(SecurityGroupRulesTestJSON, cls).resource_setup()
- cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
cls.ip_protocol = 'tcp'
cls.from_port = 22
@@ -61,10 +65,10 @@
# Positive test: Creation of Security Group rule
# should be successful
# Creating a Security Group to add rules to it
- _, security_group = self.create_security_group()
+ security_group = self.create_security_group()
securitygroup_id = security_group['id']
# Adding rules to the created Security Group
- _, rule = \
+ rule = \
self.client.create_security_group_rule(securitygroup_id,
self.ip_protocol,
self.from_port,
@@ -81,12 +85,12 @@
# should be successful
# Creating a Security Group to add rules to it
- _, security_group = self.create_security_group()
+ security_group = self.create_security_group()
parent_group_id = security_group['id']
# Adding rules to the created Security Group with optional cidr
cidr = '10.2.3.124/24'
- _, rule = \
+ rule = \
self.client.create_security_group_rule(parent_group_id,
self.ip_protocol,
self.from_port,
@@ -104,16 +108,16 @@
# should be successful
# Creating a Security Group to add rules to it
- _, security_group = self.create_security_group()
+ security_group = self.create_security_group()
parent_group_id = security_group['id']
# Creating a Security Group so as to assign group_id to the rule
- _, security_group = self.create_security_group()
+ security_group = self.create_security_group()
group_id = security_group['id']
group_name = security_group['name']
# Adding rules to the created Security Group with optional group_id
- _, rule = \
+ rule = \
self.client.create_security_group_rule(parent_group_id,
self.ip_protocol,
self.from_port,
@@ -130,11 +134,11 @@
# Positive test: Created Security Group rules should be
# in the list of all rules
# Creating a Security Group to add rules to it
- resp, security_group = self.create_security_group()
+ security_group = self.create_security_group()
securitygroup_id = security_group['id']
# Add a first rule to the created Security Group
- resp, rule = \
+ rule = \
self.client.create_security_group_rule(securitygroup_id,
self.ip_protocol,
self.from_port,
@@ -145,7 +149,7 @@
ip_protocol2 = 'icmp'
from_port2 = -1
to_port2 = -1
- resp, rule = \
+ rule = \
self.client.create_security_group_rule(securitygroup_id,
ip_protocol2,
from_port2, to_port2)
@@ -154,7 +158,7 @@
self.addCleanup(self.client.delete_security_group_rule, rule2_id)
# Get rules of the created Security Group
- resp, rules = \
+ rules = \
self.client.list_security_group_rules(securitygroup_id)
self.assertTrue(any([i for i in rules if i['id'] == rule1_id]))
self.assertTrue(any([i for i in rules if i['id'] == rule2_id]))
@@ -164,25 +168,22 @@
def test_security_group_rules_delete_when_peer_group_deleted(self):
# Positive test:rule will delete when peer group deleting
# Creating a Security Group to add rules to it
- resp, security_group = self.create_security_group()
+ security_group = self.create_security_group()
sg1_id = security_group['id']
# Creating other Security Group to access to group1
- resp, security_group = self.create_security_group()
+ security_group = self.create_security_group()
sg2_id = security_group['id']
# Adding rules to the Group1
- resp, rule = \
- self.client.create_security_group_rule(sg1_id,
- self.ip_protocol,
- self.from_port,
- self.to_port,
- group_id=sg2_id)
+ self.client.create_security_group_rule(sg1_id,
+ self.ip_protocol,
+ self.from_port,
+ self.to_port,
+ group_id=sg2_id)
- self.assertEqual(200, resp.status)
# Delete group2
- resp, body = self.client.delete_security_group(sg2_id)
- self.assertEqual(202, resp.status)
+ self.client.delete_security_group(sg2_id)
# Get rules of the Group1
- resp, rules = \
+ rules = \
self.client.list_security_group_rules(sg1_id)
# The group1 has no rules because group2 has deleted
self.assertEqual(0, len(rules))
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 88a99b9..bd48cbe 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,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.security_groups import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -32,8 +33,8 @@
class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def resource_setup(cls):
- super(SecurityGroupRulesNegativeTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(SecurityGroupRulesNegativeTestJSON, cls).setup_clients()
cls.client = cls.security_groups_client
@test.attr(type=['negative', 'smoke'])
@@ -46,7 +47,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)
@@ -60,7 +61,7 @@
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -69,22 +70,21 @@
def test_create_security_group_rule_duplicate(self):
# Negative test: Create Security Group rule duplicate should fail
# Creating a Security Group to add rule to it
- resp, sg = self.create_security_group()
+ sg = self.create_security_group()
# Adding rules to the created Security Group
parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, rule = \
+ rule = \
self.client.create_security_group_rule(parent_group_id,
ip_protocol,
from_port,
to_port)
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
- self.assertEqual(200, resp.status)
# Add the same rule to the group should fail
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -94,14 +94,14 @@
# Negative test: Creation of Security Group rule should FAIL
# with invalid ip_protocol
# Creating a Security Group to add rule to it
- resp, sg = self.create_security_group()
+ sg = self.create_security_group()
# Adding rules to the created Security Group
parent_group_id = sg['id']
ip_protocol = data_utils.rand_name('999')
from_port = 22
to_port = 22
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -111,13 +111,13 @@
# Negative test: Creation of Security Group rule should FAIL
# with invalid from_port
# Creating a Security Group to add rule to it
- resp, sg = self.create_security_group()
+ sg = self.create_security_group()
# Adding rules to the created Security Group
parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = data_utils.rand_int_id(start=65536)
to_port = 22
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -127,13 +127,13 @@
# Negative test: Creation of Security Group rule should FAIL
# with invalid to_port
# Creating a Security Group to add rule to it
- resp, sg = self.create_security_group()
+ sg = self.create_security_group()
# Adding rules to the created Security Group
parent_group_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = data_utils.rand_int_id(start=65536)
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
@@ -143,13 +143,13 @@
# Negative test: Creation of Security Group rule should FAIL
# with invalid port range.
# Creating a Security Group to add rule to it.
- resp, sg = self.create_security_group()
+ sg = self.create_security_group()
# Adding a rule to the created Security Group
secgroup_id = sg['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 21
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group_rule,
secgroup_id, ip_protocol, from_port, to_port)
@@ -159,6 +159,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.py b/tempest/api/compute/security_groups/test_security_groups.py
index 1cfb16b..1e2b6e7 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -13,17 +13,18 @@
# 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 exceptions
from tempest import test
class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def resource_setup(cls):
- super(SecurityGroupsTestJSON, cls).resource_setup()
+ def setup_clients(cls):
+ super(SecurityGroupsTestJSON, cls).setup_clients()
cls.client = cls.security_groups_client
@test.attr(type='smoke')
@@ -33,13 +34,11 @@
# Create 3 Security Groups
security_group_list = []
for i in range(3):
- resp, body = self.create_security_group()
- self.assertEqual(200, resp.status)
+ body = self.create_security_group()
security_group_list.append(body)
# Fetch all Security Groups and verify the list
# has all created Security Groups
- resp, fetched_list = self.client.list_security_groups()
- self.assertEqual(200, resp.status)
+ fetched_list = self.client.list_security_groups()
# Now check if all the created Security Groups are in fetched list
missing_sgs = \
[sg for sg in security_group_list if sg not in fetched_list]
@@ -49,11 +48,10 @@
for m_group in missing_sgs))
# Delete all security groups
for sg in security_group_list:
- resp, _ = self.client.delete_security_group(sg['id'])
- self.assertEqual(202, resp.status)
+ self.client.delete_security_group(sg['id'])
self.client.wait_for_resource_deletion(sg['id'])
# Now check if all the created Security Groups are deleted
- resp, fetched_list = self.client.list_security_groups()
+ fetched_list = self.client.list_security_groups()
deleted_sgs = \
[sg for sg in security_group_list if sg in fetched_list]
self.assertFalse(deleted_sgs,
@@ -68,22 +66,19 @@
# with char space between name along with
# leading and trailing spaces
s_name = ' %s ' % data_utils.rand_name('securitygroup ')
- resp, securitygroup = self.create_security_group(name=s_name)
- self.assertEqual(200, resp.status)
+ securitygroup = self.create_security_group(name=s_name)
self.assertIn('name', securitygroup)
securitygroup_name = securitygroup['name']
self.assertEqual(securitygroup_name, s_name,
"The created Security Group name is "
"not equal to the requested name")
# Now fetch the created Security Group by its 'id'
- resp, fetched_group = \
+ fetched_group = \
self.client.get_security_group(securitygroup['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(securitygroup, fetched_group,
"The fetched Security Group is different "
"from the created Group")
- resp, _ = self.client.delete_security_group(securitygroup['id'])
- self.assertEqual(202, resp.status)
+ self.client.delete_security_group(securitygroup['id'])
self.client.wait_for_resource_deletion(securitygroup['id'])
@test.attr(type='smoke')
@@ -93,13 +88,13 @@
# and not deleted if the server is active.
# Create a couple security groups that we will use
# for the server resource this test creates
- resp, sg = self.create_security_group()
- resp, sg2 = self.create_security_group()
+ sg = self.create_security_group()
+ sg2 = self.create_security_group()
# Create server and add the security group created
# above to the server we just created
server_name = data_utils.rand_name('server')
- resp, server = self.create_test_server(name=server_name)
+ server = self.create_test_server(name=server_name)
server_id = server['id']
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
resp, body = self.servers_client.add_security_group(server_id,
@@ -107,7 +102,7 @@
# Check that we are not able to delete the security
# group since it is in use by an active server
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.delete_security_group,
sg['id'])
@@ -119,7 +114,7 @@
# Check that we are not able to delete the other security
# group since it is in use by an active server
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.delete_security_group,
sg2['id'])
@@ -128,30 +123,25 @@
self.servers_client.delete_server(server_id)
self.servers_client.wait_for_server_termination(server_id)
- resp, _ = self.client.delete_security_group(sg['id'])
- self.assertEqual(202, resp.status)
- resp, _ = self.client.delete_security_group(sg2['id'])
- self.assertEqual(202, resp.status)
+ self.client.delete_security_group(sg['id'])
+ self.client.delete_security_group(sg2['id'])
@test.attr(type='smoke')
@test.services('network')
def test_update_security_groups(self):
# Update security group name and description
# Create a security group
- resp, securitygroup = self.create_security_group()
- self.assertEqual(200, resp.status)
+ securitygroup = self.create_security_group()
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
# Update the name and description
s_new_name = data_utils.rand_name('sg-hth-')
s_new_des = data_utils.rand_name('description-hth-')
- resp, sg_new = \
- self.client.update_security_group(securitygroup_id,
- name=s_new_name,
- description=s_new_des)
- self.assertEqual(200, resp.status)
+ self.client.update_security_group(securitygroup_id,
+ name=s_new_name,
+ description=s_new_des)
# get the security group
- resp, fetched_group = \
+ fetched_group = \
self.client.get_security_group(securitygroup_id)
self.assertEqual(s_new_name, fetched_group['name'])
self.assertEqual(s_new_des, fetched_group['description'])
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 ce06180..2cbea1a 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# 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
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -27,14 +28,18 @@
class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest):
@classmethod
+ def setup_clients(cls):
+ super(SecurityGroupsNegativeTestJSON, cls).setup_clients()
+ cls.client = cls.security_groups_client
+
+ @classmethod
def resource_setup(cls):
super(SecurityGroupsNegativeTestJSON, cls).resource_setup()
- cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
def _generate_a_non_existent_security_group_id(self):
security_group_id = []
- resp, body = self.client.list_security_groups()
+ body = self.client.list_security_groups()
for i in range(len(body)):
security_group_id.append(body[i]['id'])
# Generate a non-existent security group id
@@ -52,11 +57,11 @@
# 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)
- @test.skip_because(bug="1161411",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1161411",
+ condition=CONF.service_available.neutron)
@test.attr(type=['negative', 'smoke'])
@test.services('network')
def test_security_group_create_with_invalid_group_name(self):
@@ -64,20 +69,20 @@
# as an empty string/with white spaces/chars more than 255
s_description = data_utils.rand_name('description-')
# Create Security Group with empty string as group name
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, "", s_description)
# Create Security Group with white space in group name
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, " ",
s_description)
# Create Security Group with group name longer than 255 chars
s_name = 'securitygroup-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, s_name,
s_description)
- @test.skip_because(bug="1161411",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1161411",
+ condition=CONF.service_available.neutron)
@test.attr(type=['negative', 'smoke'])
@test.services('network')
def test_security_group_create_with_invalid_group_description(self):
@@ -85,14 +90,14 @@
# as an empty string/with white spaces/chars more than 255
s_name = data_utils.rand_name('securitygroup-')
# Create Security Group with empty string as description
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, s_name, "")
# Create Security Group with white space in description
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, s_name, " ")
# Create Security Group with group description longer than 255 chars
s_description = 'description-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, s_name,
s_description)
@@ -105,11 +110,9 @@
# be created
s_name = data_utils.rand_name('securitygroup-')
s_description = data_utils.rand_name('description-')
- resp, security_group =\
- self.create_security_group(s_name, s_description)
- self.assertEqual(200, resp.status)
+ self.create_security_group(s_name, s_description)
# Now try the Security Group with the same 'Name'
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_security_group, s_name,
s_description)
@@ -118,13 +121,13 @@
def test_delete_the_default_security_group(self):
# Negative test:Deletion of the "default" Security Group should Fail
default_security_group_id = None
- resp, body = self.client.list_security_groups()
+ body = self.client.list_security_groups()
for i in range(len(body)):
if body[i]['name'] == 'default':
default_security_group_id = body[i]['id']
break
# Deleting the "default" Security Group
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.delete_security_group,
default_security_group_id)
@@ -133,7 +136,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'])
@@ -141,7 +144,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,
@@ -154,7 +157,7 @@
s_description = data_utils.rand_name('description-')
# Create a non int sg_id
sg_id_invalid = data_utils.rand_name('sg-')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_security_group, sg_id_invalid,
name=s_name, description=s_description)
@@ -164,13 +167,12 @@
@test.services('network')
def test_update_security_group_with_invalid_sg_name(self):
# Update security_group with invalid sg_name should fail
- resp, securitygroup = self.create_security_group()
- self.assertEqual(200, resp.status)
+ securitygroup = self.create_security_group()
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
# Update Security Group with group name longer than 255 chars
s_new_name = 'securitygroup-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_security_group,
securitygroup_id, name=s_new_name)
@@ -180,13 +182,12 @@
@test.services('network')
def test_update_security_group_with_invalid_sg_des(self):
# Update security_group with invalid sg_des should fail
- resp, securitygroup = self.create_security_group()
- self.assertEqual(200, resp.status)
+ securitygroup = self.create_security_group()
self.assertIn('id', securitygroup)
securitygroup_id = securitygroup['id']
# Update Security Group with group description longer than 255 chars
s_new_des = 'des-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_security_group,
securitygroup_id, description=s_new_des)
@@ -197,7 +198,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_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index 4b14dc4..33995f3 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -26,14 +26,22 @@
class AttachInterfacesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(AttachInterfacesTestJSON, cls).skip_checks()
if not CONF.service_available.neutron:
raise cls.skipException("Neutron is required")
if not CONF.compute_feature_enabled.interface_attach:
raise cls.skipException("Interface attachment is not available.")
+
+ @classmethod
+ def setup_credentials(cls):
# This test class requires network and subnet
cls.set_network_resources(network=True, subnet=True)
- super(AttachInterfacesTestJSON, cls).resource_setup()
+ super(AttachInterfacesTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(AttachInterfacesTestJSON, cls).setup_clients()
cls.client = cls.os.interfaces_client
def _check_interface(self, iface, port_id=None, network_id=None,
@@ -49,7 +57,7 @@
self.assertEqual(iface['mac_addr'], mac_addr)
def _create_server_get_interfaces(self):
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, ifs = self.client.list_interfaces(server['id'])
self.assertEqual(200, resp.status)
resp, body = self.client.wait_for_interface_status(
@@ -148,7 +156,7 @@
network_id)
self.assertEqual(202, resp.status)
# Remove the fixed IP from server.
- server_resp, server_detail = self.os.servers_client.get_server(
+ server_detail = self.os.servers_client.get_server(
server['id'])
# Get the Fixed IP from server.
fixed_ip = None
diff --git a/tempest/api/compute/servers/test_availability_zone.py b/tempest/api/compute/servers/test_availability_zone.py
index 5ddf053..dfff014 100644
--- a/tempest/api/compute/servers/test_availability_zone.py
+++ b/tempest/api/compute/servers/test_availability_zone.py
@@ -31,6 +31,5 @@
@test.attr(type='gate')
def test_get_availability_zone_list_with_non_admin_user(self):
# List of availability zone with non-administrator user
- resp, availability_zone = self.client.get_availability_zone_list()
- self.assertEqual(200, resp.status)
+ availability_zone = self.client.get_availability_zone_list()
self.assertTrue(len(availability_zone) > 0)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 13ec045..73e7d15 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -43,16 +43,16 @@
'contents': base64.b64encode(file_contents)}]
cls.client = cls.servers_client
cls.network_client = cls.os.network_client
- cli_resp = cls.create_test_server(name=cls.name,
- meta=cls.meta,
- accessIPv4=cls.accessIPv4,
- accessIPv6=cls.accessIPv6,
- personality=personality,
- disk_config=cls.disk_config)
- cls.resp, cls.server_initial = cli_resp
+ disk_config = cls.disk_config
+ cls.server_initial = cls.create_test_server(name=cls.name,
+ meta=cls.meta,
+ accessIPv4=cls.accessIPv4,
+ accessIPv6=cls.accessIPv6,
+ personality=personality,
+ disk_config=disk_config)
cls.password = cls.server_initial['adminPass']
cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
- resp, cls.server = cls.client.get_server(cls.server_initial['id'])
+ cls.server = cls.client.get_server(cls.server_initial['id'])
@test.attr(type='smoke')
def test_verify_server_details(self):
@@ -89,7 +89,7 @@
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
- resp, flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
+ flavor = self.flavors_client.get_flavor_details(self.flavor_ref)
linux_client = remote_client.RemoteClient(self.server, self.ssh_user,
self.password)
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@@ -115,9 +115,8 @@
self.addCleanup(self.client.delete_server_group, group_id)
hints = {'group': group_id}
- resp, server = self.create_test_server(sched_hints=hints,
- wait_until='ACTIVE')
- self.assertEqual(202, resp.status)
+ server = self.create_test_server(sched_hints=hints,
+ wait_until='ACTIVE')
# Check a server is in the group
resp, server_group = self.client.get_server_group(group_id)
@@ -156,7 +155,7 @@
networks = [{'uuid': net1['network']['id']},
{'uuid': net2['network']['id']}]
- _, server_multi_nics = self.create_test_server(
+ server_multi_nics = self.create_test_server(
networks=networks, wait_until='ACTIVE')
# Cleanup server; this is needed in the test case because with the LIFO
@@ -210,13 +209,12 @@
disk = 0
# Create a flavor with extra specs
- resp, flavor = (self.flavor_client.
- create_flavor(flavor_with_eph_disk_name,
- ram, vcpus, disk,
- flavor_with_eph_disk_id,
- ephemeral=1))
+ flavor = (self.flavor_client.
+ create_flavor(flavor_with_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_with_eph_disk_id,
+ ephemeral=1))
self.addCleanup(flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
return flavor['id']
@@ -229,18 +227,16 @@
disk = 0
# Create a flavor without extra specs
- resp, flavor = (self.flavor_client.
- create_flavor(flavor_no_eph_disk_name,
- ram, vcpus, disk,
- flavor_no_eph_disk_id))
+ flavor = (self.flavor_client.
+ create_flavor(flavor_no_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_no_eph_disk_id))
self.addCleanup(flavor_clean_up, flavor['id'])
- self.assertEqual(200, resp.status)
return flavor['id']
def flavor_clean_up(flavor_id):
- resp, body = self.flavor_client.delete_flavor(flavor_id)
- self.assertEqual(resp.status, 202)
+ self.flavor_client.delete_flavor(flavor_id)
self.flavor_client.wait_for_resource_deletion(flavor_id)
flavor_with_eph_disk_id = create_flavor_with_extra_specs()
@@ -248,22 +244,22 @@
admin_pass = self.image_ssh_password
- resp, server_no_eph_disk = (self.create_test_server(
- wait_until='ACTIVE',
- adminPass=admin_pass,
- flavor=flavor_no_eph_disk_id))
- resp, server_with_eph_disk = (self.create_test_server(
- wait_until='ACTIVE',
- adminPass=admin_pass,
- flavor=flavor_with_eph_disk_id))
+ server_no_eph_disk = (self.create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_no_eph_disk_id))
+ server_with_eph_disk = (self.create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_with_eph_disk_id))
# Get partition number of server without extra specs.
- _, server_no_eph_disk = self.client.get_server(
+ server_no_eph_disk = self.client.get_server(
server_no_eph_disk['id'])
linux_client = remote_client.RemoteClient(server_no_eph_disk,
self.ssh_user, admin_pass)
partition_num = len(linux_client.get_partitions().split('\n'))
- _, server_with_eph_disk = self.client.get_server(
+ server_with_eph_disk = self.client.get_server(
server_with_eph_disk['id'])
linux_client = remote_client.RemoteClient(server_with_eph_disk,
self.ssh_user, admin_pass)
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 9d1ea9e..aec2f6f 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -35,27 +35,24 @@
@test.attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
- resp, server = self.create_test_server(wait_until='BUILD')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ server = self.create_test_server(wait_until='BUILD')
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@test.attr(type='gate')
def test_delete_active_server(self):
# Delete a server while it's VM state is Active
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ server = self.create_test_server(wait_until='ACTIVE')
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@test.attr(type='gate')
def test_delete_server_while_in_shutoff_state(self):
# Delete a server while it's VM state is Shutoff
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, body = self.client.stop(server['id'])
self.client.wait_for_server_status(server['id'], 'SHUTOFF')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -63,11 +60,10 @@
@test.attr(type='gate')
def test_delete_server_while_in_pause_state(self):
# Delete a server while it's VM state is Pause
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, body = self.client.pause_server(server['id'])
self.client.wait_for_server_status(server['id'], 'PAUSED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -75,11 +71,10 @@
@test.attr(type='gate')
def test_delete_server_while_in_suspended_state(self):
# Delete a server while it's VM state is Suspended
- _, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
self.client.suspend_server(server['id'])
self.client.wait_for_server_status(server['id'], 'SUSPENDED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
@@ -87,7 +82,7 @@
@test.attr(type='gate')
def test_delete_server_while_in_shelved_state(self):
# Delete a server while it's VM state is Shelved
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, body = self.client.shelve_server(server['id'])
self.assertEqual(202, resp.status)
@@ -99,8 +94,7 @@
else:
self.client.wait_for_server_status(server['id'],
'SHELVED')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@testtools.skipIf(not CONF.compute_feature_enabled.resize,
@@ -108,12 +102,11 @@
@test.attr(type='gate')
def test_delete_server_while_in_verify_resize_state(self):
# Delete a server while it's VM state is VERIFY_RESIZE
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, body = self.client.resize(server['id'], self.flavor_ref_alt)
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(server['id'], 'VERIFY_RESIZE')
- resp, _ = self.client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
@test.services('volume')
@@ -122,18 +115,17 @@
# Delete a server while a volume is attached to it
volumes_client = self.volumes_extensions_client
device = '/dev/%s' % CONF.compute.volume_device_name
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ 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'])
- self.assertEqual('204', resp['status'])
+ self.client.delete_server(server['id'])
self.client.wait_for_server_termination(server['id'])
volumes_client.wait_for_volume_status(volume['id'], 'available')
@@ -151,21 +143,19 @@
@test.attr(type='gate')
def test_delete_server_while_in_error_state(self):
# Delete a server while it's VM state is error
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
resp, body = self.admin_client.reset_state(server['id'], state='error')
self.assertEqual(202, resp.status)
# Verify server's state
- resp, server = self.non_admin_client.get_server(server['id'])
+ server = self.non_admin_client.get_server(server['id'])
self.assertEqual(server['status'], 'ERROR')
- resp, _ = self.non_admin_client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ self.non_admin_client.delete_server(server['id'])
self.servers_client.wait_for_server_termination(server['id'],
ignore_error=True)
@test.attr(type='gate')
def test_admin_delete_servers_of_others(self):
# Administrator can delete servers of others
- resp, server = self.create_test_server(wait_until='ACTIVE')
- resp, _ = self.admin_client.delete_server(server['id'])
- self.assertEqual('204', resp['status'])
+ server = self.create_test_server(wait_until='ACTIVE')
+ self.admin_client.delete_server(server['id'])
self.servers_client.wait_for_server_termination(server['id'])
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index eeef0e5..f7a5bfb 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -31,17 +31,16 @@
raise cls.skipException(msg)
super(ServerDiskConfigTestJSON, cls).resource_setup()
cls.client = cls.os.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
def _update_server_with_disk_config(self, disk_config):
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
if disk_config != server['OS-DCF:diskConfig']:
- resp, server = self.client.update_server(self.server_id,
- disk_config=disk_config)
- self.assertEqual(200, resp.status)
+ server = self.client.update_server(self.server_id,
+ disk_config=disk_config)
self.client.wait_for_server_status(server['id'], 'ACTIVE')
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual(disk_config, server['OS-DCF:diskConfig'])
@test.attr(type='gate')
@@ -57,7 +56,7 @@
self.client.wait_for_server_status(server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.attr(type='gate')
@@ -73,11 +72,11 @@
self.client.wait_for_server_status(server['id'], 'ACTIVE')
# Verify the specified attributes are set correctly
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
def _get_alternative_flavor(self):
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
if server['flavor']['id'] == self.flavor_ref:
return self.flavor_ref_alt
@@ -98,7 +97,7 @@
self.client.confirm_resize(self.server_id)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
@@ -115,7 +114,7 @@
self.client.confirm_resize(self.server_id)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
@test.attr(type='gate')
@@ -124,11 +123,10 @@
self._update_server_with_disk_config(disk_config='AUTO')
# Update the disk_config attribute to manual
- resp, server = self.client.update_server(self.server_id,
- disk_config='MANUAL')
- self.assertEqual(200, resp.status)
+ server = self.client.update_server(self.server_id,
+ disk_config='MANUAL')
self.client.wait_for_server_status(server['id'], 'ACTIVE')
# Verify the disk_config attribute is set correctly
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual('MANUAL', server['OS-DCF:diskConfig'])
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 80b2a69..103c241 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -23,8 +23,8 @@
def resource_setup(cls):
super(InstanceActionsTestJSON, cls).resource_setup()
cls.client = cls.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- cls.request_id = resp['x-compute-request-id']
+ server = cls.create_test_server(wait_until='ACTIVE')
+ cls.request_id = server.response['x-compute-request-id']
cls.server_id = server['id']
@test.attr(type='gate')
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index e92f04c..2f9216f 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
@@ -25,19 +26,19 @@
def resource_setup(cls):
super(InstanceActionsNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
@test.attr(type=['negative', 'gate'])
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 7964cf7..58740fd 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -13,11 +13,13 @@
# License for the specific language governing permissions and limitations
# 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
@@ -26,11 +28,19 @@
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
cls.set_network_resources(network=True, subnet=True, dhcp=True)
- super(ListServerFiltersTestJSON, cls).resource_setup()
+ super(ListServerFiltersTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(ListServerFiltersTestJSON, cls).setup_clients()
cls.client = cls.servers_client
+ @classmethod
+ def resource_setup(cls):
+ super(ListServerFiltersTestJSON, cls).resource_setup()
+
# Check to see if the alternate image ref actually exists...
images_client = cls.images_client
images = images_client.list_images()
@@ -46,29 +56,29 @@
# 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)
cls.s1_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s1 = cls.create_test_server(name=cls.s1_name,
- wait_until='ACTIVE')
+ cls.s1 = cls.create_test_server(name=cls.s1_name,
+ wait_until='ACTIVE')
cls.s2_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s2 = cls.create_test_server(name=cls.s2_name,
- image_id=cls.image_ref_alt,
- wait_until='ACTIVE')
+ cls.s2 = cls.create_test_server(name=cls.s2_name,
+ image_id=cls.image_ref_alt,
+ wait_until='ACTIVE')
cls.s3_name = data_utils.rand_name(cls.__name__ + '-instance')
- resp, cls.s3 = cls.create_test_server(name=cls.s3_name,
- flavor=cls.flavor_ref_alt,
- wait_until='ACTIVE')
+ cls.s3 = cls.create_test_server(name=cls.s3_name,
+ flavor=cls.flavor_ref_alt,
+ wait_until='ACTIVE')
cls.fixed_network_name = CONF.compute.fixed_network_name
if CONF.service_available.neutron:
@@ -259,7 +269,7 @@
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
# Here should be listed 1 server
- resp, self.s1 = self.client.get_server(self.s1['id'])
+ self.s1 = self.client.get_server(self.s1['id'])
ip = self.s1['addresses'][self.fixed_network_name][0]['addr']
params = {'ip': ip}
resp, body = self.client.list_servers(params)
@@ -269,14 +279,14 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @test.skip_because(bug="1182883",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1182883",
+ condition=CONF.service_available.neutron)
@test.attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
# List all servers filtered by part of ip address.
# Here should be listed all servers
- resp, self.s1 = self.client.get_server(self.s1['id'])
+ self.s1 = self.client.get_server(self.s1['id'])
ip = self.s1['addresses'][self.fixed_network_name][0]['addr'][0:-3]
params = {'ip': ip}
resp, body = self.client.list_servers(params)
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index fd66d2b..2f12882 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -14,9 +14,9 @@
# under the License.
from six import moves
+from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -35,10 +35,10 @@
cls.existing_fixtures = []
cls.deleted_fixtures = []
for x in moves.xrange(2):
- resp, srv = cls.create_test_server(wait_until='ACTIVE')
+ srv = cls.create_test_server(wait_until='ACTIVE')
cls.existing_fixtures.append(srv)
- resp, srv = cls.create_test_server()
+ srv = cls.create_test_server()
cls.client.delete_server(srv['id'])
# We ignore errors on termination because the server may
# be put into ERROR status on a quick spawn, then delete,
@@ -101,7 +101,6 @@
# List servers by specifying limits
resp, body = self.client.list_servers({'limit': 1})
self.assertEqual('200', resp['status'])
- # when _interface='xml', one element for servers_links in servers
self.assertEqual(1, len([x for x in body['servers'] if 'id' in x]))
@test.attr(type=['negative', 'gate'])
@@ -114,19 +113,19 @@
@test.attr(type=['negative', 'gate'])
def test_list_servers_by_limits_pass_string(self):
# Return an error if a string value is passed for limit
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
+ self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
{'limit': 'testing'})
@test.attr(type=['negative', 'gate'])
def test_list_servers_by_limits_pass_negative_value(self):
# Return an error if a negative value for limit is passed
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
+ self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
{'limit': -1})
@test.attr(type=['negative', 'gate'])
def test_list_servers_by_changes_since_invalid_date(self):
# Return an error when invalid date format is passed
- self.assertRaises(exceptions.BadRequest, self.client.list_servers,
+ self.assertRaises(lib_exc.BadRequest, self.client.list_servers,
{'changes-since': '2011/01/01'})
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index 6fd2a75..cffda95 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -30,26 +30,24 @@
created servers into the servers list to be cleaned up after all.
"""
kwargs['name'] = kwargs.get('name', self._generate_name())
- resp, body = self.create_test_server(**kwargs)
+ body = self.create_test_server(**kwargs)
- return resp, body
+ return body
@test.attr(type='gate')
def test_multiple_create(self):
- resp, body = self._create_multiple_servers(wait_until='ACTIVE',
- min_count=1,
- max_count=2)
+ body = self._create_multiple_servers(wait_until='ACTIVE',
+ min_count=1,
+ max_count=2)
# NOTE(maurosr): do status response check and also make sure that
# reservation_id is not in the response body when the request send
# contains return_reservation_id=False
- self.assertEqual('202', resp['status'])
self.assertNotIn('reservation_id', body)
@test.attr(type='gate')
def test_multiple_create_with_reservation_return(self):
- resp, body = self._create_multiple_servers(wait_until='ACTIVE',
- min_count=1,
- max_count=2,
- return_reservation_id=True)
- self.assertEqual(resp['status'], '202')
+ body = self._create_multiple_servers(wait_until='ACTIVE',
+ min_count=1,
+ max_count=2,
+ return_reservation_id=True)
self.assertIn('reservation_id', body)
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index 55db605..eca97c1 100644
--- a/tempest/api/compute/servers/test_multiple_create_negative.py
+++ b/tempest/api/compute/servers/test_multiple_create_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
@@ -31,38 +32,38 @@
created servers into the servers list to be cleaned up after all.
"""
kwargs['name'] = kwargs.get('name', self._generate_name())
- resp, body = self.create_test_server(**kwargs)
+ body = self.create_test_server(**kwargs)
- return resp, body
+ return body
@test.attr(type=['negative', 'gate'])
def test_min_count_less_than_one(self):
invalid_min_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ self.assertRaises(lib_exc.BadRequest, self._create_multiple_servers,
min_count=invalid_min_count)
@test.attr(type=['negative', 'gate'])
def test_min_count_non_integer(self):
invalid_min_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ self.assertRaises(lib_exc.BadRequest, self._create_multiple_servers,
min_count=invalid_min_count)
@test.attr(type=['negative', 'gate'])
def test_max_count_less_than_one(self):
invalid_max_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ self.assertRaises(lib_exc.BadRequest, self._create_multiple_servers,
max_count=invalid_max_count)
@test.attr(type=['negative', 'gate'])
def test_max_count_non_integer(self):
invalid_max_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ self.assertRaises(lib_exc.BadRequest, self._create_multiple_servers,
max_count=invalid_max_count)
@test.attr(type=['negative', 'gate'])
def test_max_count_less_than_min_count(self):
min_count = 3
max_count = 2
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ self.assertRaises(lib_exc.BadRequest, self._create_multiple_servers,
min_count=min_count,
max_count=max_count)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 17e3669..f849b8c 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -17,13 +17,14 @@
import logging
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
@@ -46,7 +47,7 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
def tearDown(self):
- _, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
self.assertEqual(self.image_ref, server['image']['id'])
self.server_check_teardown()
super(ServerActionsTestJSON, self).tearDown()
@@ -70,7 +71,7 @@
if self.run_ssh:
# Verify that the user can authenticate with the new password
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
linux_client = remote_client.RemoteClient(server, self.ssh_user,
new_password)
linux_client.validate_authentication()
@@ -78,7 +79,7 @@
def _test_reboot_server(self, reboot_type):
if self.run_ssh:
# Get the time the server was last rebooted,
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
linux_client = remote_client.RemoteClient(server, self.ssh_user,
self.password)
boot_time = linux_client.get_boot_time()
@@ -100,7 +101,7 @@
# The server should be power cycled
self._test_reboot_server('HARD')
- @test.skip_because(bug="1014647")
+ @decorators.skip_because(bug="1014647")
@test.attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
@@ -130,7 +131,7 @@
# Verify the server properties after the rebuild completes
self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
- resp, server = self.client.get_server(rebuilt_server['id'])
+ server = self.client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
self.assertEqual(new_name, server['name'])
@@ -147,7 +148,7 @@
def test_rebuild_server_in_stop_state(self):
# The server in stop state should be rebuilt using the provided
# image and remain in SHUTOFF state
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
old_image = server['image']['id']
new_image = self.image_ref_alt \
if old_image == self.image_ref else self.image_ref
@@ -164,7 +165,7 @@
# Verify the server properties after the rebuild completes
self.client.wait_for_server_status(rebuilt_server['id'], 'SHUTOFF')
- resp, server = self.client.get_server(rebuilt_server['id'])
+ server = self.client.get_server(rebuilt_server['id'])
rebuilt_image_id = server['image']['id']
self.assertEqual(new_image, rebuilt_image_id)
@@ -176,7 +177,7 @@
def _detect_server_image_flavor(self, server_id):
# Detects the current server image flavor ref.
- resp, server = self.client.get_server(server_id)
+ server = self.client.get_server(server_id)
current_flavor = server['flavor']['id']
new_flavor_ref = self.flavor_ref_alt \
if current_flavor == self.flavor_ref else self.flavor_ref
@@ -203,7 +204,7 @@
expected_status = 'SHUTOFF' if stop else 'ACTIVE'
self.client.wait_for_server_status(self.server_id, expected_status)
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
self.assertEqual(new_flavor_ref, server['flavor']['id'])
if stop:
@@ -239,7 +240,7 @@
self.client.revert_resize(self.server_id)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
self.assertEqual(previous_flavor_ref, server['flavor']['id'])
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -261,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 "
@@ -357,7 +358,7 @@
'Console output not supported.')
@test.attr(type='gate')
def test_get_console_output_with_unlimited_size(self):
- _, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
def _check_full_length_console_log():
_, output = self.servers_client.get_console_output(server['id'],
@@ -382,7 +383,7 @@
# NOTE: SHUTOFF is irregular status. To avoid test instability,
# one server is created only for this test without using
# the server that was created in setupClass.
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
temp_server_id = server['id']
resp, server = self.servers_client.stop(temp_server_id)
@@ -434,7 +435,7 @@
self.client.wait_for_server_status(self.server_id,
'SHELVED_OFFLOADED')
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(params)
@@ -459,11 +460,10 @@
# Lock the server,try server stop(exceptions throw),unlock it and retry
resp, server = self.servers_client.lock_server(self.server_id)
self.assertEqual(202, resp.status)
- resp, server = self.servers_client.get_server(self.server_id)
- self.assertEqual(200, resp.status)
+ server = self.servers_client.get_server(self.server_id)
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.py b/tempest/api/compute/servers/test_server_addresses.py
index 3d1d964..5a63033 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -20,13 +20,21 @@
class ServerAddressesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
# This test module might use a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesTestJSON, cls).resource_setup()
+ super(ServerAddressesTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(ServerAddressesTestJSON, cls).setup_clients()
cls.client = cls.servers_client
- resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
+ @classmethod
+ def resource_setup(cls):
+ super(ServerAddressesTestJSON, cls).resource_setup()
+
+ cls.server = cls.create_test_server(wait_until='ACTIVE')
@test.attr(type='smoke')
@test.services('network')
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index 3087e59..b32231a 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -13,32 +13,40 @@
# 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
class ServerAddressesNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesNegativeTestJSON, cls).resource_setup()
+ super(ServerAddressesNegativeTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(ServerAddressesNegativeTestJSON, cls).setup_clients()
cls.client = cls.servers_client
- resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
+ @classmethod
+ def resource_setup(cls):
+ super(ServerAddressesNegativeTestJSON, cls).resource_setup()
+ cls.server = cls.create_test_server(wait_until='ACTIVE')
@test.attr(type=['negative', 'gate'])
@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_group.py b/tempest/api/compute/servers/test_server_group.py
index 0af19c0..fe5dca0 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
+
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import test
@@ -74,7 +76,7 @@
policy = ['anti-affinity']
self._create_delete_server_group(policy)
- @test.skip_because(bug="1324348")
+ @decorators.skip_because(bug="1324348")
@test.attr(type='gate')
def test_create_delete_server_group_with_multiple_policies(self):
# Create and Delete the server-group with multiple policies
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index 6fd6a6d..7e8247f 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -24,7 +24,7 @@
super(ServerMetadataTestJSON, cls).resource_setup()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
- resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
+ server = cls.create_test_server(meta={}, wait_until='ACTIVE')
cls.server_id = server['id']
def setUp(self):
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index ee1e652..441c965 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_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
@@ -27,7 +28,7 @@
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
cls.tenant_id = cls.client.tenant_id
- resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
+ server = cls.create_test_server(meta={}, wait_until='ACTIVE')
cls.server_id = server['id']
@@ -40,7 +41,7 @@
for sz in [256, 257, 511, 1023]:
key = "k" * sz
meta = {key: 'data1'}
- self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
+ self.assertRaises((lib_exc.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=meta)
@@ -50,7 +51,7 @@
def test_create_server_metadata_blank_key(self):
# Blank key should trigger an error.
meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
meta=meta)
@@ -58,7 +59,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 +68,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)
@@ -76,7 +77,7 @@
# Raise BadRequest if key in uri does not match
# the key passed in body.
meta = {'testkey': 'testvalue'}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.set_server_metadata_item,
self.server_id, 'key', meta)
@@ -85,7 +86,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 +96,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)
@@ -104,7 +105,7 @@
def test_update_metadata_with_blank_key(self):
# Blank key should trigger an error
meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_server_metadata,
self.server_id, meta=meta)
@@ -112,7 +113,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')
@@ -122,7 +123,7 @@
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised while exceeding metadata items limit for
# tenant.
- _, quota_set = self.quotas.get_quota_set(self.tenant_id)
+ quota_set = self.quotas.get_quota_set(self.tenant_id)
quota_metadata = quota_set['metadata_items']
if quota_metadata == -1:
raise self.skipException("No limit for metadata_items")
@@ -130,14 +131,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)
@@ -146,7 +147,7 @@
# Raise a bad request error for blank key.
# set_server_metadata will replace all metadata with new value
meta = {'': 'data1'}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta)
@@ -155,6 +156,6 @@
# Raise a bad request error for a missing metadata field
# set_server_metadata will replace all metadata with new value
meta = {'meta1': 'data1'}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.set_server_metadata,
self.server_id, meta=meta, no_metadata_field=True)
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index 994caa4..b2e09f2 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -24,7 +24,7 @@
def resource_setup(cls):
super(ServerPasswordTestJSON, cls).resource_setup()
cls.client = cls.servers_client
- resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
+ cls.server = cls.create_test_server(wait_until="ACTIVE")
@test.attr(type='gate')
def test_get_server_password(self):
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index c6d48bc..ca6e28c 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')
@@ -63,5 +63,4 @@
'path': path,
'contents': base64.b64encode(file_contents),
})
- resp, server = self.create_test_server(personality=person)
- self.assertEqual('202', resp['status'])
+ self.create_test_server(personality=person)
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index ee1e268..8d5c8f8 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -24,29 +24,36 @@
class ServerRescueTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(ServerRescueTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
+ @classmethod
+ def setup_credentials(cls):
cls.set_network_resources(network=True, subnet=True, router=True)
+ super(ServerRescueTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def resource_setup(cls):
super(ServerRescueTestJSON, cls).resource_setup()
# Floating IP creation
- resp, body = cls.floating_ips_client.create_floating_ip()
+ body = cls.floating_ips_client.create_floating_ip()
cls.floating_ip_id = str(body['id']).strip()
cls.floating_ip = str(body['ip']).strip()
# Security group creation
cls.sg_name = data_utils.rand_name('sg')
cls.sg_desc = data_utils.rand_name('sg-desc')
- resp, cls.sg = \
+ cls.sg = \
cls.security_groups_client.create_security_group(cls.sg_name,
cls.sg_desc)
cls.sg_id = cls.sg['id']
# Server for positive tests
- resp, server = cls.create_test_server(wait_until='BUILD')
+ server = cls.create_test_server(wait_until='BUILD')
cls.server_id = server['id']
cls.password = server['adminPass']
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
@@ -58,7 +65,7 @@
def resource_cleanup(cls):
# Deleting the floating IP which is created in this method
cls.floating_ips_client.delete_floating_ip(cls.floating_ip_id)
- resp, cls.sg = cls.security_groups_client.delete_security_group(
+ cls.sg = cls.security_groups_client.delete_security_group(
cls.sg_id)
super(ServerRescueTestJSON, cls).resource_cleanup()
@@ -90,15 +97,12 @@
# Association of floating IP to a rescued vm
client = self.floating_ips_client
- resp, body = client.associate_floating_ip_to_server(self.floating_ip,
- self.server_id)
- self.assertEqual(202, resp.status)
+ client.associate_floating_ip_to_server(self.floating_ip,
+ self.server_id)
# Disassociation of floating IP that was associated in this method
- resp, body = \
- client.disassociate_floating_ip_from_server(self.floating_ip,
- self.server_id)
- self.assertEqual(202, resp.status)
+ client.disassociate_floating_ip_from_server(self.floating_ip,
+ self.server_id)
@test.attr(type='gate')
def test_rescued_vm_add_remove_security_group(self):
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index f1e2f7f..58353e7 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
@@ -26,18 +27,25 @@
class ServerRescueNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(ServerRescueNegativeTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
+ @classmethod
+ def setup_credentials(cls):
cls.set_network_resources(network=True, subnet=True, router=True)
+ super(ServerRescueNegativeTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def resource_setup(cls):
super(ServerRescueNegativeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
# Server for negative tests
- resp, server = cls.create_test_server(wait_until='BUILD')
- resp, resc_server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='BUILD')
+ resc_server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
cls.password = server['adminPass']
cls.rescue_id = resc_server['id']
@@ -49,7 +57,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 +89,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 +125,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 +152,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.py b/tempest/api/compute/servers/test_servers.py
index aba6dff..1375039 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -33,7 +33,7 @@
def test_create_server_with_admin_password(self):
# If an admin password is provided on server creation, the server's
# root password should be set to that password.
- resp, server = self.create_test_server(adminPass='testpassword')
+ server = self.create_test_server(adminPass='testpassword')
# Verify the password is set correctly in the response
self.assertEqual('testpassword', server['adminPass'])
@@ -44,16 +44,16 @@
# TODO(sdague): clear out try, we do cleanup one layer up
server_name = data_utils.rand_name('server')
- resp, server = self.create_test_server(name=server_name,
- wait_until='ACTIVE')
+ server = self.create_test_server(name=server_name,
+ wait_until='ACTIVE')
id1 = server['id']
- resp, server = self.create_test_server(name=server_name,
- wait_until='ACTIVE')
+ server = self.create_test_server(name=server_name,
+ wait_until='ACTIVE')
id2 = server['id']
self.assertNotEqual(id1, id2, "Did not create a new server")
- resp, server = self.client.get_server(id1)
+ server = self.client.get_server(id1)
name1 = server['name']
- resp, server = self.client.get_server(id2)
+ server = self.client.get_server(id2)
name2 = server['name']
self.assertEqual(name1, name2)
@@ -62,38 +62,37 @@
# Specify a keypair while creating a server
key_name = data_utils.rand_name('key')
- resp, keypair = self.keypairs_client.create_keypair(key_name)
- resp, body = self.keypairs_client.list_keypairs()
- resp, server = self.create_test_server(key_name=key_name)
- self.assertEqual('202', resp['status'])
+ self.keypairs_client.create_keypair(key_name)
+ self.keypairs_client.list_keypairs()
+ server = self.create_test_server(key_name=key_name)
self.client.wait_for_server_status(server['id'], 'ACTIVE')
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual(key_name, server['key_name'])
def _update_server_name(self, server_id, status):
# The server name should be changed to the the provided value
new_name = data_utils.rand_name('server')
# Update the server with a new name
- resp, server = self.client.update_server(server_id,
- name=new_name)
+ self.client.update_server(server_id,
+ name=new_name)
self.client.wait_for_server_status(server_id, status)
# Verify the name of the server has changed
- resp, server = self.client.get_server(server_id)
+ server = self.client.get_server(server_id)
self.assertEqual(new_name, server['name'])
return server
@test.attr(type='gate')
def test_update_server_name(self):
# The server name should be changed to the the provided value
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
self._update_server_name(server['id'], 'ACTIVE')
@test.attr(type='gate')
def test_update_server_name_in_stop_state(self):
# The server name should be changed to the the provided value
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
self.client.stop(server['id'])
self.client.wait_for_server_status(server['id'], 'SHUTOFF')
updated_server = self._update_server_name(server['id'], 'SHUTOFF')
@@ -102,25 +101,23 @@
@test.attr(type='gate')
def test_update_access_server_address(self):
# The server's access addresses should reflect the provided values
- resp, server = self.create_test_server(wait_until='ACTIVE')
+ server = self.create_test_server(wait_until='ACTIVE')
# Update the IPv4 and IPv6 access addresses
- resp, body = self.client.update_server(server['id'],
- accessIPv4='1.1.1.1',
- accessIPv6='::babe:202:202')
- self.assertEqual(200, resp.status)
+ self.client.update_server(server['id'],
+ accessIPv4='1.1.1.1',
+ accessIPv6='::babe:202:202')
self.client.wait_for_server_status(server['id'], 'ACTIVE')
# Verify the access addresses have been updated
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual('1.1.1.1', server['accessIPv4'])
self.assertEqual('::babe:202:202', server['accessIPv6'])
@test.attr(type='gate')
def test_create_server_with_ipv6_addr_only(self):
# Create a server without an IPv4 address(only IPv6 address).
- resp, server = self.create_test_server(accessIPv6='2001:2001::3')
- self.assertEqual('202', resp['status'])
+ server = self.create_test_server(accessIPv6='2001:2001::3')
self.client.wait_for_server_status(server['id'], 'ACTIVE')
- resp, server = self.client.get_server(server['id'])
+ server = self.client.get_server(server['id'])
self.assertEqual('2001:2001::3', server['accessIPv6'])
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index b703cfe..d89aff4 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -15,13 +15,13 @@
import sys
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.api.compute 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
@@ -46,14 +46,14 @@
cls.client = cls.servers_client
cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
cls.alt_client = cls.alt_os.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
@test.attr(type=['negative', 'gate'])
def test_server_name_blank(self):
# Create a server with name parameter empty
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
name='')
@@ -65,7 +65,7 @@
person = [{'path': '/etc/testfile.txt',
'contents': file_contents}]
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
personality=person)
@@ -73,7 +73,7 @@
def test_create_with_invalid_image(self):
# Create a server with an unknown image
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
image_id=-1)
@@ -81,7 +81,7 @@
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
flavor=-1,)
@@ -90,7 +90,7 @@
# An access IPv4 address must match a valid address pattern
IPv4 = '1.1.1.1.1.1'
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server, accessIPv4=IPv4)
@test.attr(type=['negative', 'gate'])
@@ -99,7 +99,7 @@
IPv6 = 'notvalid'
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server, accessIPv6=IPv6)
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
@@ -108,7 +108,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)
@@ -118,7 +118,7 @@
def test_resize_server_with_non_existent_flavor(self):
# Resize a server with non-existent flavor
nonexistent_flavor = data_utils.rand_uuid()
- self.assertRaises(exceptions.BadRequest, self.client.resize,
+ self.assertRaises(lib_exc.BadRequest, self.client.resize,
self.server_id, flavor_ref=nonexistent_flavor)
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
@@ -126,14 +126,14 @@
@test.attr(type=['negative', 'gate'])
def test_resize_server_with_null_flavor(self):
# Resize a server with null flavor
- self.assertRaises(exceptions.BadRequest, self.client.resize,
+ self.assertRaises(lib_exc.BadRequest, self.client.resize,
self.server_id, flavor_ref="")
@test.attr(type=['negative', 'gate'])
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 +143,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)
@@ -151,21 +151,21 @@
@test.attr(type=['negative', 'gate'])
def test_rebuild_reboot_deleted_server(self):
# Rebuild and Reboot a deleted server
- _, server = self.create_test_server()
+ server = self.create_test_server()
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)
@@ -173,7 +173,7 @@
@test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
server_name = 12345
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
name=server_name)
@@ -182,7 +182,7 @@
# Create a server with name length exceeding 256 characters
server_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
name=server_name)
@@ -192,7 +192,7 @@
networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
networks=networks)
@@ -201,7 +201,7 @@
# Pass a non-existent keypair while creating a server
key_name = data_utils.rand_name('key')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
key_name=key_name)
@@ -210,7 +210,7 @@
# Pass really long metadata while creating a server
metadata = {'a': 'b' * 260}
- self.assertRaises((exceptions.BadRequest, exceptions.OverLimit),
+ self.assertRaises((lib_exc.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=metadata)
@@ -221,7 +221,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'])
@@ -231,7 +231,7 @@
server_name = data_utils.rand_name('server')
new_name = ''
- self.assertRaises(exceptions.BadRequest, self.client.update_server,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_server,
server_name, name=new_name)
@test.attr(type=['negative', 'gate'])
@@ -239,7 +239,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)
@@ -248,7 +248,7 @@
# Update name of server exceed the name length limit
new_name = 'a' * 256
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_server,
self.server_id,
name=new_name)
@@ -258,13 +258,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 +272,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'])
@@ -286,7 +286,7 @@
# Create a server with a nonexistent security group
security_groups = [{'name': 'does_not_exist'}]
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_test_server,
security_groups=security_groups)
@@ -294,14 +294,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 +310,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 +319,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 +327,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 +337,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 +348,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 +359,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 +367,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 +375,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 +383,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 +391,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 +408,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,
@@ -428,14 +428,14 @@
self.client.wait_for_server_status(self.server_id,
'SHELVED')
- resp, server = self.client.get_server(self.server_id)
+ server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
params = {'name': image_name}
images = self.images_client.list_images(params)
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 +447,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 +455,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.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 48af084..5c76ba7 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -14,6 +14,7 @@
# under the License.
import netaddr
+from tempest_lib import decorators
from tempest.api.compute import base
from tempest import config
@@ -25,16 +26,24 @@
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
# This test needs a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(VirtualInterfacesTestJSON, cls).resource_setup()
+ super(VirtualInterfacesTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(VirtualInterfacesTestJSON, cls).setup_clients()
cls.client = cls.servers_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
+
+ @classmethod
+ def resource_setup(cls):
+ super(VirtualInterfacesTestJSON, cls).resource_setup()
+ server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @test.skip_because(bug="1183436",
- condition=CONF.service_available.neutron)
+ @decorators.skip_because(bug="1183436",
+ condition=CONF.service_available.neutron)
@test.attr(type='gate')
@test.services('network')
def test_list_virtual_interfaces(self):
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
index e81ccc6..58c4fcd 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -15,18 +15,23 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def resource_setup(cls):
+ def setup_credentials(cls):
# For this test no network resources are needed
cls.set_network_resources()
- super(VirtualInterfacesNegativeTestJSON, cls).resource_setup()
+ super(VirtualInterfacesNegativeTestJSON, cls).setup_credentials()
+
+ @classmethod
+ def setup_clients(cls):
+ super(VirtualInterfacesNegativeTestJSON, cls).setup_clients()
cls.client = cls.servers_client
@test.attr(type=['negative', 'gate'])
@@ -35,6 +40,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 60cb812..1211db3 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -15,11 +15,12 @@
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
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest import test
@@ -29,32 +30,44 @@
class AuthorizationTestJSON(base.BaseV2ComputeTest):
+
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(AuthorizationTestJSON, cls).skip_checks()
if not CONF.service_available.glance:
raise cls.skipException('Glance is not available.')
+
+ @classmethod
+ def setup_credentials(cls):
# No network resources required for this test
cls.set_network_resources()
- super(AuthorizationTestJSON, cls).resource_setup()
+ super(AuthorizationTestJSON, cls).setup_credentials()
if not cls.multi_user:
msg = "Need >1 user"
raise cls.skipException(msg)
+
+ creds = cls.isolated_creds.get_alt_creds()
+ cls.alt_manager = clients.Manager(credentials=creds)
+
+ @classmethod
+ def setup_clients(cls):
+ super(AuthorizationTestJSON, cls).setup_clients()
cls.client = cls.os.servers_client
cls.images_client = cls.os.images_client
cls.glance_client = cls.os.image_client
cls.keypairs_client = cls.os.keypairs_client
cls.security_client = cls.os.security_groups_client
- creds = cls.isolated_creds.get_alt_creds()
- cls.alt_manager = clients.Manager(credentials=creds)
-
cls.alt_client = cls.alt_manager.servers_client
cls.alt_images_client = cls.alt_manager.images_client
cls.alt_keypairs_client = cls.alt_manager.keypairs_client
cls.alt_security_client = cls.alt_manager.security_groups_client
- resp, server = cls.create_test_server(wait_until='ACTIVE')
- resp, cls.server = cls.client.get_server(server['id'])
+ @classmethod
+ def resource_setup(cls):
+ super(AuthorizationTestJSON, cls).resource_setup()
+ server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server = cls.client.get_server(server['id'])
name = data_utils.rand_name('image')
body = cls.glance_client.create_image(name=name,
@@ -68,19 +81,18 @@
cls.image = cls.images_client.get_image(image_id)
cls.keypairname = data_utils.rand_name('keypair')
- resp, keypair = \
- cls.keypairs_client.create_keypair(cls.keypairname)
+ cls.keypairs_client.create_keypair(cls.keypairname)
name = data_utils.rand_name('security')
description = data_utils.rand_name('description')
- resp, cls.security_group = cls.security_client.create_security_group(
+ cls.security_group = cls.security_client.create_security_group(
name, description)
parent_group_id = cls.security_group['id']
ip_protocol = 'tcp'
from_port = 22
to_port = 22
- resp, cls.rule = cls.security_client.create_security_group_rule(
+ cls.rule = cls.security_client.create_security_group_rule(
parent_group_id, ip_protocol, from_port, to_port)
@classmethod
@@ -94,32 +106,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')
@@ -136,38 +148,38 @@
@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')
@test.attr(type='gate')
def test_create_server_with_unauthorized_image(self):
# Server creation with another user's image should fail
- self.assertRaises(exceptions.BadRequest, self.alt_client.create_server,
+ self.assertRaises(lib_exc.BadRequest, self.alt_client.create_server,
'test', self.image['id'], self.flavor_ref)
@test.attr(type='gate')
@@ -179,7 +191,7 @@
request_part='url',
auth_data=self.client.auth_provider.auth_data
)
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.alt_client.create_server, 'test',
self.image['id'], self.flavor_ref)
@@ -197,39 +209,39 @@
)
resp = {}
resp['status'] = None
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.alt_keypairs_client.create_keypair, k_name)
finally:
# Next request the base_url is back to normal
if (resp['status'] is not None):
- resp, _ = self.alt_keypairs_client.delete_keypair(k_name)
+ self.alt_keypairs_client.delete_keypair(k_name)
LOG.error("Create keypair request should not happen "
"if the tenant id does not match the current user")
@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'])
@@ -248,7 +260,7 @@
)
resp = {}
resp['status'] = None
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.alt_security_client.create_security_group,
s_name, s_description)
finally:
@@ -261,14 +273,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'])
@@ -289,7 +301,7 @@
)
resp = {}
resp['status'] = None
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.alt_security_client.
create_security_group_rule,
parent_group_id, ip_protocol, from_port,
@@ -306,7 +318,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'])
@@ -314,7 +326,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)
@@ -323,7 +335,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)
@@ -334,7 +346,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')
@@ -346,7 +358,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')
@@ -357,7 +369,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')
@@ -369,13 +381,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/test_extensions.py b/tempest/api/compute/test_extensions.py
index 46e7251..f40ae9f 100644
--- a/tempest/api/compute/test_extensions.py
+++ b/tempest/api/compute/test_extensions.py
@@ -32,8 +32,7 @@
# List of all extensions
if len(CONF.compute_feature_enabled.api_extensions) == 0:
raise self.skipException('There are not any extensions configured')
- resp, extensions = self.extensions_client.list_extensions()
- self.assertEqual(200, resp.status)
+ extensions = self.extensions_client.list_extensions()
ext = CONF.compute_feature_enabled.api_extensions[0]
if ext == 'all':
self.assertIn('Hosts', map(lambda x: x['name'], extensions))
@@ -49,6 +48,5 @@
@test.attr(type='gate')
def test_get_extension(self):
# get the specified extensions
- resp, extension = self.extensions_client.get_extension('os-consoles')
- self.assertEqual(200, resp.status)
+ extension = self.extensions_client.get_extension('os-consoles')
self.assertEqual('os-consoles', extension['alias'])
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index 180dffd..6da6b79 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -44,7 +44,7 @@
]
def _get_server_details(self, server_id):
- _resp, body = self.admin_servers_client.get_server(server_id)
+ body = self.admin_servers_client.get_server(server_id)
return body
def _get_host_for_server(self, server_id):
@@ -69,15 +69,13 @@
if 'ACTIVE' == self._get_server_status(server_id):
return server_id
else:
- _, server = self.create_test_server(wait_until="ACTIVE")
+ server = self.create_test_server(wait_until="ACTIVE")
server_id = server['id']
- self.password = server['adminPass']
- self.password = 'password'
self.created_server_ids.append(server_id)
return server_id
def _volume_clean_up(self, server_id, volume_id):
- resp, body = self.volumes_client.get_volume(volume_id)
+ body = self.volumes_client.get_volume(volume_id)
if body['status'] == 'in-use':
self.servers_client.detach_volume(server_id, volume_id)
self.volumes_client.wait_for_volume_status(volume_id, 'available')
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
index 281b2b3..586bc5c 100644
--- a/tempest/api/compute/test_live_block_migration_negative.py
+++ b/tempest/api/compute/test_live_block_migration_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
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
@@ -45,9 +45,9 @@
def test_invalid_host_for_migration(self):
# Migrating to an invalid host should not change the status
target_host = data_utils.rand_name('host-')
- _, server = self.create_test_server(wait_until="ACTIVE")
+ server = self.create_test_server(wait_until="ACTIVE")
server_id = server['id']
- self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
+ self.assertRaises(lib_exc.BadRequest, self._migrate_server_to,
server_id, target_host)
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index 4177751..db2e281 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -43,16 +43,14 @@
def test_get_quotas(self):
# User can get the quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
+ quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
# get the quota set using user id
- resp, quota_set = self.client.get_quota_set(self.tenant_id,
- self.user_id)
- self.assertEqual(200, resp.status)
+ quota_set = self.client.get_quota_set(self.tenant_id,
+ self.user_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -61,8 +59,7 @@
def test_get_default_quotas(self):
# User can get the default quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
- resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
+ quota_set = self.client.get_default_quota_set(self.tenant_id)
self.assertEqual(quota_set['id'], self.tenant_id)
for quota in expected_quota_set:
self.assertIn(quota, quota_set.keys())
@@ -70,9 +67,7 @@
@test.attr(type='smoke')
def test_compare_tenant_quotas_with_default_quotas(self):
# Tenants are created with the default quota values
- resp, defualt_quota_set = \
+ defualt_quota_set = \
self.client.get_default_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
- resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
- self.assertEqual(200, resp.status)
+ tenant_quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(defualt_quota_set, tenant_quota_set)
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 7fef52f..64ea555 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -53,8 +53,8 @@
def _create_and_attach(self):
# Start a server and wait for it to become ready
admin_pass = self.image_ssh_password
- _, self.server = self.create_test_server(wait_until='ACTIVE',
- adminPass=admin_pass)
+ self.server = self.create_test_server(wait_until='ACTIVE',
+ adminPass=admin_pass)
# Record addresses so that we can ssh later
_, self.server['addresses'] = (
@@ -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..69998d2 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -38,14 +38,13 @@
def test_volume_create_get_delete(self):
# CREATE, GET, DELETE Volume
volume = None
- v_name = data_utils.rand_name('Volume-%s-') % self._interface
+ v_name = data_utils.rand_name('Volume')
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..ba7ee6b 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -42,14 +42,14 @@
cls.volume_list = []
cls.volume_id_list = []
for i in range(3):
- v_name = data_utils.rand_name('volume-%s' % cls._interface)
+ v_name = data_utils.rand_name('volume')
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..ed54aaf 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_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
@@ -39,7 +40,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 +48,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'])
@@ -56,7 +57,7 @@
# in request
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='#$%', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -65,7 +66,7 @@
# in request
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -73,28 +74,28 @@
# Negative: Should not be able to create volume with size zero
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='0', display_name=v_name, metadata=metadata)
@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..5992921 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
@@ -21,16 +22,26 @@
class BaseDataProcessingTest(tempest.test.BaseTestCase):
- _interface = 'json'
+
+ @classmethod
+ 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()
- if not CONF.service_available.sahara:
- raise cls.skipException('Sahara support is required')
-
- cls.os = cls.get_client_manager()
- cls.client = cls.os.data_processing_client
cls.flavor_ref = CONF.compute.flavor_ref
@@ -63,7 +74,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 +88,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 +108,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 +126,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 +139,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 +153,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 +167,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/base.py b/tempest/api/database/base.py
index dd4c684..31c5d2a 100644
--- a/tempest/api/database/base.py
+++ b/tempest/api/database/base.py
@@ -24,22 +24,30 @@
class BaseDatabaseTest(tempest.test.BaseTestCase):
"""Base test case class for all Database API tests."""
- _interface = 'json'
-
@classmethod
- def resource_setup(cls):
- super(BaseDatabaseTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(BaseDatabaseTest, cls).skip_checks()
if not CONF.service_available.trove:
skip_msg = ("%s skipped as trove is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- cls.catalog_type = CONF.database.catalog_type
- cls.db_flavor_ref = CONF.database.db_flavor_ref
- cls.db_current_version = CONF.database.db_current_version
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseDatabaseTest, cls).setup_credentials()
+ cls.os = cls.get_client_manager()
- os = cls.get_client_manager()
- cls.os = os
+ @classmethod
+ def setup_clients(cls):
+ super(BaseDatabaseTest, cls).setup_clients()
cls.database_flavors_client = cls.os.database_flavors_client
cls.os_flavors_client = cls.os.flavors_client
cls.database_limits_client = cls.os.database_limits_client
cls.database_versions_client = cls.os.database_versions_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseDatabaseTest, cls).resource_setup()
+
+ cls.catalog_type = CONF.database.catalog_type
+ cls.db_flavor_ref = CONF.database.db_flavor_ref
+ cls.db_current_version = CONF.database.db_current_version
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index aed1abe..bb7035b 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -20,8 +20,8 @@
class DatabaseFlavorsTest(base.BaseDatabaseTest):
@classmethod
- def resource_setup(cls):
- super(DatabaseFlavorsTest, cls).resource_setup()
+ def setup_clients(cls):
+ super(DatabaseFlavorsTest, cls).setup_clients()
cls.client = cls.database_flavors_client
@test.attr(type='smoke')
@@ -55,7 +55,7 @@
@test.services('compute')
def test_compare_db_flavors_with_os(self):
_, db_flavors = self.client.list_db_flavors()
- _, os_flavors = self.os_flavors_client.list_flavors_with_detail()
+ os_flavors = self.os_flavors_client.list_flavors_with_detail()
self.assertEqual(len(os_flavors), len(db_flavors),
"OS flavors %s do not match DB flavors %s" %
(os_flavors, db_flavors))
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
index 9f14cce..bb9c05d 100644
--- a/tempest/api/database/flavors/test_flavors_negative.py
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -13,20 +13,21 @@
# 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
class DatabaseFlavorsNegativeTest(base.BaseDatabaseTest):
@classmethod
- def resource_setup(cls):
- super(DatabaseFlavorsNegativeTest, cls).resource_setup()
+ def setup_clients(cls):
+ super(DatabaseFlavorsNegativeTest, cls).setup_clients()
cls.client = cls.database_flavors_client
@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/database/limits/test_limits.py b/tempest/api/database/limits/test_limits.py
index 30d0a77..68a3884 100644
--- a/tempest/api/database/limits/test_limits.py
+++ b/tempest/api/database/limits/test_limits.py
@@ -18,7 +18,6 @@
class DatabaseLimitsTest(base.BaseDatabaseTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/database/versions/test_versions.py b/tempest/api/database/versions/test_versions.py
index 80fcecf..37a7407 100644
--- a/tempest/api/database/versions/test_versions.py
+++ b/tempest/api/database/versions/test_versions.py
@@ -18,11 +18,10 @@
class DatabaseVersionsTest(base.BaseDatabaseTest):
- _interface = 'json'
@classmethod
- def resource_setup(cls):
- super(DatabaseVersionsTest, cls).resource_setup()
+ def setup_clients(cls):
+ super(DatabaseVersionsTest, cls).setup_clients()
cls.client = cls.database_versions_client
@test.attr(type='smoke')
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index c6c7dc3..80ad6db 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -21,7 +21,6 @@
class RolesTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 58f726a..c38e6e0 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -13,16 +13,15 @@
# 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
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
def _get_role_params(self):
self.data.setup_test_user()
@@ -35,7 +34,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,19 +42,19 @@
# 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'])
def test_role_create_blank_name(self):
# Should not be able to create a role with a blank name
- self.assertRaises(exceptions.BadRequest, self.client.create_role, '')
+ self.assertRaises(lib_exc.BadRequest, self.client.create_role, '')
@test.attr(type=['negative', 'gate'])
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 +63,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 +74,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 +84,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 +96,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 +105,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 +113,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 +123,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 +133,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 +141,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 +149,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 +160,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 +173,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 +186,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 +197,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 +206,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 +217,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..af38afc 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -14,21 +14,20 @@
# 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
class ServicesTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
def _del_service(self, service_id):
# 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..db51f14 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -13,21 +13,20 @@
# 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
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@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 +34,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 +43,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 +54,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 +75,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,27 +91,27 @@
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()
@test.attr(type=['negative', 'gate'])
def test_create_tenant_with_empty_name(self):
# Tenant name should not be empty
- self.assertRaises(exceptions.BadRequest, self.client.create_tenant,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_tenant,
name='')
@test.attr(type=['negative', 'gate'])
def test_create_tenants_name_length_over_64(self):
# Tenant name length should not be greater than 64 characters
tenant_name = 'a' * 65
- self.assertRaises(exceptions.BadRequest, self.client.create_tenant,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_tenant,
tenant_name)
@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 +120,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 +131,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_tenants.py b/tempest/api/identity/admin/test_tenants.py
index 549e952..cfae3a1 100644
--- a/tempest/api/identity/admin/test_tenants.py
+++ b/tempest/api/identity/admin/test_tenants.py
@@ -21,7 +21,6 @@
class TenantsTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_tenant_list_delete(self):
diff --git a/tempest/api/identity/admin/test_tokens.py b/tempest/api/identity/admin/test_tokens.py
index bec621c..5323fde 100644
--- a/tempest/api/identity/admin/test_tokens.py
+++ b/tempest/api/identity/admin/test_tokens.py
@@ -19,7 +19,6 @@
class TokensTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_create_get_delete_token(self):
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 25312e8..9159468 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -21,7 +21,6 @@
class UsersTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index c039da6..99993b9 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -13,16 +13,15 @@
# 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
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -35,7 +34,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)
@@ -44,7 +43,7 @@
def test_create_user_with_empty_name(self):
# User with an empty name should not be created
self.data.setup_test_tenant()
- self.assertRaises(exceptions.BadRequest, self.client.create_user, '',
+ self.assertRaises(lib_exc.BadRequest, self.client.create_user, '',
self.alt_password, self.data.tenant['id'],
self.alt_email)
@@ -52,7 +51,7 @@
def test_create_user_with_name_length_over_255(self):
# Length of user name filed should be restricted to 255 characters
self.data.setup_test_tenant()
- self.assertRaises(exceptions.BadRequest, self.client.create_user,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_user,
'a' * 256, self.alt_password,
self.data.tenant['id'], self.alt_email)
@@ -60,14 +59,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 +78,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)
@@ -91,7 +90,7 @@
# Attempt to create a user with valid enabled para should fail
self.data.setup_test_tenant()
name = data_utils.rand_name('test_user_')
- self.assertRaises(exceptions.BadRequest, self.client.create_user,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_user,
name, self.alt_password,
self.data.tenant['id'],
self.alt_email, enabled=3)
@@ -101,7 +100,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 +111,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 +121,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 +146,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 +157,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 +167,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 +176,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 +185,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 +193,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 +201,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 +209,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 +224,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_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 6f2f6d4..f22ceec 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -19,7 +19,6 @@
class CredentialsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/v3/test_default_project_id.py b/tempest/api/identity/admin/v3/test_default_project_id.py
index bd29cb8..72d323a 100644
--- a/tempest/api/identity/admin/v3/test_default_project_id.py
+++ b/tempest/api/identity/admin/v3/test_default_project_id.py
@@ -18,7 +18,6 @@
class TestDefaultProjectId (base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -74,8 +73,7 @@
domain_name=dom_name)
auth_provider = auth.KeystoneV3AuthProvider(creds)
creds = auth_provider.fill_credentials()
- admin_client = clients.Manager(interface=self._interface,
- credentials=creds)
+ admin_client = clients.Manager(credentials=creds)
# verify the user's token and see that it is scoped to the project
token, auth_data = admin_client.auth_provider.get_auth()
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index c1bc705..0914674 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -20,7 +20,6 @@
class DomainsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
def _delete_domain(self, domain_id):
# It is necessary to disable the domain before deleting,
@@ -62,10 +61,7 @@
self.assertIsNotNone(domain['id'])
self.assertEqual(d_name, domain['name'])
self.assertEqual(d_desc, domain['description'])
- if self._interface == "json":
- self.assertEqual(True, domain['enabled'])
- else:
- self.assertEqual('true', str(domain['enabled']).lower())
+ self.assertEqual(True, domain['enabled'])
new_desc = data_utils.rand_name('new-desc-')
new_name = data_utils.rand_name('new-name-')
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index eed0eb5..2283c21 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -19,7 +19,6 @@
class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index 9da0a57..cf41f9c 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -14,15 +14,14 @@
# 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
class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -51,7 +50,7 @@
interface = 'public'
url = data_utils.rand_url()
region = data_utils.rand_name('region')
- self.assertRaises(exceptions.BadRequest, self.client.create_endpoint,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint,
self.service_id, interface, url, region=region,
force_enabled='False')
@@ -61,7 +60,7 @@
interface = 'public'
url = data_utils.rand_url()
region = data_utils.rand_name('region')
- self.assertRaises(exceptions.BadRequest, self.client.create_endpoint,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint,
self.service_id, interface, url, region=region,
force_enabled='True')
@@ -76,7 +75,7 @@
url1, region=region1, enabled=True))
self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id'])
- self.assertRaises(exceptions.BadRequest, self.client.update_endpoint,
+ self.assertRaises(lib_exc.BadRequest, self.client.update_endpoint,
endpoint_for_update['id'], force_enabled=enabled)
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index d8c7063..6dfddb0 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -19,7 +19,6 @@
class GroupsV3TestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index c0187f9..24b130c 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -19,7 +19,6 @@
class ListProjectsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index e728867..a6c3309 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -19,7 +19,6 @@
class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
def _list_users_with_params(self, params, key, expected, not_expected):
# Helper method to list users filtered with params and
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 23df13d..0d5dc47 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -19,7 +19,6 @@
class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
def _delete_policy(self, policy_id):
self.policy_client.delete_policy(policy_id)
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index 2cf6458..d879c7a 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -19,7 +19,6 @@
class ProjectsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_project_create_with_description(self):
diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
index f5e832b..a194198 100644
--- a/tempest/api/identity/admin/v3/test_projects_negative.py
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -13,19 +13,19 @@
# 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
class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@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,27 +36,27 @@
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'])
def test_create_project_with_empty_name(self):
# Project name should not be empty
- self.assertRaises(exceptions.BadRequest, self.client.create_project,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_project,
name='')
@test.attr(type=['negative', 'gate'])
def test_create_projects_name_length_over_64(self):
# Project name length should not be greater than 64 characters
project_name = 'a' * 65
- self.assertRaises(exceptions.BadRequest, self.client.create_project,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_project,
project_name)
@test.attr(type=['negative', 'gate'])
@@ -66,11 +66,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..359c0cf 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -13,14 +13,14 @@
# 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
class RegionsTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -40,7 +40,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_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index b8b309d..747911b 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -19,7 +19,6 @@
class RolesV3TestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -140,9 +139,11 @@
self.client.add_group_user(self.group_body['id'], self.user_body['id'])
self.addCleanup(self.client.delete_group_user,
self.group_body['id'], self.user_body['id'])
- body = self.token.auth(self.user_body['id'], self.u_password,
- self.project['name'],
- domain=self.domain['name'])
+ body = self.token.auth(user=self.user_body['id'],
+ password=self.u_password,
+ user_domain=self.domain['name'],
+ project=self.project['name'],
+ project_domain=self.domain['name'])
roles = body['token']['roles']
self.assertEqual(len(roles), 1)
self.assertEqual(roles[0]['id'], self.role['id'])
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 9e45b50..13e6d66 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -13,20 +13,20 @@
# 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
class ServicesTestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
def _del_service(self, service_id):
# 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..919eab9 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -13,14 +13,14 @@
# 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
class TokensV3TestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@test.attr(type='smoke')
def test_tokens(self):
@@ -44,7 +44,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')
@@ -108,8 +108,8 @@
# Use the unscoped token to get a scoped token.
token_auth = self.token.auth(token=token_id,
- tenant=project1_name,
- domain='Default')
+ project=project1_name,
+ project_domain='Default')
token1_id = token_auth.response['x-subject-token']
self.assertEqual(orig_expires_at, token_auth['token']['expires_at'],
@@ -138,8 +138,8 @@
# Now get another scoped token using the unscoped token.
token_auth = self.token.auth(token=token_id,
- tenant=project2_name,
- domain='Default')
+ project=project2_name,
+ project_domain='Default')
self.assertEqual(project2['id'],
token_auth['token']['project']['id'])
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index cd28e96..48201ec 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -13,12 +13,13 @@
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
from tempest.openstack.common import timeutils
from tempest import test
@@ -87,13 +88,11 @@
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)
- os = clients.Manager(
- credentials=creds,
- interface=self._interface)
+ os = clients.Manager(credentials=creds)
self.trustor_client = os.identity_v3_client
def cleanup_user_and_roles(self):
@@ -166,26 +165,25 @@
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
class TrustsV3TestJSON(BaseTrustsV3Test):
- _interface = 'json'
def setUp(self):
super(TrustsV3TestJSON, self).setUp()
@@ -238,7 +236,7 @@
# is rejected with the correct error
# with an expiry specified
expires_str = 'bad.123Z'
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_trust,
expires=expires_str)
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 4f3ec05..2481d9d 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -19,7 +19,6 @@
class UsersV3TestJSON(base.BaseIdentityV3AdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_user_update(self):
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 08bfd4f..8f07a6a 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
@@ -31,8 +31,8 @@
@classmethod
def resource_setup(cls):
super(BaseIdentityAdminTest, cls).resource_setup()
- cls.os_adm = clients.AdminManager(interface=cls._interface)
- cls.os = clients.Manager(interface=cls._interface)
+ cls.os_adm = clients.AdminManager()
+ cls.os = clients.Manager()
@classmethod
def disable_user(cls, user_name):
@@ -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/identity/test_extension.py b/tempest/api/identity/test_extension.py
index e3badfc..bbc4c13 100644
--- a/tempest/api/identity/test_extension.py
+++ b/tempest/api/identity/test_extension.py
@@ -18,7 +18,6 @@
class ExtensionTestJSON(base.BaseIdentityV2AdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_list_extensions(self):
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 12f3fdd..ffc3071 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
@@ -31,24 +31,31 @@
"""Base test class for Image API tests."""
@classmethod
+ def skip_checks(cls):
+ super(BaseImageTest, cls).skip_checks()
+ if not CONF.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseImageTest, cls).setup_credentials()
+ cls.isolated_creds = credentials.get_isolated_credentials(
+ cls.__name__, network_resources=cls.network_resources)
+ cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
+
+ @classmethod
def resource_setup(cls):
cls.set_network_resources()
super(BaseImageTest, cls).resource_setup()
cls.created_images = []
- cls._interface = 'json'
- cls.isolated_creds = credentials.get_isolated_credentials(
- cls.__name__, network_resources=cls.network_resources)
- if not CONF.service_available.glance:
- skip_msg = ("%s skipped as glance is not available" % cls.__name__)
- raise cls.skipException(skip_msg)
- cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
@classmethod
def resource_cleanup(cls):
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:
@@ -76,21 +83,33 @@
class BaseV1ImageTest(BaseImageTest):
@classmethod
- def resource_setup(cls):
- super(BaseV1ImageTest, cls).resource_setup()
- cls.client = cls.os.image_client
+ def skip_checks(cls):
+ super(BaseV1ImageTest, cls).skip_checks()
if not CONF.image_feature_enabled.api_v1:
msg = "Glance API v1 not supported"
raise cls.skipException(msg)
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV1ImageTest, cls).setup_clients()
+ cls.client = cls.os.image_client
+
class BaseV1ImageMembersTest(BaseV1ImageTest):
+
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseV1ImageMembersTest, cls).setup_credentials()
+ cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV1ImageMembersTest, cls).setup_clients()
+ cls.alt_img_cli = cls.os_alt.image_client
+
@classmethod
def resource_setup(cls):
super(BaseV1ImageMembersTest, cls).resource_setup()
- cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
-
- cls.alt_img_cli = cls.os_alt.image_client
cls.alt_tenant_id = cls.alt_img_cli.tenant_id
def _create_image(self):
@@ -106,23 +125,35 @@
class BaseV2ImageTest(BaseImageTest):
@classmethod
- def resource_setup(cls):
- super(BaseV2ImageTest, cls).resource_setup()
- cls.client = cls.os.image_client_v2
+ def skip_checks(cls):
+ super(BaseV2ImageTest, cls).skip_checks()
if not CONF.image_feature_enabled.api_v2:
msg = "Glance API v2 not supported"
raise cls.skipException(msg)
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV2ImageTest, cls).setup_clients()
+ cls.client = cls.os.image_client_v2
+
class BaseV2MemberImageTest(BaseV2ImageTest):
@classmethod
- def resource_setup(cls):
- super(BaseV2MemberImageTest, cls).resource_setup()
+ def setup_credentials(cls):
+ super(BaseV2MemberImageTest, cls).setup_credentials()
creds = cls.isolated_creds.get_alt_creds()
cls.os_alt = clients.Manager(creds)
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseV2MemberImageTest, cls).setup_clients()
cls.os_img_client = cls.os.image_client_v2
cls.alt_img_client = cls.os_alt.image_client_v2
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseV2MemberImageTest, cls).resource_setup()
cls.alt_tenant_id = cls.alt_img_client.tenant_id
def _list_image_ids_as_alt(self):
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..698bac0 100644
--- a/tempest/api/image/v1/test_images_negative.py
+++ b/tempest/api/image/v1/test_images_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.image import base
-from tempest import exceptions
from tempest import test
@@ -24,18 +25,18 @@
@test.attr(type=['negative', 'gate'])
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
'test', 'wrong', 'vhd')
@test.attr(type=['negative', 'gate'])
def test_register_with_invalid_disk_format(self):
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
'test', 'bare', 'wrong')
@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 +44,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.py b/tempest/api/image/v2/test_images.py
index e307c5c..6b654ca 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -65,8 +65,8 @@
self.assertEqual(1024, body.get('size'))
# Now try get image file
- _, body = self.client.get_image_file(image_id)
- self.assertEqual(file_content, body)
+ body = self.client.get_image_file(image_id)
+ self.assertEqual(file_content, body.data)
@test.attr(type='gate')
def test_delete_image(self):
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index ec1cf14..956829e 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -15,7 +15,6 @@
class ImagesMemberTest(base.BaseV2MemberImageTest):
- _interface = 'json'
@test.attr(type='gate')
def test_image_share_accept(self):
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index 1f8e3d0..068a6e5 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -10,13 +10,13 @@
# 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
class ImagesMemberNegativeTest(base.BaseV2MemberImageTest):
- _interface = 'json'
@test.attr(type=['negative', 'gate'])
def test_image_share_invalid_status(self):
@@ -24,7 +24,7 @@
member = self.os_img_client.add_member(image_id,
self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.alt_img_client.update_member_status,
image_id, self.alt_tenant_id, 'notavalidstatus')
@@ -35,7 +35,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..9f0ad2d 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -16,8 +16,9 @@
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 +40,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,33 +61,33 @@
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'])
def test_register_with_invalid_container_format(self):
# Negative tests for invalid data supplied to POST /images
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
'test', 'wrong', 'vhd')
@test.attr(type=['negative', 'gate'])
def test_register_with_invalid_disk_format(self):
- self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_image,
'test', 'bare', 'wrong')
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/base.py b/tempest/api/messaging/base.py
index 58511a9..eae0707 100644
--- a/tempest/api/messaging/base.py
+++ b/tempest/api/messaging/base.py
@@ -35,13 +35,25 @@
"""
@classmethod
- def resource_setup(cls):
- super(BaseMessagingTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(BaseMessagingTest, cls).skip_checks()
if not CONF.service_available.zaqar:
raise cls.skipException("Zaqar support is required")
- os = cls.get_client_manager()
+
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseMessagingTest, cls).setup_credentials()
+ cls.os = cls.get_client_manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseMessagingTest, cls).setup_clients()
+ cls.client = cls.os.messaging_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseMessagingTest, cls).resource_setup()
cls.messaging_cfg = CONF.messaging
- cls.client = os.messaging_client
@classmethod
def create_queue(cls, queue_name):
diff --git a/tempest/api/messaging/test_claims.py b/tempest/api/messaging/test_claims.py
index 1b004dd..c9064b0 100644
--- a/tempest/api/messaging/test_claims.py
+++ b/tempest/api/messaging/test_claims.py
@@ -16,6 +16,8 @@
import logging
import urlparse
+from tempest_lib import decorators
+
from tempest.api.messaging import base
from tempest.common.utils import data_utils
from tempest import config
@@ -27,7 +29,6 @@
class TestClaims(base.BaseMessagingTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -65,7 +66,7 @@
# Delete Claimed message
self.client.delete_messages(claimed_message_uri)
- @test.skip_because(bug="1331517")
+ @decorators.skip_because(bug="1331517")
@test.attr(type='smoke')
def test_query_claim(self):
# Post a Claim
@@ -79,7 +80,7 @@
claimed_message_uri = body[0]['href']
self.delete_messages(claimed_message_uri)
- @test.skip_because(bug="1328111")
+ @decorators.skip_because(bug="1328111")
@test.attr(type='smoke')
def test_update_claim(self):
# Post a Claim
diff --git a/tempest/api/messaging/test_messages.py b/tempest/api/messaging/test_messages.py
index 3c27ac2..dca95fc 100644
--- a/tempest/api/messaging/test_messages.py
+++ b/tempest/api/messaging/test_messages.py
@@ -26,7 +26,6 @@
class TestMessages(base.BaseMessagingTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/messaging/test_queues.py b/tempest/api/messaging/test_queues.py
index accbd17..24656bf 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,13 +42,12 @@
self.assertEqual('', body)
self.delete_queue(queue_name)
- self.assertRaises(exceptions.NotFound,
+ self.assertRaises(lib_exc.NotFound,
self.client.get_queue,
queue_name)
class TestManageQueue(base.BaseMessagingTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index e7fd016..20948cc 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -18,7 +18,6 @@
class AgentManagementTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index a89f25c..4eb6b87 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -17,7 +17,6 @@
class DHCPAgentSchedulersTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 06cce48..6e24f8e 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -15,7 +15,6 @@
class ExternalNetworksTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py
index 7dbb347..aa8dd9a 100644
--- a/tempest/api/network/admin/test_external_networks_negative.py
+++ b/tempest/api/network/admin/test_external_networks_negative.py
@@ -13,16 +13,16 @@
# 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
class ExternalNetworksAdminNegativeTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
@test.attr(type=['negative'])
def test_create_port_with_precreated_floatingip_as_fixed_ip(self):
@@ -47,7 +47,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/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index 62ba1b3..ee3b0bb 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -22,7 +22,7 @@
class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
+
force_tenant_isolation = True
@classmethod
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index a6de581..05a8e35 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -18,7 +18,6 @@
class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
index da1af36..8cfd5c2 100644
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -18,7 +18,6 @@
class LBaaSAgentSchedulerTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
index e81616b..2537b28 100644
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -19,7 +19,6 @@
class LoadBalancerAdminTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Test admin actions for load balancer.
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index f8dfca9..39850f5 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -20,7 +20,6 @@
class QuotasTest(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 10cda53..e8c8de3 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
@@ -49,7 +50,6 @@
neutron as True
"""
- _interface = 'json'
force_tenant_isolation = False
# Default to ipv4.
@@ -177,7 +177,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
@@ -223,7 +223,7 @@
gateway_ip=gateway_ip,
**kwargs)
break
- except exceptions.BadRequest as e:
+ except lib_exc.BadRequest as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
@@ -399,7 +399,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'])
@@ -420,8 +420,7 @@
try:
creds = cls.isolated_creds.get_admin_creds()
- cls.os_adm = clients.Manager(
- credentials=creds, interface=cls._interface)
+ cls.os_adm = clients.Manager(credentials=creds)
except NotImplementedError:
msg = ("Missing Administrative Network API credentials "
"in configuration.")
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 57887ac..a4954af 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -23,7 +23,6 @@
class AllowedAddressPairTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the Neutron Allowed Address Pair API extension using the Tempest
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index 1257699..1b28bac 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -16,10 +16,11 @@
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
-from tempest import exceptions
CONF = config.CONF
@@ -144,7 +145,7 @@
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_subnet,
self.network,
**kwargs)
@@ -327,7 +328,7 @@
subnet["allocation_pools"][0]["end"])
ip = netaddr.IPAddress(random.randrange(
ip_range.last + 1, ip_range.last + 10)).format()
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.create_port,
self.network,
fixed_ips=[{'subnet_id': subnet['id'],
@@ -348,7 +349,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_extensions.py b/tempest/api/network/test_extensions.py
index 54c3cb9..2b4ccaf 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -19,7 +19,6 @@
class ExtensionsTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index bd70323..1faac58 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -19,7 +19,6 @@
class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations with the Extra DHCP Options Neutron API
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 1151c5d..43b296c 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -24,7 +24,6 @@
class FloatingIPTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Quantum API using the REST client for
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index 82f0519..7d70976 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -14,17 +14,18 @@
# 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
class FloatingIPNegativeTestJSON(base.BaseNetworkTest):
- _interface = 'json'
+
"""
Test the following negative operations for floating ips:
@@ -49,7 +50,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]
@@ -57,7 +58,7 @@
@test.attr(type=['negative', 'smoke'])
def test_create_floatingip_in_private_network(self):
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.create_floatingip,
floating_network_id=self.network['id'],
port_id=self.port['id'],
@@ -72,7 +73,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..280c5bb 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
@@ -22,7 +24,6 @@
class FWaaSExtensionTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
@@ -63,7 +64,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 +72,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 +80,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_load_balancer.py b/tempest/api/network/test_load_balancer.py
index b606115..107d8cd 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -13,13 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
+
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import test
class LoadBalancerTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
@@ -422,6 +423,6 @@
self.assertEqual(2, member['weight'])
-@test.skip_because(bug="1402007")
+@decorators.skip_because(bug="1402007")
class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
_ip_version = 6
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 6ba1ea4..c80d0e9 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -24,7 +24,6 @@
class MeteringTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 65aeb24..0df455e 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -15,19 +15,18 @@
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
class NetworksTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
@@ -280,7 +279,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 +299,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
@@ -399,7 +398,6 @@
class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
@@ -614,7 +612,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..09bd9c3 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -14,41 +14,41 @@
# 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
class NetworksNegativeTestJSON(base.BaseNetworkTest):
- _interface = 'json'
@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_ports.py b/tempest/api/network/test_ports.py
index bf85e90..2460092 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -27,7 +27,6 @@
class PortsTestJSON(sec_base.BaseSecGroupTest):
- _interface = 'json'
"""
Test the following operations for ports:
@@ -300,7 +299,6 @@
class PortsAdminExtendedAttrsTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 210a8af..b0ee00d 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -25,7 +25,6 @@
class RoutersTest(base.BaseRouterTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index d571e92..67a6c94 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -14,18 +14,17 @@
# 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
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
class RoutersNegativeTest(base.BaseRouterTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -42,7 +41,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={
@@ -54,7 +53,7 @@
network_name=data_utils.rand_name('router-negative-'))
sub_cidr = netaddr.IPNetwork(self.tenant_cidr).next()
self.create_subnet(alt_network, cidr=sub_cidr)
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_router,
self.router['id'],
external_gateway_info={
@@ -70,7 +69,7 @@
subnet02 = self.create_subnet(network02)
self._add_router_interface_with_subnet_id(self.router['id'],
subnet01['id'])
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self._add_router_interface_with_subnet_id,
self.router['id'],
subnet02['id'])
@@ -79,26 +78,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.py b/tempest/api/network/test_security_groups.py
index 415dedd..f9af3cc 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -24,7 +24,7 @@
class SecGroupTest(base.BaseSecGroupTest):
- _interface = 'json'
+
_tenant_network_cidr = CONF.network.tenant_network_cidr
@classmethod
@@ -162,7 +162,7 @@
"""Verify security group rule for icmp protocol works.
Specify icmp type (port_range_min) and icmp code
- (port_range_max) with different values. A seperate testcase
+ (port_range_max) with different values. A separate testcase
is added for icmp protocol as icmp validation would be
different from tcp/udp.
"""
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index fb51e30..0da1aac 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -15,16 +15,17 @@
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
from tempest import test
CONF = config.CONF
class NegativeSecGroupTest(base.BaseSecGroupTest):
- _interface = 'json'
+
_tenant_network_cidr = CONF.network.tenant_network_cidr
@classmethod
@@ -37,20 +38,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
)
@@ -62,7 +63,7 @@
# Create rule with bad protocol name
pname = 'bad_protocol_name'
self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol=pname, direction='ingress', ethertype=self.ethertype)
@@ -74,7 +75,7 @@
prefix = ['192.168.1./24', '192.168.1.1/33', 'bad_prefix', '256']
for remote_ip_prefix in prefix:
self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol='tcp', direction='ingress', ethertype=self.ethertype,
remote_ip_prefix=remote_ip_prefix)
@@ -88,7 +89,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)
@@ -101,7 +102,7 @@
# Create rule specifying both remote_ip_prefix and remote_group_id
prefix = self._tenant_network_cidr
self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=sg1_body['security_group']['id'],
protocol='tcp', direction='ingress',
ethertype=self.ethertype, remote_ip_prefix=prefix,
@@ -114,7 +115,7 @@
# Create rule with bad ethertype
ethertype = 'bad_ethertype'
self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol='udp', direction='ingress', ethertype=ethertype)
@@ -130,7 +131,7 @@
(-16, 65536, 'Invalid value for port')]
for pmin, pmax, msg in states:
ex = self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol='tcp', port_range_min=pmin, port_range_max=pmax,
direction='ingress', ethertype=self.ethertype)
@@ -142,7 +143,7 @@
(300, 1, 'Invalid value for ICMP type')]
for pmin, pmax, msg in states:
ex = self.assertRaises(
- exceptions.BadRequest, self.client.create_security_group_rule,
+ lib_exc.BadRequest, self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
protocol='icmp', port_range_min=pmin, port_range_max=pmax,
direction='ingress', ethertype=self.ethertype)
@@ -152,7 +153,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 +176,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 +185,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)
@@ -205,7 +206,7 @@
'ip_prefix': CONF.network.tenant_network_v6_cidr})
for pair in pairs:
self.assertRaisesRegexp(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
"Conflicting value ethertype",
self.client.create_security_group_rule,
security_group_id=group_create_body['security_group']['id'],
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index 447c3f3..e620ae6 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -10,12 +10,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
+
from tempest.api.network import base
from tempest import test
class ServiceTypeManagementTestJSON(base.BaseNetworkTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -24,7 +25,7 @@
msg = "Neutron Service Type Management not enabled."
raise cls.skipException(msg)
- @test.skip_because(bug="1400370")
+ @decorators.skip_because(bug="1400370")
@test.attr(type='smoke')
def test_service_provider_list(self):
body = self.client.list_service_providers()
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 56e1a05..d869b55 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -13,17 +13,17 @@
# 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
class VPNaaSTestJSON(base.BaseAdminNetworkTest):
- _interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
@@ -74,7 +74,7 @@
try:
self.client.delete_ipsecpolicy(ipsec_policy_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
def _assertExpected(self, expected, actual):
@@ -304,7 +304,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..6a025d9 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
@@ -28,21 +28,31 @@
class BaseObjectTest(tempest.test.BaseTestCase):
@classmethod
- def resource_setup(cls):
- cls.set_network_resources()
- super(BaseObjectTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(BaseObjectTest, cls).skip_checks()
if not CONF.service_available.swift:
skip_msg = ("%s skipped as swift is not available" % cls.__name__)
raise cls.skipException(skip_msg)
+
+ @classmethod
+ def setup_credentials(cls):
+ cls.set_network_resources()
+ super(BaseObjectTest, cls).setup_credentials()
+
cls.isolated_creds = credentials.get_isolated_credentials(
cls.__name__, network_resources=cls.network_resources)
# Get isolated creds for normal user
cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
# Get isolated creds for admin user
cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
+ cls.data = SwiftDataGenerator(cls.os_admin.identity_client)
# Get isolated creds for alt user
cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
+ @classmethod
+ def setup_clients(cls):
+ super(BaseObjectTest, cls).setup_clients()
+
cls.object_client = cls.os.object_client
cls.container_client = cls.os.container_client
cls.account_client = cls.os.account_client
@@ -52,6 +62,10 @@
cls.container_client_alt = cls.os_alt.container_client
cls.identity_client_alt = cls.os_alt.identity_client
+ @classmethod
+ def resource_setup(cls):
+ super(BaseObjectTest, cls).resource_setup()
+
# Make sure we get fresh auth data after assigning swift role
cls.object_client.auth_provider.clear_auth()
cls.container_client.auth_provider.clear_auth()
@@ -59,8 +73,6 @@
cls.object_client_alt.auth_provider.clear_auth()
cls.container_client_alt.auth_provider.clear_auth()
- cls.data = SwiftDataGenerator(cls.identity_admin_client)
-
@classmethod
def resource_cleanup(cls):
cls.data.teardown_all()
@@ -93,10 +105,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 +138,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.py b/tempest/api/object_storage/test_account_quotas.py
index 1832b37..e3f5f3d 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -26,15 +26,17 @@
class AccountQuotasTest(base.BaseObjectTest):
@classmethod
+ def setup_credentials(cls):
+ super(AccountQuotasTest, cls).setup_credentials()
+ cls.data.setup_test_user(reseller=True)
+ cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
+
+ @classmethod
def resource_setup(cls):
super(AccountQuotasTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name="TestContainer")
cls.container_client.create_container(cls.container_name)
- cls.data.setup_test_user(reseller=True)
-
- cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
-
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index a6ea6ee..783bf1a 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -14,11 +14,13 @@
# License for the specific language governing permissions and limitations
# 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
@@ -27,15 +29,17 @@
class AccountQuotasNegativeTest(base.BaseObjectTest):
@classmethod
+ def setup_credentials(cls):
+ super(AccountQuotasNegativeTest, cls).setup_credentials()
+ cls.data.setup_test_user(reseller=True)
+ cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
+
+ @classmethod
def resource_setup(cls):
super(AccountQuotasNegativeTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name="TestContainer")
cls.container_client.create_container(cls.container_name)
- cls.data.setup_test_user(reseller=True)
-
- cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
-
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
@@ -83,21 +87,21 @@
"""
# 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"})
@test.attr(type=["negative", "smoke"])
- @test.skip_because(bug="1310597")
+ @decorators.skip_because(bug="1310597")
@test.requires_ext(extension='account_quotas', service='object')
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.py b/tempest/api/object_storage/test_container_acl.py
index 205bc91..44763a1 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -20,12 +20,17 @@
class ObjectTestACLs(base.BaseObjectTest):
+
+ @classmethod
+ def setup_credentials(cls):
+ super(ObjectTestACLs, cls).setup_credentials()
+ cls.data.setup_test_user()
+ cls.test_os = clients.Manager(cls.data.test_credentials)
+
@classmethod
def resource_setup(cls):
super(ObjectTestACLs, cls).resource_setup()
- cls.data.setup_test_user()
- test_os = clients.Manager(cls.data.test_credentials)
- cls.test_auth_data = test_os.auth_provider.auth_data
+ cls.test_auth_data = cls.test_os.auth_provider.auth_data
def setUp(self):
super(ObjectTestACLs, self).setUp()
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index 138d25a..edc052e 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -14,20 +14,26 @@
# 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
class ObjectACLsNegativeTest(base.BaseObjectTest):
+
+ @classmethod
+ def setup_credentials(cls):
+ super(ObjectACLsNegativeTest, cls).setup_credentials()
+ cls.data.setup_test_user()
+ cls.test_os = clients.Manager(cls.data.test_credentials)
+
@classmethod
def resource_setup(cls):
super(ObjectACLsNegativeTest, cls).resource_setup()
- cls.data.setup_test_user()
- test_os = clients.Manager(cls.data.test_credentials)
- cls.test_auth_data = test_os.auth_provider.auth_data
+ cls.test_auth_data = cls.test_os.auth_provider.auth_data
def setUp(self):
super(ObjectACLsNegativeTest, self).setUp()
@@ -47,7 +53,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 +69,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 +83,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 +100,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 +117,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 +140,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 +159,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 +181,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 +207,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_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index 7f8cb8b..09b0ce0 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
import testtools
import time
import urlparse
@@ -112,7 +113,7 @@
self.assertEqual(object_content, obj_name[::-1])
@test.attr(type='slow')
- @test.skip_because(bug='1317133')
+ @decorators.skip_because(bug='1317133')
@testtools.skipIf(
not CONF.object_storage_feature_enabled.container_sync,
'Old-style container sync function is disabled')
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index 53c0347..6fbd77b 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -22,10 +22,6 @@
class HealthcheckTest(base.BaseObjectTest):
- @classmethod
- def resource_setup(cls):
- super(HealthcheckTest, cls).resource_setup()
-
def setUp(self):
super(HealthcheckTest, self).setUp()
# Turning http://.../v1/foobar into http://.../
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 d3dffbf..b8b0562 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
@@ -30,14 +30,19 @@
"""Base test case class for all Orchestration API tests."""
@classmethod
- def resource_setup(cls):
- super(BaseOrchestrationTest, cls).resource_setup()
- cls.os = clients.Manager()
+ def skip_checks(cls):
+ super(BaseOrchestrationTest, cls).skip_checks()
if not CONF.service_available.heat:
raise cls.skipException("Heat support is required")
- cls.build_timeout = CONF.orchestration.build_timeout
- cls.build_interval = CONF.orchestration.build_interval
+ @classmethod
+ def setup_credentials(cls):
+ super(BaseOrchestrationTest, cls).setup_credentials()
+ cls.os = clients.Manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseOrchestrationTest, cls).setup_clients()
cls.orchestration_client = cls.os.orchestration_client
cls.client = cls.orchestration_client
cls.servers_client = cls.os.servers_client
@@ -45,6 +50,12 @@
cls.network_client = cls.os.network_client
cls.volumes_client = cls.os.volumes_client
cls.images_v2_client = cls.os.image_client_v2
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseOrchestrationTest, cls).resource_setup()
+ cls.build_timeout = CONF.orchestration.build_timeout
+ cls.build_interval = CONF.orchestration.build_interval
cls.stacks = []
cls.keypairs = []
cls.images = []
@@ -59,7 +70,7 @@
@classmethod
def _get_identity_admin_client(cls):
"""Returns an instance of the Identity Admin API client."""
- manager = clients.AdminManager(interface=cls._interface)
+ manager = clients.AdminManager()
admin_client = manager.identity_client
return admin_client
@@ -84,20 +95,20 @@
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
def _create_keypair(cls, name_start='keypair-heat-'):
kp_name = data_utils.rand_name(name_start)
- _, body = cls.keypairs_client.create_keypair(kp_name)
+ body = cls.keypairs_client.create_keypair(kp_name)
cls.keypairs.append(kp_name)
return body
@@ -125,7 +136,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_limits.py b/tempest/api/orchestration/stacks/test_limits.py
index 8ee62ab..5f7f954 100644
--- a/tempest/api/orchestration/stacks/test_limits.py
+++ b/tempest/api/orchestration/stacks/test_limits.py
@@ -11,11 +11,11 @@
# under the License.
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
CONF = config.CONF
@@ -34,7 +34,7 @@
Description: '%s'
Outputs:
Foo: bar''' % fill
- ex = self.assertRaises(exceptions.BadRequest, self.create_stack,
+ ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
stack_name, template)
self.assertIn('Template exceeds maximum allowed size', str(ex))
@@ -48,6 +48,6 @@
for i in range(num_resources):
template += rsrc_snippet % i
- ex = self.assertRaises(exceptions.BadRequest, self.create_stack,
+ ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
stack_name, template)
self.assertIn('Maximum resources per stack exceeded', str(ex))
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index ea6d4be..3987ee3 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -30,15 +30,27 @@
class NeutronResourcesTestJSON(base.BaseOrchestrationTest):
@classmethod
- def resource_setup(cls):
- super(NeutronResourcesTestJSON, cls).resource_setup()
+ def skip_checks(cls):
+ super(NeutronResourcesTestJSON, cls).skip_checks()
if not CONF.orchestration.image_ref:
raise cls.skipException("No image available to test")
- os = clients.Manager()
if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
+
+ @classmethod
+ def setup_credentials(cls):
+ super(NeutronResourcesTestJSON, cls).setup_credentials()
+ cls.os = clients.Manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(NeutronResourcesTestJSON, cls).setup_clients()
+ cls.network_client = cls.os.network_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(NeutronResourcesTestJSON, cls).resource_setup()
cls.neutron_basic_template = cls.load_template('neutron_basic')
- cls.network_client = os.network_client
cls.stack_name = data_utils.rand_name('heat')
template = cls.read_template('neutron_basic')
cls.keypair_name = (CONF.orchestration.keypair_name or
@@ -173,7 +185,7 @@
def test_created_server(self):
"""Verifies created sever."""
server_id = self.test_resources.get('Server')['physical_resource_id']
- _, server = self.servers_client.get_server(server_id)
+ server = self.servers_client.get_server(server_id)
self.assertEqual(self.keypair_name, server['key_name'])
self.assertEqual('ACTIVE', server['status'])
network = server['addresses'][self.neutron_basic_template['resources'][
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_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index 0288fd4..83abc91 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -26,15 +26,27 @@
class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
@classmethod
+ def skip_checks(cls):
+ super(SwiftResourcesTestJSON, cls).skip_checks()
+ if not CONF.service_available.swift:
+ raise cls.skipException("Swift support is required")
+
+ @classmethod
+ def setup_credentials(cls):
+ super(SwiftResourcesTestJSON, cls).setup_credentials()
+ cls.os = clients.Manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(SwiftResourcesTestJSON, cls).setup_clients()
+ cls.account_client = cls.os.account_client
+ cls.container_client = cls.os.container_client
+
+ @classmethod
def resource_setup(cls):
super(SwiftResourcesTestJSON, cls).resource_setup()
cls.stack_name = data_utils.rand_name('heat')
template = cls.read_template('swift_basic')
- os = clients.Manager()
- if not CONF.service_available.swift:
- raise cls.skipException("Swift support is required")
- cls.account_client = os.account_client
- cls.container_client = os.container_client
# create the stack
cls.stack_identifier = cls.create_stack(
cls.stack_name,
diff --git a/tempest/api/orchestration/stacks/test_templates_negative.py b/tempest/api/orchestration/stacks/test_templates_negative.py
index 9082107..9a5bc68 100644
--- a/tempest/api/orchestration/stacks/test_templates_negative.py
+++ b/tempest/api/orchestration/stacks/test_templates_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.orchestration import base
-from tempest import exceptions
from tempest import test
@@ -37,7 +38,7 @@
@test.attr(type=['gate', 'negative'])
def test_validate_template_url(self):
"""Validating template passing url to it."""
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.validate_template_url,
template_url=self.invalid_template_url,
parameters=self.parameters)
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index 6fddb21..8356497 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
@@ -26,8 +27,8 @@
class CinderResourcesTest(base.BaseOrchestrationTest):
@classmethod
- def resource_setup(cls):
- super(CinderResourcesTest, cls).resource_setup()
+ def skip_checks(cls):
+ super(CinderResourcesTest, cls).skip_checks()
if not CONF.service_available.cinder:
raise cls.skipException('Cinder support is required')
@@ -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 e840e3b..c521b37 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
@@ -26,18 +28,29 @@
"""Base test case class for all Telemetry API tests."""
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(BaseTelemetryTest, cls).skip_checks()
if not CONF.service_available.ceilometer:
raise cls.skipException("Ceilometer support is required")
- cls.set_network_resources()
- super(BaseTelemetryTest, cls).resource_setup()
- os = cls.get_client_manager()
- cls.telemetry_client = os.telemetry_client
- cls.servers_client = os.servers_client
- cls.flavors_client = os.flavors_client
- cls.image_client = os.image_client
- cls.image_client_v2 = os.image_client_v2
+ @classmethod
+ def setup_credentials(cls):
+ cls.set_network_resources()
+ super(BaseTelemetryTest, cls).setup_credentials()
+ cls.os = cls.get_client_manager()
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseTelemetryTest, cls).setup_clients()
+ cls.telemetry_client = cls.os.telemetry_client
+ cls.servers_client = cls.os.servers_client
+ cls.flavors_client = cls.os.flavors_client
+ cls.image_client = cls.os.image_client
+ cls.image_client_v2 = cls.os.image_client_v2
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseTelemetryTest, cls).resource_setup()
cls.nova_notifications = ['memory', 'vcpus', 'disk.root.size',
'disk.ephemeral.size']
@@ -52,20 +65,20 @@
@classmethod
def create_alarm(cls, **kwargs):
- resp, body = cls.telemetry_client.create_alarm(
+ body = cls.telemetry_client.create_alarm(
name=data_utils.rand_name('telemetry_alarm'),
type='threshold', **kwargs)
cls.alarm_ids.append(body['alarm_id'])
- return resp, body
+ return body
@classmethod
def create_server(cls):
- resp, body = cls.servers_client.create_server(
+ body = cls.servers_client.create_server(
data_utils.rand_name('ceilometer-instance'),
CONF.compute.image_ref, CONF.compute.flavor_ref,
wait_until='ACTIVE')
cls.server_ids.append(body['id'])
- return resp, body
+ return body
@classmethod
def create_image(cls, client):
@@ -80,7 +93,7 @@
for resource_id in list_of_ids:
try:
method(resource_id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
pass
@classmethod
@@ -100,10 +113,9 @@
timeout = CONF.compute.build_timeout
start = timeutils.utcnow()
while timeutils.delta_seconds(start, timeutils.utcnow()) < timeout:
- resp, body = self.telemetry_client.list_samples(metric, query)
- self.assertEqual(resp.status, 200)
+ body = self.telemetry_client.list_samples(metric, query)
if body:
- return resp, body
+ return body
time.sleep(CONF.compute.build_interval)
raise exceptions.TimeoutException(
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index b45d545..cb2d2bd 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -10,14 +10,14 @@
# 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
class TelemetryAlarmingAPITestJSON(base.BaseTelemetryTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -32,8 +32,7 @@
@test.attr(type="gate")
def test_alarm_list(self):
# List alarms
- resp, alarm_list = self.telemetry_client.list_alarms()
- self.assertEqual(200, resp.status)
+ alarm_list = self.telemetry_client.list_alarms()
# Verify created alarm in the list
fetched_ids = [a['alarm_id'] for a in alarm_list]
@@ -47,9 +46,8 @@
def test_create_update_get_delete_alarm(self):
# Create an alarm
alarm_name = data_utils.rand_name('telemetry_alarm')
- resp, body = self.telemetry_client.create_alarm(
+ body = self.telemetry_client.create_alarm(
name=alarm_name, type='threshold', threshold_rule=self.rule)
- self.assertEqual(201, resp.status)
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(self.rule, body['threshold_rule'])
@@ -59,40 +57,35 @@
'threshold': 70.0,
'period': 60}
alarm_name = data_utils.rand_name('telemetry-alarm-update')
- resp, body = self.telemetry_client.update_alarm(
+ body = self.telemetry_client.update_alarm(
alarm_id,
threshold_rule=new_rule,
name=alarm_name,
type='threshold')
- self.assertEqual(200, resp.status)
self.assertEqual(alarm_name, body['name'])
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Get and verify details of an alarm after update
- resp, body = self.telemetry_client.get_alarm(alarm_id)
- self.assertEqual(200, resp.status)
+ body = self.telemetry_client.get_alarm(alarm_id)
self.assertEqual(alarm_name, body['name'])
self.assertDictContainsSubset(new_rule, body['threshold_rule'])
# Delete alarm and verify if deleted
- resp, _ = self.telemetry_client.delete_alarm(alarm_id)
- self.assertEqual(204, resp.status)
- self.assertRaises(exceptions.NotFound,
+ self.telemetry_client.delete_alarm(alarm_id)
+ self.assertRaises(lib_exc.NotFound,
self.telemetry_client.get_alarm, alarm_id)
@test.attr(type="gate")
def test_set_get_alarm_state(self):
alarm_states = ['ok', 'alarm', 'insufficient data']
- _, alarm = self.create_alarm(threshold_rule=self.rule)
+ alarm = self.create_alarm(threshold_rule=self.rule)
# Set alarm state and verify
new_state =\
[elem for elem in alarm_states if elem != alarm['state']][0]
- resp, state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
- new_state)
- self.assertEqual(200, resp.status)
- self.assertEqual(new_state, state)
+ state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
+ new_state)
+ self.assertEqual(new_state, state.data)
# Get alarm state and verify
- resp, state = self.telemetry_client.alarm_get_state(alarm['alarm_id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(new_state, state)
+ state = self.telemetry_client.alarm_get_state(alarm['alarm_id'])
+ self.assertEqual(new_state, state.data)
@test.attr(type="gate")
def test_create_delete_alarm_with_combination_rule(self):
@@ -100,15 +93,13 @@
"operator": "or"}
# Verifies alarm create
alarm_name = data_utils.rand_name('combination_alarm')
- resp, body = self.telemetry_client.create_alarm(name=alarm_name,
- combination_rule=rule,
- type='combination')
- self.assertEqual(201, resp.status)
+ body = self.telemetry_client.create_alarm(name=alarm_name,
+ combination_rule=rule,
+ type='combination')
self.assertEqual(alarm_name, body['name'])
alarm_id = body['alarm_id']
self.assertDictContainsSubset(rule, body['combination_rule'])
# Verify alarm delete
- resp, _ = self.telemetry_client.delete_alarm(alarm_id)
- self.assertEqual(204, resp.status)
- self.assertRaises(exceptions.NotFound,
+ self.telemetry_client.delete_alarm(alarm_id)
+ self.assertRaises(lib_exc.NotFound,
self.telemetry_client.get_alarm, alarm_id)
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index e64cd4a..a0256af 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
import testtools
from tempest.api.telemetry import base
@@ -20,22 +21,20 @@
class TelemetryNotificationAPITestJSON(base.BaseTelemetryTest):
- _interface = 'json'
@classmethod
- def resource_setup(cls):
+ def skip_checks(cls):
+ super(TelemetryNotificationAPITestJSON, cls).skip_checks()
if CONF.telemetry.too_slow_to_test:
raise cls.skipException("Ceilometer feature for fast work mysql "
"is disabled")
- super(TelemetryNotificationAPITestJSON, cls).resource_setup()
@test.attr(type="gate")
@testtools.skipIf(not CONF.service_available.nova,
"Nova is not available.")
def test_check_nova_notification(self):
- resp, body = self.create_server()
- self.assertEqual(resp.status, 202)
+ body = self.create_server()
query = ('resource', 'eq', body['id'])
@@ -46,7 +45,7 @@
@test.services("image")
@testtools.skipIf(not CONF.image_feature_enabled.api_v1,
"Glance api v1 is disabled")
- @test.skip_because(bug='1351627')
+ @decorators.skip_because(bug='1351627')
def test_check_glance_v1_notifications(self):
body = self.create_image(self.image_client)
self.image_client.update_image(body['id'], data='data')
@@ -62,7 +61,7 @@
@test.services("image")
@testtools.skipIf(not CONF.image_feature_enabled.api_v2,
"Glance api v2 is disabled")
- @test.skip_because(bug='1351627')
+ @decorators.skip_because(bug='1351627')
def test_check_glance_v2_notifications(self):
body = self.create_image(self.image_client_v2)
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index 65c4bd3..245161a 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -22,7 +22,6 @@
class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 6c64298..e7d9d7b 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -19,7 +19,6 @@
class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index a214edf..8189aab 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -18,7 +18,6 @@
class VolumeHostsAdminV2TestsJSON(base.BaseVolumeAdminTest):
- _interface = "json"
@test.attr(type='gate')
def test_list_hosts(self):
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 52f2d90..2a30b54 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -23,7 +23,6 @@
class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
- _interface = "json"
force_tenant_isolation = True
@classmethod
diff --git a/tempest/api/volume/admin/test_volume_quotas_negative.py b/tempest/api/volume/admin/test_volume_quotas_negative.py
index 5cf6af0..f972457 100644
--- a/tempest/api/volume/admin/test_volume_quotas_negative.py
+++ b/tempest/api/volume/admin/test_volume_quotas_negative.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.volume import base
-from tempest import exceptions
from tempest import test
class BaseVolumeQuotasNegativeV2TestJSON(base.BaseVolumeAdminTest):
- _interface = "json"
force_tenant_isolation = True
@classmethod
@@ -42,13 +42,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 +65,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 +73,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_services.py b/tempest/api/volume/admin/test_volume_services.py
index 46db70f..3bab185 100644
--- a/tempest/api/volume/admin/test_volume_services.py
+++ b/tempest/api/volume/admin/test_volume_services.py
@@ -22,7 +22,6 @@
Tests Volume Services API.
volume service list requires admin privileges.
"""
- _interface = "json"
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 58f1551..d4062cc 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -22,7 +22,6 @@
class VolumeTypesV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
def _delete_volume(self, volume_id):
self.volumes_client.delete_volume(volume_id)
@@ -38,45 +37,54 @@
self.assertIsInstance(body, list)
@test.attr(type='smoke')
- def test_create_get_delete_volume_with_volume_type_and_extra_specs(self):
- # Create/get/delete volume with volume_type and extra spec.
- volume = {}
+ def test_volume_crud_with_volume_type_and_extra_specs(self):
+ # Create/update/get/delete volume with volume_type and extra spec.
+ volume_types = list()
vol_name = data_utils.rand_name("volume-")
- vol_type_name = data_utils.rand_name("volume-type-")
self.name_field = self.special_fields['name_field']
proto = CONF.volume.storage_protocol
vendor = CONF.volume.vendor_name
extra_specs = {"storage_protocol": proto,
"vendor_name": vendor}
- body = {}
- body = self.volume_types_client.create_volume_type(
- vol_type_name,
- extra_specs=extra_specs)
- self.assertIn('id', body)
- self.addCleanup(self._delete_volume_type, body['id'])
- self.assertIn('name', body)
- params = {self.name_field: vol_name, 'volume_type': vol_type_name}
- volume = self.volumes_client.create_volume(
- size=1, **params)
- self.assertIn('id', volume)
+ # Create two volume_types
+ for i in range(2):
+ vol_type_name = data_utils.rand_name("volume-type-")
+ vol_type = self.volume_types_client.create_volume_type(
+ vol_type_name,
+ extra_specs=extra_specs)
+ volume_types.append(vol_type)
+ self.addCleanup(self._delete_volume_type, vol_type['id'])
+ params = {self.name_field: vol_name,
+ 'volume_type': volume_types[0]['id']}
+
+ # Create volume
+ volume = self.volumes_client.create_volume(size=1, **params)
self.addCleanup(self._delete_volume, volume['id'])
- self.assertIn(self.name_field, volume)
+ self.assertEqual(volume_types[0]['name'], volume["volume_type"])
self.assertEqual(volume[self.name_field], vol_name,
"The created volume name is not equal "
"to the requested name")
- self.assertTrue(volume['id'] is not None,
- "Field volume id is empty or not found.")
+ self.assertIsNotNone(volume['id'],
+ "Field volume id is empty or not found.")
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ # Update volume with new volume_type
+ self.volumes_client.retype_volume(volume['id'],
+ volume_type=volume_types[1]['id'])
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ # Get volume details and Verify
fetched_volume = self.volumes_client.get_volume(volume['id'])
+ self.assertEqual(volume_types[1]['name'],
+ fetched_volume['volume_type'],
+ 'The fetched Volume type is different '
+ 'from updated volume type')
self.assertEqual(vol_name, fetched_volume[self.name_field],
'The fetched Volume is different '
'from the created Volume')
self.assertEqual(volume['id'], fetched_volume['id'],
'The fetched Volume is different '
'from the created Volume')
- self.assertEqual(vol_type_name, fetched_volume['volume_type'],
- 'The fetched Volume is different '
- 'from the created Volume')
@test.attr(type='smoke')
def test_volume_type_create_get_delete(self):
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index 460a6c3..1ce1402 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -19,7 +19,6 @@
class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
@classmethod
def resource_setup(cls):
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..23979cd 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,14 +15,14 @@
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
from tempest import test
class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -43,7 +43,7 @@
# Should not update volume type extra specs with no body
extra_spec = {"spec1": "val2"}
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.update_volume_type_extra_specs,
self.volume_type['id'], extra_spec.keys()[0], None)
@@ -52,7 +52,7 @@
# Should not update volume type extra specs with nonexistent id.
extra_spec = {"spec1": "val2"}
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.update_volume_type_extra_specs,
self.volume_type['id'], str(uuid.uuid4()),
extra_spec)
@@ -62,7 +62,7 @@
# Should not update volume type extra specs with none id.
extra_spec = {"spec1": "val2"}
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.update_volume_type_extra_specs,
self.volume_type['id'], None, extra_spec)
@@ -72,7 +72,7 @@
# body.
extra_spec = {"spec1": "val2", 'spec2': 'val1'}
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.update_volume_type_extra_specs,
self.volume_type['id'], extra_spec.keys()[0],
extra_spec)
@@ -83,7 +83,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)
@@ -91,7 +91,7 @@
def test_create_none_body(self):
# Should not create volume type extra spec for none POST body.
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.create_volume_type_extra_specs,
self.volume_type['id'], None)
@@ -99,7 +99,7 @@
def test_create_invalid_body(self):
# Should not create volume type extra spec for invalid POST body.
self.assertRaises(
- exceptions.BadRequest,
+ lib_exc.BadRequest,
self.volume_types_client.create_volume_type_extra_specs,
self.volume_type['id'], ['invalid'])
@@ -109,7 +109,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 +117,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 +126,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 +135,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..a40f1c4 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -15,13 +15,13 @@
import uuid
+from tempest_lib import exceptions as lib_exc
+
from tempest.api.volume import base
-from tempest import exceptions
from tempest import test
class VolumeTypesNegativeV2Test(base.BaseVolumeAdminTest):
- _interface = 'json'
@test.attr(type='gate')
def test_create_with_nonexistent_volume_type(self):
@@ -29,27 +29,27 @@
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)
@test.attr(type='gate')
def test_create_with_empty_name(self):
# Should not be able to create volume type with an empty name.
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.volume_types_client.create_volume_type, '')
@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/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 4feba73..439dd35 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -19,7 +19,6 @@
class VolumesActionsV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 0739480..d572893 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -24,7 +24,6 @@
class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
- _interface = "json"
@classmethod
def resource_setup(cls):
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 127a216..2489b79 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
@@ -29,7 +31,6 @@
"""Base test case class for all Cinder API tests."""
_api_version = 2
- _interface = 'json'
@classmethod
def resource_setup(cls):
@@ -153,8 +154,7 @@
try:
cls.adm_creds = cls.isolated_creds.get_admin_creds()
- cls.os_adm = clients.Manager(
- credentials=cls.adm_creds, interface=cls._interface)
+ cls.os_adm = clients.Manager(credentials=cls.adm_creds)
except NotImplementedError:
msg = "Missing Volume Admin API credentials in configuration."
raise cls.skipException(msg)
@@ -208,13 +208,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_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index b2961bd..7451050 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -30,13 +30,11 @@
super(VolumesV2TransfersTest, cls).resource_setup()
# Add another tenant to test volume-transfer
- cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds(),
- interface=cls._interface)
+ cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
# Add admin tenant to cleanup resources
try:
creds = cls.isolated_creds.get_admin_creds()
- cls.os_adm = clients.Manager(
- credentials=creds, interface=cls._interface)
+ cls.os_adm = clients.Manager(credentials=creds)
except NotImplementedError:
msg = "Missing Volume Admin API credentials in configuration."
raise cls.skipException(msg)
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index ceabb1c..333a4f7 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -31,13 +31,14 @@
# Create a test shared instance
srv_name = data_utils.rand_name(cls.__name__ + '-Instance-')
- resp, cls.server = cls.servers_client.create_server(srv_name,
- cls.image_ref,
- cls.flavor_ref)
+ cls.server = cls.servers_client.create_server(srv_name,
+ cls.image_ref,
+ cls.flavor_ref)
cls.servers_client.wait_for_server_status(cls.server['id'], 'ACTIVE')
# Create a test shared volume for attach/detach tests
cls.volume = cls.create_volume()
+ cls.client.wait_for_volume_status(cls.volume['id'], 'available')
def _delete_image_with_wait(self, image_id):
self.image_client.delete_image(image_id)
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..595ddf4 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -15,9 +15,10 @@
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
from tempest import test
@@ -37,13 +38,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'])
@@ -52,7 +53,7 @@
# in request
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='#$%', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -61,7 +62,7 @@
# in request
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -69,7 +70,7 @@
# Should not be able to create volume with size zero
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='0', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -77,7 +78,7 @@
# Should not be able to create volume with size negative
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
- self.assertRaises(exceptions.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
size='-1', display_name=v_name, metadata=metadata)
@test.attr(type=['negative', 'gate'])
@@ -85,7 +86,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 +95,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 +104,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 +112,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 +120,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,42 +128,42 @@
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')
def test_attach_volumes_with_nonexistent_volume_id(self):
srv_name = data_utils.rand_name('Instance-')
- resp, server = self.servers_client.create_server(srv_name,
- self.image_ref,
- self.flavor_ref)
+ server = self.servers_client.create_server(srv_name,
+ self.image_ref,
+ 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 +171,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')
@@ -178,46 +179,46 @@
def test_volume_extend_with_size_smaller_than_original_size(self):
# Extend volume with smaller size than original size.
extend_size = 0
- self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
@test.attr(type=['negative', 'gate'])
def test_volume_extend_with_non_number_size(self):
# Extend volume when size is non number.
extend_size = 'abc'
- self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
@test.attr(type=['negative', 'gate'])
def test_volume_extend_with_None_size(self):
# Extend volume with None size.
extend_size = None
- self.assertRaises(exceptions.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
self.volume['id'], extend_size)
@test.attr(type=['negative', 'gate'])
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()))
@@ -226,7 +227,7 @@
# Mark volume as reserved.
self.client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
- self.assertRaises(exceptions.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.reserve_volume,
self.volume['id'])
# Unmark volume as reserved.
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 179eb09..98598c1 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -64,13 +64,13 @@
# Create a snapshot when volume status is in-use
# Create a test instance
server_name = data_utils.rand_name('instance-')
- resp, server = self.servers_client.create_server(server_name,
- self.image_ref,
- self.flavor_ref)
+ server = self.servers_client.create_server(server_name,
+ self.image_ref,
+ self.flavor_ref)
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/api_schema/response/compute/baremetal_nodes.py b/tempest/api_schema/response/compute/baremetal_nodes.py
new file mode 100644
index 0000000..2f67d37
--- /dev/null
+++ b/tempest/api_schema/response/compute/baremetal_nodes.py
@@ -0,0 +1,53 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+node = {
+ 'type': 'object',
+ 'properties': {
+ 'id': {'type': 'string'},
+ 'interfaces': {'type': 'array'},
+ 'host': {'type': 'string'},
+ 'task_state': {'type': ['string', 'null']},
+ 'cpus': {'type': 'integer'},
+ 'memory_mb': {'type': 'integer'},
+ 'disk_gb': {'type': 'integer'},
+ },
+ 'required': ['id', 'interfaces', 'host', 'task_state', 'cpus', 'memory_mb',
+ 'disk_gb']
+}
+
+list_baremetal_nodes = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'nodes': {
+ 'type': 'array',
+ 'items': node
+ }
+ },
+ 'required': ['nodes']
+ }
+}
+
+get_baremetal_node = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'node': node
+ },
+ 'required': ['node']
+ }
+}
diff --git a/tempest/api_schema/response/compute/v2/images.py b/tempest/api_schema/response/compute/v2/images.py
index 923c744..2317e6b 100644
--- a/tempest/api_schema/response/compute/v2/images.py
+++ b/tempest/api_schema/response/compute/v2/images.py
@@ -12,15 +12,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+import copy
+
from tempest.api_schema.response.compute import parameter_types
+image_links = copy.deepcopy(parameter_types.links)
+image_links['items']['properties'].update({'type': {'type': 'string'}})
+
common_image_schema = {
'type': 'object',
'properties': {
'id': {'type': 'string'},
'status': {'type': 'string'},
'updated': {'type': 'string'},
- 'links': parameter_types.links,
+ 'links': image_links,
'name': {'type': 'string'},
'created': {'type': 'string'},
'minDisk': {'type': 'integer'},
@@ -67,7 +72,7 @@
'type': 'object',
'properties': {
'id': {'type': 'string'},
- 'links': parameter_types.links,
+ 'links': image_links,
'name': {'type': 'string'}
},
'required': ['id', 'links', 'name']
diff --git a/tempest/auth.py b/tempest/auth.py
index 6a92b5f..f78bb20 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -22,13 +22,11 @@
import six
-from tempest import config
from tempest.openstack.common import log as logging
from tempest.services.identity.json import token_client as json_id
from tempest.services.identity.v3.json import token_client as json_v3id
-CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -38,34 +36,21 @@
Provide authentication
"""
- def __init__(self, credentials, interface=None):
+ def __init__(self, credentials):
"""
:param credentials: credentials for authentication
- :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:
raise TypeError("Invalid credentials")
- self.interface = 'json'
self.cache = None
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(
- creds=self.credentials, interface=self.interface,
- cache=self.cache)
+ return "Creds :{creds}, cached auth data: {cache}".format(
+ creds=self.credentials, cache=self.cache)
@abc.abstractmethod
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -201,8 +186,8 @@
token_expiry_threshold = datetime.timedelta(seconds=60)
- def __init__(self, credentials, interface=None):
- super(KeystoneAuthProvider, self).__init__(credentials, interface)
+ def __init__(self, credentials):
+ super(KeystoneAuthProvider, self).__init__(credentials)
self.auth_client = self._auth_client()
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -336,8 +321,9 @@
return dict(
user=self.credentials.username,
password=self.credentials.password,
- tenant=self.credentials.tenant_name,
- domain=self.credentials.user_domain_name,
+ project=self.credentials.tenant_name,
+ user_domain=self.credentials.user_domain_name,
+ project_domain=self.credentials.project_domain_name,
auth_data=True)
def _fill_credentials(self, auth_data_body):
@@ -440,44 +426,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 +470,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 +525,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 +542,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,26 +553,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):
- """
- If domain is not specified, load the one configured for the
- identity manager.
- """
- domain_fields = set(x for x in self.ATTRIBUTES if 'domain' in x)
- if not domain_fields.intersection(kwargs.keys()):
- kwargs['user_domain_name'] = CONF.identity.admin_domain_name
- super(KeystoneV3Credentials, self).__init__(**kwargs)
def __setattr__(self, key, value):
parent = super(KeystoneV3Credentials, self)
@@ -685,3 +619,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/cli/simple_read_only/compute/__init__.py b/tempest/cli/simple_read_only/compute/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/cli/simple_read_only/compute/__init__.py
+++ /dev/null
diff --git a/tempest/cli/simple_read_only/compute/test_nova.py b/tempest/cli/simple_read_only/compute/test_nova.py
deleted file mode 100644
index 5efeb75..0000000
--- a/tempest/cli/simple_read_only/compute/test_nova.py
+++ /dev/null
@@ -1,209 +0,0 @@
-# Copyright 2013 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest_lib import exceptions
-import testtools
-
-from tempest import cli
-from tempest import config
-from tempest.openstack.common import log as logging
-import tempest.test
-
-CONF = config.CONF
-
-LOG = logging.getLogger(__name__)
-
-
-class SimpleReadOnlyNovaClientTest(cli.ClientTestBase):
-
- """
- This is a first pass at a simple read only python-novaclient test. This
- only exercises client commands that are read only.
-
- This should test commands:
- * as a regular user
- * as a admin user
- * with and without optional parameters
- * initially just check return codes, and later test command outputs
-
- """
-
- @classmethod
- def resource_setup(cls):
- if not CONF.service_available.nova:
- msg = ("%s skipped as Nova is not available" % cls.__name__)
- raise cls.skipException(msg)
- super(SimpleReadOnlyNovaClientTest, cls).resource_setup()
-
- def nova(self, *args, **kwargs):
- return self.clients.nova(*args,
- endpoint_type=CONF.compute.endpoint_type,
- **kwargs)
-
- def test_admin_fake_action(self):
- self.assertRaises(exceptions.CommandFailed,
- self.nova,
- 'this-does-nova-exist')
-
- # NOTE(jogo): Commands in order listed in 'nova help'
-
- # Positional arguments:
-
- def test_admin_absolute_limites(self):
- self.nova('absolute-limits')
- self.nova('absolute-limits', params='--reserved')
-
- def test_admin_aggregate_list(self):
- self.nova('aggregate-list')
-
- def test_admin_availability_zone_list(self):
- self.assertIn("internal", self.nova('availability-zone-list'))
-
- def test_admin_cloudpipe_list(self):
- self.nova('cloudpipe-list')
-
- def test_admin_credentials(self):
- self.nova('credentials')
-
- @testtools.skipIf(CONF.service_available.neutron,
- "Neutron does not provide this feature")
- def test_admin_dns_domains(self):
- self.nova('dns-domains')
-
- @tempest.test.skip_because(bug="1157349")
- def test_admin_dns_list(self):
- self.nova('dns-list')
-
- def test_admin_endpoints(self):
- self.nova('endpoints')
-
- def test_admin_flavor_acces_list(self):
- self.assertRaises(exceptions.CommandFailed,
- self.nova,
- 'flavor-access-list')
- # Failed to get access list for public flavor type
- self.assertRaises(exceptions.CommandFailed,
- self.nova,
- 'flavor-access-list',
- params='--flavor m1.tiny')
-
- def test_admin_flavor_list(self):
- self.assertIn("Memory_MB", self.nova('flavor-list'))
-
- def test_admin_floating_ip_bulk_list(self):
- self.nova('floating-ip-bulk-list')
-
- def test_admin_floating_ip_list(self):
- self.nova('floating-ip-list')
-
- def test_admin_floating_ip_pool_list(self):
- self.nova('floating-ip-pool-list')
-
- def test_admin_host_list(self):
- self.nova('host-list')
-
- def test_admin_hypervisor_list(self):
- self.nova('hypervisor-list')
-
- def test_admin_image_list(self):
- self.nova('image-list')
-
- @tempest.test.skip_because(bug="1157349")
- def test_admin_interface_list(self):
- self.nova('interface-list')
-
- def test_admin_keypair_list(self):
- self.nova('keypair-list')
-
- def test_admin_list(self):
- self.nova('list')
- self.nova('list', params='--all-tenants 1')
- self.nova('list', params='--all-tenants 0')
- self.assertRaises(exceptions.CommandFailed,
- self.nova,
- 'list',
- params='--all-tenants bad')
-
- def test_admin_network_list(self):
- self.nova('network-list')
-
- def test_admin_rate_limits(self):
- self.nova('rate-limits')
-
- def test_admin_secgroup_list(self):
- self.nova('secgroup-list')
-
- @tempest.test.skip_because(bug="1157349")
- def test_admin_secgroup_list_rules(self):
- self.nova('secgroup-list-rules')
-
- @cli.min_client_version(client='nova', version='2.18')
- def test_admin_server_group_list(self):
- self.nova('server-group-list')
-
- def test_admin_servce_list(self):
- self.nova('service-list')
-
- def test_admin_usage(self):
- self.nova('usage')
-
- def test_admin_usage_list(self):
- self.nova('usage-list')
-
- @testtools.skipIf(not CONF.service_available.cinder,
- "Skipped as Cinder is not available")
- def test_admin_volume_list(self):
- self.nova('volume-list')
-
- @testtools.skipIf(not CONF.service_available.cinder,
- "Skipped as Cinder is not available")
- def test_admin_volume_snapshot_list(self):
- self.nova('volume-snapshot-list')
-
- @testtools.skipIf(not CONF.service_available.cinder,
- "Skipped as Cinder is not available")
- def test_admin_volume_type_list(self):
- self.nova('volume-type-list')
-
- def test_admin_help(self):
- self.nova('help')
-
- def test_admin_list_extensions(self):
- self.nova('list-extensions')
-
- def test_admin_net_list(self):
- self.nova('net-list')
-
- def test_agent_list(self):
- self.nova('agent-list')
- self.nova('agent-list', flags='--debug')
-
- def test_migration_list(self):
- self.nova('migration-list')
- self.nova('migration-list', flags='--debug')
-
- # Optional arguments:
-
- def test_admin_version(self):
- self.nova('', flags='--version')
-
- def test_admin_debug_list(self):
- self.nova('list', flags='--debug')
-
- def test_admin_timeout(self):
- self.nova('list', flags='--timeout %d' % CONF.cli.timeout)
-
- def test_admin_timing(self):
- self.nova('list', flags='--timing')
diff --git a/tempest/clients.py b/tempest/clients.py
index 03928ba..bb08d87 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
@@ -29,6 +29,8 @@
AggregatesClientJSON
from tempest.services.compute.json.availability_zone_client import \
AvailabilityZoneClientJSON
+from tempest.services.compute.json.baremetal_nodes_client import \
+ BaremetalNodesClientJSON
from tempest.services.compute.json.certificates_client import \
CertificatesClientJSON
from tempest.services.compute.json.extensions_client import \
@@ -64,7 +66,8 @@
TenantUsagesClientJSON
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
-from tempest.services.data_processing.v1_1.client import DataProcessingClient
+from tempest.services.data_processing.v1_1.data_processing_client import \
+ DataProcessingClient
from tempest.services.database.json.flavors_client import \
DatabaseFlavorsClientJSON
from tempest.services.database.json.limits_client import \
@@ -155,10 +158,7 @@
}
default_params_with_timeout_values.update(default_params)
- def __init__(self, credentials=None, interface='json', service=None):
- # Set interface and client type first
- self.interface = interface
- # super cares for credentials validation
+ def __init__(self, credentials=None, service=None):
super(Manager, self).__init__(credentials=credentials)
self._set_compute_clients()
@@ -204,6 +204,12 @@
build_interval=CONF.orchestration.build_interval,
build_timeout=CONF.orchestration.build_timeout,
**self.default_params)
+ self.data_processing_client = DataProcessingClient(
+ self.auth_provider,
+ CONF.data_processing.catalog_type,
+ CONF.identity.region,
+ endpoint_type=CONF.data_processing.endpoint_type,
+ **self.default_params_with_timeout_values)
self.negative_client = negative_rest_client.NegativeRestClient(
self.auth_provider, service)
@@ -214,8 +220,6 @@
self.credentials.tenant_name)
self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
- self.data_processing_client = DataProcessingClient(
- self.auth_provider)
def _set_compute_clients(self):
params = {
@@ -267,6 +271,8 @@
InstanceUsagesAuditLogClientJSON(self.auth_provider, **params)
self.tenant_networks_client = \
TenantNetworksClientJSON(self.auth_provider, **params)
+ self.baremetal_nodes_client = BaremetalNodesClientJSON(
+ self.auth_provider, **params)
# NOTE: The following client needs special timeout values because
# the API is a proxy for the other component.
@@ -296,16 +302,27 @@
**self.default_params_with_timeout_values)
def _set_identity_clients(self):
- self.identity_client = IdentityClientJSON(self.auth_provider)
- self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider)
- self.endpoints_client = EndPointClientJSON(self.auth_provider)
- self.service_client = ServiceClientJSON(self.auth_provider)
- self.policy_client = PolicyClientJSON(self.auth_provider)
- self.region_client = RegionClientJSON(self.auth_provider)
+ params = {
+ 'service': CONF.identity.catalog_type,
+ 'region': CONF.identity.region,
+ 'endpoint_type': 'adminURL'
+ }
+ params.update(self.default_params_with_timeout_values)
+
+ self.identity_client = IdentityClientJSON(self.auth_provider,
+ **params)
+ self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider,
+ **params)
+ self.endpoints_client = EndPointClientJSON(self.auth_provider,
+ **params)
+ self.service_client = ServiceClientJSON(self.auth_provider, **params)
+ self.policy_client = PolicyClientJSON(self.auth_provider, **params)
+ self.region_client = RegionClientJSON(self.auth_provider, **params)
+ self.credentials_client = CredentialsClientJSON(self.auth_provider,
+ **params)
self.token_client = TokenClientJSON()
if CONF.identity_feature_enabled.api_v3:
self.token_v3_client = V3TokenClientJSON()
- self.credentials_client = CredentialsClientJSON(self.auth_provider)
def _set_volume_clients(self):
params = {
@@ -330,9 +347,12 @@
**params)
self.snapshots_v2_client = SnapshotsV2ClientJSON(self.auth_provider,
**params)
- self.volumes_client = VolumesClientJSON(self.auth_provider, **params)
- self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider,
- **params)
+ self.volumes_client = VolumesClientJSON(
+ self.auth_provider, default_volume_size=CONF.volume.volume_size,
+ **params)
+ self.volumes_v2_client = VolumesV2ClientJSON(
+ self.auth_provider, default_volume_size=CONF.volume.volume_size,
+ **params)
self.volume_types_client = VolumeTypesClientJSON(self.auth_provider,
**params)
self.volume_services_client = VolumesServicesClientJSON(
@@ -376,8 +396,8 @@
managed client objects
"""
- def __init__(self, interface='json', service=None):
+ def __init__(self, service=None):
super(AdminManager, self).__init__(
- credentials=auth.get_default_credentials('identity_admin'),
- interface=interface,
+ credentials=cred_provider.get_configured_credentials(
+ 'identity_admin'),
service=service)
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index 28992b9..669f506 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,
@@ -221,7 +222,7 @@
needs_role = False
LOG.debug("User already had admin privilege for this tenant")
if needs_role:
- LOG.debug("Adding admin priviledge for : %s" % tenant_id)
+ LOG.debug("Adding admin privilege for : %s" % tenant_id)
id_cl.assign_user_role(tenant_id, self.admin_id,
self.admin_role_id)
self.admin_role_added.append(tenant_id)
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index a0bbb70..67eb182 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -244,7 +244,7 @@
def list(self):
client = self.client
- _, keypairs = client.list_keypairs()
+ keypairs = client.list_keypairs()
LOG.debug("List count, %s Keypairs" % len(keypairs))
return keypairs
@@ -271,7 +271,7 @@
def list(self):
client = self.client
- _, secgrps = client.list_security_groups()
+ secgrps = client.list_security_groups()
secgrp_del = [grp for grp in secgrps if grp['name'] != 'default']
LOG.debug("List count, %s Security Groups" % len(secgrp_del))
return secgrp_del
@@ -297,7 +297,7 @@
def list(self):
client = self.client
- _, floating_ips = client.list_floating_ips()
+ floating_ips = client.list_floating_ips()
LOG.debug("List count, %s Floating IPs" % len(floating_ips))
return floating_ips
@@ -778,7 +778,7 @@
def list(self):
client = self.client
- _, alarms = client.list_alarms()
+ alarms = client.list_alarms()
LOG.debug("List count, %s Alarms" % len(alarms))
return alarms
@@ -805,7 +805,7 @@
def list(self):
client = self.client
- _, flavors = client.list_flavors({"is_public": None})
+ flavors = client.list_flavors({"is_public": None})
if not self.is_save_state:
# recreate list removing saved flavors
flavors = [flavor for flavor in flavors if flavor['id']
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 48ea823..503745c 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -110,11 +110,11 @@
import unittest
import netaddr
+from tempest_lib import exceptions as lib_exc
import yaml
import tempest.auth
from tempest import config
-from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.openstack.common import timeutils
from tempest.services.compute.json import flavors_client
@@ -177,7 +177,12 @@
password=pw,
tenant_name=tenant)
_auth = tempest.auth.KeystoneV2AuthProvider(_creds)
- self.identity = identity_client.IdentityClientJSON(_auth)
+ self.identity = identity_client.IdentityClientJSON(
+ _auth,
+ CONF.identity.catalog_type,
+ CONF.identity.region,
+ endpoint_type='adminURL',
+ **default_params_with_timeout_values)
self.servers = servers_client.ServersClientJSON(_auth,
**compute_params)
self.flavors = flavors_client.FlavorsClientJSON(_auth,
@@ -232,9 +237,6 @@
LOG.error("%s not found in USERS: %s" % (name, USERS))
-def resp_ok(response):
- return 200 >= int(response['status']) < 300
-
###################
#
# TENANTS
@@ -297,7 +299,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 +315,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']),
@@ -432,7 +434,7 @@
found,
"Couldn't find expected server %s" % server['name'])
- r, found = client.servers.get_server(found['id'])
+ found = client.servers.get_server(found['id'])
# validate neutron is enabled and ironic disabled:
if (CONF.service_available.neutron and
not CONF.baremetal.driver_enabled):
@@ -474,11 +476,10 @@
LOG.info("checking telemetry")
for server in self.res['servers']:
client = client_for_user(server['owner'])
- response, body = client.telemetry.list_samples(
+ body = client.telemetry.list_samples(
'instance',
query=('metadata.display_name', 'eq', server['name'])
)
- self.assertEqual(response.status, 200)
self.assertTrue(len(body) >= 1, 'expecting at least one sample')
self._confirm_telemetry_sample(server, body[-1])
@@ -708,7 +709,7 @@
cidr=subnet['range'],
name=subnet['name'],
ip_version=ip_version)
- except exceptions.BadRequest as e:
+ except lib_exc.BadRequest as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
@@ -789,7 +790,7 @@
def _get_flavor_by_name(client, name):
- r, body = client.flavors.list_flavors()
+ body = client.flavors.list_flavors()
for flavor in body:
if name == flavor['name']:
return flavor
@@ -817,7 +818,7 @@
client.networks, 'networks', x)['id'])
kwargs['networks'] = [{'uuid': get_net_id(network)}
for network in server['networks']]
- resp, body = client.servers.create_server(
+ body = client.servers.create_server(
server['name'], image_id, flavor_id, **kwargs)
server_id = body['id']
client.servers.wait_for_server_status(server_id, 'ACTIVE')
@@ -851,17 +852,14 @@
# only create a security group if the name isn't here
# i.e. a security group may be used by another server
# only create a router if the name isn't here
- r, body = client.secgroups.list_security_groups()
+ body = client.secgroups.list_security_groups()
if any(item['name'] == secgroup['name'] for item in body):
LOG.warning("Security group '%s' already exists" %
secgroup['name'])
continue
- resp, body = client.secgroups.create_security_group(
+ body = client.secgroups.create_security_group(
secgroup['name'], secgroup['description'])
- if not resp_ok(resp):
- raise ValueError("Failed to create security group: [%s] %s" %
- (resp, body))
secgroup_id = body['id']
# for each security group, create the rules
for rule in secgroup['rules']:
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 65a3a95..697965f 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -154,7 +154,7 @@
def verify_extensions(os, service, results):
extensions_client = get_extension_client(os, service)
- if service == 'neutron' or service == 'cinder':
+ if service != 'swift':
resp = extensions_client.list_extensions()
else:
__, resp = extensions_client.list_extensions()
@@ -327,7 +327,7 @@
CONF_PARSER = moves.configparser.SafeConfigParser()
CONF_PARSER.optionxform = str
CONF_PARSER.readfp(conf_file)
- os = clients.AdminManager(interface='json')
+ os = clients.AdminManager()
services = check_service_availability(os, update)
results = {}
for service in ['nova', 'cinder', 'neutron', 'swift']:
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..d899303 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -16,17 +16,74 @@
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
+ # In case of "v3" add the domain from config if not specified
+ if identity_version == 'v3':
+ domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
+ if 'domain' in x)
+ if not domain_fields.intersection(kwargs.keys()):
+ kwargs['user_domain_name'] = CONF.identity.admin_domain_name
+ return auth.get_credentials(fill_in=fill_in,
+ identity_version=identity_version,
+ **kwargs)
+
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
- def __init__(self, name, interface='json', password='pass',
- network_resources=None):
+ def __init__(self, name, password='pass', network_resources=None):
self.name = name
@abc.abstractmethod
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
index 08b592f..6a4ee08c 100644
--- a/tempest/common/credentials.py
+++ b/tempest/common/credentials.py
@@ -12,6 +12,7 @@
# limitations under the License.
from tempest.common import accounts
+from tempest.common import cred_provider
from tempest.common import isolated_creds
from tempest import config
@@ -37,3 +38,22 @@
return accounts.Accounts(name=name)
else:
return accounts.NotLockingAccounts(name=name)
+
+
+# We want a helper function here to check and see if admin credentials
+# are available so we can do a single call from skip_checks if admin
+# creds area vailable.
+def is_admin_available():
+ is_admin = True
+ # In the case of a pre-provisioned account, if even if creds were
+ # configured, the admin credentials won't be available
+ if (CONF.auth.locking_credentials_provider and
+ not CONF.auth.allow_tenant_isolation):
+ is_admin = False
+ else:
+ try:
+ cred_provider.get_configured_credentials('identity_admin')
+ except NotImplementedError:
+ is_admin = False
+
+ return is_admin
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index a663931..f81c3ed 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
@@ -28,15 +28,12 @@
class IsolatedCreds(cred_provider.CredentialProvider):
- def __init__(self, name, interface='json', password='pass',
- network_resources=None):
- super(IsolatedCreds, self).__init__(name, interface, password,
- network_resources)
+ def __init__(self, name, password='pass', network_resources=None):
+ super(IsolatedCreds, self).__init__(name, password, network_resources)
self.network_resources = network_resources
self.isolated_creds = {}
self.isolated_net_resources = {}
self.ports = []
- self.interface = interface
self.password = password
self.identity_admin_client, self.network_admin_client = (
self._get_admin_clients())
@@ -48,7 +45,7 @@
identity
network
"""
- os = clients.AdminManager(interface=self.interface)
+ os = clients.AdminManager()
return os.identity_client, os.network_client
def _create_tenant(self, name, description):
@@ -81,7 +78,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 +126,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)
@@ -201,7 +198,7 @@
tenant_id=tenant_id,
ip_version=4)
break
- except exceptions.BadRequest as e:
+ except lib_exc.BadRequest as e:
if 'overlaps with another subnet' not in str(e):
raise
else:
@@ -282,7 +279,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 +287,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 +295,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 +307,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 +323,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 +341,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..8949609 100644
--- a/tempest/common/service_client.py
+++ b/tempest/common/service_client.py
@@ -16,7 +16,6 @@
from tempest_lib import exceptions as lib_exceptions
from tempest import config
-from tempest import exceptions
CONF = config.CONF
@@ -59,22 +58,12 @@
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):
@@ -94,6 +83,18 @@
return "response: %s\nBody: %s" % (self.response, body)
+class ResponseBodyData(object):
+ """Class that wraps an http response and string data into a single value.
+ """
+
+ def __init__(self, response, data):
+ self.response = response
+ self.data = data
+
+ def __str__(self):
+ return "response: %s\nBody: %s" % (self.response, self.data)
+
+
class ResponseBodyList(list):
"""Class that wraps an http response and list body into a single value.
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index c77c81e..9b11676 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -32,7 +32,7 @@
# NOTE(afazekas): UNKNOWN status possible on ERROR
# or in a very early stage.
- resp, body = client.get_server(server_id)
+ body = client.get_server(server_id)
old_status = server_status = body['status']
old_task_state = task_state = _get_task_state(body)
start_time = int(time.time())
@@ -59,7 +59,7 @@
return
time.sleep(client.build_interval)
- resp, body = client.get_server(server_id)
+ body = client.get_server(server_id)
server_status = body['status']
task_state = _get_task_state(body)
if (server_status != old_status) or (task_state != old_task_state):
diff --git a/tempest/config.py b/tempest/config.py
index 70f972f..4588b20 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -349,7 +349,10 @@
cfg.BoolOpt('snapshot',
default=True,
help='Does the test environment support creating snapshot '
- 'images of running instances?')
+ 'images of running instances?'),
+ cfg.BoolOpt('ec2_api',
+ default=True,
+ help='Does the test environment have the ec2 api running?')
]
@@ -452,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..421d2de 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
@@ -63,5 +64,4 @@
'Credentials must be specified')
auth_provider_class = self.get_auth_provider_class(credentials)
return auth_provider_class(
- interface=getattr(self, 'interface', None),
credentials=credentials)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 5b092c3..eb7265f 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
@@ -160,7 +161,7 @@
client = self.keypairs_client
name = data_utils.rand_name(self.__class__.__name__)
# We don't need to create a keypair by pubkey in scenario
- resp, body = client.create_keypair(name)
+ body = client.create_keypair(name)
self.addCleanup(client.delete_keypair, name)
return body
@@ -186,8 +187,8 @@
LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
name, image, flavor)
- _, server = self.servers_client.create_server(name, image, flavor,
- **create_kwargs)
+ server = self.servers_client.create_server(name, image, flavor,
+ **create_kwargs)
if wait_on_delete:
self.addCleanup(self.servers_client.wait_for_server_termination,
server['id'])
@@ -202,7 +203,7 @@
# The instance retrieved on creation is missing network
# details, necessitating retrieval after it becomes active to
# ensure correct details.
- _, server = self.servers_client.get_server(server['id'])
+ server = self.servers_client.get_server(server['id'])
self.assertEqual(server['name'], name)
return server
@@ -236,7 +237,7 @@
def _create_loginable_secgroup_rule(self, secgroup_id=None):
_client = self.security_groups_client
if secgroup_id is None:
- _, sgs = _client.list_security_groups()
+ sgs = _client.list_security_groups()
for sg in sgs:
if sg['name'] == 'default':
secgroup_id = sg['id']
@@ -263,8 +264,8 @@
]
rules = list()
for ruleset in rulesets:
- _, sg_rule = _client.create_security_group_rule(secgroup_id,
- **ruleset)
+ sg_rule = _client.create_security_group_rule(secgroup_id,
+ **ruleset)
self.addCleanup(self.delete_wrapper,
_client.delete_security_group_rule,
sg_rule['id'])
@@ -275,7 +276,7 @@
# Create security group
sg_name = data_utils.rand_name(self.__class__.__name__)
sg_desc = sg_name + " description"
- _, secgroup = self.security_groups_client.create_security_group(
+ secgroup = self.security_groups_client.create_security_group(
sg_name, sg_desc)
self.assertEqual(secgroup['name'], sg_name)
self.assertEqual(secgroup['description'], sg_desc)
@@ -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
@@ -512,7 +513,7 @@
Nova clients
"""
- _, floating_ip = self.floating_ips_client.create_floating_ip(pool_name)
+ floating_ip = self.floating_ips_client.create_floating_ip(pool_name)
self.addCleanup(self.delete_wrapper,
self.floating_ips_client.delete_floating_ip,
floating_ip['id'])
@@ -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
@@ -1187,7 +1249,7 @@
self.servers_client.wait_for_server_status(self.instance['id'],
'ACTIVE')
self.node = self.get_node(instance_id=self.instance['id'])
- _, self.instance = self.servers_client.get_server(self.instance['id'])
+ self.instance = self.servers_client.get_server(self.instance['id'])
def terminate_instance(self):
self.servers_client.delete_server(self.instance['id'])
@@ -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/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index 18b759e..9c38d2f 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -12,6 +12,8 @@
import json
+from tempest_lib import decorators
+
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
@@ -79,7 +81,7 @@
server_resource = self.client.get_resource(sid, 'SmokeServer')
server_id = server_resource['physical_resource_id']
- _, server = self.servers_client.get_server(server_id)
+ server = self.servers_client.get_server(server_id)
server_ip =\
server['addresses'][CONF.compute.network_for_ssh][0]['addr']
@@ -123,7 +125,7 @@
log_console_of_servers=[server])
@test.attr(type='slow')
- @test.skip_because(bug='1374175')
+ @decorators.skip_because(bug='1374175')
@test.services('orchestration', 'compute')
def test_server_cfn_init(self):
self.assign_keypair()
diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py
index d59e31e..fe49dc1 100644
--- a/tempest/scenario/test_baremetal_basic_ops.py
+++ b/tempest/scenario/test_baremetal_basic_ops.py
@@ -97,14 +97,14 @@
def get_flavor_ephemeral_size(self):
"""Returns size of the ephemeral partition in GiB."""
f_id = self.instance['flavor']['id']
- _, flavor = self.flavors_client.get_flavor_details(f_id)
+ flavor = self.flavors_client.get_flavor_details(f_id)
ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
if not ephemeral or ephemeral == 'N/A':
return None
return int(ephemeral)
def add_floating_ip(self):
- _, floating_ip = self.floating_ips_client.create_floating_ip()
+ floating_ip = self.floating_ips_client.create_floating_ip()
self.floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], self.instance['id'])
return floating_ip['ip']
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 60fd2bd..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()
@@ -74,7 +74,7 @@
# Explicitly create secgroup to avoid cleanup at the end of testcases.
# Since no traffic is tested, we don't need to actually add rules to
# secgroup
- _, secgroup = self.security_groups_client.create_security_group(
+ secgroup = self.security_groups_client.create_security_group(
'secgroup-%s' % name, 'secgroup-desc-%s' % name)
self.addCleanupClass(self.security_groups_client.delete_security_group,
secgroup['id'])
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 57a5406..426ada3 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -161,7 +161,7 @@
"""
for server_id, ip in self.server_ips.iteritems():
private_key = self.servers_keypairs[server_id]['private_key']
- server_name = self.servers_client.get_server(server_id)[1]['name']
+ server_name = self.servers_client.get_server(server_id)['name']
username = config.scenario.ssh_user
ssh_client = self.get_remote_client(
server_or_ip=ip,
@@ -185,7 +185,7 @@
# Start netcat
start_server = ('while true; do '
- 'sudo nc -l -p %(port)s -e sh /tmp/%(script)s; '
+ 'sudo nc -ll -p %(port)s -e sh /tmp/%(script)s; '
'done &')
cmd = start_server % {'port': self.port1,
'script': 'script1'}
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 5ea48e0..f13ff0f 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -59,7 +59,7 @@
self.assertIn(self.server['id'], [x['id'] for x in servers])
def nova_show(self):
- _, got_server = self.servers_client.get_server(self.server['id'])
+ got_server = self.servers_client.get_server(self.server['id'])
self.assertThat(
self.server, custom_matchers.MatchesDictExceptForKeys(
got_server, excluded_keys=['OS-EXT-AZ:availability_zone']))
@@ -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
@@ -109,7 +109,7 @@
self.server['id'], secgroup['name'])
def wait_for_secgroup_add():
- _, body = self.servers_client.get_server(self.server['id'])
+ body = self.servers_client.get_server(self.server['id'])
return {'name': secgroup['name']} in body['security_groups']
if not test.call_until_true(wait_for_secgroup_add,
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 194a0bd..598c6d1 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
import testtools
from tempest.common.utils import data_utils
@@ -92,7 +93,7 @@
self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
self._check_network_connectivity()
- @test.skip_because(bug="1323658")
+ @decorators.skip_because(bug="1323658")
@test.services('compute', 'network')
def test_server_connectivity_stop_start(self):
self._setup_network_and_servers()
@@ -140,7 +141,7 @@
self.servers_client.resume_server(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
- @test.skip_because(bug="1323658")
+ @decorators.skip_because(bug="1323658")
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
@test.services('compute', 'network')
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index de211fb..aeb73a9 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -16,6 +16,7 @@
import collections
import re
+from tempest_lib import decorators
import testtools
from tempest.common.utils import data_utils
@@ -242,7 +243,7 @@
def check_ports():
self.new_port_list = [port for port in
self._list_ports(device_id=server['id'])
- if port != old_port]
+ if port['id'] != old_port['id']]
return len(self.new_port_list) == 1
if not test.call_until_true(check_ports, CONF.network.build_timeout,
@@ -380,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):
@@ -438,7 +442,7 @@
act_serv=servers,
trgt_serv=dns_servers))
- @test.skip_because(bug="1412325")
+ @decorators.skip_because(bug="1412325")
@testtools.skipUnless(CONF.scenario.dhcp_client,
"DHCP client is not available.")
@test.attr(type='smoke')
@@ -488,6 +492,9 @@
ssh_client.renew_lease(fixed_ip=floating_ip['fixed_ip_address'])
self._check_dns_server(ssh_client, [alt_dns_server])
+ @testtools.skipIf(CONF.baremetal.driver_enabled,
+ 'admin_state of instance ports cannot be altered '
+ 'for baremetal nodes')
@test.attr(type='smoke')
@test.services('compute', 'network')
def test_update_instance_port_admin_state(self):
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 83739fd..394aed0 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -76,6 +76,8 @@
* test that traffic is blocked with default security group
* test that traffic is enabled after updating port with new security
group having appropriate rule
+ 8. _test_multiple_security_groups: test multiple security groups can be
+ associated with the vm
assumptions:
1. alt_tenant/user existed and is different from primary_tenant/user
@@ -238,7 +240,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(
@@ -511,3 +514,37 @@
for tenant in self.tenants.values():
self._log_console_output(servers=tenant.servers)
raise
+
+ @test.attr(type='smoke')
+ @test.services('compute', 'network')
+ def test_multiple_security_groups(self):
+ """
+ This test verifies multiple security groups and checks that rules
+ provided in the both the groups is applied onto VM
+ """
+ tenant = self.primary_tenant
+ ip = self._get_server_ip(tenant.access_point,
+ floating=self.floating_ip_access)
+ ssh_login = CONF.compute.image_ssh_user
+ private_key = tenant.keypair['private_key']
+ self.check_vm_connectivity(ip,
+ should_connect=False)
+ ruleset = dict(
+ protocol='icmp',
+ direction='ingress'
+ )
+ self._create_security_group_rule(
+ secgroup=tenant.security_groups['default'],
+ **ruleset
+ )
+ """
+ Vm now has 2 security groups one with ssh rule(
+ already added in setUp() method),and other with icmp rule
+ (added in the above step).The check_vm_connectivity tests
+ -that vm ping test is successful
+ -ssh to vm is successful
+ """
+ self.check_vm_connectivity(ip,
+ username=ssh_login,
+ private_key=private_key,
+ should_connect=True)
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index d10fcce..0e0e174 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -74,19 +74,19 @@
self.servers_client.suspend_server(instance_id)
self.servers_client.wait_for_server_status(instance_id,
'SUSPENDED')
- _, fetched_instance = self.servers_client.get_server(instance_id)
+ fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
self.servers_client.wait_for_server_status(instance_id,
'ACTIVE')
- _, fetched_instance = self.servers_client.get_server(instance_id)
+ fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Suspending instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.suspend_server(instance_id)
self.servers_client.wait_for_server_status(instance_id,
'SUSPENDED')
- _, fetched_instance = self.servers_client.get_server(instance_id)
+ fetched_instance = self.servers_client.get_server(instance_id)
LOG.debug("Resuming instance %s. Current status: %s",
instance_id, fetched_instance['status'])
self.servers_client.resume_server(instance_id)
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 23743c5..509ce60 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -80,7 +80,7 @@
def verify_ssh(self):
if self.run_ssh:
# Obtain a floating IP
- _, floating_ip = self.floating_ips_client.create_floating_ip()
+ floating_ip = self.floating_ips_client.create_floating_ip()
self.addCleanup(self.delete_wrapper,
self.floating_ips_client.delete_floating_ip,
floating_ip['id'])
diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py
index 8882177..5ba650d 100644
--- a/tempest/scenario/test_shelve_instance.py
+++ b/tempest/scenario/test_shelve_instance.py
@@ -77,7 +77,7 @@
create_kwargs=create_kwargs)
if CONF.compute.use_floatingip_for_ssh:
- _, floating_ip = self.floating_ips_client.create_floating_ip()
+ floating_ip = self.floating_ips_client.create_floating_ip()
self.addCleanup(self.delete_wrapper,
self.floating_ips_client.delete_floating_ip,
floating_ip['id'])
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index cfc1d37..e97f089 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -15,6 +15,8 @@
import time
+from tempest_lib import decorators
+from tempest_lib import exceptions as lib_exc
import testtools
from tempest.common.utils import data_utils
@@ -84,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')
@@ -101,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')
@@ -137,7 +139,7 @@
got_timestamp = ssh_client.exec_command('sudo cat /mnt/timestamp')
self.assertEqual(self.timestamp, got_timestamp)
- @tempest.test.skip_because(bug="1205344")
+ @decorators.skip_because(bug="1205344")
@testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
'Snapshotting is not available.')
@tempest.test.services('compute', 'network', 'volume', 'image')
diff --git a/tempest/scenario/test_swift_telemetry_middleware.py b/tempest/scenario/test_swift_telemetry_middleware.py
index e8eb45c..dce6023 100644
--- a/tempest/scenario/test_swift_telemetry_middleware.py
+++ b/tempest/scenario/test_swift_telemetry_middleware.py
@@ -71,7 +71,7 @@
Otherwise returning False will case _check_samples to be
called again.
"""
- _, results = self.telemetry_client.list_samples(
+ results = self.telemetry_client.list_samples(
'storage.api.request')
LOG.debug('got samples %s', results)
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 910fd79..21a399c 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest_lib import decorators
+
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log
@@ -99,7 +101,7 @@
def _ssh_to_server(self, server, keypair):
if CONF.compute.use_floatingip_for_ssh:
- _, floating_ip = self.floating_ips_client.create_floating_ip()
+ floating_ip = self.floating_ips_client.create_floating_ip()
self.addCleanup(self.delete_wrapper,
self.floating_ips_client.delete_floating_ip,
floating_ip['id'])
@@ -130,7 +132,7 @@
actual = self._get_content(ssh_client)
self.assertEqual(expected, actual)
- @test.skip_because(bug='1373513')
+ @decorators.skip_because(bug='1373513')
@test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index 7967949..68ec6e7 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
@@ -67,7 +67,7 @@
def is_flavor_enough(self, flavor_id, image_id):
_image = self.images_client.get_image(image_id)
- _, _flavor = self.flavors_client.get_flavor_details(flavor_id)
+ _flavor = self.flavors_client.get_flavor_details(flavor_id)
return self._is_flavor_enough(_flavor, _image)
@@ -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
@@ -120,12 +120,15 @@
if not CONF.service_available.glance:
return []
if not hasattr(self, '_scenario_images'):
- images = self.images_client.list_images()
- self._scenario_images = [
- (self._normalize_name(i['name']), dict(image_ref=i['id']))
- for i in images if re.search(self.image_pattern,
- str(i['name']))
- ]
+ try:
+ images = self.images_client.list_images()
+ self._scenario_images = [
+ (self._normalize_name(i['name']), dict(image_ref=i['id']))
+ for i in images if re.search(self.image_pattern,
+ str(i['name']))
+ ]
+ except Exception:
+ self._scenario_images = []
return self._scenario_images
@property
@@ -134,12 +137,15 @@
:return: a scenario with name and uuid of flavors
"""
if not hasattr(self, '_scenario_flavors'):
- _, flavors = self.flavors_client.list_flavors()
- self._scenario_flavors = [
- (self._normalize_name(f['name']), dict(flavor_ref=f['id']))
- for f in flavors if re.search(self.flavor_pattern,
- str(f['name']))
- ]
+ try:
+ flavors = self.flavors_client.list_flavors()
+ self._scenario_flavors = [
+ (self._normalize_name(f['name']), dict(flavor_ref=f['id']))
+ for f in flavors if re.search(self.flavor_pattern,
+ str(f['name']))
+ ]
+ except Exception:
+ self._scenario_flavors = []
return self._scenario_flavors
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/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
index e37c9d9..343c412 100644
--- a/tempest/services/compute/json/availability_zone_client.py
+++ b/tempest/services/compute/json/availability_zone_client.py
@@ -25,11 +25,13 @@
resp, body = self.get('os-availability-zone')
body = json.loads(body)
self.validate_response(schema.get_availability_zone_list, resp, body)
- return resp, body['availabilityZoneInfo']
+ return service_client.ResponseBodyList(resp,
+ body['availabilityZoneInfo'])
def get_availability_zone_list_detail(self):
resp, body = self.get('os-availability-zone/detail')
body = json.loads(body)
self.validate_response(schema.get_availability_zone_list_detail, resp,
body)
- return resp, body['availabilityZoneInfo']
+ return service_client.ResponseBodyList(resp,
+ body['availabilityZoneInfo'])
diff --git a/tempest/services/compute/json/baremetal_nodes_client.py b/tempest/services/compute/json/baremetal_nodes_client.py
new file mode 100644
index 0000000..d8bbadd
--- /dev/null
+++ b/tempest/services/compute/json/baremetal_nodes_client.py
@@ -0,0 +1,43 @@
+# Copyright 2015 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+import urllib
+
+from tempest.api_schema.response.compute import baremetal_nodes as schema
+from tempest.common import service_client
+
+
+class BaremetalNodesClientJSON(service_client.ServiceClient):
+ """
+ Tests Baremetal API
+ """
+
+ def list_baremetal_nodes(self, params=None):
+ """List all baremetal nodes."""
+ url = 'os-baremetal-nodes'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.validate_response(schema.list_baremetal_nodes, resp, body)
+ return service_client.ResponseBodyList(resp, body['nodes'])
+
+ def get_baremetal_node(self, baremetal_node_id):
+ """Returns the details of a single baremetal node."""
+ url = 'os-baremetal-nodes/%s' % baremetal_node_id
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.validate_response(schema.get_baremetal_node, resp, body)
+ return service_client.ResponseBody(resp, body['node'])
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
index b705c37..4a30f1e 100644
--- a/tempest/services/compute/json/certificates_client.py
+++ b/tempest/services/compute/json/certificates_client.py
@@ -27,7 +27,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_certificate, resp, body)
- return resp, body['certificate']
+ return service_client.ResponseBody(resp, body['certificate'])
def create_certificate(self):
"""create certificates."""
@@ -35,4 +35,4 @@
resp, body = self.post(url, None)
body = json.loads(body)
self.validate_response(v2schema.create_certificate, resp, body)
- return resp, body['certificate']
+ return service_client.ResponseBody(resp, body['certificate'])
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index d3148b4..09561b3 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/json/extensions_client.py
@@ -26,14 +26,14 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_extensions, resp, body)
- return resp, body['extensions']
+ return service_client.ResponseBodyList(resp, body['extensions'])
def is_enabled(self, extension):
- _, extensions = self.list_extensions()
+ extensions = self.list_extensions()
exts = extensions['extensions']
return any([e for e in exts if e['name'] == extension])
def get_extension(self, extension_alias):
resp, body = self.get('extensions/%s' % extension_alias)
body = json.loads(body)
- return resp, body['extension']
+ return service_client.ResponseBody(resp, body['extension'])
diff --git a/tempest/services/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
index 5797c16..31cf5b2 100644
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ b/tempest/services/compute/json/fixed_ips_client.py
@@ -26,11 +26,11 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.fixed_ips, resp, body)
- return resp, body['fixed_ip']
+ return service_client.ResponseBody(resp, body['fixed_ip'])
def reserve_fixed_ip(self, ip, body):
"""This reserves and unreserves fixed ips."""
url = "os-fixed-ips/%s/action" % (ip)
resp, body = self.post(url, json.dumps(body))
self.validate_response(schema.fixed_ip_action, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp)
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index b42ea40..433c325 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -34,7 +34,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(common_schema.list_flavors, resp, body)
- return resp, body['flavors']
+ return service_client.ResponseBodyList(resp, body['flavors'])
def list_flavors_with_detail(self, params=None):
url = 'flavors/detail'
@@ -44,13 +44,13 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(v2schema.list_flavors_details, resp, body)
- return resp, body['flavors']
+ return service_client.ResponseBodyList(resp, body['flavors'])
def get_flavor_details(self, flavor_id):
resp, body = self.get("flavors/%s" % str(flavor_id))
body = json.loads(body)
self.validate_response(v2schema.create_get_flavor_details, resp, body)
- return resp, body['flavor']
+ return service_client.ResponseBody(resp, body['flavor'])
def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
"""Creates a new flavor or instance type."""
@@ -74,19 +74,19 @@
body = json.loads(body)
self.validate_response(v2schema.create_get_flavor_details, resp, body)
- return resp, body['flavor']
+ return service_client.ResponseBody(resp, body['flavor'])
def delete_flavor(self, flavor_id):
"""Deletes the given flavor."""
resp, body = self.delete("flavors/{0}".format(flavor_id))
self.validate_response(v2schema.delete_flavor, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
# Did not use get_flavor_details(id) for verification as it gives
# 200 ok even for deleted id. LP #981263
# we can remove the loop here and use get by ID when bug gets sortedout
- resp, flavors = self.list_flavors_with_detail()
+ flavors = self.list_flavors_with_detail()
for flavor in flavors:
if flavor['id'] == id:
return False
@@ -105,7 +105,7 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs,
resp, body)
- return resp, body['extra_specs']
+ return service_client.ResponseBody(resp, body['extra_specs'])
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
@@ -113,7 +113,7 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs,
resp, body)
- return resp, body['extra_specs']
+ return service_client.ResponseBody(resp, body['extra_specs'])
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
@@ -122,7 +122,7 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key."""
@@ -131,14 +131,14 @@
body = json.loads(body)
self.validate_response(schema_extra_specs.flavor_extra_specs_key,
resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
resp, body = self.delete('flavors/%s/os-extra_specs/%s' %
(str(flavor_id), key))
self.validate_response(v2schema.unset_flavor_extra_specs, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
@@ -146,7 +146,7 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return resp, body['flavor_access']
+ return service_client.ResponseBodyList(resp, body['flavor_access'])
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
@@ -160,7 +160,7 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return resp, body['flavor_access']
+ return service_client.ResponseBodyList(resp, body['flavor_access'])
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
@@ -174,4 +174,4 @@
body = json.loads(body)
self.validate_response(schema_access.add_remove_list_flavor_access,
resp, body)
- return resp, body['flavor_access']
+ return service_client.ResponseBody(resp, body['flavor_access'])
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 9c586e3..0354ba4 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):
@@ -32,17 +33,15 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_floating_ips, resp, body)
- return resp, body['floating_ips']
+ return service_client.ResponseBodyList(resp, body['floating_ips'])
def get_floating_ip_details(self, floating_ip_id):
"""Get the details of a floating IP."""
url = "os-floating-ips/%s" % str(floating_ip_id)
resp, body = self.get(url)
body = json.loads(body)
- if resp.status == 404:
- raise exceptions.NotFound(body)
self.validate_response(schema.floating_ip, resp, body)
- return resp, body['floating_ip']
+ return service_client.ResponseBody(resp, body['floating_ip'])
def create_floating_ip(self, pool_name=None):
"""Allocate a floating IP to the project."""
@@ -52,14 +51,14 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.validate_response(schema.floating_ip, resp, body)
- return resp, body['floating_ip']
+ return service_client.ResponseBody(resp, body['floating_ip'])
def delete_floating_ip(self, floating_ip_id):
"""Deletes the provided floating IP from the project."""
url = "os-floating-ips/%s" % str(floating_ip_id)
resp, body = self.delete(url)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def associate_floating_ip_to_server(self, floating_ip, server_id):
"""Associate the provided floating IP to a specific server."""
@@ -73,7 +72,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
"""Disassociate the provided floating IP from a specific server."""
@@ -87,12 +86,12 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
try:
self.get_floating_ip_details(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
@@ -110,7 +109,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.floating_ip_pools, resp, body)
- return resp, body['floating_ip_pools']
+ return service_client.ResponseBodyList(resp, body['floating_ip_pools'])
def create_floating_ips_bulk(self, ip_range, pool, interface):
"""Allocate floating IPs in bulk."""
@@ -123,14 +122,15 @@
resp, body = self.post('os-floating-ips-bulk', post_body)
body = json.loads(body)
self.validate_response(schema.create_floating_ips_bulk, resp, body)
- return resp, body['floating_ips_bulk_create']
+ return service_client.ResponseBody(resp,
+ body['floating_ips_bulk_create'])
def list_floating_ips_bulk(self):
"""Returns a list of all floating IPs bulk."""
resp, body = self.get('os-floating-ips-bulk')
body = json.loads(body)
self.validate_response(schema.list_floating_ips_bulk, resp, body)
- return resp, body['floating_ip_info']
+ return service_client.ResponseBodyList(resp, body['floating_ip_info'])
def delete_floating_ips_bulk(self, ip_range):
"""Deletes the provided floating IPs bulk."""
@@ -138,4 +138,5 @@
resp, body = self.put('os-floating-ips-bulk/delete', post_body)
body = json.loads(body)
self.validate_response(schema.delete_floating_ips_bulk, resp, body)
- return resp, body['floating_ips_bulk_delete']
+ data = body['floating_ips_bulk_delete']
+ return service_client.ResponseBodyData(resp, data)
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/instance_usage_audit_log_client.py b/tempest/services/compute/json/instance_usage_audit_log_client.py
index 80d7334..551d751 100644
--- a/tempest/services/compute/json/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/json/instance_usage_audit_log_client.py
@@ -28,11 +28,13 @@
body = json.loads(body)
self.validate_response(schema.list_instance_usage_audit_log,
resp, body)
- return resp, body["instance_usage_audit_logs"]
+ return service_client.ResponseBody(resp,
+ body["instance_usage_audit_logs"])
def get_instance_usage_audit_log(self, time_before):
url = 'os-instance_usage_audit_log/%s' % time_before
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_instance_usage_audit_log, resp, body)
- return resp, body["instance_usage_audit_log"]
+ return service_client.ResponseBody(resp,
+ body["instance_usage_audit_log"])
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 69dd9ae..18729c3 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -31,13 +31,13 @@
# For now we shall adhere to the spec, but the spec for keypairs
# is yet to be found
self.validate_response(common_schema.list_keypairs, resp, body)
- return resp, body['keypairs']
+ return service_client.ResponseBodyList(resp, body['keypairs'])
def get_keypair(self, key_name):
resp, body = self.get("os-keypairs/%s" % str(key_name))
body = json.loads(body)
self.validate_response(schema.get_keypair, resp, body)
- return resp, body['keypair']
+ return service_client.ResponseBody(resp, body['keypair'])
def create_keypair(self, name, pub_key=None):
post_body = {'keypair': {'name': name}}
@@ -47,9 +47,9 @@
resp, body = self.post("os-keypairs", body=post_body)
body = json.loads(body)
self.validate_response(schema.create_keypair, resp, body)
- return resp, body['keypair']
+ return service_client.ResponseBody(resp, body['keypair'])
def delete_keypair(self, key_name):
resp, body = self.delete("os-keypairs/%s" % str(key_name))
self.validate_response(schema.delete_keypair, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/compute/json/limits_client.py b/tempest/services/compute/json/limits_client.py
index 3a725ae..8769906 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -25,7 +25,7 @@
resp, body = self.get("limits")
body = json.loads(body)
self.validate_response(schema.get_limit, resp, body)
- return resp, body['limits']['absolute']
+ return service_client.ResponseBody(resp, body['limits']['absolute'])
def get_specific_absolute_limit(self, absolute_limit):
resp, body = self.get("limits")
diff --git a/tempest/services/compute/json/migrations_client.py b/tempest/services/compute/json/migrations_client.py
index b41abc8..a65b655 100644
--- a/tempest/services/compute/json/migrations_client.py
+++ b/tempest/services/compute/json/migrations_client.py
@@ -31,4 +31,4 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_migrations, resp, body)
- return resp, body['migrations']
+ return service_client.ResponseBodyList(resp, body['migrations'])
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index f9f02a5..ea0f423 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -32,7 +32,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.quota_set, resp, body)
- return resp, body['quota_set']
+ return service_client.ResponseBody(resp, body['quota_set'])
def get_default_quota_set(self, tenant_id):
"""List the default quota set for a tenant."""
@@ -41,7 +41,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.quota_set, resp, body)
- return resp, body['quota_set']
+ return service_client.ResponseBody(resp, body['quota_set'])
def update_quota_set(self, tenant_id, user_id=None,
force=None, injected_file_content_bytes=None,
@@ -106,13 +106,13 @@
body = json.loads(body)
self.validate_response(schema.quota_set_update, resp, body)
- return resp, body['quota_set']
+ return service_client.ResponseBody(resp, body['quota_set'])
def delete_quota_set(self, tenant_id):
"""Delete the tenant's quota set."""
resp, body = self.delete('os-quota-sets/%s' % str(tenant_id))
self.validate_response(schema.delete_quota, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
class QuotaClassesClientJSON(service_client.ServiceClient):
@@ -124,7 +124,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(classes_schema.quota_set, resp, body)
- return resp, body['quota_class_set']
+ return service_client.ResponseBody(resp, body['quota_class_set'])
def update_quota_class_set(self, quota_class_id, **kwargs):
"""
@@ -137,4 +137,4 @@
body = json.loads(body)
self.validate_response(classes_schema.quota_set_update, resp, body)
- return resp, body['quota_class_set']
+ return service_client.ResponseBody(resp, body['quota_class_set'])
diff --git a/tempest/services/compute/json/security_group_default_rules_client.py b/tempest/services/compute/json/security_group_default_rules_client.py
index 5d0c16f..b370e00 100644
--- a/tempest/services/compute/json/security_group_default_rules_client.py
+++ b/tempest/services/compute/json/security_group_default_rules_client.py
@@ -43,7 +43,8 @@
body = json.loads(body)
self.validate_response(schema.create_get_security_group_default_rule,
resp, body)
- return resp, body['security_group_default_rule']
+ rule = body['security_group_default_rule']
+ return service_client.ResponseBody(resp, rule)
def delete_security_group_default_rule(self,
security_group_default_rule_id):
@@ -52,7 +53,7 @@
security_group_default_rule_id))
self.validate_response(schema.delete_security_group_default_rule,
resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def list_security_group_default_rules(self):
"""List all Security Group default rules."""
@@ -60,7 +61,8 @@
body = json.loads(body)
self.validate_response(schema.list_security_group_default_rules,
resp, body)
- return resp, body['security_group_default_rules']
+ rules = body['security_group_default_rules']
+ return service_client.ResponseBodyList(resp, rules)
def get_security_group_default_rule(self, security_group_default_rule_id):
"""Return the details of provided Security Group default rule."""
@@ -69,4 +71,5 @@
body = json.loads(body)
self.validate_response(schema.create_get_security_group_default_rule,
resp, body)
- return resp, body['security_group_default_rule']
+ rule = body['security_group_default_rule']
+ return service_client.ResponseBody(resp, rule)
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 1ac52af..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):
@@ -33,7 +34,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_security_groups, resp, body)
- return resp, body['security_groups']
+ return service_client.ResponseBodyList(resp, body['security_groups'])
def get_security_group(self, security_group_id):
"""Get the details of a Security Group."""
@@ -41,7 +42,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_security_group, resp, body)
- return resp, body['security_group']
+ return service_client.ResponseBody(resp, body['security_group'])
def create_security_group(self, name, description):
"""
@@ -57,7 +58,7 @@
resp, body = self.post('os-security-groups', post_body)
body = json.loads(body)
self.validate_response(schema.get_security_group, resp, body)
- return resp, body['security_group']
+ return service_client.ResponseBody(resp, body['security_group'])
def update_security_group(self, security_group_id, name=None,
description=None):
@@ -77,14 +78,14 @@
post_body)
body = json.loads(body)
self.validate_response(schema.update_security_group, resp, body)
- return resp, body['security_group']
+ return service_client.ResponseBody(resp, body['security_group'])
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
resp, body = self.delete(
'os-security-groups/%s' % str(security_group_id))
self.validate_response(schema.delete_security_group, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_security_group_rule(self, parent_group_id, ip_proto, from_port,
to_port, **kwargs):
@@ -111,14 +112,14 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.validate_response(schema.create_security_group_rule, resp, body)
- return resp, body['security_group_rule']
+ return service_client.ResponseBody(resp, body['security_group_rule'])
def delete_security_group_rule(self, group_rule_id):
"""Deletes the provided Security Group rule."""
resp, body = self.delete('os-security-group-rules/%s' %
str(group_rule_id))
self.validate_response(schema.delete_security_group_rule, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def list_security_group_rules(self, security_group_id):
"""List all rules for a security group."""
@@ -127,13 +128,13 @@
self.validate_response(schema.list_security_groups, resp, body)
for sg in body['security_groups']:
if sg['id'] == security_group_id:
- return resp, sg['rules']
- raise exceptions.NotFound('No such Security Group')
+ return service_client.ResponseBodyList(resp, sg['rules'])
+ 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..6a5bce7 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
@@ -90,13 +92,13 @@
# NOTE(maurosr): this deals with the case of multiple server create
# with return reservation id set True
if 'reservation_id' in body:
- return resp, body
+ return service_client.ResponseBody(resp, body)
if CONF.compute_feature_enabled.enable_instance_password:
create_schema = schema.create_server_with_admin_pass
else:
create_schema = schema.create_server
self.validate_response(create_schema, resp, body)
- return resp, body['server']
+ return service_client.ResponseBody(resp, body['server'])
def update_server(self, server_id, name=None, meta=None, accessIPv4=None,
accessIPv6=None, disk_config=None):
@@ -130,20 +132,20 @@
resp, body = self.put("servers/%s" % str(server_id), post_body)
body = json.loads(body)
self.validate_response(schema.update_server, resp, body)
- return resp, body['server']
+ return service_client.ResponseBody(resp, body['server'])
def get_server(self, server_id):
"""Returns the details of an existing server."""
resp, body = self.get("servers/%s" % str(server_id))
body = json.loads(body)
self.validate_response(schema.get_server, resp, body)
- return resp, body['server']
+ return service_client.ResponseBody(resp, body['server'])
def delete_server(self, server_id):
"""Deletes the given server."""
resp, body = self.delete("servers/%s" % str(server_id))
self.validate_response(common_schema.delete_server, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def list_servers(self, params=None):
"""Lists all servers for a user."""
@@ -182,8 +184,8 @@
start_time = int(time.time())
while True:
try:
- resp, body = self.get_server(server_id)
- except exceptions.NotFound:
+ body = self.get_server(server_id)
+ 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/tenant_usages_client.py b/tempest/services/compute/json/tenant_usages_client.py
index 5dc1d5d..bbc1051 100644
--- a/tempest/services/compute/json/tenant_usages_client.py
+++ b/tempest/services/compute/json/tenant_usages_client.py
@@ -30,7 +30,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_tenant, resp, body)
- return resp, body['tenant_usages'][0]
+ return service_client.ResponseBodyList(resp, body['tenant_usages'][0])
def get_tenant_usage(self, tenant_id, params=None):
url = 'os-simple-tenant-usage/%s' % tenant_id
@@ -40,4 +40,4 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.get_tenant, resp, body)
- return resp, body['tenant_usage']
+ return service_client.ResponseBodyList(resp, body['tenant_usage'])
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/data_processing_client.py
similarity index 79%
rename from tempest/services/data_processing/v1_1/client.py
rename to tempest/services/data_processing/v1_1/data_processing_client.py
index 55b6be6..04cf9a3 100644
--- a/tempest/services/data_processing/v1_1/client.py
+++ b/tempest/services/data_processing/v1_1/data_processing_client.py
@@ -15,25 +15,25 @@
import json
from tempest.common import service_client
-from tempest import config
-
-CONF = config.CONF
class DataProcessingClient(service_client.ServiceClient):
- def __init__(self, auth_provider):
- super(DataProcessingClient, self).__init__(
- auth_provider,
- CONF.data_processing.catalog_type,
- CONF.identity.region,
- endpoint_type=CONF.data_processing.endpoint_type)
-
def _request_and_check_resp(self, request_func, uri, resp_status):
"""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 +44,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 +113,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 +128,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 +170,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 +208,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 +235,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 +278,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/database/json/limits_client.py b/tempest/services/database/json/limits_client.py
index 4daf028..6168bfd 100644
--- a/tempest/services/database/json/limits_client.py
+++ b/tempest/services/database/json/limits_client.py
@@ -15,11 +15,8 @@
import urllib
-from tempest import config
from tempest_lib.common import rest_client
-CONF = config.CONF
-
class DatabaseLimitsClientJSON(rest_client.RestClient):
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index d4f57e0..6c4a6b4 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -11,23 +11,13 @@
# 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
class IdentityClientJSON(service_client.ServiceClient):
- def __init__(self, auth_provider):
- super(IdentityClientJSON, self).__init__(
- auth_provider,
- CONF.identity.catalog_type,
- CONF.identity.region,
- endpoint_type='adminURL')
-
def has_admin_extensions(self):
"""
Returns True if the KSADM Admin Extensions are supported
@@ -134,7 +124,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 +217,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/base.py b/tempest/services/identity/v3/json/base.py
deleted file mode 100644
index cba480a..0000000
--- a/tempest/services/identity/v3/json/base.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2014 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-from tempest.common import service_client
-from tempest import config
-
-CONF = config.CONF
-
-
-class IdentityV3Client(service_client.ServiceClient):
- """
- Base identity v3 client class
- """
-
- def __init__(self, auth_provider):
- super(IdentityV3Client, self).__init__(
- auth_provider,
- CONF.identity.catalog_type,
- CONF.identity.region,
- endpoint_type='adminURL')
- self.api_version = "v3"
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index 1289e48..0a614cd 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -16,10 +16,10 @@
import json
from tempest.common import service_client
-from tempest.services.identity.v3.json import base
-class CredentialsClientJSON(base.IdentityV3Client):
+class CredentialsClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def create_credential(self, access_key, secret_key, user_id, project_id):
"""Creates a credential."""
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index d71836e..5b7e812 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -16,10 +16,10 @@
import json
from tempest.common import service_client
-from tempest.services.identity.v3.json import base
-class EndPointClientJSON(base.IdentityV3Client):
+class EndPointClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def list_endpoints(self):
"""GET endpoints."""
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index f3d9d2d..be5aa80 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -17,13 +17,10 @@
import urllib
from tempest.common import service_client
-from tempest import config
-from tempest.services.identity.v3.json import base
-
-CONF = config.CONF
-class IdentityV3ClientJSON(base.IdentityV3Client):
+class IdentityV3ClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def create_user(self, user_name, password=None, project_id=None,
email=None, domain_id='default', **kwargs):
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 25931c8..8c9c9ce 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -16,10 +16,10 @@
import json
from tempest.common import service_client
-from tempest.services.identity.v3.json import base
-class PolicyClientJSON(base.IdentityV3Client):
+class PolicyClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def create_policy(self, blob, type):
"""Creates a Policy."""
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index 482cbc6..faaf43c 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -17,10 +17,10 @@
import urllib
from tempest.common import service_client
-from tempest.services.identity.v3.json import base
-class RegionClientJSON(base.IdentityV3Client):
+class RegionClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def create_region(self, description, **kwargs):
"""Create region."""
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index 2e2df13..e039dc6 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -16,10 +16,10 @@
import json
from tempest.common import service_client
-from tempest.services.identity.v3.json import base
-class ServiceClientJSON(base.IdentityV3Client):
+class ServiceClientJSON(service_client.ServiceClient):
+ api_version = "v3"
def update_service(self, service_id, **kwargs):
"""Updates a service."""
diff --git a/tempest/services/identity/v3/json/token_client.py b/tempest/services/identity/v3/json/token_client.py
index 14c4a0a..5d75efa 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
@@ -35,23 +36,22 @@
self.auth_url = auth_url
- def auth(self, user=None, password=None, tenant=None, user_type='id',
- domain=None, token=None):
+ def auth(self, user=None, password=None, project=None, user_type='id',
+ user_domain=None, project_domain=None, token=None):
"""
:param user: user id or name, as specified in user_type
- :param domain: the user and tenant domain
+ :param user_domain: the user domain
+ :param project_domain: the project domain
:param token: a token to re-scope.
Accepts different combinations of credentials. Restrictions:
- - tenant and domain are only name (no id)
- - user domain and tenant domain are assumed identical
- - domain scope is not supported here
+ - project and domain are only name (no id)
Sample sample valid combinations:
- token
- - token, tenant, domain
+ - token, project, project_domain
- user_id, password
- - username, password, domain
- - username, password, tenant, domain
+ - username, password, user_domain
+ - username, password, project, user_domain, project_domain
Validation is left to the server side.
"""
creds = {
@@ -78,13 +78,13 @@
id_obj['password']['user']['id'] = user
else:
id_obj['password']['user']['name'] = user
- if domain is not None:
- _domain = dict(name=domain)
+ if user_domain is not None:
+ _domain = dict(name=user_domain)
id_obj['password']['user']['domain'] = _domain
- if tenant is not None:
- _domain = dict(name=domain)
- project = dict(name=tenant, domain=_domain)
- scope = dict(project=project)
+ if project is not None:
+ _domain = dict(name=project_domain)
+ _project = dict(name=project, domain=_domain)
+ scope = dict(project=_project)
creds['auth']['scope'] = scope
body = json.dumps(creds)
@@ -112,21 +112,22 @@
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))
return resp, json.loads(resp_body)
- def get_token(self, user, password, tenant, domain='Default',
- auth_data=False):
+ def get_token(self, user, password, project=None, project_domain='Default',
+ user_domain='Default', auth_data=False):
"""
:param user: username
Returns (token id, token data) for supplied credentials
"""
- body = self.auth(user, password, tenant, user_type='name',
- domain=domain)
+ body = self.auth(user, password, project, user_type='name',
+ user_domain=user_domain,
+ project_domain=project_domain)
token = body.response.get('x-subject-token')
if auth_data:
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index a7b8f63..4ea710f 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
@@ -237,13 +239,12 @@
url = 'v1/images/%s' % image_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
- # We can't return a ResponseBody because the body is a string
- return resp, body
+ return service_client.ResponseBodyData(resp, body)
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..50f273c 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
@@ -141,8 +141,7 @@
url = 'v2/images/%s/file' % image_id
resp, body = self.get(url)
self.expected_success(200, resp.status)
- # We can't return a ResponseBody because the body is a string
- return resp, body
+ return service_client.ResponseBodyData(resp, body)
def add_image_tag(self, image_id, tag):
url = 'v2/images/%s/tags/%s' % (image_id, tag)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 1ce4bf0..ba069e8 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/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index 2967cfa..a249625 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -45,8 +45,9 @@
uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
body = self.serialize(sample_list)
resp, body = self.post(uri, body)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def helper_list(self, uri, query=None, period=None):
uri_dict = {}
@@ -59,8 +60,9 @@
if uri_dict:
uri += "?%s" % urllib.urlencode(uri_dict)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBodyList(resp, body)
def list_resources(self, query=None):
uri = '%s/resources' % self.uri_prefix
@@ -85,45 +87,52 @@
def get_resource(self, resource_id):
uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def get_alarm(self, alarm_id):
uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def delete_alarm(self, alarm_id):
uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
resp, body = self.delete(uri)
+ self.expected_success(204, resp.status)
if body:
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def create_alarm(self, **kwargs):
uri = "%s/alarms" % self.uri_prefix
body = self.serialize(kwargs)
resp, body = self.post(uri, body)
+ self.expected_success(201, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def update_alarm(self, alarm_id, **kwargs):
uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
body = self.serialize(kwargs)
resp, body = self.put(uri, body)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def alarm_get_state(self, alarm_id):
uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBodyData(resp, body)
def alarm_set_state(self, alarm_id, state):
uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
body = self.serialize(state)
resp, body = self.put(uri, body)
+ self.expected_success(200, resp.status)
body = self.deserialize(body)
- return resp, body
+ return service_client.ResponseBodyData(resp, body)
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..059664c 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,11 +17,10 @@
import time
import urllib
-from tempest.common import service_client
-from tempest import config
-from tempest import exceptions
+from tempest_lib import exceptions as lib_exc
-CONF = config.CONF
+from tempest.common import service_client
+from tempest import exceptions
class BaseVolumesClientJSON(service_client.ServiceClient):
@@ -31,6 +30,12 @@
create_resp = 200
+ def __init__(self, auth_provider, service, region,
+ default_volume_size=1, **kwargs):
+ super(BaseVolumesClientJSON, self).__init__(
+ auth_provider, service, region, **kwargs)
+ self.default_volume_size = default_volume_size
+
def get_attachment_from_volume(self, volume):
"""Return the element 'attachment' from input volumes."""
return volume['attachments'][0]
@@ -77,10 +82,8 @@
snapshot_id: When specified the volume is created from this snapshot
imageRef: When specified the volume is created from this image
"""
- # for bug #1293885:
- # If no size specified, read volume size from CONF
if size is None:
- size = CONF.volume.volume_size
+ size = self.default_volume_size
post_body = {'size': size}
post_body.update(kwargs)
post_body = json.dumps({'volume': post_body})
@@ -181,7 +184,7 @@
def is_resource_deleted(self, id):
try:
self.get_volume(id)
- except exceptions.NotFound:
+ except lib_exc.NotFound:
return True
return False
@@ -333,6 +336,14 @@
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, body)
+ def retype_volume(self, volume_id, volume_type, **kwargs):
+ """Updates volume with new volume type."""
+ post_body = {'new_type': volume_type}
+ post_body.update(kwargs)
+ post_body = json.dumps({'os-retype': post_body})
+ resp, body = self.post('volumes/%s/action' % volume_id, post_body)
+ self.expected_success(202, resp.status)
+
class VolumesClientJSON(BaseVolumesClientJSON):
"""
diff --git a/tempest/stress/actions/server_create_destroy.py b/tempest/stress/actions/server_create_destroy.py
index 34e299d..d0e4eea 100644
--- a/tempest/stress/actions/server_create_destroy.py
+++ b/tempest/stress/actions/server_create_destroy.py
@@ -28,7 +28,7 @@
def run(self):
name = data_utils.rand_name("instance")
self.logger.info("creating %s" % name)
- _, server = self.manager.servers_client.create_server(
+ server = self.manager.servers_client.create_server(
name, self.image, self.flavor)
server_id = server['id']
self.manager.servers_client.wait_for_server_status(server_id,
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 5bc8cac..b2c612e 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -74,9 +74,9 @@
self.logger.info("creating %s" % name)
vm_args = self.vm_extra_args.copy()
vm_args['security_groups'] = [self.sec_grp]
- _, server = servers_client.create_server(name, self.image,
- self.flavor,
- **vm_args)
+ server = servers_client.create_server(name, self.image,
+ self.flavor,
+ **vm_args)
self.server_id = server['id']
if self.wait_after_vm_create:
self.manager.servers_client.wait_for_server_status(self.server_id,
@@ -92,8 +92,8 @@
sec_grp_cli = self.manager.security_groups_client
s_name = data_utils.rand_name('sec_grp-')
s_description = data_utils.rand_name('desc-')
- _, self.sec_grp = sec_grp_cli.create_security_group(s_name,
- s_description)
+ self.sec_grp = sec_grp_cli.create_security_group(s_name,
+ s_description)
create_rule = sec_grp_cli.create_security_group_rule
create_rule(self.sec_grp['id'], 'tcp', 22, 22)
create_rule(self.sec_grp['id'], 'icmp', -1, -1)
@@ -104,7 +104,7 @@
def _create_floating_ip(self):
floating_cli = self.manager.floating_ips_client
- _, self.floating = floating_cli.create_floating_ip(self.floating_pool)
+ self.floating = floating_cli.create_floating_ip(self.floating_pool)
def _destroy_floating_ip(self):
cli = self.manager.floating_ips_client
@@ -144,7 +144,7 @@
cli = self.manager.floating_ips_client
def func():
- _, floating = cli.get_floating_ip_details(self.floating['id'])
+ floating = cli.get_floating_ip_details(self.floating['id'])
return floating['instance_id'] is None
if not tempest.test.call_until_true(func, self.check_timeout,
diff --git a/tempest/stress/actions/volume_attach_delete.py b/tempest/stress/actions/volume_attach_delete.py
index 9c4070f..2e1d623 100644
--- a/tempest/stress/actions/volume_attach_delete.py
+++ b/tempest/stress/actions/volume_attach_delete.py
@@ -28,7 +28,7 @@
# Step 1: create volume
name = data_utils.rand_name("volume")
self.logger.info("creating volume: %s" % name)
- _, volume = self.manager.volumes_client.create_volume(
+ volume = self.manager.volumes_client.create_volume(
size=1,
display_name=name)
self.manager.volumes_client.wait_for_volume_status(volume['id'],
@@ -38,7 +38,7 @@
# Step 2: create vm instance
vm_name = data_utils.rand_name("instance")
self.logger.info("creating vm: %s" % vm_name)
- _, server = self.manager.servers_client.create_server(
+ server = self.manager.servers_client.create_server(
vm_name, self.image, self.flavor)
server_id = server['id']
self.manager.servers_client.wait_for_server_status(server_id, 'ACTIVE')
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index a13d890..c013af3 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -24,7 +24,7 @@
def _create_keypair(self):
keyname = data_utils.rand_name("key")
- _, self.key = self.manager.keypairs_client.create_keypair(keyname)
+ self.key = self.manager.keypairs_client.create_keypair(keyname)
def _delete_keypair(self):
self.manager.keypairs_client.delete_keypair(self.key['name'])
@@ -36,9 +36,9 @@
vm_args = self.vm_extra_args.copy()
vm_args['security_groups'] = [self.sec_grp]
vm_args['key_name'] = self.key['name']
- _, server = servers_client.create_server(name, self.image,
- self.flavor,
- **vm_args)
+ server = servers_client.create_server(name, self.image,
+ self.flavor,
+ **vm_args)
self.server_id = server['id']
self.manager.servers_client.wait_for_server_status(self.server_id,
'ACTIVE')
@@ -53,8 +53,8 @@
sec_grp_cli = self.manager.security_groups_client
s_name = data_utils.rand_name('sec_grp-')
s_description = data_utils.rand_name('desc-')
- _, self.sec_grp = sec_grp_cli.create_security_group(s_name,
- s_description)
+ self.sec_grp = sec_grp_cli.create_security_group(s_name,
+ s_description)
create_rule = sec_grp_cli.create_security_group_rule
create_rule(self.sec_grp['id'], 'tcp', 22, 22)
create_rule(self.sec_grp['id'], 'icmp', -1, -1)
@@ -65,7 +65,7 @@
def _create_floating_ip(self):
floating_cli = self.manager.floating_ips_client
- _, self.floating = floating_cli.create_floating_ip(self.floating_pool)
+ self.floating = floating_cli.create_floating_ip(self.floating_pool)
def _destroy_floating_ip(self):
cli = self.manager.floating_ips_client
@@ -77,7 +77,7 @@
name = data_utils.rand_name("volume")
self.logger.info("creating volume: %s" % name)
volumes_client = self.manager.volumes_client
- _, self.volume = volumes_client.create_volume(
+ self.volume = volumes_client.create_volume(
size=1,
display_name=name)
volumes_client.wait_for_volume_status(self.volume['id'],
@@ -95,7 +95,7 @@
cli = self.manager.floating_ips_client
def func():
- _, floating = cli.get_floating_ip_details(self.floating['id'])
+ floating = cli.get_floating_ip_details(self.floating['id'])
return floating['instance_id'] is None
if not tempest.test.call_until_true(func, CONF.compute.build_timeout,
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index b494db6..86325f5 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -37,7 +37,7 @@
except Exception:
pass
- _, keypairs = admin_manager.keypairs_client.list_keypairs()
+ keypairs = admin_manager.keypairs_client.list_keypairs()
LOG.info("Cleanup::remove %s keypairs" % len(keypairs))
for k in keypairs:
try:
@@ -46,7 +46,7 @@
pass
secgrp_client = admin_manager.security_groups_client
- _, secgrp = secgrp_client.list_security_groups({"all_tenants": True})
+ secgrp = secgrp_client.list_security_groups({"all_tenants": True})
secgrp_del = [grp for grp in secgrp if grp['name'] != 'default']
LOG.info("Cleanup::remove %s Security Group" % len(secgrp_del))
for g in secgrp_del:
@@ -55,7 +55,7 @@
except Exception:
pass
- _, floating_ips = admin_manager.floating_ips_client.list_floating_ips()
+ floating_ips = admin_manager.floating_ips_client.list_floating_ips()
LOG.info("Cleanup::remove %s floating ips" % len(floating_ips))
for f in floating_ips:
try:
@@ -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/test.py b/tempest/test.py
index cc8370c..d4123a4 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -39,9 +39,6 @@
CONF = config.CONF
-# All the successful HTTP status codes from RFC 2616
-HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
-
def attr(*args, **kwargs):
"""A decorator which applies the testtools attr decorator
@@ -140,35 +137,6 @@
return decorator
-def skip_because(*args, **kwargs):
- """A decorator useful to skip tests hitting known bugs
-
- @param bug: bug number causing the test to skip
- @param condition: optional condition to be True for the skip to have place
- @param interface: skip the test if it is the same as self._interface
- """
- def decorator(f):
- @functools.wraps(f)
- def wrapper(self, *func_args, **func_kwargs):
- skip = False
- if "condition" in kwargs:
- if kwargs["condition"] is True:
- skip = True
- elif "interface" in kwargs:
- if kwargs["interface"] == self._interface:
- skip = True
- else:
- skip = True
- if "bug" in kwargs and skip is True:
- if not kwargs['bug'].isdigit():
- raise ValueError('bug must be a valid bug number')
- msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
- raise testtools.TestCase.skipException(msg)
- return f(self, *func_args, **func_kwargs)
- return wrapper
- return decorator
-
-
def requires_ext(*args, **kwargs):
"""A decorator to skip tests if an extension is not enabled
@@ -391,7 +359,7 @@
level=None))
@classmethod
- def get_client_manager(cls, interface=None):
+ def get_client_manager(cls):
"""
Returns an OpenStack client manager
"""
@@ -405,12 +373,7 @@
)
creds = cls.isolated_creds.get_primary_creds()
- params = dict(credentials=creds, service=cls._service)
- if getattr(cls, '_interface', None):
- interface = cls._interface
- if interface:
- params['interface'] = interface
- os = clients.Manager(**params)
+ os = clients.Manager(credentials=creds, service=cls._service)
return os
@classmethod
@@ -426,13 +389,12 @@
"""
Returns an instance of the Identity Admin API client
"""
- os = clients.AdminManager(interface=cls._interface,
- service=cls._service)
+ os = clients.AdminManager(service=cls._service)
admin_client = os.identity_client
return admin_client
@classmethod
- def set_network_resources(self, network=False, router=False, subnet=False,
+ def set_network_resources(cls, network=False, router=False, subnet=False,
dhcp=False):
"""Specify which network resources should be created
@@ -445,8 +407,8 @@
# in order to ensure that even if it's called multiple times in
# a chain of overloaded methods, the attribute is set only
# in the leaf class
- if not self.network_resources:
- self.network_resources = {
+ if not cls.network_resources:
+ cls.network_resources = {
'network': network,
'router': router,
'subnet': subnet,
@@ -468,8 +430,7 @@
super(NegativeAutoTest, cls).setUpClass()
os = cls.get_client_manager()
cls.client = os.negative_client
- os_admin = clients.AdminManager(interface=cls._interface,
- service=cls._service)
+ os_admin = clients.AdminManager(service=cls._service)
cls.admin_client = os_admin.negative_client
@staticmethod
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index 1abe29a..17e2550 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -282,8 +282,8 @@
def test_verify_extensions_nova(self):
def fake_list_extensions():
- return (None, [{'alias': 'fake1'}, {'alias': 'fake2'},
- {'alias': 'not_fake'}])
+ return ([{'alias': 'fake1'}, {'alias': 'fake2'},
+ {'alias': 'not_fake'}])
fake_os = mock.MagicMock()
fake_os.extensions_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
@@ -303,9 +303,9 @@
def test_verify_extensions_nova_all(self):
def fake_list_extensions():
- return (None, {'extensions': [{'alias': 'fake1'},
- {'alias': 'fake2'},
- {'alias': 'not_fake'}]})
+ return ({'extensions': [{'alias': 'fake1'},
+ {'alias': 'fake2'},
+ {'alias': 'not_fake'}]})
fake_os = mock.MagicMock()
fake_os.extensions_client.list_extensions = fake_list_extensions
self.useFixture(mockpatch.PatchObject(
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/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 2b31d6b..afe4abc 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -43,8 +43,18 @@
from tempest.services.compute.json import tenant_usages_client
from tempest.services.compute.json import volumes_extensions_client \
as compute_volumes_extensions_client
+from tempest.services.data_processing.v1_1 import data_processing_client
from tempest.services.database.json import flavors_client as db_flavor_client
from tempest.services.database.json import versions_client as db_version_client
+from tempest.services.identity.json import identity_client as \
+ identity_v2_identity_client
+from tempest.services.identity.v3.json import credentials_client
+from tempest.services.identity.v3.json import endpoints_client
+from tempest.services.identity.v3.json import identity_client as \
+ identity_v3_identity_client
+from tempest.services.identity.v3.json import policy_client
+from tempest.services.identity.v3.json import region_client
+from tempest.services.identity.v3.json import service_client
from tempest.services.messaging.json import messaging_client
from tempest.services.network.json import network_client
from tempest.services.object_storage import account_client
@@ -117,6 +127,7 @@
services_client.ServicesClientJSON,
tenant_usages_client.TenantUsagesClientJSON,
compute_volumes_extensions_client.VolumesExtensionsClientJSON,
+ data_processing_client.DataProcessingClient,
db_flavor_client.DatabaseFlavorsClientJSON,
db_version_client.DatabaseVersionsClientJSON,
messaging_client.MessagingClientJSON,
@@ -146,6 +157,13 @@
volume_v2_qos_client.QosSpecsV2ClientJSON,
volume_v2_snapshots_client.SnapshotsV2ClientJSON,
volume_v2_volumes_client.VolumesV2ClientJSON,
+ identity_v2_identity_client.IdentityClientJSON,
+ credentials_client.CredentialsClientJSON,
+ endpoints_client.EndPointClientJSON,
+ identity_v3_identity_client.IdentityV3ClientJSON,
+ policy_client.PolicyClientJSON,
+ region_client.RegionClientJSON,
+ service_client.ServiceClientJSON
]
for client in test_clients:
diff --git a/tempest/tests/negative/test_negative_auto_test.py b/tempest/tests/negative/test_negative_auto_test.py
index fb1da43..7a127cd 100644
--- a/tempest/tests/negative/test_negative_auto_test.py
+++ b/tempest/tests/negative/test_negative_auto_test.py
@@ -21,7 +21,6 @@
class TestNegativeAutoTest(base.TestCase):
# Fake entries
- _interface = 'json'
_service = 'compute'
fake_input_desc = {"name": "list-flavors-with-detail",
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
diff --git a/tempest/tests/test_decorators.py b/tempest/tests/test_decorators.py
index 32cefd0..1f1835e 100644
--- a/tempest/tests/test_decorators.py
+++ b/tempest/tests/test_decorators.py
@@ -150,70 +150,6 @@
allow_inheritance=True)
-class TestSkipBecauseDecorator(BaseDecoratorsTest):
- def _test_skip_because_helper(self, expected_to_skip=True,
- **decorator_args):
- class TestFoo(test.BaseTestCase):
- _interface = 'json'
-
- @test.skip_because(**decorator_args)
- def test_bar(self):
- return 0
-
- t = TestFoo('test_bar')
- if expected_to_skip:
- self.assertRaises(testtools.TestCase.skipException, t.test_bar)
- else:
- # assert that test_bar returned 0
- self.assertEqual(TestFoo('test_bar').test_bar(), 0)
-
- def test_skip_because_bug(self):
- self._test_skip_because_helper(bug='12345')
-
- def test_skip_because_bug_and_interface_match(self):
- self._test_skip_because_helper(bug='12346', interface='json')
-
- def test_skip_because_bug_interface_not_match(self):
- self._test_skip_because_helper(expected_to_skip=False,
- bug='12347', interface='xml')
-
- def test_skip_because_bug_and_condition_true(self):
- self._test_skip_because_helper(bug='12348', condition=True)
-
- def test_skip_because_bug_and_condition_false(self):
- self._test_skip_because_helper(expected_to_skip=False,
- bug='12349', condition=False)
-
- def test_skip_because_bug_condition_false_and_interface_match(self):
- """
- Assure that only condition will be evaluated if both parameters are
- passed.
- """
- self._test_skip_because_helper(expected_to_skip=False,
- bug='12350', condition=False,
- interface='json')
-
- def test_skip_because_bug_condition_true_and_interface_not_match(self):
- """
- Assure that only condition will be evaluated if both parameters are
- passed.
- """
- self._test_skip_because_helper(bug='12351', condition=True,
- interface='xml')
-
- def test_skip_because_bug_without_bug_never_skips(self):
- """Never skip without a bug parameter."""
- self._test_skip_because_helper(expected_to_skip=False,
- condition=True)
- self._test_skip_because_helper(expected_to_skip=False,
- interface='json')
-
- def test_skip_because_invalid_bug_number(self):
- """Raise ValueError if with an invalid bug number"""
- self.assertRaises(ValueError, self._test_skip_because_helper,
- bug='critical_bug')
-
-
class TestRequiresExtDecorator(BaseDecoratorsTest):
def setUp(self):
super(TestRequiresExtDecorator, self).setUp()
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 62073bd..edd9de1 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -79,7 +79,7 @@
except keystoneclient.exceptions.Unauthorized:
EC2_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " faild to get them even by keystoneclient"
+ " failed to get them even by keystoneclient"
except Exception as exc:
EC2_CAN_CONNECT_ERROR = str(exc)
@@ -96,7 +96,7 @@
S3_CAN_CONNECT_ERROR = str(exc)
except keystoneclient.exceptions.Unauthorized:
S3_CAN_CONNECT_ERROR = "AWS credentials not set," +\
- " faild to get them even by keystoneclient"
+ " failed to get them even by keystoneclient"
boto_logger.logger.setLevel(level)
return {'A_I_IMAGES_READY': A_I_IMAGES_READY,
'S3_CAN_CONNECT_ERROR': S3_CAN_CONNECT_ERROR,
@@ -195,6 +195,12 @@
"""Recommended to use as base class for boto related test."""
@classmethod
+ def skip_checks(cls):
+ super(BotoTestCase, cls).skip_checks()
+ if not CONF.compute_feature_enabled.ec2_api:
+ raise cls.skipException("The EC2 API is not available")
+
+ @classmethod
def resource_setup(cls):
super(BotoTestCase, cls).resource_setup()
cls.conclusion = decision_maker()