Merge "Add the description of hacking rule T107"
diff --git a/tempest/api/baremetal/admin/test_ports_negative.py b/tempest/api/baremetal/admin/test_ports_negative.py
index dd19edc..8dbdedf 100644
--- a/tempest/api/baremetal/admin/test_ports_negative.py
+++ b/tempest/api/baremetal/admin/test_ports_negative.py
@@ -14,7 +14,6 @@
from tempest.api.baremetal.admin import base
from tempest.common.utils import data_utils
-from tempest import exceptions as exc
from tempest import test
@@ -32,19 +31,19 @@
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'])
@@ -54,7 +53,7 @@
@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'])
@@ -71,15 +70,15 @@
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):
@@ -87,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'])
@@ -117,7 +116,7 @@
'op': 'replace',
'value': 'new-value'}]
- self.assertRaises(exc.BadRequest,
+ self.assertRaises(lib_exc.BadRequest,
self.client.update_port, address,
patch)
@@ -147,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}])
@@ -160,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'}])
@@ -175,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'])
@@ -206,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'])
@@ -221,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'])
@@ -234,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'])
@@ -245,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'])
@@ -256,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'])
@@ -267,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'])
@@ -276,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):
@@ -306,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_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index 48f6f94..fd44f7f 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -18,7 +18,6 @@
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
@@ -52,7 +51,7 @@
@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='')
@@ -60,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)
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_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_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index b553397..f717291 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -16,7 +16,6 @@
from tempest.api.compute import base
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -73,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((lib_exc.NotFound, exceptions.BadRequest),
+ self.assertRaises((lib_exc.NotFound, lib_exc.BadRequest),
self.client.reserve_fixed_ip,
"my.invalid.ip", body)
@@ -81,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 360bcf7..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
@@ -210,7 +210,7 @@
self.addCleanup(self.flavor_clean_up, flavor['id'])
# 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'])
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 e414973..c22602a 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -18,7 +18,6 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -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_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 20429b1..8d70c44 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -16,7 +16,6 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -72,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',
@@ -84,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',
@@ -95,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',
@@ -106,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)
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 1e03bd0..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
@@ -19,7 +19,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -44,6 +43,6 @@
@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 7e567d3..c51ad61 100644
--- a/tempest/api/compute/admin/test_migrations.py
+++ b/tempest/api/compute/admin/test_migrations.py
@@ -31,8 +31,7 @@
@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.')
@@ -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_security_group_default_rules.py b/tempest/api/compute/admin/test_security_group_default_rules.py
index 31103df..a0606cd 100644
--- a/tempest/api/compute/admin/test_security_group_default_rules.py
+++ b/tempest/api/compute/admin/test_security_group_default_rules.py
@@ -30,10 +30,14 @@
@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',
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 3ef2f80..7fd87f6 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -21,7 +21,6 @@
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
@@ -100,13 +99,13 @@
@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)
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index 31566d6..6775d1f 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -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 b371f2d..0d88f6c 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -17,7 +17,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.compute import base
-from tempest import exceptions
from tempest import test
@@ -52,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)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 4120a9a..c448975 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -17,6 +17,7 @@
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
@@ -36,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
@@ -59,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):
@@ -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")
@@ -335,15 +347,21 @@
"""Base test case class for Compute Admin API tests."""
@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)
- 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/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 2fce564..46a6ddb 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -25,9 +25,13 @@
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
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 9697d57..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
@@ -20,7 +20,6 @@
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
@@ -30,9 +29,13 @@
server_id = None
@classmethod
+ 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()
- cls.client = cls.floating_ips_client
# Server creation
server = cls.create_test_server(wait_until='ACTIVE')
@@ -92,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((lib_exc.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 ca46918..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,9 +20,13 @@
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):
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 b3ff132..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
@@ -28,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'])
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 65a91b0..7f15ad1 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -19,7 +19,6 @@
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
@@ -79,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'])
@@ -87,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'])
@@ -112,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'])
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 1586405..ea25527 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -18,7 +18,6 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -38,7 +37,7 @@
# 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'])
@@ -53,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'])
@@ -61,7 +60,7 @@
# 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'])
@@ -77,19 +76,19 @@
@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/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 527f2dd..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
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 c8da63f..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
@@ -18,7 +18,6 @@
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
@@ -34,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'])
@@ -62,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)
@@ -85,7 +84,7 @@
to_port)
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
# 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)
@@ -102,7 +101,7 @@
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)
@@ -118,7 +117,7 @@
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)
@@ -134,7 +133,7 @@
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)
@@ -150,7 +149,7 @@
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)
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index eff91b0..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')
@@ -101,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'])
@@ -113,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'])
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 a083406..2cbea1a 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -20,7 +20,6 @@
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
@@ -29,9 +28,13 @@
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):
@@ -66,15 +69,15 @@
# 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)
@@ -87,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)
@@ -109,7 +112,7 @@
s_description = data_utils.rand_name('description-')
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)
@@ -124,7 +127,7 @@
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)
@@ -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)
@@ -169,7 +172,7 @@
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)
@@ -184,7 +187,7 @@
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)
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index c0b58ff..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,
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_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index c5148c1..58740fd 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -28,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()
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 3827ad9..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
@@ -113,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_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
index dc83bfc..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
@@ -38,31 +39,31 @@
@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_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 46e8642..5a63033 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -20,12 +20,20 @@
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
+ @classmethod
+ def resource_setup(cls):
+ super(ServerAddressesTestJSON, cls).resource_setup()
+
cls.server = cls.create_test_server(wait_until='ACTIVE')
@test.attr(type='smoke')
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index 3329583..b32231a 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -22,11 +22,18 @@
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
+ @classmethod
+ def resource_setup(cls):
+ super(ServerAddressesNegativeTestJSON, cls).resource_setup()
cls.server = cls.create_test_server(wait_until='ACTIVE')
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index 5357f80..441c965 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -17,7 +17,6 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -42,7 +41,7 @@
for sz in [256, 257, 511, 1023]:
key = "k" * sz
meta = {key: 'data1'}
- self.assertRaises((exceptions.BadRequest, lib_exc.OverLimit),
+ self.assertRaises((lib_exc.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=meta)
@@ -52,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)
@@ -78,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)
@@ -106,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)
@@ -148,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)
@@ -157,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_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index a1658df..8d5c8f8 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -24,12 +24,19 @@
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
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index 0583106..58353e7 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -27,12 +27,19 @@
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
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 830c8d0..d89aff4 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -22,7 +22,6 @@
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
@@ -54,7 +53,7 @@
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='')
@@ -66,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)
@@ -74,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)
@@ -82,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,)
@@ -91,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'])
@@ -100,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,
@@ -119,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,
@@ -127,7 +126,7 @@
@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'])
@@ -174,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)
@@ -183,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)
@@ -193,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)
@@ -202,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)
@@ -211,7 +210,7 @@
# Pass really long metadata while creating a server
metadata = {'a': 'b' * 260}
- self.assertRaises((exceptions.BadRequest, lib_exc.OverLimit),
+ self.assertRaises((lib_exc.BadRequest, lib_exc.OverLimit),
self.create_test_server,
meta=metadata)
@@ -232,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'])
@@ -249,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)
@@ -287,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)
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index bc26881..5c76ba7 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -26,11 +26,19 @@
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
+
+ @classmethod
+ def resource_setup(cls):
+ super(VirtualInterfacesTestJSON, cls).resource_setup()
server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
index d66b7ba..58c4fcd 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -24,10 +24,14 @@
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'])
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 10d8bfa..1211db3 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -21,7 +21,6 @@
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
@@ -31,30 +30,42 @@
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
+ @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'])
@@ -168,7 +179,7 @@
@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')
@@ -180,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)
@@ -198,7 +209,7 @@
)
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
@@ -249,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:
@@ -290,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,
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 92a1c86..6da6b79 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -71,8 +71,6 @@
else:
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
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
index 1583278..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
@@ -48,6 +48,6 @@
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/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 53253c9..ed54aaf 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -20,7 +20,6 @@
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
@@ -58,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'])
@@ -67,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'])
@@ -75,7 +74,7 @@
# 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'])
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 2c51715..c38e6e0 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -18,7 +18,6 @@
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -49,7 +48,7 @@
@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):
diff --git a/tempest/api/identity/admin/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py
index 16ea96a..db51f14 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -18,7 +18,6 @@
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -99,14 +98,14 @@
@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'])
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index db8c564..99993b9 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -18,7 +18,6 @@
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -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)
@@ -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)
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index 9846010..cf41f9c 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -14,10 +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.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -50,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')
@@ -60,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')
@@ -75,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_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py
index fc013c5..a194198 100644
--- a/tempest/api/identity/admin/v3/test_projects_negative.py
+++ b/tempest/api/identity/admin/v3/test_projects_negative.py
@@ -17,7 +17,6 @@
from tempest.api.identity import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -50,14 +49,14 @@
@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'])
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 15ca21e..747911b 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -139,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_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 36be098..919eab9 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -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 fd62004..48201ec 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -20,7 +20,6 @@
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
@@ -237,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/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py
index b144a83..698bac0 100644
--- a/tempest/api/image/v1/test_images_negative.py
+++ b/tempest/api/image/v1/test_images_negative.py
@@ -16,7 +16,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
-from tempest import exceptions
from tempest import test
@@ -26,12 +25,12 @@
@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'])
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_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index 4402af9..068a6e5 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -13,7 +13,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
-from tempest import exceptions
from tempest import test
@@ -25,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')
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index d32fc3b..9f0ad2d 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -19,7 +19,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.image import base
-from tempest import exceptions
from tempest import test
@@ -85,10 +84,10 @@
@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/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/network/base.py b/tempest/api/network/base.py
index 4cb1485..e8c8de3 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -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
diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py
index f7a6fb7..1b28bac 100644
--- a/tempest/api/network/test_dhcp_ipv6.py
+++ b/tempest/api/network/test_dhcp_ipv6.py
@@ -21,7 +21,6 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
CONF = config.CONF
@@ -146,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)
@@ -329,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'],
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index 81eedd4..7d70976 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -19,7 +19,6 @@
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
@@ -59,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'],
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index 655fa58..67a6c94 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -19,7 +19,6 @@
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
@@ -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'])
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 47b218c..0da1aac 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -19,7 +19,6 @@
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
@@ -64,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)
@@ -76,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)
@@ -103,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,
@@ -116,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)
@@ -132,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)
@@ -144,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)
@@ -207,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/object_storage/base.py b/tempest/api/object_storage/base.py
index 79a1960..6a025d9 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -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()
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 0e136bf..783bf1a 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -29,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 = \
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 7fe472c..edc052e 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -23,12 +23,17 @@
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()
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/orchestration/base.py b/tempest/api/orchestration/base.py
index 6873756..b8b0562 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -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 = []
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 deb6b1d..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
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 322bdf1..8356497 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -27,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')
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index 05aed08..cb2d2bd 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -80,12 +80,12 @@
# Set alarm state and verify
new_state =\
[elem for elem in alarm_states if elem != alarm['state']][0]
- _, state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
- new_state)
- 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
- _, state = self.telemetry_client.alarm_get_state(alarm['alarm_id'])
- 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):
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index f2c1dda..d4062cc 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -37,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_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 2f3b382..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
@@ -19,7 +19,6 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -44,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)
@@ -53,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)
@@ -63,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)
@@ -73,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)
@@ -92,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)
@@ -100,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'])
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 77ca34c..a40f1c4 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -18,7 +18,6 @@
from tempest_lib import exceptions as lib_exc
from tempest.api.volume import base
-from tempest import exceptions
from tempest import test
@@ -37,7 +36,7 @@
@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')
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 39aba01..595ddf4 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -19,7 +19,6 @@
from tempest.api.volume import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest import test
@@ -54,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'])
@@ -63,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'])
@@ -71,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'])
@@ -79,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'])
@@ -180,21 +179,21 @@
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'])
@@ -228,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_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 7e1928f..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__)
@@ -323,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):
@@ -564,16 +563,6 @@
'project_name', 'tenant_id', 'tenant_name', 'user_domain_id',
'user_domain_name', 'user_id']
- 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)
# for tenant_* set both project and tenant
diff --git a/tempest/clients.py b/tempest/clients.py
index 786e05f..096470e 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -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 \
@@ -269,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.
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 9172972..e9b6621 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -115,7 +115,6 @@
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
@@ -233,9 +232,6 @@
LOG.error("%s not found in USERS: %s" % (name, USERS))
-def resp_ok(response):
- return 200 >= int(response['status']) < 300
-
###################
#
# TENANTS
@@ -708,7 +704,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
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 87f5ca6..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()
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index f40ed7a..d899303 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -70,6 +70,12 @@
# 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)
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 1cfb963..f81c3ed 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -198,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:
diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py
index 0812b99..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,8 +58,6 @@
method, url,
extra_headers=extra_headers,
headers=headers, body=body)
- except lib_exceptions.BadRequest as ex:
- raise exceptions.BadRequest(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
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 5ec1d6c..426ada3 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -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_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 265f9e5..aeb73a9 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -492,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/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/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/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/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/identity/v3/json/token_client.py b/tempest/services/identity/v3/json/token_client.py
index 1467d7c..5d75efa 100644
--- a/tempest/services/identity/v3/json/token_client.py
+++ b/tempest/services/identity/v3/json/token_client.py
@@ -36,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 = {
@@ -79,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)
@@ -120,14 +119,15 @@
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 0c05118..4ea710f 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -239,8 +239,7 @@
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:
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 4cddc59..50f273c 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -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/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index dd899e4..a249625 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -127,7 +127,7 @@
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)
@@ -135,4 +135,4 @@
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/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 9ef1686..059664c 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -336,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 c473df6..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,
@@ -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 3c052ac..c013af3 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -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')
@@ -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/test.py b/tempest/test.py
index 0c9cbfd..d4123a4 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -394,7 +394,7 @@
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
@@ -407,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,
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(