Merge "Add test list_servers_filtered_by_name_regex"
diff --git a/HACKING.rst b/HACKING.rst
index 025bf74..29d5bf4 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -227,3 +227,48 @@
2. The unit tests cannot use setUpClass, instead fixtures and testresources
should be used for shared state between tests.
+
+
+.. _TestDocumentation:
+
+Test Documentation
+------------------
+For tests being added we need to require inline documentation in the form of
+docstings to explain what is being tested. In API tests for a new API a class
+level docstring should be added to an API reference doc. If one doesn't exist
+a TODO comment should be put indicating that the reference needs to be added.
+For individual API test cases a method level docstring should be used to
+explain the functionality being tested if the test name isn't descriptive
+enough. For example::
+
+ def test_get_role_by_id(self):
+ """Get a role by its id."""
+
+the docstring there is superfluous and shouldn't be added. but for a method
+like::
+
+ def test_volume_backup_create_get_detailed_list_restore_delete(self):
+ pass
+
+a docstring would be useful because while the test title is fairly descriptive
+the operations being performed are complex enough that a bit more explanation
+will help people figure out the intent of the test.
+
+For scenario tests a class level docstring describing the steps in the scenario
+is required. If there is more than one test case in the class individual
+docstrings for the workflow in each test methods can be used instead. A good
+example of this would be::
+
+ class TestVolumeBootPattern(manager.OfficialClientTest):
+ """
+ This test case attempts to reproduce the following steps:
+
+ * Create in Cinder some bootable volume importing a Glance image
+ * Boot an instance from the bootable volume
+ * Write content to the volume
+ * Delete an instance and Boot a new instance from the volume
+ * Check written content in the instance
+ * Create a volume snapshot while the instance is running
+ * Boot an additional instance from the new snapshot based volume
+ * Check written content in the instance booted from snapshot
+ """
diff --git a/REVIEWING.rst b/REVIEWING.rst
index d6dc83e..74bd2ad 100644
--- a/REVIEWING.rst
+++ b/REVIEWING.rst
@@ -51,6 +51,15 @@
whether to skip or not.
+Test Documentation
+------------------
+When a new test is being added refer to the :ref:`TestDocumentation` section in
+hacking to see if the requirements are being met. With the exception of a class
+level docstring linking to the API ref doc in the API tests and a docstring for
+scenario tests this is up to the reviewers discretion whether a docstring is
+required or not.
+
+
When to approve
---------------
* Every patch needs two +2s before being approved.
diff --git a/doc/source/conf.py b/doc/source/conf.py
index bd4e553..daa293c 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -27,7 +27,6 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc',
- 'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'oslosphinx'
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index ef56ab3..dfcbaba 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -709,6 +709,42 @@
#ssh_user_regex=[["^.*[Cc]irros.*$", "root"]]
+[messaging]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Messaging service. (string value)
+#catalog_type=messaging
+
+# The maximum number of queue records per page when listing
+# queues (integer value)
+#max_queues_per_page=20
+
+# The maximum metadata size for a queue (integer value)
+#max_queue_metadata=65536
+
+# The maximum number of queue message per page when listing
+# (or) posting messages (integer value)
+#max_messages_per_page=20
+
+# The maximum size of a message body (integer value)
+#max_message_size=262144
+
+# The maximum number of messages per claim (integer value)
+#max_messages_per_claim=20
+
+# The maximum ttl for a message (integer value)
+#max_message_ttl=1209600
+
+# The maximum ttl for a claim (integer value)
+#max_claim_ttl=43200
+
+# The maximum grace period for a claim (integer value)
+#max_claim_grace=43200
+
+
[negative]
#
@@ -747,10 +783,10 @@
# The cidr block to allocate tenant ipv6 subnets from (string
# value)
-#tenant_network_v6_cidr=2003::/64
+#tenant_network_v6_cidr=2003::/48
# The mask bits for tenant ipv6 subnets (integer value)
-#tenant_network_v6_mask_bits=96
+#tenant_network_v6_mask_bits=64
# Whether tenant network connectivity should be evaluated
# directly (boolean value)
@@ -843,6 +879,15 @@
# expected to be enabled (list value)
#discoverable_apis=all
+# Execute (old style) container-sync tests (boolean value)
+#container_sync=true
+
+# Execute object-versioning tests (boolean value)
+#object_versioning=true
+
+# Execute discoverability tests (boolean value)
+#discoverability=true
+
[orchestration]
@@ -888,42 +933,6 @@
#max_resources_per_stack=1000
-[queuing]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the Queuing service. (string value)
-#catalog_type=queuing
-
-# The maximum number of queue records per page when listing
-# queues (integer value)
-#max_queues_per_page=20
-
-# The maximum metadata size for a queue (integer value)
-#max_queue_metadata=65536
-
-# The maximum number of queue message per page when listing
-# (or) posting messages (integer value)
-#max_messages_per_page=20
-
-# The maximum size of a message body (integer value)
-#max_message_size=262144
-
-# The maximum number of messages per claim (integer value)
-#max_messages_per_claim=20
-
-# The maximum ttl for a message (integer value)
-#max_message_ttl=1209600
-
-# The maximum ttl for a claim (integer value)
-#max_claim_ttl=43200
-
-# The maximum grace period for a claim (integer value)
-#max_claim_grace=43200
-
-
[scenario]
#
diff --git a/requirements.txt b/requirements.txt
index 9a3b74d..708ede3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,25 +1,28 @@
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
pbr>=0.6,!=0.7,<1.0
anyjson>=0.3.3
httplib2>=0.7.5
jsonschema>=2.0.0,<3.0.0
testtools>=0.9.34
lxml>=2.3
-boto>=2.12.0,!=2.13.0
+boto>=2.32.1
paramiko>=1.13.0
-netaddr>=0.7.6
+netaddr>=0.7.12
python-ceilometerclient>=1.0.6
-python-glanceclient>=0.13.1
-python-keystoneclient>=0.9.0
-python-novaclient>=2.17.0
-python-neutronclient>=2.3.5,<3
-python-cinderclient>=1.0.7
+python-glanceclient>=0.14.0
+python-keystoneclient>=0.10.0
+python-novaclient>=2.18.0
+python-neutronclient>=2.3.6,<3
+python-cinderclient>=1.1.0
python-heatclient>=0.2.9
-python-ironicclient
-python-saharaclient>=0.6.0
-python-swiftclient>=2.0.2
+python-ironicclient>=0.2.1
+python-saharaclient>=0.7.3
+python-swiftclient>=2.2.0
testresources>=0.2.4
testrepository>=0.0.18
-oslo.config>=1.2.1
+oslo.config>=1.4.0 # Apache-2.0
six>=1.7.0
iso8601>=0.1.9
fixtures>=0.3.14
diff --git a/tempest/api/baremetal/admin/base.py b/tempest/api/baremetal/admin/base.py
index 62edd10..3b12b8e 100644
--- a/tempest/api/baremetal/admin/base.py
+++ b/tempest/api/baremetal/admin/base.py
@@ -28,6 +28,10 @@
# which has no external dependencies.
SUPPORTED_DRIVERS = ['fake']
+# NOTE(jroll): resources must be deleted in a specific order, this list
+# defines the resource types to clean up, and the correct order.
+RESOURCE_TYPES = ['port', 'node', 'chassis']
+
def creates(resource):
"""Decorator that adds resources to the appropriate cleanup list."""
@@ -49,8 +53,8 @@
"""Base class for Baremetal API tests."""
@classmethod
- def setUpClass(cls):
- super(BaseBaremetalTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseBaremetalTest, cls).resource_setup()
if not CONF.service_available.ironic:
skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
@@ -66,21 +70,22 @@
mgr = clients.AdminManager()
cls.client = mgr.baremetal_client
cls.power_timeout = CONF.baremetal.power_timeout
- cls.created_objects = {'chassis': set(),
- 'port': set(),
- 'node': set()}
+ cls.created_objects = {}
+ for resource in RESOURCE_TYPES:
+ cls.created_objects[resource] = set()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
"""Ensure that all created objects get destroyed."""
try:
- for resource, uuids in cls.created_objects.iteritems():
+ for resource in RESOURCE_TYPES:
+ uuids = cls.created_objects[resource]
delete_method = getattr(cls.client, 'delete_%s' % resource)
for u in uuids:
delete_method(u, ignore_errors=exc.NotFound)
finally:
- super(BaseBaremetalTest, cls).tearDownClass()
+ super(BaseBaremetalTest, cls).resource_cleanup()
@classmethod
@creates('chassis')
diff --git a/tempest/api/baremetal/admin/test_chassis.py b/tempest/api/baremetal/admin/test_chassis.py
index 254a969..6f83412 100644
--- a/tempest/api/baremetal/admin/test_chassis.py
+++ b/tempest/api/baremetal/admin/test_chassis.py
@@ -21,8 +21,8 @@
"""Tests for chassis."""
@classmethod
- def setUpClass(cls):
- super(TestChassis, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestChassis, cls).resource_setup()
_, cls.chassis = cls.create_chassis()
def _assertExpected(self, expected, actual):
@@ -75,3 +75,9 @@
description=new_description))
_, chassis = self.client.show_chassis(uuid)
self.assertEqual(chassis['description'], new_description)
+
+ @test.attr(type='smoke')
+ def test_chassis_node_list(self):
+ _, node = self.create_node(self.chassis['uuid'])
+ _, body = self.client.list_chassis_nodes(self.chassis['uuid'])
+ self.assertIn(node['uuid'], [n['uuid'] for n in body['nodes']])
diff --git a/tempest/api/baremetal/admin/test_drivers.py b/tempest/api/baremetal/admin/test_drivers.py
index 9e215dc..9d99295 100644
--- a/tempest/api/baremetal/admin/test_drivers.py
+++ b/tempest/api/baremetal/admin/test_drivers.py
@@ -22,9 +22,8 @@
class TestDrivers(base.BaseBaremetalTest):
"""Tests for drivers."""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(TestDrivers, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestDrivers, cls).resource_setup()
cls.driver_name = CONF.baremetal.driver
@test.attr(type="smoke")
diff --git a/tempest/api/baremetal/admin/test_nodes.py b/tempest/api/baremetal/admin/test_nodes.py
index ab6aed3..8ccd36b 100644
--- a/tempest/api/baremetal/admin/test_nodes.py
+++ b/tempest/api/baremetal/admin/test_nodes.py
@@ -13,6 +13,8 @@
import six
from tempest.api.baremetal.admin import base
+from tempest.common.utils import data_utils
+from tempest.common import waiters
from tempest import exceptions as exc
from tempest import test
@@ -33,6 +35,17 @@
self.assertIn(key, actual)
self.assertEqual(value, actual[key])
+ def _associate_node_with_instance(self):
+ self.client.set_node_power_state(self.node['uuid'], 'power off')
+ waiters.wait_for_bm_node_status(self.client, self.node['uuid'],
+ 'power_state', 'power off')
+ instance_uuid = data_utils.rand_uuid()
+ self.client.update_node(self.node['uuid'],
+ instance_uuid=instance_uuid)
+ self.addCleanup(self.client.update_node,
+ uuid=self.node['uuid'], instance_uuid=None)
+ return instance_uuid
+
@test.attr(type='smoke')
def test_create_node(self):
params = {'cpu_arch': 'x86_64',
@@ -63,6 +76,34 @@
[i['uuid'] for i in body['nodes']])
@test.attr(type='smoke')
+ def test_list_nodes_association(self):
+ _, body = self.client.list_nodes(associated=True)
+ self.assertNotIn(self.node['uuid'],
+ [n['uuid'] for n in body['nodes']])
+
+ self._associate_node_with_instance()
+
+ _, body = self.client.list_nodes(associated=True)
+ self.assertIn(self.node['uuid'], [n['uuid'] for n in body['nodes']])
+
+ _, body = self.client.list_nodes(associated=False)
+ self.assertNotIn(self.node['uuid'], [n['uuid'] for n in body['nodes']])
+
+ @test.attr(type='smoke')
+ def test_node_port_list(self):
+ _, port = self.create_port(self.node['uuid'],
+ data_utils.rand_mac_address())
+ _, body = self.client.list_node_ports(self.node['uuid'])
+ self.assertIn(port['uuid'],
+ [p['uuid'] for p in body['ports']])
+
+ @test.attr(type='smoke')
+ def test_node_port_list_no_ports(self):
+ _, node = self.create_node(self.chassis['uuid'])
+ _, body = self.client.list_node_ports(node['uuid'])
+ self.assertEmpty(body['ports'])
+
+ @test.attr(type='smoke')
def test_update_node(self):
props = {'cpu_arch': 'x86_64',
'cpu_num': '12',
@@ -106,3 +147,24 @@
body = self.client.get_node_supported_boot_devices(self.node['uuid'])
self.assertIn('supported_boot_devices', body)
self.assertTrue(isinstance(body['supported_boot_devices'], list))
+
+ @test.attr(type='smoke')
+ def test_get_console(self):
+ _, body = self.client.get_console(self.node['uuid'])
+ con_info = ['console_enabled', 'console_info']
+ for key in con_info:
+ self.assertIn(key, body)
+
+ @test.attr(type='smoke')
+ def test_set_console_mode(self):
+ self.client.set_console_mode(self.node['uuid'], True)
+
+ _, body = self.client.get_console(self.node['uuid'])
+ self.assertEqual(True, body['console_enabled'])
+
+ @test.attr(type='smoke')
+ def test_get_node_by_instance_uuid(self):
+ instance_uuid = self._associate_node_with_instance()
+ _, body = self.client.show_node_by_instance_uuid(instance_uuid)
+ self.assertEqual(len(body['nodes']), 1)
+ self.assertIn(self.node['uuid'], [n['uuid'] for n in body['nodes']])
diff --git a/tempest/api/baremetal/admin/test_nodestates.py b/tempest/api/baremetal/admin/test_nodestates.py
index 76f47f9..f4f8054 100644
--- a/tempest/api/baremetal/admin/test_nodestates.py
+++ b/tempest/api/baremetal/admin/test_nodestates.py
@@ -22,8 +22,8 @@
"""Tests for baremetal NodeStates."""
@classmethod
- def setUpClass(cls):
- super(TestNodeStates, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestNodeStates, cls).resource_setup()
_, cls.chassis = cls.create_chassis()
_, cls.node = cls.create_node(cls.chassis['uuid'])
diff --git a/tempest/api/compute/admin/test_agents.py b/tempest/api/compute/admin/test_agents.py
index 4808601..3bdcfd6 100644
--- a/tempest/api/compute/admin/test_agents.py
+++ b/tempest/api/compute/admin/test_agents.py
@@ -27,8 +27,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AgentsAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AgentsAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.agents_client
def setUp(self):
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 3485943..f33089c 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -29,8 +29,8 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
- def setUpClass(cls):
- super(AggregatesAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AggregatesAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.aggregates_client
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
index 690f2ab..ef6752b 100644
--- a/tempest/api/compute/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -27,8 +27,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AggregatesAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AggregatesAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os_adm.aggregates_client
cls.user_client = cls.aggregates_client
cls.aggregate_name_prefix = 'test_aggregate_'
diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py
index 3a6de36..0a040d7 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -24,8 +24,8 @@
_api_version = 3
@classmethod
- def setUpClass(cls):
- super(AZAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AZAdminV3Test, cls).resource_setup()
cls.client = cls.availability_zone_admin_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
index ce97491..ea157b3 100644
--- a/tempest/api/compute/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AZAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AZAdminNegativeTestJSON, cls).resource_setup()
cls.non_adm_client = cls.availability_zone_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index 939f1a1..e7f269d 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -23,8 +23,8 @@
class FixedIPsTestJson(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(FixedIPsTestJson, cls).setUpClass()
+ def resource_setup(cls):
+ super(FixedIPsTestJson, cls).resource_setup()
if CONF.service_available.neutron:
msg = ("%s skipped as neutron is available" % cls.__name__)
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index 1caa246..90be820 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -23,8 +23,8 @@
class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(FixedIPsNegativeTestJson, cls).setUpClass()
+ def resource_setup(cls):
+ super(FixedIPsNegativeTestJson, cls).resource_setup()
if CONF.service_available.neutron:
msg = ("%s skipped as neutron is available" % cls.__name__)
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 18866e5..d365f3a 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAdminTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index f2554ea..176a134 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -26,8 +26,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAccessTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAccessTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index b636ccd..9cc2a92 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -29,8 +29,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAccessNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAccessNegativeTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 56daf96..c05abe2 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -27,8 +27,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsExtraSpecsTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
@@ -51,10 +51,10 @@
swap=swap, rxtx=rxtx)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsTestJSON, cls).resource_cleanup()
@test.attr(type='gate')
def test_flavor_set_get_update_show_unset_keys(self):
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 1e5695f..30adf73 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsExtraSpecsNegativeTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
@@ -52,10 +52,10 @@
swap=swap, rxtx=rxtx)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsNegativeTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsNegativeTestJSON, cls).resource_cleanup()
@test.attr(type=['negative', 'gate'])
def test_flavor_non_admin_set_keys(self):
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
index eece096..3389aee 100644
--- a/tempest/api/compute/admin/test_flavors_negative.py
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -31,8 +31,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAdminNegativeTestJSON, cls).resource_setup()
if not test.is_extension_enabled('OS-FLV-EXT-DATA', 'compute'):
msg = "OS-FLV-EXT-DATA extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index 16c2810..c1263ea 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -31,9 +31,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(FloatingIPsBulkAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPsBulkAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.floating_ips_client
cls.ip_range = CONF.compute.floating_ip_range
cls.verify_unallocated_floating_ip_range(cls.ip_range)
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index e612566..bcae492 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HostsAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(HostsAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.hosts_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 0f26e84..4111aba 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -25,8 +25,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HostsAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(HostsAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os_adm.hosts_client
cls.non_admin_client = cls.os.hosts_client
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 85b26a1..c51d0a5 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HypervisorAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(HypervisorAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.hypervisor_client
def _list_hypervisors(self):
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index 4ba8d30..d3804e8 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HypervisorAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(HypervisorAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os_adm.hypervisor_client
cls.non_adm_client = cls.hypervisor_client
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 055a177..91f0b02 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -23,8 +23,8 @@
class InstanceUsageAuditLogTestJSON(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(InstanceUsageAuditLogTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceUsageAuditLogTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.instance_usages_audit_log_client
@test.attr(type='gate')
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 6a5fc96..1af340d 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
@@ -24,8 +24,8 @@
class InstanceUsageAuditLogNegativeTestJSON(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(InstanceUsageAuditLogNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceUsageAuditLogNegativeTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.instance_usages_audit_log_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/admin/test_migrations.py b/tempest/api/compute/admin/test_migrations.py
index 514f1fa..7ba05ef 100644
--- a/tempest/api/compute/admin/test_migrations.py
+++ b/tempest/api/compute/admin/test_migrations.py
@@ -24,8 +24,8 @@
class MigrationsAdminTest(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(MigrationsAdminTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(MigrationsAdminTest, cls).resource_setup()
cls.client = cls.os_adm.migrations_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/admin/test_networks.py b/tempest/api/compute/admin/test_networks.py
index 032e2f5..75f3199 100644
--- a/tempest/api/compute/admin/test_networks.py
+++ b/tempest/api/compute/admin/test_networks.py
@@ -29,8 +29,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(NetworksTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(NetworksTest, cls).resource_setup()
cls.client = cls.os_adm.networks_client
def test_get_network(self):
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index d27d78b..701e1c2 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -34,8 +34,8 @@
super(QuotasAdminTestJSON, self).setUp()
@classmethod
- def setUpClass(cls):
- super(QuotasAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasAdminTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.quotas_client
# NOTE(afazekas): these test cases should always create and use a new
@@ -57,9 +57,9 @@
resp, quota_set = self.adm_client.get_default_quota_set(
self.demo_tenant_id)
self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.demo_tenant_id)
+ for quota in expected_quota_set:
+ self.assertIn(quota, quota_set.keys())
@test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
@@ -79,10 +79,18 @@
**new_quota_set)
default_quota_set.pop('id')
+ # NOTE(PhilDay) The following is safe as we're not updating these
+ # two quota values yet. Once the Nova change to add these is merged
+ # and the client updated to support them this can be removed
+ if 'server_groups' in default_quota_set:
+ default_quota_set.pop('server_groups')
+ if 'server_group_members' in default_quota_set:
+ default_quota_set.pop('server_group_members')
self.addCleanup(self.adm_client.update_quota_set,
self.demo_tenant_id, **default_quota_set)
self.assertEqual(200, resp.status)
- self.assertEqual(new_quota_set, quota_set)
+ for quota in new_quota_set:
+ self.assertIn(quota, quota_set.keys())
# TODO(afazekas): merge these test cases
@test.attr(type='gate')
@@ -159,8 +167,8 @@
super(QuotaClassesAdminTestJSON, self).setUp()
@classmethod
- def setUpClass(cls):
- super(QuotaClassesAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotaClassesAdminTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.quota_classes_client
def _restore_default_quotas(self, original_defaults):
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 4afda03..a9ed7ce 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -25,8 +25,8 @@
force_tenant_isolation = True
@classmethod
- def setUpClass(cls):
- super(QuotasAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os.quotas_client
cls.adm_client = cls.os_adm.quotas_client
cls.sg_client = cls.security_groups_client
@@ -44,7 +44,6 @@
# TODO(afazekas): Add dedicated tenant to the skiped quota tests
# it can be moved into the setUpClass as well
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
@@ -58,9 +57,9 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
cores=default_vcpu_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
@@ -74,9 +73,9 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
ram=default_mem_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
@@ -89,7 +88,8 @@
instances=instances_quota)
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
instances=default_instances_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
@test.skip_because(bug="1186354",
condition=CONF.service_available.neutron)
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 a07d270..4c0bd47 100644
--- a/tempest/api/compute/admin/test_security_group_default_rules.py
+++ b/tempest/api/compute/admin/test_security_group_default_rules.py
@@ -30,11 +30,10 @@
@testtools.skipIf(CONF.service_available.neutron,
"Skip as this functionality is not yet "
"implemented in Neutron. Related Bug#1311500")
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
# A network and a subnet will be created for these tests
cls.set_network_resources(network=True, subnet=True)
- super(SecurityGroupDefaultRulesTest, cls).setUpClass()
+ super(SecurityGroupDefaultRulesTest, cls).resource_setup()
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_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index 004ce8f..40ae236 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -26,8 +26,8 @@
class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(SecurityGroupsTestAdminJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecurityGroupsTestAdminJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.security_groups_client
cls.client = cls.security_groups_client
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 49af645..47aaee3 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -26,9 +26,8 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ServersAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.servers_client
cls.non_admin_client = cls.servers_client
cls.flavors_client = cls.os_adm.flavors_client
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index f4d010e..9aa489c 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -17,6 +17,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -32,8 +33,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServersAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os_adm.servers_client
cls.non_adm_client = cls.servers_client
cls.flavors_client = cls.os_adm.flavors_client
@@ -54,11 +55,12 @@
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
- @test.skip_because(bug="1298131")
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize not available.')
@test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_ram(self):
+ # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
+ self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
resp, quota_set = self.quotas_client.get_default_quota_set(
@@ -70,16 +72,17 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
- @test.skip_because(bug="1298131")
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize not available.')
@test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_vcpus(self):
+ # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
+ self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
ram = 512
@@ -91,7 +94,7 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index 2feb825..76153e7 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -25,8 +25,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServicesAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServicesAdminTestJSON, cls).resource_setup()
cls.client = cls.os_adm.services_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index c78d70d..5331097 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServicesAdminNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServicesAdminNegativeTestJSON, cls).resource_setup()
cls.client = cls.os_adm.services_client
cls.non_admin_client = cls.services_client
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index f3a81d1..5d596ba 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -23,8 +23,8 @@
class TenantUsagesTestJSON(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(TenantUsagesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(TenantUsagesTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.tenant_usages_client
cls.client = cls.os.tenant_usages_client
cls.tenant_id = cls.client.tenant_id
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 1031b24..5e2c593 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -23,8 +23,8 @@
class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest):
@classmethod
- def setUpClass(cls):
- super(TenantUsagesNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(TenantUsagesNegativeTestJSON, cls).resource_setup()
cls.adm_client = cls.os_adm.tenant_usages_client
cls.client = cls.os.tenant_usages_client
cls.identity_client = cls._get_identity_admin_client()
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 47d1254..6c93d33 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -19,6 +19,7 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
+from tempest.openstack.common import excutils
from tempest.openstack.common import log as logging
import tempest.test
@@ -34,9 +35,9 @@
force_tenant_isolation = False
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources()
- super(BaseComputeTest, cls).setUpClass()
+ super(BaseComputeTest, cls).resource_setup()
if getattr(cls, '_interface', None) == 'xml' and cls._api_version == 2:
if not CONF.compute_feature_enabled.xml_api_v2:
raise cls.skipException('XML API is not enabled')
@@ -144,14 +145,19 @@
for server in cls.servers:
try:
cls.servers_client.delete_server(server['id'])
- except Exception:
+ except exceptions.NotFound:
+ # Something else already cleaned up the server, nothing to be
+ # worried about
pass
+ except Exception:
+ LOG.exception('Deleting server %s failed' % server['id'])
for server in cls.servers:
try:
cls.servers_client.wait_for_server_termination(server['id'])
except Exception:
- pass
+ LOG.exception('Waiting for deletion of server %s failed'
+ % server['id'])
@classmethod
def server_check_teardown(cls):
@@ -211,13 +217,12 @@
server_group_id)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.clear_images()
cls.clear_servers()
cls.clear_security_groups()
- cls.clear_isolated_creds()
cls.clear_server_groups()
- super(BaseComputeTest, cls).tearDownClass()
+ super(BaseComputeTest, cls).resource_cleanup()
@classmethod
def create_test_server(cls, **kwargs):
@@ -243,15 +248,16 @@
try:
cls.servers_client.wait_for_server_status(
server['id'], kwargs['wait_until'])
- except Exception as ex:
- if ('preserve_server_on_error' not in kwargs
- or kwargs['preserve_server_on_error'] is False):
- for server in servers:
- try:
- cls.servers_client.delete_server(server['id'])
- except Exception:
- pass
- raise ex
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ if ('preserve_server_on_error' not in kwargs
+ or kwargs['preserve_server_on_error'] is False):
+ for server in servers:
+ try:
+ cls.servers_client.delete_server(
+ server['id'])
+ except Exception:
+ pass
cls.servers.extend(servers)
@@ -382,8 +388,8 @@
_interface = "json"
@classmethod
- def setUpClass(cls):
- super(BaseComputeAdminTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseComputeAdminTest, cls).resource_setup()
if (CONF.compute.allow_tenant_isolation or
cls.force_tenant_isolation is True):
creds = cls.isolated_creds.get_admin_creds()
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index c1c2d05..7beef23 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -24,8 +24,8 @@
_min_ram = 'min_ram'
@classmethod
- def setUpClass(cls):
- super(FlavorsV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsV3Test, cls).resource_setup()
cls.client = cls.flavors_client
@test.attr(type='smoke')
diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py
index 7672fc6..cae1ac4 100644
--- a/tempest/api/compute/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/flavors/test_flavors_negative.py
@@ -35,6 +35,6 @@
_schema = flavors.flavors_details
@classmethod
- def setUpClass(cls):
- super(FlavorDetailsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorDetailsNegativeTestJSON, cls).resource_setup()
cls.set_resource("flavor", cls.flavor_ref)
diff --git a/tempest/api/compute/flavors/test_flavors_negative_xml.py b/tempest/api/compute/flavors/test_flavors_negative_xml.py
index bf73c0e..299b18a 100644
--- a/tempest/api/compute/flavors/test_flavors_negative_xml.py
+++ b/tempest/api/compute/flavors/test_flavors_negative_xml.py
@@ -24,8 +24,8 @@
_interface = 'xml'
@classmethod
- def setUpClass(cls):
- super(FlavorsNegativeTestXML, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsNegativeTestXML, cls).resource_setup()
cls.client = cls.flavors_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py
index fd76e62..19b6a50 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 setUpClass(cls):
+ def resource_setup(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).setUpClass()
+ super(BaseFloatingIPsTest, cls).resource_setup()
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 1eae66f..ba66ab9 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -24,9 +24,8 @@
floating_ip = None
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(FloatingIPsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPsTestJSON, cls).resource_setup()
cls.client = cls.floating_ips_client
cls.floating_ip_id = None
@@ -39,11 +38,11 @@
cls.floating_ip = body['ip']
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
# Deleting the floating IP which is created in this method
if cls.floating_ip_id:
resp, body = cls.client.delete_floating_ip(cls.floating_ip_id)
- super(FloatingIPsTestJSON, cls).tearDownClass()
+ super(FloatingIPsTestJSON, cls).resource_cleanup()
def _try_delete_floating_ip(self, floating_ip_id):
# delete floating ip, if it exists
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 042a19a..104d130 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
@@ -28,8 +28,8 @@
server_id = None
@classmethod
- def setUpClass(cls):
- super(FloatingIPsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPsNegativeTestJSON, cls).resource_setup()
cls.client = cls.floating_ips_client
# Server creation
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 a6878d9..cb93177 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -20,8 +20,8 @@
class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(FloatingIPDetailsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPDetailsTestJSON, cls).resource_setup()
cls.client = cls.floating_ips_client
cls.floating_ip = []
cls.floating_ip_id = []
@@ -31,10 +31,10 @@
cls.floating_ip_id.append(body['id'])
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for i in range(3):
cls.client.delete_floating_ip(cls.floating_ip_id[i])
- super(FloatingIPDetailsTestJSON, cls).tearDownClass()
+ super(FloatingIPDetailsTestJSON, cls).resource_cleanup()
@test.attr(type='gate')
@test.services('network')
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 b11ef5b..08819c2 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
@@ -27,8 +27,8 @@
class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(FloatingIPDetailsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPDetailsNegativeTestJSON, cls).resource_setup()
cls.client = cls.floating_ips_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 9036726..1fa591f 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -26,9 +26,8 @@
class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ImagesMetadataTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesMetadataTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 15bb66a..7f0bc4e 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -22,8 +22,8 @@
class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ImagesMetadataTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesMetadataTestJSON, cls).resource_setup()
cls.client = cls.images_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index bbb887f..68f793a 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -23,8 +23,8 @@
class ImagesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ImagesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/images/test_images_negative.py b/tempest/api/compute/images/test_images_negative.py
index 771040b..e406374 100644
--- a/tempest/api/compute/images/test_images_negative.py
+++ b/tempest/api/compute/images/test_images_negative.py
@@ -24,8 +24,8 @@
class ImagesNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ImagesNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesNegativeTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 1c5d4a3..c0b6730 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -47,9 +47,8 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ImagesOneServerTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesOneServerTestJSON, cls).resource_setup()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index 51d9b85..dc3d6bc 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -55,9 +55,8 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ImagesOneServerNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesOneServerNegativeTestJSON, cls).resource_setup()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
@@ -73,19 +72,6 @@
cls.image_ids = []
- @test.skip_because(bug="1006725")
- @test.attr(type=['negative', 'gate'])
- def test_create_image_specify_multibyte_character_image_name(self):
- if self.__class__._interface == "xml":
- raise self.skipException("Not testable in XML")
- # invalid multibyte sequence from:
- # http://stackoverflow.com/questions/1301402/
- # example-invalid-utf8-string
- invalid_name = data_utils.rand_name(u'\xc3\x28')
- self.assertRaises(exceptions.BadRequest,
- self.client.create_image, self.server_id,
- invalid_name)
-
@test.attr(type=['negative', 'gate'])
def test_create_image_specify_invalid_metadata(self):
# Return an error when creating image with invalid metadata
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 9f1cfc8..30a99dd 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -32,9 +32,8 @@
class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ListImageFiltersTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListImageFiltersTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/images/test_list_image_filters_negative.py b/tempest/api/compute/images/test_list_image_filters_negative.py
index 80d59a7..53a21a0 100644
--- a/tempest/api/compute/images/test_list_image_filters_negative.py
+++ b/tempest/api/compute/images/test_list_image_filters_negative.py
@@ -24,8 +24,8 @@
class ListImageFiltersNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ListImageFiltersNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListImageFiltersNegativeTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index eba331f..eceac82 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -23,8 +23,8 @@
class ListImagesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ListImagesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListImagesTestJSON, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index 01979c0..2f0febf 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -23,8 +23,8 @@
_api_version = 3
@classmethod
- def setUpClass(cls):
- super(KeyPairsV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(KeyPairsV3Test, cls).resource_setup()
cls.client = cls.keypairs_client
def _delete_keypair(self, keypair_name):
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index a91a9c2..0da449b 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -23,8 +23,8 @@
class KeyPairsNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(KeyPairsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(KeyPairsNegativeTestJSON, cls).resource_setup()
cls.client = cls.keypairs_client
def _create_keypair(self, keypair_name, pub_key=None):
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index d64fd57..bac1a39 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -20,8 +20,8 @@
class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(AbsoluteLimitsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AbsoluteLimitsTestJSON, cls).resource_setup()
cls.client = cls.limits_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
index b2e2981..2b41ea0 100644
--- a/tempest/api/compute/limits/test_absolute_limits_negative.py
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -21,8 +21,8 @@
class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(AbsoluteLimitsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AbsoluteLimitsNegativeTestJSON, cls).resource_setup()
cls.client = cls.limits_client
cls.server_client = cls.servers_client
diff --git a/tempest/api/compute/security_groups/base.py b/tempest/api/compute/security_groups/base.py
index 6838ce1..05cad9a 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 setUpClass(cls):
+ def resource_setup(cls):
# A network and a subnet will be created for these tests
cls.set_network_resources(network=True, subnet=True)
- super(BaseSecurityGroupsTest, cls).setUpClass()
+ super(BaseSecurityGroupsTest, cls).resource_setup()
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 a1808dc..b28124c 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -23,8 +23,8 @@
class SecurityGroupRulesTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def setUpClass(cls):
- super(SecurityGroupRulesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecurityGroupRulesTestJSON, cls).resource_setup()
cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
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 cfa839a..7850909 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
@@ -32,8 +32,8 @@
class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def setUpClass(cls):
- super(SecurityGroupRulesNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecurityGroupRulesNegativeTestJSON, cls).resource_setup()
cls.client = cls.security_groups_client
@test.attr(type=['negative', 'smoke'])
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 860aebc..82dd4f0 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -22,8 +22,8 @@
class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def setUpClass(cls):
- super(SecurityGroupsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecurityGroupsTestJSON, cls).resource_setup()
cls.client = cls.security_groups_client
@test.attr(type='smoke')
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 a9cca55..3101052 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -27,8 +27,8 @@
class SecurityGroupsNegativeTestJSON(base.BaseSecurityGroupsTest):
@classmethod
- def setUpClass(cls):
- super(SecurityGroupsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecurityGroupsNegativeTestJSON, cls).resource_setup()
cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index d1192c0..d62d19f 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -26,14 +26,14 @@
class AttachInterfacesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
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.")
# This test class requires network and subnet
cls.set_network_resources(network=True, subnet=True)
- super(AttachInterfacesTestJSON, cls).setUpClass()
+ super(AttachInterfacesTestJSON, cls).resource_setup()
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 cf9837f..44bd7d3 100644
--- a/tempest/api/compute/servers/test_availability_zone.py
+++ b/tempest/api/compute/servers/test_availability_zone.py
@@ -24,8 +24,8 @@
_api_version = 3
@classmethod
- def setUpClass(cls):
- super(AZV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AZV3Test, cls).resource_setup()
cls.client = cls.availability_zone_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 279dc51..5df8d82 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -31,9 +31,9 @@
disk_config = 'AUTO'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServersTestJSON, cls).setUpClass()
+ super(ServersTestJSON, cls).resource_setup()
cls.meta = {'hello': 'world'}
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
@@ -129,9 +129,9 @@
disk_config = 'AUTO'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServersWithSpecificFlavorTestJSON, cls).setUpClass()
+ super(ServersWithSpecificFlavorTestJSON, cls).resource_setup()
cls.flavor_client = cls.os_adm.flavors_client
cls.client = cls.servers_client
@@ -214,11 +214,11 @@
disk_config = 'MANUAL'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
- super(ServersTestManualDisk, cls).setUpClass()
+ super(ServersTestManualDisk, cls).resource_setup()
class ServersTestXML(ServersTestJSON):
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 9c8271f..6a5da58 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -28,8 +28,8 @@
# for preventing "Quota exceeded for instances"
@classmethod
- def setUpClass(cls):
- super(DeleteServersTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(DeleteServersTestJSON, cls).resource_setup()
cls.client = cls.servers_client
@test.attr(type='gate')
@@ -70,6 +70,18 @@
self.assertEqual('204', resp['status'])
self.client.wait_for_server_termination(server['id'])
+ @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
+ 'Suspend is not available.')
+ @test.attr(type='gate')
+ def test_delete_server_while_in_suspended_state(self):
+ # Delete a server while it's VM state is Suspended
+ _, server = self.create_test_server(wait_until='ACTIVE')
+ self.client.suspend_server(server['id'])
+ self.client.wait_for_server_status(server['id'], 'SUSPENDED')
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_server_termination(server['id'])
+
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
'Shelve is not available.')
@test.attr(type='gate')
@@ -130,8 +142,8 @@
# for preventing "Quota exceeded for instances".
@classmethod
- def setUpClass(cls):
- super(DeleteServersAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(DeleteServersAdminTestJSON, cls).resource_setup()
cls.non_admin_client = cls.servers_client
cls.admin_client = cls.os_adm.servers_client
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 332358c..51f2eb4 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -25,11 +25,11 @@
class ServerDiskConfigTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
- super(ServerDiskConfigTestJSON, cls).setUpClass()
+ super(ServerDiskConfigTestJSON, cls).resource_setup()
cls.client = cls.os.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index dd31165..d11ce25 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -20,8 +20,8 @@
class InstanceActionsTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(InstanceActionsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceActionsTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.request_id = resp['x-compute-request-id']
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
index e67b69d..c706ad5 100644
--- a/tempest/api/compute/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -22,8 +22,8 @@
class InstanceActionsNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(InstanceActionsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceActionsNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 5e9a2bf..98fe387 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -26,10 +26,9 @@
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources(network=True, subnet=True, dhcp=True)
- super(ListServerFiltersTestJSON, cls).setUpClass()
+ super(ListServerFiltersTestJSON, cls).resource_setup()
cls.client = cls.servers_client
# Check to see if the alternate image ref actually exists...
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 28d64fb..f4d8dda 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -24,9 +24,8 @@
force_tenant_isolation = True
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ListServersNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListServersNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
# The following servers are created for use
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index fd6df3e..071bbfb 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -52,9 +52,9 @@
super(ServerActionsTestJSON, self).tearDown()
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServerActionsTestJSON, cls).setUpClass()
+ super(ServerActionsTestJSON, cls).resource_setup()
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 846bf3e..6c29f51 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -23,10 +23,10 @@
class ServerAddressesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# This test module might use a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesTestJSON, cls).setUpClass()
+ super(ServerAddressesTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
index e190161..c7e4c89 100644
--- a/tempest/api/compute/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -21,9 +21,9 @@
class ServerAddressesNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesNegativeTestJSON, cls).setUpClass()
+ super(ServerAddressesNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
diff --git a/tempest/api/compute/servers/test_server_group.py b/tempest/api/compute/servers/test_server_group.py
index f1ef5d5..0af19c0 100644
--- a/tempest/api/compute/servers/test_server_group.py
+++ b/tempest/api/compute/servers/test_server_group.py
@@ -26,9 +26,8 @@
It also adds the tests for list and get details of server-groups
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ServerGroupTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerGroupTestJSON, cls).resource_setup()
if not test.is_extension_enabled('os-server-groups', 'compute'):
msg = "os-server-groups extension is not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/compute/servers/test_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index 01ff6b9..c265352 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -20,8 +20,8 @@
class ServerMetadataTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerMetadataTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerMetadataTestJSON, cls).resource_setup()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py
index fbda401..497b94b 100644
--- a/tempest/api/compute/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/servers/test_server_metadata_negative.py
@@ -22,8 +22,8 @@
class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerMetadataNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerMetadataNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
cls.tenant_id = cls.client.tenant_id
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index 50c881a..aba9bb6 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -21,8 +21,8 @@
class ServerPasswordTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerPasswordTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerPasswordTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index 6cc463d..effb52f 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -23,8 +23,8 @@
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerPersonalityTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerPersonalityTestJSON, cls).resource_setup()
cls.client = cls.servers_client
cls.user_client = cls.limits_client
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index b737888..a984ade 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -24,14 +24,13 @@
class ServerRescueTestJSON(base.BaseV2ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
cls.set_network_resources(network=True, subnet=True, router=True)
- super(ServerRescueTestJSON, cls).setUpClass()
+ super(ServerRescueTestJSON, cls).resource_setup()
# Floating IP creation
resp, body = cls.floating_ips_client.create_floating_ip()
@@ -62,13 +61,14 @@
super(ServerRescueTestJSON, self).setUp()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
# Deleting the floating IP which is created in this method
cls.floating_ips_client.delete_floating_ip(cls.floating_ip_id)
- cls.delete_volume(cls.volume['id'])
+ if getattr(cls, 'volume', None):
+ cls.delete_volume(cls.volume['id'])
resp, cls.sg = cls.security_groups_client.delete_security_group(
cls.sg_id)
- super(ServerRescueTestJSON, cls).tearDownClass()
+ super(ServerRescueTestJSON, cls).resource_cleanup()
def tearDown(self):
super(ServerRescueTestJSON, self).tearDown()
diff --git a/tempest/api/compute/servers/test_server_rescue_negative.py b/tempest/api/compute/servers/test_server_rescue_negative.py
index 4582a46..0d29968 100644
--- a/tempest/api/compute/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/servers/test_server_rescue_negative.py
@@ -26,14 +26,13 @@
class ServerRescueNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
cls.set_network_resources(network=True, subnet=True, router=True)
- super(ServerRescueNegativeTestJSON, cls).setUpClass()
+ super(ServerRescueNegativeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
# Create a volume and wait for it to become ready for attach
@@ -56,9 +55,10 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
@classmethod
- def tearDownClass(cls):
- cls.delete_volume(cls.volume['id'])
- super(ServerRescueNegativeTestJSON, cls).tearDownClass()
+ def resource_cleanup(cls):
+ if getattr(cls, 'volume', None):
+ cls.delete_volume(cls.volume['id'])
+ super(ServerRescueNegativeTestJSON, cls).resource_cleanup()
def _detach(self, server_id, volume_id):
self.servers_client.detach_volume(server_id, volume_id)
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index 936b871..d501839 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -21,8 +21,8 @@
class ServersTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServersTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersTestJSON, cls).resource_setup()
cls.client = cls.servers_client
def tearDown(self):
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index b9ec29e..b86ee06 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -42,8 +42,8 @@
super(ServersNegativeTestJSON, self).tearDown()
@classmethod
- def setUpClass(cls):
- super(ServersNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersNegativeTestJSON, cls).resource_setup()
cls.client = cls.servers_client
if CONF.compute.allow_tenant_isolation:
cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
diff --git a/tempest/api/compute/servers/test_servers_negative_new.py b/tempest/api/compute/servers/test_servers_negative_new.py
index c5f9fdd..7fc2d4f 100644
--- a/tempest/api/compute/servers/test_servers_negative_new.py
+++ b/tempest/api/compute/servers/test_servers_negative_new.py
@@ -29,7 +29,7 @@
_schema = servers.get_console_output
@classmethod
- def setUpClass(cls):
- super(GetConsoleOutputNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(GetConsoleOutputNegativeTestJSON, cls).resource_setup()
_resp, server = cls.create_test_server()
cls.set_resource("server", server['id'])
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 421ba8b..f205761 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -25,10 +25,10 @@
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# This test needs a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(VirtualInterfacesTestJSON, cls).setUpClass()
+ super(VirtualInterfacesTestJSON, cls).resource_setup()
cls.client = cls.servers_client
resp, 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 bcb2686..1f4a20e 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces_negative.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -23,10 +23,10 @@
class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# For this test no network resources are needed
cls.set_network_resources()
- super(VirtualInterfacesNegativeTestJSON, cls).setUpClass()
+ super(VirtualInterfacesNegativeTestJSON, cls).resource_setup()
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 3fa4a89..015d9f5 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -30,12 +30,12 @@
class AuthorizationTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.service_available.glance:
raise cls.skipException('Glance is not available.')
# No network resources required for this test
cls.set_network_resources()
- super(AuthorizationTestJSON, cls).setUpClass()
+ super(AuthorizationTestJSON, cls).resource_setup()
if not cls.multi_user:
msg = "Need >1 user"
raise cls.skipException(msg)
@@ -88,12 +88,12 @@
parent_group_id, ip_protocol, from_port, to_port)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if cls.multi_user:
cls.images_client.delete_image(cls.image['id'])
cls.keypairs_client.delete_keypair(cls.keypairname)
cls.security_client.delete_security_group(cls.security_group['id'])
- super(AuthorizationTestJSON, cls).tearDownClass()
+ super(AuthorizationTestJSON, cls).resource_cleanup()
@test.attr(type='gate')
def test_get_server_for_alt_account_fails(self):
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index 93ff4b0..86b8395 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -27,8 +27,8 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
- def setUpClass(cls):
- super(LiveBlockMigrationTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(LiveBlockMigrationTestJSON, cls).resource_setup()
cls.admin_hosts_client = cls.os_adm.hosts_client
cls.admin_servers_client = cls.os_adm.servers_client
diff --git a/tempest/api/compute/test_live_block_migration_negative.py b/tempest/api/compute/test_live_block_migration_negative.py
index c10818e..95eea19 100644
--- a/tempest/api/compute/test_live_block_migration_negative.py
+++ b/tempest/api/compute/test_live_block_migration_negative.py
@@ -27,8 +27,8 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
@classmethod
- def setUpClass(cls):
- super(LiveBlockMigrationNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(LiveBlockMigrationNegativeTestJSON, cls).resource_setup()
if not CONF.compute_feature_enabled.live_migration:
raise cls.skipException("Live migration is not enabled")
cls.admin_hosts_client = cls.os_adm.hosts_client
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index eeff3ce..e66b652 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -26,8 +26,8 @@
super(QuotasTestJSON, self).setUp()
@classmethod
- def setUpClass(cls):
- super(QuotasTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasTestJSON, cls).resource_setup()
cls.client = cls.quotas_client
cls.tenant_id = cls.client.tenant_id
cls.user_id = cls.client.user_id
@@ -45,17 +45,17 @@
expected_quota_set = self.default_quota_set | set(['id'])
resp, quota_set = self.client.get_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
+ for quota in expected_quota_set:
+ self.assertIn(quota, quota_set.keys())
# get the quota set using user id
resp, quota_set = self.client.get_quota_set(self.tenant_id,
self.user_id)
self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
+ for quota in expected_quota_set:
+ self.assertIn(quota, quota_set.keys())
@test.attr(type='smoke')
def test_get_default_quotas(self):
@@ -63,9 +63,9 @@
expected_quota_set = self.default_quota_set | set(['id'])
resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
self.assertEqual(200, resp.status)
- self.assertEqual(sorted(expected_quota_set),
- sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
+ for quota in expected_quota_set:
+ self.assertIn(quota, quota_set.keys())
@test.attr(type='smoke')
def test_compare_tenant_quotas_with_default_quotas(self):
diff --git a/tempest/api/compute/v3/admin/test_agents.py b/tempest/api/compute/v3/admin/test_agents.py
index 9d01b71..b7c0011 100644
--- a/tempest/api/compute/v3/admin/test_agents.py
+++ b/tempest/api/compute/v3/admin/test_agents.py
@@ -23,8 +23,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AgentsAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AgentsAdminV3Test, cls).resource_setup()
cls.client = cls.agents_admin_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
index 886b6a7..1beeb13 100644
--- a/tempest/api/compute/v3/admin/test_aggregates.py
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -28,8 +28,8 @@
_host_key = 'os-extended-server-attributes:host'
@classmethod
- def setUpClass(cls):
- super(AggregatesAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AggregatesAdminV3Test, cls).resource_setup()
cls.client = cls.aggregates_admin_client
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
index 1505f74..093963f 100644
--- a/tempest/api/compute/v3/admin/test_aggregates_negative.py
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -27,8 +27,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AggregatesAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AggregatesAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.aggregates_admin_client
cls.user_client = cls.aggregates_client
cls.aggregate_name_prefix = 'test_aggregate_'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
index b012e65..56cdd6c 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone_negative.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
@@ -25,8 +25,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(AZAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(AZAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.availability_zone_admin_client
cls.non_adm_client = cls.availability_zone_client
diff --git a/tempest/api/compute/v3/admin/test_flavors.py b/tempest/api/compute/v3/admin/test_flavors.py
index 09d76b8..f307907 100644
--- a/tempest/api/compute/v3/admin/test_flavors.py
+++ b/tempest/api/compute/v3/admin/test_flavors.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAdminV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
cls.user_client = cls.flavors_client
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 09b6ebd..c79e591 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -26,8 +26,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAccessV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAccessV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
admin_client = cls._get_identity_admin_client()
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
index 0fdfabd..87e8cbf 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -29,8 +29,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAccessNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAccessNegativeV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
cls.tenant_id = cls.client.tenant_id
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
index 29cd8db..24844b1 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -27,8 +27,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsExtraSpecsV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
@@ -48,10 +48,10 @@
swap=swap, rxtx=rxtx)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsV3Test, cls).tearDownClass()
+ super(FlavorsExtraSpecsV3Test, cls).resource_cleanup()
@test.attr(type='gate')
def test_flavor_set_get_update_show_unset_keys(self):
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
index e9c04a3..5fcd7a4 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsExtraSpecsNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsExtraSpecsNegativeV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
@@ -49,10 +49,10 @@
swap=swap, rxtx=rxtx)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsNegativeV3Test, cls).tearDownClass()
+ super(FlavorsExtraSpecsNegativeV3Test, cls).resource_cleanup()
@test.attr(type=['negative', 'gate'])
def test_flavor_non_admin_set_keys(self):
diff --git a/tempest/api/compute/v3/admin/test_flavors_negative.py b/tempest/api/compute/v3/admin/test_flavors_negative.py
index 6d3308e..426d13e 100644
--- a/tempest/api/compute/v3/admin/test_flavors_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_negative.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FlavorsAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorsAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.flavors_admin_client
cls.user_client = cls.flavors_client
diff --git a/tempest/api/compute/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
index 8cb1f23..898a704 100644
--- a/tempest/api/compute/v3/admin/test_hosts.py
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HostsAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(HostsAdminV3Test, cls).resource_setup()
cls.client = cls.hosts_admin_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
index 79cd97f..2b82baa 100644
--- a/tempest/api/compute/v3/admin/test_hosts_negative.py
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -25,8 +25,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HostsAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(HostsAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.hosts_admin_client
cls.non_admin_client = cls.hosts_client
diff --git a/tempest/api/compute/v3/admin/test_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
index 9a23789..831e20f 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor.py
@@ -24,8 +24,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HypervisorAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(HypervisorAdminV3Test, cls).resource_setup()
cls.client = cls.hypervisor_admin_client
def _list_hypervisors(self):
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
index ae4df15..df23b46 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
@@ -28,8 +28,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(HypervisorAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(HypervisorAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.hypervisor_admin_client
cls.non_adm_client = cls.hypervisor_client
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index 19c31fe..3dad45c 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -25,8 +25,8 @@
force_tenant_isolation = True
@classmethod
- def setUpClass(cls):
- super(QuotasAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasAdminV3Test, cls).resource_setup()
cls.client = cls.quotas_client
cls.adm_client = cls.quotas_admin_client
diff --git a/tempest/api/compute/v3/admin/test_quotas_negative.py b/tempest/api/compute/v3/admin/test_quotas_negative.py
index 7739f09..86abcab 100644
--- a/tempest/api/compute/v3/admin/test_quotas_negative.py
+++ b/tempest/api/compute/v3/admin/test_quotas_negative.py
@@ -23,8 +23,8 @@
force_tenant_isolation = True
@classmethod
- def setUpClass(cls):
- super(QuotasAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.quotas_client
cls.adm_client = cls.quotas_admin_client
@@ -34,7 +34,6 @@
# TODO(afazekas): Add dedicated tenant to the skiped quota tests
# it can be moved into the setUpClass as well
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
@@ -48,9 +47,9 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
cores=default_vcpu_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
@@ -64,7 +63,8 @@
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
ram=default_mem_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
@test.attr(type=['negative', 'gate'])
def test_update_quota_normal_user(self):
@@ -73,7 +73,6 @@
self.demo_tenant_id,
ram=0)
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
@@ -86,4 +85,5 @@
instances=instances_quota)
self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id,
instances=default_instances_quota)
- self.assertRaises(exceptions.Unauthorized, self.create_test_server)
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
+ self.create_test_server)
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
index d99c329..36ea7ba 100644
--- a/tempest/api/compute/v3/admin/test_servers.py
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -26,9 +26,8 @@
_host_key = 'os-extended-server-attributes:host'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ServersAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersAdminV3Test, cls).resource_setup()
cls.client = cls.servers_admin_client
cls.non_admin_client = cls.servers_client
cls.flavors_client = cls.flavors_admin_client
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
index 5eb6395..f561ed3 100644
--- a/tempest/api/compute/v3/admin/test_servers_negative.py
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -17,6 +17,7 @@
import testtools
from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -32,8 +33,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServersAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.servers_admin_client
cls.non_adm_client = cls.servers_client
cls.flavors_client = cls.flavors_admin_client
@@ -54,9 +55,10 @@
flavor_id = data_utils.rand_int_id(start=1000)
return flavor_id
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_ram(self):
+ # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
+ self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
resp, quota_set = self.quotas_client.get_default_quota_set(
@@ -68,14 +70,15 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
- @test.skip_because(bug="1298131")
@test.attr(type=['negative', 'gate'])
def test_resize_server_using_overlimit_vcpus(self):
+ # NOTE(mriedem): Avoid conflicts with os-quota-class-sets tests.
+ self.useFixture(fixtures.LockFixture('compute_quotas'))
flavor_name = data_utils.rand_name("flavor-")
flavor_id = self._get_unused_flavor_id()
ram = 512
@@ -87,7 +90,7 @@
ram, vcpus, disk,
flavor_id)
self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
- self.assertRaises(exceptions.Unauthorized,
+ self.assertRaises((exceptions.Unauthorized, exceptions.OverLimit),
self.client.resize,
self.servers[0]['id'],
flavor_ref['id'])
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index e6efb70..f1c3b9a 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -25,8 +25,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServicesAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServicesAdminV3Test, cls).resource_setup()
cls.client = cls.services_admin_client
@test.attr(type='gate')
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
index 6ac78d4..1f9f2b1 100644
--- a/tempest/api/compute/v3/admin/test_services_negative.py
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -26,8 +26,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ServicesAdminNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServicesAdminNegativeV3Test, cls).resource_setup()
cls.client = cls.services_admin_client
cls.non_admin_client = cls.services_client
diff --git a/tempest/api/compute/v3/flavors/test_flavors_negative.py b/tempest/api/compute/v3/flavors/test_flavors_negative.py
index cdf018f..2dd7b71 100644
--- a/tempest/api/compute/v3/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/v3/flavors/test_flavors_negative.py
@@ -35,6 +35,6 @@
_schema = flavors.flavors_details
@classmethod
- def setUpClass(cls):
- super(FlavorDetailsNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(FlavorDetailsNegativeV3Test, cls).resource_setup()
cls.set_resource("flavor", cls.flavor_ref)
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index bb81626..a234a22 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -23,8 +23,8 @@
class ImagesV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ImagesV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesV3Test, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/v3/images/test_images_negative.py b/tempest/api/compute/v3/images/test_images_negative.py
index 0705bdc..83e9436 100644
--- a/tempest/api/compute/v3/images/test_images_negative.py
+++ b/tempest/api/compute/v3/images/test_images_negative.py
@@ -24,8 +24,8 @@
class ImagesNegativeV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ImagesNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesNegativeV3Test, cls).resource_setup()
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
index edf91a7..87e730c 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -47,9 +47,8 @@
super(ImagesOneServerV3Test, self).tearDown()
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ImagesOneServerV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesOneServerV3Test, cls).resource_setup()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
index 544a5a5..5892cd7 100644
--- a/tempest/api/compute/v3/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -55,9 +55,8 @@
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ImagesOneServerNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ImagesOneServerNegativeV3Test, cls).resource_setup()
cls.client = cls.images_client
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
index e426b85..1f7206a 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -23,8 +23,8 @@
class KeyPairsNegativeV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(KeyPairsNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(KeyPairsNegativeV3Test, cls).resource_setup()
cls.client = cls.keypairs_client
def _create_keypair(self, keypair_name, pub_key=None):
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
index c2cf7e0..d4d4fca 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -26,14 +26,14 @@
class AttachInterfacesV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
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.")
# This test class requires network and subnet
cls.set_network_resources(network=True, subnet=True)
- super(AttachInterfacesV3Test, cls).setUpClass()
+ super(AttachInterfacesV3Test, cls).resource_setup()
cls.client = cls.interfaces_client
def _check_interface(self, iface, port_id=None, network_id=None,
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
index e994c7f..76b5549 100644
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -32,9 +32,9 @@
self.attached = False
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(AttachVolumeV3Test, cls).setUpClass()
+ super(AttachVolumeV3Test, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
if not CONF.service_available.cinder:
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index c59fe91..bcd6176 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -31,9 +31,9 @@
disk_config = 'AUTO'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServersV3Test, cls).setUpClass()
+ super(ServersV3Test, cls).resource_setup()
cls.meta = {'hello': 'world'}
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
@@ -108,9 +108,9 @@
disk_config = 'AUTO'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServersWithSpecificFlavorV3Test, cls).setUpClass()
+ super(ServersWithSpecificFlavorV3Test, cls).resource_setup()
cls.client = cls.servers_client
cls.flavor_client = cls.flavors_admin_client
@@ -192,8 +192,8 @@
disk_config = 'MANUAL'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
- super(ServersV3TestManualDisk, cls).setUpClass()
+ super(ServersV3TestManualDisk, cls).resource_setup()
diff --git a/tempest/api/compute/v3/servers/test_delete_server.py b/tempest/api/compute/v3/servers/test_delete_server.py
index e2b47ee..ab10b4c 100644
--- a/tempest/api/compute/v3/servers/test_delete_server.py
+++ b/tempest/api/compute/v3/servers/test_delete_server.py
@@ -26,8 +26,8 @@
# for preventing "Quota exceeded for instances".
@classmethod
- def setUpClass(cls):
- super(DeleteServersV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(DeleteServersV3Test, cls).resource_setup()
cls.client = cls.servers_client
@test.attr(type='gate')
@@ -128,8 +128,8 @@
# for preventing "Quota exceeded for instances".
@classmethod
- def setUpClass(cls):
- super(DeleteServersAdminV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(DeleteServersAdminV3Test, cls).resource_setup()
cls.non_admin_client = cls.servers_client
cls.admin_client = cls.servers_admin_client
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
index 4c2dcbe..227f6cd 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions.py
@@ -20,8 +20,8 @@
class InstanceActionsV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(InstanceActionsV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceActionsV3Test, cls).resource_setup()
cls.client = cls.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.resp = resp
diff --git a/tempest/api/compute/v3/servers/test_instance_actions_negative.py b/tempest/api/compute/v3/servers/test_instance_actions_negative.py
index 0b2c6f9..b9d4be2 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions_negative.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions_negative.py
@@ -22,8 +22,8 @@
class InstanceActionsNegativeV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(InstanceActionsNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(InstanceActionsNegativeV3Test, cls).resource_setup()
cls.client = cls.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index 778b033..209d293 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -26,10 +26,9 @@
class ListServerFiltersV3Test(base.BaseV3ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources(network=True, subnet=True, dhcp=True)
- super(ListServerFiltersV3Test, cls).setUpClass()
+ super(ListServerFiltersV3Test, cls).resource_setup()
cls.client = cls.servers_client
# Check to see if the alternate image ref actually exists...
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
index 18e5c67..67e1155 100644
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_list_servers_negative.py
@@ -26,9 +26,8 @@
force_tenant_isolation = True
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ListServersNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListServersNegativeV3Test, cls).resource_setup()
cls.client = cls.servers_client
# The following servers are created for use
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index 538507f..a4e8dba 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -51,9 +51,9 @@
super(ServerActionsV3Test, self).tearDown()
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(ServerActionsV3Test, cls).setUpClass()
+ super(ServerActionsV3Test, cls).resource_setup()
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index efd7500..0590146 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -23,10 +23,10 @@
class ServerAddressesV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# This test module might use a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesV3Test, cls).setUpClass()
+ super(ServerAddressesV3Test, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
diff --git a/tempest/api/compute/v3/servers/test_server_addresses_negative.py b/tempest/api/compute/v3/servers/test_server_addresses_negative.py
index 8a9877b..7a1b6fc 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses_negative.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses_negative.py
@@ -23,10 +23,10 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# This test module might use a network and a subnet
cls.set_network_resources(network=True, subnet=True)
- super(ServerAddressesV3NegativeTest, cls).setUpClass()
+ super(ServerAddressesV3NegativeTest, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
index c5443ee..ccdfbad 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata.py
@@ -20,8 +20,8 @@
class ServerMetadataV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerMetadataV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerMetadataV3Test, cls).resource_setup()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
resp, server = cls.create_test_server(meta={}, wait_until='ACTIVE')
diff --git a/tempest/api/compute/v3/servers/test_server_metadata_negative.py b/tempest/api/compute/v3/servers/test_server_metadata_negative.py
index f746be3..036b126 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata_negative.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata_negative.py
@@ -21,8 +21,8 @@
class ServerMetadataV3NegativeTest(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerMetadataV3NegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerMetadataV3NegativeTest, cls).resource_setup()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
cls.tenant_id = cls.client.tenant_id
diff --git a/tempest/api/compute/v3/servers/test_server_password.py b/tempest/api/compute/v3/servers/test_server_password.py
index fc0b145..bb0e310 100644
--- a/tempest/api/compute/v3/servers/test_server_password.py
+++ b/tempest/api/compute/v3/servers/test_server_password.py
@@ -21,8 +21,8 @@
class ServerPasswordV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServerPasswordV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServerPasswordV3Test, cls).resource_setup()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until="ACTIVE")
diff --git a/tempest/api/compute/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
index da58f26..ae21a7e 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue.py
@@ -23,11 +23,11 @@
class ServerRescueV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
- super(ServerRescueV3Test, cls).setUpClass()
+ super(ServerRescueV3Test, cls).resource_setup()
# Server for positive tests
resp, server = cls.create_test_server(wait_until='BUILD')
diff --git a/tempest/api/compute/v3/servers/test_server_rescue_negative.py b/tempest/api/compute/v3/servers/test_server_rescue_negative.py
index 6d192a3..db26298 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue_negative.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue_negative.py
@@ -26,13 +26,12 @@
class ServerRescueNegativeV3Test(base.BaseV3ComputeTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.compute_feature_enabled.rescue:
msg = "Server rescue not available."
raise cls.skipException(msg)
- super(ServerRescueNegativeV3Test, cls).setUpClass()
+ super(ServerRescueNegativeV3Test, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
# Create a volume and wait for it to become ready for attach
@@ -55,10 +54,10 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if hasattr(cls, 'volume'):
cls.delete_volume(cls.volume['id'])
- super(ServerRescueNegativeV3Test, cls).tearDownClass()
+ super(ServerRescueNegativeV3Test, cls).resource_cleanup()
def _detach(self, server_id, volume_id):
self.servers_client.detach_volume(server_id, volume_id)
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index 426ee8d..e09f4a8 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -21,8 +21,8 @@
class ServersV3Test(base.BaseV3ComputeTest):
@classmethod
- def setUpClass(cls):
- super(ServersV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersV3Test, cls).resource_setup()
cls.client = cls.servers_client
def tearDown(self):
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index f8ff7c8..30ac0ac 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -42,8 +42,8 @@
super(ServersNegativeV3Test, self).tearDown()
@classmethod
- def setUpClass(cls):
- super(ServersNegativeV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServersNegativeV3Test, cls).resource_setup()
cls.client = cls.servers_client
if CONF.compute.allow_tenant_isolation:
cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
index 6ca37e6..d6231b7 100644
--- a/tempest/api/compute/v3/test_live_block_migration.py
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -26,8 +26,8 @@
_host_key = 'os-extended-server-attributes:host'
@classmethod
- def setUpClass(cls):
- super(LiveBlockMigrationV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(LiveBlockMigrationV3Test, cls).resource_setup()
cls.admin_hosts_client = cls.hosts_admin_client
cls.admin_servers_client = cls.servers_admin_client
diff --git a/tempest/api/compute/v3/test_live_block_migration_negative.py b/tempest/api/compute/v3/test_live_block_migration_negative.py
index b4ec505..93127f3 100644
--- a/tempest/api/compute/v3/test_live_block_migration_negative.py
+++ b/tempest/api/compute/v3/test_live_block_migration_negative.py
@@ -27,8 +27,8 @@
_host_key = 'os-extended-server-attributes:host'
@classmethod
- def setUpClass(cls):
- super(LiveBlockMigrationV3NegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(LiveBlockMigrationV3NegativeTest, cls).resource_setup()
if not CONF.compute_feature_enabled.live_migration:
raise cls.skipException("Live migration is not enabled")
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
index ecf70cf..f6d8b3f 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -26,8 +26,8 @@
super(QuotasV3Test, self).setUp()
@classmethod
- def setUpClass(cls):
- super(QuotasV3Test, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasV3Test, cls).resource_setup()
cls.client = cls.quotas_client
cls.tenant_id = cls.client.tenant_id
cls.user_id = cls.client.user_id
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 5a64544..484c34d 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -32,9 +32,9 @@
self.attached = False
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.prepare_instance_network()
- super(AttachVolumeTestJSON, cls).setUpClass()
+ super(AttachVolumeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
if not CONF.service_available.cinder:
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index 708524c..4f77fa7 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -27,8 +27,8 @@
class VolumesGetTestJSON(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(VolumesGetTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(VolumesGetTestJSON, cls).resource_setup()
cls.client = cls.volumes_extensions_client
if not CONF.service_available.cinder:
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index 25a8547..dc54c67 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -32,8 +32,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(VolumesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(VolumesTestJSON, cls).resource_setup()
cls.client = cls.volumes_extensions_client
if not CONF.service_available.cinder:
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
@@ -69,11 +69,11 @@
raise
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
# Delete the created Volumes
for volume in cls.volume_list:
cls.delete_volume(volume['id'])
- super(VolumesTestJSON, cls).tearDownClass()
+ super(VolumesTestJSON, cls).resource_cleanup()
@test.attr(type='gate')
def test_volume_list(self):
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 5dfbad7..ad94ea7 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -27,8 +27,8 @@
class VolumesNegativeTest(base.BaseV2ComputeTest):
@classmethod
- def setUpClass(cls):
- super(VolumesNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(VolumesNegativeTest, cls).resource_setup()
cls.client = cls.volumes_extensions_client
if not CONF.service_available.cinder:
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
diff --git a/tempest/api/data_processing/base.py b/tempest/api/data_processing/base.py
index 65085b9..2ec1017 100644
--- a/tempest/api/data_processing/base.py
+++ b/tempest/api/data_processing/base.py
@@ -24,8 +24,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(BaseDataProcessingTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseDataProcessingTest, cls).resource_setup()
if not CONF.service_available.sahara:
raise cls.skipException('Sahara support is required')
@@ -43,7 +43,7 @@
cls._jobs = []
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.cleanup_resources(getattr(cls, '_cluster_templates', []),
cls.client.delete_cluster_template)
cls.cleanup_resources(getattr(cls, '_node_group_templates', []),
@@ -56,7 +56,7 @@
cls.cleanup_resources(getattr(cls, '_data_sources', []),
cls.client.delete_data_source)
cls.clear_isolated_creds()
- super(BaseDataProcessingTest, cls).tearDownClass()
+ super(BaseDataProcessingTest, cls).resource_cleanup()
@staticmethod
def cleanup_resources(resource_id_list, method):
diff --git a/tempest/api/data_processing/test_cluster_templates.py b/tempest/api/data_processing/test_cluster_templates.py
index ff67c1c..537f90c 100644
--- a/tempest/api/data_processing/test_cluster_templates.py
+++ b/tempest/api/data_processing/test_cluster_templates.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.0.html#cluster-templates
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ClusterTemplateTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ClusterTemplateTest, cls).resource_setup()
# create node group template
node_group_template = {
'name': data_utils.rand_name('sahara-ng-template'),
diff --git a/tempest/api/data_processing/test_data_sources.py b/tempest/api/data_processing/test_data_sources.py
index aae56c4..3650751 100644
--- a/tempest/api/data_processing/test_data_sources.py
+++ b/tempest/api/data_processing/test_data_sources.py
@@ -19,8 +19,8 @@
class DataSourceTest(dp_base.BaseDataProcessingTest):
@classmethod
- def setUpClass(cls):
- super(DataSourceTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DataSourceTest, cls).resource_setup()
cls.swift_data_source_with_creds = {
'url': 'swift://sahara-container.sahara/input-source',
'description': 'Test data source',
diff --git a/tempest/api/data_processing/test_job_binaries.py b/tempest/api/data_processing/test_job_binaries.py
index 15ee145..d006991 100644
--- a/tempest/api/data_processing/test_job_binaries.py
+++ b/tempest/api/data_processing/test_job_binaries.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#job-binaries
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(JobBinaryTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobBinaryTest, cls).resource_setup()
cls.swift_job_binary_with_extra = {
'url': 'swift://sahara-container.sahara/example.jar',
'description': 'Test job binary',
diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/tempest/api/data_processing/test_job_binary_internals.py
index 45e1140..7e99867 100644
--- a/tempest/api/data_processing/test_job_binary_internals.py
+++ b/tempest/api/data_processing/test_job_binary_internals.py
@@ -22,8 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#job-binary-internals
"""
@classmethod
- def setUpClass(cls):
- super(JobBinaryInternalTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobBinaryInternalTest, cls).resource_setup()
cls.job_binary_internal_data = 'Some script may be data'
def _create_job_binary_internal(self, binary_name=None):
diff --git a/tempest/api/data_processing/test_jobs.py b/tempest/api/data_processing/test_jobs.py
index 8591dbd..5af2eef 100644
--- a/tempest/api/data_processing/test_jobs.py
+++ b/tempest/api/data_processing/test_jobs.py
@@ -22,9 +22,8 @@
sahara/restapi/rest_api_v1.1_EDP.html#jobs
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(JobTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(JobTest, cls).resource_setup()
# create job binary
job_binary = {
'name': data_utils.rand_name('sahara-job-binary'),
diff --git a/tempest/api/data_processing/test_node_group_templates.py b/tempest/api/data_processing/test_node_group_templates.py
index c2c0075..f3f59fc 100644
--- a/tempest/api/data_processing/test_node_group_templates.py
+++ b/tempest/api/data_processing/test_node_group_templates.py
@@ -19,8 +19,8 @@
class NodeGroupTemplateTest(dp_base.BaseDataProcessingTest):
@classmethod
- def setUpClass(cls):
- super(NodeGroupTemplateTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(NodeGroupTemplateTest, cls).resource_setup()
cls.node_group_template = {
'description': 'Test node group template',
'plugin_name': 'vanilla',
diff --git a/tempest/api/database/base.py b/tempest/api/database/base.py
index 6e0f431..c9f16ca 100644
--- a/tempest/api/database/base.py
+++ b/tempest/api/database/base.py
@@ -27,8 +27,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(BaseDatabaseTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseDatabaseTest, cls).resource_setup()
if not CONF.service_available.trove:
skip_msg = ("%s skipped as trove is not available" % cls.__name__)
raise cls.skipException(skip_msg)
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index a5c8caa..aed1abe 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -20,8 +20,8 @@
class DatabaseFlavorsTest(base.BaseDatabaseTest):
@classmethod
- def setUpClass(cls):
- super(DatabaseFlavorsTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseFlavorsTest, cls).resource_setup()
cls.client = cls.database_flavors_client
@test.attr(type='smoke')
diff --git a/tempest/api/database/flavors/test_flavors_negative.py b/tempest/api/database/flavors/test_flavors_negative.py
index 202dc48..9f14cce 100644
--- a/tempest/api/database/flavors/test_flavors_negative.py
+++ b/tempest/api/database/flavors/test_flavors_negative.py
@@ -21,8 +21,8 @@
class DatabaseFlavorsNegativeTest(base.BaseDatabaseTest):
@classmethod
- def setUpClass(cls):
- super(DatabaseFlavorsNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseFlavorsNegativeTest, cls).resource_setup()
cls.client = cls.database_flavors_client
@test.attr(type=['negative', 'gate'])
diff --git a/tempest/api/database/versions/test_versions.py b/tempest/api/database/versions/test_versions.py
index 453abe7..80fcecf 100644
--- a/tempest/api/database/versions/test_versions.py
+++ b/tempest/api/database/versions/test_versions.py
@@ -21,8 +21,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(DatabaseVersionsTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(DatabaseVersionsTest, cls).resource_setup()
cls.client = cls.database_versions_client
@test.attr(type='smoke')
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index 492d56f..d87d5c1 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -24,9 +24,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(RolesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(RolesTestJSON, cls).resource_setup()
for _ in moves.xrange(5):
role_name = data_utils.rand_name(name='role-')
_, role = cls.client.create_role(role_name)
diff --git a/tempest/api/identity/admin/test_tokens.py b/tempest/api/identity/admin/test_tokens.py
index e1db008..2c5fb74 100644
--- a/tempest/api/identity/admin/test_tokens.py
+++ b/tempest/api/identity/admin/test_tokens.py
@@ -35,10 +35,9 @@
tenant['id'], '')
self.data.users.append(user)
# then get a token for the user
- rsp, body = self.token_client.auth(user_name,
- user_password,
- tenant['name'])
- self.assertEqual(rsp['status'], '200')
+ _, body = self.token_client.auth(user_name,
+ user_password,
+ tenant['name'])
self.assertEqual(body['token']['tenant']['name'],
tenant['name'])
# Perform GET Token
@@ -89,15 +88,13 @@
role['id'])
# Get an unscoped token.
- resp, body = self.token_client.auth(user_name, user_password)
- self.assertEqual(200, resp.status)
+ _, body = self.token_client.auth(user_name, user_password)
token_id = body['token']['id']
# Use the unscoped token to get a token scoped to tenant1
- resp, body = self.token_client.auth_token(token_id,
- tenant=tenant1_name)
- self.assertEqual(200, resp.status)
+ _, body = self.token_client.auth_token(token_id,
+ tenant=tenant1_name)
scoped_token_id = body['token']['id']
@@ -105,9 +102,8 @@
self.client.delete_token(scoped_token_id)
# Use the unscoped token to get a token scoped to tenant2
- resp, body = self.token_client.auth_token(token_id,
- tenant=tenant2_name)
- self.assertEqual(200, resp.status)
+ _, body = self.token_client.auth_token(token_id,
+ tenant=tenant2_name)
class TokensTestXML(TokensTestJSON):
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 5838da3..66a1737 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -24,8 +24,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(UsersTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(UsersTestJSON, cls).resource_setup()
cls.alt_user = data_utils.rand_name('test_user_')
cls.alt_password = data_utils.rand_name('pass_')
cls.alt_email = cls.alt_user + '@testmail.tm'
@@ -97,10 +97,9 @@
self.token_client.auth(self.data.test_user, self.data.test_password,
self.data.test_tenant)
# Re-auth
- resp, body = self.token_client.auth(self.data.test_user,
- self.data.test_password,
- self.data.test_tenant)
- self.assertEqual('200', resp['status'])
+ self.token_client.auth(self.data.test_user,
+ self.data.test_password,
+ self.data.test_tenant)
@test.attr(type='gate')
def test_authentication_request_without_token(self):
@@ -113,10 +112,9 @@
# Delete the token from database
self.client.delete_token(token)
# Re-auth
- resp, body = self.token_client.auth(self.data.test_user,
- self.data.test_password,
- self.data.test_tenant)
- self.assertEqual('200', resp['status'])
+ self.token_client.auth(self.data.test_user,
+ self.data.test_password,
+ self.data.test_tenant)
self.client.auth_provider.clear_auth()
@test.attr(type='smoke')
@@ -205,9 +203,8 @@
# Validate the updated password
# Get a token
- resp, body = self.token_client.auth(self.data.test_user, new_pass,
- self.data.test_tenant)
- self.assertEqual('200', resp['status'])
+ _, body = self.token_client.auth(self.data.test_user, new_pass,
+ self.data.test_tenant)
self.assertTrue('id' in body['token'])
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index a584a7b..bad2b89 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -25,8 +25,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(UsersNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(UsersNegativeTestJSON, cls).resource_setup()
cls.alt_user = data_utils.rand_name('test_user_')
cls.alt_password = data_utils.rand_name('pass_')
cls.alt_email = cls.alt_user + '@testmail.tm'
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index d40e0f3..7a0edb0 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -22,9 +22,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(CredentialsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(CredentialsTestJSON, cls).resource_setup()
cls.projects = list()
cls.creds_list = [['project_id', 'user_id', 'id'],
['access', 'secret']]
@@ -43,25 +42,23 @@
email=u_email, project_id=cls.projects[0])
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.client.delete_user(cls.user_body['id'])
for p in cls.projects:
cls.client.delete_project(p)
- super(CredentialsTestJSON, cls).tearDownClass()
+ super(CredentialsTestJSON, cls).resource_cleanup()
def _delete_credential(self, cred_id):
- resp, body = self.creds_client.delete_credential(cred_id)
- self.assertEqual(resp['status'], '204')
+ self.creds_client.delete_credential(cred_id)
@test.attr(type='smoke')
def test_credentials_create_get_update_delete(self):
keys = [data_utils.rand_name('Access-'),
data_utils.rand_name('Secret-')]
- resp, cred = self.creds_client.create_credential(
+ _, cred = self.creds_client.create_credential(
keys[0], keys[1], self.user_body['id'],
self.projects[0])
self.addCleanup(self._delete_credential, cred['id'])
- self.assertEqual(resp['status'], '201')
for value1 in self.creds_list[0]:
self.assertIn(value1, cred)
for value2 in self.creds_list[1]:
@@ -69,18 +66,16 @@
new_keys = [data_utils.rand_name('NewAccess-'),
data_utils.rand_name('NewSecret-')]
- resp, update_body = self.creds_client.update_credential(
+ _, update_body = self.creds_client.update_credential(
cred['id'], access_key=new_keys[0], secret_key=new_keys[1],
project_id=self.projects[1])
- self.assertEqual(resp['status'], '200')
self.assertEqual(cred['id'], update_body['id'])
self.assertEqual(self.projects[1], update_body['project_id'])
self.assertEqual(self.user_body['id'], update_body['user_id'])
self.assertEqual(update_body['blob']['access'], new_keys[0])
self.assertEqual(update_body['blob']['secret'], new_keys[1])
- resp, get_body = self.creds_client.get_credential(cred['id'])
- self.assertEqual(resp['status'], '200')
+ _, get_body = self.creds_client.get_credential(cred['id'])
for value1 in self.creds_list[0]:
self.assertEqual(update_body[value1],
get_body[value1])
@@ -94,16 +89,14 @@
fetched_cred_ids = list()
for i in range(2):
- resp, cred = self.creds_client.create_credential(
+ _, cred = self.creds_client.create_credential(
data_utils.rand_name('Access-'),
data_utils.rand_name('Secret-'),
self.user_body['id'], self.projects[0])
- self.assertEqual(resp['status'], '201')
created_cred_ids.append(cred['id'])
self.addCleanup(self._delete_credential, cred['id'])
- resp, creds = self.creds_client.list_credentials()
- self.assertEqual(resp['status'], '200')
+ _, creds = self.creds_client.list_credentials()
for i in creds:
fetched_cred_ids.append(i['id'])
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index 6beb8f2..f1f1eb6 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -22,9 +22,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(EndPointsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(EndPointsTestJSON, cls).resource_setup()
cls.identity_client = cls.client
cls.client = cls.endpoints_client
cls.service_ids = list()
@@ -47,19 +46,18 @@
cls.setup_endpoints.append(endpoint)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for e in cls.setup_endpoints:
cls.client.delete_endpoint(e['id'])
for s in cls.service_ids:
cls.service_client.delete_service(s)
- super(EndPointsTestJSON, cls).tearDownClass()
+ super(EndPointsTestJSON, cls).resource_cleanup()
@test.attr(type='gate')
def test_list_endpoints(self):
# Get a list of endpoints
- resp, fetched_endpoints = self.client.list_endpoints()
+ _, fetched_endpoints = self.client.list_endpoints()
# Asserting LIST endpoints
- self.assertEqual(resp['status'], '200')
missing_endpoints =\
[e for e in self.setup_endpoints if e not in fetched_endpoints]
self.assertEqual(0, len(missing_endpoints),
@@ -71,11 +69,10 @@
region = data_utils.rand_name('region')
url = data_utils.rand_url()
interface = 'public'
- resp, endpoint =\
+ _, endpoint =\
self.client.create_endpoint(self.service_id, interface, url,
region=region, enabled=True)
# Asserting Create Endpoint response body
- self.assertEqual(resp['status'], '201')
self.assertIn('id', endpoint)
self.assertEqual(region, endpoint['region'])
self.assertEqual(url, endpoint['url'])
@@ -84,8 +81,7 @@
fetched_endpoints_id = [e['id'] for e in fetched_endpoints]
self.assertIn(endpoint['id'], fetched_endpoints_id)
# Deleting the endpoint created in this method
- resp, body = self.client.delete_endpoint(endpoint['id'])
- self.assertEqual(resp['status'], '204')
+ _, body = self.client.delete_endpoint(endpoint['id'])
self.assertEqual(body, '')
# Checking whether endpoint is deleted successfully
resp, fetched_endpoints = self.client.list_endpoints()
@@ -116,12 +112,11 @@
region2 = data_utils.rand_name('region')
url2 = data_utils.rand_url()
interface2 = 'internal'
- resp, endpoint = \
+ _, endpoint = \
self.client.update_endpoint(endpoint_for_update['id'],
service_id=service2['id'],
interface=interface2, url=url2,
region=region2, enabled=False)
- self.assertEqual(resp['status'], '200')
# Asserting if the attributes of endpoint are updated
self.assertEqual(service2['id'], endpoint['service_id'])
self.assertEqual(interface2, endpoint['interface'])
diff --git a/tempest/api/identity/admin/v3/test_endpoints_negative.py b/tempest/api/identity/admin/v3/test_endpoints_negative.py
index d728b1d..b987d12 100644
--- a/tempest/api/identity/admin/v3/test_endpoints_negative.py
+++ b/tempest/api/identity/admin/v3/test_endpoints_negative.py
@@ -25,8 +25,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(EndpointsNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(EndpointsNegativeTestJSON, cls).resource_setup()
cls.identity_client = cls.client
cls.client = cls.endpoints_client
cls.service_ids = list()
@@ -40,10 +40,10 @@
cls.service_ids.append(cls.service_id)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for s in cls.service_ids:
cls.service_client.delete_service(s)
- super(EndpointsNegativeTestJSON, cls).tearDownClass()
+ super(EndpointsNegativeTestJSON, cls).resource_cleanup()
@test.attr(type=['negative', 'gate'])
def test_create_with_enabled_False(self):
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
index 4d2cc46..987a9d5 100644
--- a/tempest/api/identity/admin/v3/test_groups.py
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -22,8 +22,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(GroupsV3TestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(GroupsV3TestJSON, cls).resource_setup()
@test.attr(type='smoke')
def test_group_create_update_get(self):
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index a3944e2..be06c7f 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -22,8 +22,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(ListProjectsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListProjectsTestJSON, cls).resource_setup()
cls.project_ids = list()
cls.data.setup_test_domain()
# Create project with domain
diff --git a/tempest/api/identity/admin/v3/test_list_users.py b/tempest/api/identity/admin/v3/test_list_users.py
index 497c5ea..903ad5c 100644
--- a/tempest/api/identity/admin/v3/test_list_users.py
+++ b/tempest/api/identity/admin/v3/test_list_users.py
@@ -32,8 +32,8 @@
map(lambda x: x[key], body))
@classmethod
- def setUpClass(cls):
- super(UsersV3TestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(UsersV3TestJSON, cls).resource_setup()
alt_user = data_utils.rand_name('test_user')
alt_password = data_utils.rand_name('pass')
cls.alt_email = alt_user + '@testmail.tm'
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 0e79440..65c5230 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -22,8 +22,7 @@
_interface = 'json'
def _delete_policy(self, policy_id):
- resp, _ = self.policy_client.delete_policy(policy_id)
- self.assertEqual(204, resp.status)
+ self.policy_client.delete_policy(policy_id)
@test.attr(type='smoke')
def test_list_policies(self):
@@ -39,8 +38,7 @@
self.addCleanup(self._delete_policy, policy['id'])
policy_ids.append(policy['id'])
# List and Verify Policies
- resp, body = self.policy_client.list_policies()
- self.assertEqual(resp['status'], '200')
+ _, body = self.policy_client.list_policies()
for p in body:
fetched_ids.append(p['id'])
missing_pols = [p for p in policy_ids if p not in fetched_ids]
@@ -51,7 +49,7 @@
# Test to update policy
blob = data_utils.rand_name('BlobName-')
policy_type = data_utils.rand_name('PolicyType-')
- resp, policy = self.policy_client.create_policy(blob, policy_type)
+ _, policy = self.policy_client.create_policy(blob, policy_type)
self.addCleanup(self._delete_policy, policy['id'])
self.assertIn('id', policy)
self.assertIn('type', policy)
@@ -59,15 +57,13 @@
self.assertIsNotNone(policy['id'])
self.assertEqual(blob, policy['blob'])
self.assertEqual(policy_type, policy['type'])
- resp, fetched_policy = self.policy_client.get_policy(policy['id'])
- self.assertEqual(resp['status'], '200')
# Update policy
update_type = data_utils.rand_name('UpdatedPolicyType-')
- resp, data = self.policy_client.update_policy(
+ _, data = self.policy_client.update_policy(
policy['id'], type=update_type)
self.assertIn('type', data)
# Assertion for updated value with fetched value
- resp, fetched_policy = self.policy_client.get_policy(policy['id'])
+ _, fetched_policy = self.policy_client.get_policy(policy['id'])
self.assertIn('id', fetched_policy)
self.assertIn('blob', fetched_policy)
self.assertIn('type', fetched_policy)
diff --git a/tempest/api/identity/admin/v3/test_regions.py b/tempest/api/identity/admin/v3/test_regions.py
index c8b034f..c5d5824 100644
--- a/tempest/api/identity/admin/v3/test_regions.py
+++ b/tempest/api/identity/admin/v3/test_regions.py
@@ -23,9 +23,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(RegionsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(RegionsTestJSON, cls).resource_setup()
cls.setup_regions = list()
cls.client = cls.region_client
for i in range(2):
@@ -34,40 +33,36 @@
cls.setup_regions.append(region)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for r in cls.setup_regions:
cls.client.delete_region(r['id'])
- super(RegionsTestJSON, cls).tearDownClass()
+ super(RegionsTestJSON, cls).resource_cleanup()
def _delete_region(self, region_id):
- resp, _ = self.client.delete_region(region_id)
- self.assertEqual(204, resp.status)
+ self.client.delete_region(region_id)
self.assertRaises(exceptions.NotFound,
self.client.get_region, region_id)
@test.attr(type='gate')
def test_create_update_get_delete_region(self):
r_description = data_utils.rand_name('description-')
- resp, region = self.client.create_region(
+ _, region = self.client.create_region(
r_description, parent_region_id=self.setup_regions[0]['id'])
- self.assertEqual(201, resp.status)
self.addCleanup(self._delete_region, region['id'])
self.assertEqual(r_description, region['description'])
self.assertEqual(self.setup_regions[0]['id'],
region['parent_region_id'])
# Update region with new description and parent ID
r_alt_description = data_utils.rand_name('description-')
- resp, region = self.client.update_region(
+ _, region = self.client.update_region(
region['id'],
description=r_alt_description,
parent_region_id=self.setup_regions[1]['id'])
- self.assertEqual(200, resp.status)
self.assertEqual(r_alt_description, region['description'])
self.assertEqual(self.setup_regions[1]['id'],
region['parent_region_id'])
# Get the details of region
- resp, region = self.client.get_region(region['id'])
- self.assertEqual(200, resp.status)
+ _, region = self.client.get_region(region['id'])
self.assertEqual(r_alt_description, region['description'])
self.assertEqual(self.setup_regions[1]['id'],
region['parent_region_id'])
@@ -77,19 +72,17 @@
# Create a region with a specific id
r_region_id = data_utils.rand_uuid()
r_description = data_utils.rand_name('description-')
- resp, region = self.client.create_region(
+ _, region = self.client.create_region(
r_description, unique_region_id=r_region_id)
self.addCleanup(self._delete_region, region['id'])
# Asserting Create Region with specific id response body
- self.assertEqual(201, resp.status)
self.assertEqual(r_region_id, region['id'])
self.assertEqual(r_description, region['description'])
@test.attr(type='gate')
def test_list_regions(self):
# Get a list of regions
- resp, fetched_regions = self.client.list_regions()
- self.assertEqual(200, resp.status)
+ _, fetched_regions = self.client.list_regions()
missing_regions =\
[e for e in self.setup_regions if e not in fetched_regions]
# Asserting List Regions response
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index 2e732fe..5e14a04 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -22,9 +22,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(RolesV3TestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(RolesV3TestJSON, cls).resource_setup()
for _ in range(3):
role_name = data_utils.rand_name(name='role-')
_, role = cls.client.create_role(role_name)
@@ -52,7 +51,7 @@
data_utils.rand_name('Role-'))
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.client.delete_role(cls.role['id'])
cls.client.delete_group(cls.group_body['id'])
cls.client.delete_user(cls.user_body['id'])
@@ -61,7 +60,7 @@
# before deleting,or else it would result in unauthorized error
cls.client.update_domain(cls.domain['id'], enabled=False)
cls.client.delete_domain(cls.domain['id'])
- super(RolesV3TestJSON, cls).tearDownClass()
+ super(RolesV3TestJSON, cls).resource_cleanup()
def _list_assertions(self, body, fetched_role_ids, role_id):
self.assertEqual(len(body), 1)
@@ -141,11 +140,10 @@
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'])
- resp, body = self.token.auth(self.user_body['id'], self.u_password,
- self.project['name'],
- domain=self.domain['name'])
+ _, body = self.token.auth(self.user_body['id'], self.u_password,
+ self.project['name'],
+ domain=self.domain['name'])
roles = body['token']['roles']
- self.assertEqual(resp['status'], '201')
self.assertEqual(len(roles), 1)
self.assertEqual(roles[0]['id'], self.role['id'])
# Revoke role to group on project
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index f6078da..7e21cc3 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -13,41 +13,84 @@
# License for the specific language governing permissions and limitations
# under the License.
-
from tempest.api.identity import base
from tempest.common.utils import data_utils
+from tempest import exceptions
from tempest import test
class ServicesTestJSON(base.BaseIdentityV3AdminTest):
_interface = 'json'
- @test.attr(type='gate')
- def test_update_service(self):
- # Update description attribute of service
- name = data_utils.rand_name('service-')
- serv_type = data_utils.rand_name('type--')
- desc = data_utils.rand_name('description-')
- _, body = self.service_client.create_service(name, serv_type,
- description=desc)
- # Deleting the service created in this method
- self.addCleanup(self.service_client.delete_service, body['id'])
+ def _del_service(self, service_id):
+ # Used for deleting the services created in this class
+ self.service_client.delete_service(service_id)
+ # Checking whether service is deleted successfully
+ self.assertRaises(exceptions.NotFound, self.service_client.get_service,
+ service_id)
- s_id = body['id']
- resp1_desc = body['description']
+ @test.attr(type='smoke')
+ def test_create_update_get_service(self):
+ # Creating a Service
+ name = data_utils.rand_name('service')
+ serv_type = data_utils.rand_name('type')
+ desc = data_utils.rand_name('description')
+ _, create_service = self.service_client.create_service(
+ serv_type, name=name, description=desc)
+ self.addCleanup(self._del_service, create_service['id'])
+ self.assertIsNotNone(create_service['id'])
- s_desc2 = data_utils.rand_name('desc2-')
- _, body = self.service_client.update_service(
+ # Verifying response body of create service
+ expected_data = {'name': name, 'type': serv_type, 'description': desc}
+ self.assertDictContainsSubset(expected_data, create_service)
+
+ # Update description
+ s_id = create_service['id']
+ resp1_desc = create_service['description']
+ s_desc2 = data_utils.rand_name('desc2')
+ _, update_service = self.service_client.update_service(
s_id, description=s_desc2)
- resp2_desc = body['description']
+ resp2_desc = update_service['description']
+
self.assertNotEqual(resp1_desc, resp2_desc)
# Get service
- _, body = self.service_client.get_service(s_id)
- resp3_desc = body['description']
+ _, fetched_service = self.service_client.get_service(s_id)
+ resp3_desc = fetched_service['description']
- self.assertNotEqual(resp1_desc, resp3_desc)
self.assertEqual(resp2_desc, resp3_desc)
+ self.assertDictContainsSubset(update_service, fetched_service)
+
+ @test.attr(type='smoke')
+ def test_create_service_without_description(self):
+ # Create a service only with name and type
+ name = data_utils.rand_name('service')
+ serv_type = data_utils.rand_name('type')
+ _, service = self.service_client.create_service(
+ serv_type, name=name)
+ self.addCleanup(self.service_client.delete_service, service['id'])
+ self.assertIn('id', service)
+ expected_data = {'name': name, 'type': serv_type}
+ self.assertDictContainsSubset(expected_data, service)
+
+ @test.attr(type='smoke')
+ def test_list_services(self):
+ # Create, List, Verify and Delete Services
+ service_ids = list()
+ for _ in range(3):
+ name = data_utils.rand_name('service')
+ serv_type = data_utils.rand_name('type')
+ _, create_service = self.service_client.create_service(
+ serv_type, name=name)
+ self.addCleanup(self.service_client.delete_service,
+ create_service['id'])
+ service_ids.append(create_service['id'])
+
+ # List and Verify Services
+ _, services = self.service_client.list_services()
+ fetched_ids = [service['id'] for service in services]
+ found = [s for s in fetched_ids if s in service_ids]
+ self.assertEqual(len(found), len(service_ids))
class ServicesTestXML(ServicesTestJSON):
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index bd08614..230e09f 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -35,8 +35,7 @@
email=u_email)
self.addCleanup(self.client.delete_user, user['id'])
# Perform Authentication
- resp, body = self.token.auth(user['id'], u_password)
- self.assertEqual(201, resp.status)
+ resp, _ = self.token.auth(user['id'], u_password)
subject_token = resp['x-subject-token']
# Perform GET Token
_, token_details = self.client.get_token(subject_token)
@@ -48,7 +47,6 @@
self.assertRaises(exceptions.NotFound, self.client.get_token,
subject_token)
- @test.skip_because(bug="1351026")
@test.attr(type='gate')
def test_rescope_token(self):
"""Rescope a token.
@@ -89,7 +87,6 @@
# Get an unscoped token.
resp, token_auth = self.token.auth(user=user['id'],
password=user_password)
- self.assertEqual(201, resp.status)
token_id = resp['x-subject-token']
orig_expires_at = token_auth['token']['expires_at']
@@ -114,7 +111,6 @@
tenant=project1_name,
domain='Default')
token1_id = resp['x-subject-token']
- self.assertEqual(201, resp.status)
self.assertEqual(orig_expires_at, token_auth['token']['expires_at'],
'Expiration time should match original token')
@@ -141,10 +137,9 @@
self.client.delete_token(token1_id)
# Now get another scoped token using the unscoped token.
- resp, token_auth = self.token.auth(token=token_id,
- tenant=project2_name,
- domain='Default')
- self.assertEqual(201, resp.status)
+ _, token_auth = self.token.auth(token=token_id,
+ tenant=project2_name,
+ domain='Default')
self.assertEqual(project2['id'],
token_auth['token']['project']['id'])
diff --git a/tempest/api/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index 3c25819..898bcd0 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -77,8 +77,7 @@
new_password = data_utils.rand_name('pass1')
self.client.update_user_password(user['id'], new_password,
original_password)
- resp, body = self.token.auth(user['id'], new_password)
- self.assertEqual(201, resp.status)
+ resp, _ = self.token.auth(user['id'], new_password)
subject_token = resp['x-subject-token']
# Perform GET Token to verify and confirm password is updated
_, token_details = self.client.get_token(subject_token)
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 3996cc1..a225f12 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -29,8 +29,8 @@
class BaseIdentityAdminTest(tempest.test.BaseTestCase):
@classmethod
- def setUpClass(cls):
- super(BaseIdentityAdminTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseIdentityAdminTest, cls).resource_setup()
cls.os_adm = clients.AdminManager(interface=cls._interface)
cls.os = clients.Manager(interface=cls._interface)
@@ -72,10 +72,10 @@
class BaseIdentityV2AdminTest(BaseIdentityAdminTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.identity_feature_enabled.api_v2:
raise cls.skipException("Identity api v2 is not enabled")
- super(BaseIdentityV2AdminTest, cls).setUpClass()
+ super(BaseIdentityV2AdminTest, cls).resource_setup()
cls.client = cls.os_adm.identity_client
cls.token_client = cls.os_adm.token_client
if not cls.client.has_admin_extensions():
@@ -84,18 +84,18 @@
cls.non_admin_client = cls.os.identity_client
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.data.teardown_all()
- super(BaseIdentityV2AdminTest, cls).tearDownClass()
+ super(BaseIdentityV2AdminTest, cls).resource_cleanup()
class BaseIdentityV3AdminTest(BaseIdentityAdminTest):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.identity_feature_enabled.api_v3:
raise cls.skipException("Identity api v3 is not enabled")
- super(BaseIdentityV3AdminTest, cls).setUpClass()
+ super(BaseIdentityV3AdminTest, cls).resource_setup()
cls.client = cls.os_adm.identity_v3_client
cls.token = cls.os_adm.token_v3_client
cls.endpoints_client = cls.os_adm.endpoints_client
@@ -108,9 +108,9 @@
cls.non_admin_client = cls.os.identity_v3_client
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.data.teardown_all()
- super(BaseIdentityV3AdminTest, cls).tearDownClass()
+ super(BaseIdentityV3AdminTest, cls).resource_cleanup()
class DataGenerator(object):
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index c875b2f..08767e3 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -31,9 +31,9 @@
"""Base test class for Image API tests."""
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources()
- super(BaseImageTest, cls).setUpClass()
+ super(BaseImageTest, cls).resource_setup()
cls.created_images = []
cls._interface = 'json'
cls.isolated_creds = isolated_creds.IsolatedCreds(
@@ -47,7 +47,7 @@
cls.os = clients.Manager()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for image_id in cls.created_images:
try:
cls.client.delete_image(image_id)
@@ -57,7 +57,7 @@
for image_id in cls.created_images:
cls.client.wait_for_resource_deletion(image_id)
cls.isolated_creds.clear_isolated_creds()
- super(BaseImageTest, cls).tearDownClass()
+ super(BaseImageTest, cls).resource_cleanup()
@classmethod
def create_image(cls, **kwargs):
@@ -79,8 +79,8 @@
class BaseV1ImageTest(BaseImageTest):
@classmethod
- def setUpClass(cls):
- super(BaseV1ImageTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseV1ImageTest, cls).resource_setup()
cls.client = cls.os.image_client
if not CONF.image_feature_enabled.api_v1:
msg = "Glance API v1 not supported"
@@ -89,8 +89,8 @@
class BaseV1ImageMembersTest(BaseV1ImageTest):
@classmethod
- def setUpClass(cls):
- super(BaseV1ImageMembersTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseV1ImageMembersTest, cls).resource_setup()
if CONF.compute.allow_tenant_isolation:
cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
else:
@@ -113,8 +113,8 @@
class BaseV2ImageTest(BaseImageTest):
@classmethod
- def setUpClass(cls):
- super(BaseV2ImageTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseV2ImageTest, cls).resource_setup()
cls.client = cls.os.image_client_v2
if not CONF.image_feature_enabled.api_v2:
msg = "Glance API v2 not supported"
@@ -124,8 +124,8 @@
class BaseV2MemberImageTest(BaseV2ImageTest):
@classmethod
- def setUpClass(cls):
- super(BaseV2MemberImageTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseV2MemberImageTest, cls).resource_setup()
if CONF.compute.allow_tenant_isolation:
creds = cls.isolated_creds.get_alt_creds()
cls.os_alt = clients.Manager(creds)
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index bf55b89..38a623a 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -106,9 +106,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ListImagesTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListImagesTest, cls).resource_setup()
# We add a few images here to test the listing functionality of
# the images API
img1 = cls._create_remote_image('one', 'bare', 'raw')
@@ -235,8 +234,7 @@
class ListSnapshotImagesTest(base.BaseV1ImageTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
# This test class only uses nova v3 api to create snapshot
# as the similar test which uses nova v2 api already exists
# in nova v2 compute images api tests.
@@ -246,7 +244,7 @@
skip_msg = ("%s skipped as nova v3 api is not available" %
cls.__name__)
raise cls.skipException(skip_msg)
- super(ListSnapshotImagesTest, cls).setUpClass()
+ super(ListSnapshotImagesTest, cls).resource_setup()
cls.servers_client = cls.os.servers_v3_client
cls.servers = []
# We add a few images here to test the listing functionality of
@@ -265,10 +263,10 @@
cls.client.wait_for_image_status(image['id'], 'active')
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for server in getattr(cls, "servers", []):
cls.servers_client.delete_server(server['id'])
- super(ListSnapshotImagesTest, cls).tearDownClass()
+ super(ListSnapshotImagesTest, cls).resource_cleanup()
@classmethod
def _create_snapshot(cls, name, image_id, flavor, **kwargs):
@@ -329,8 +327,8 @@
class UpdateImageMetaTest(base.BaseV1ImageTest):
@classmethod
- def setUpClass(cls):
- super(UpdateImageMetaTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(UpdateImageMetaTest, cls).resource_setup()
cls.image_id = cls._create_standard_image('1', 'ami', 'ami', 42)
@classmethod
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index a974ebb..7e018e5 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -125,9 +125,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ListImagesTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ListImagesTest, cls).resource_setup()
# We add a few images here to test the listing functionality of
# the images API
cls._create_standard_image('bare', 'raw')
diff --git a/tempest/api/queuing/__init__.py b/tempest/api/messaging/__init__.py
similarity index 100%
rename from tempest/api/queuing/__init__.py
rename to tempest/api/messaging/__init__.py
diff --git a/tempest/api/queuing/base.py b/tempest/api/messaging/base.py
similarity index 78%
rename from tempest/api/queuing/base.py
rename to tempest/api/messaging/base.py
index 41a02f2..58511a9 100644
--- a/tempest/api/queuing/base.py
+++ b/tempest/api/messaging/base.py
@@ -23,25 +23,25 @@
LOG = logging.getLogger(__name__)
-class BaseQueuingTest(test.BaseTestCase):
+class BaseMessagingTest(test.BaseTestCase):
"""
- Base class for the Queuing tests that use the Tempest Zaqar REST client
+ Base class for the Messaging tests that use the Tempest Zaqar REST client
It is assumed that the following option is defined in the
[service_available] section of etc/tempest.conf
- queuing as True
+ messaging as True
"""
@classmethod
- def setUpClass(cls):
- super(BaseQueuingTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseMessagingTest, cls).resource_setup()
if not CONF.service_available.zaqar:
raise cls.skipException("Zaqar support is required")
os = cls.get_client_manager()
- cls.queuing_cfg = CONF.queuing
- cls.client = os.queuing_client
+ cls.messaging_cfg = CONF.messaging
+ cls.client = os.messaging_client
@classmethod
def create_queue(cls, queue_name):
@@ -93,42 +93,42 @@
@classmethod
def post_messages(cls, queue_name, rbody):
- '''Wrapper utility that posts messages to a queue.'''
+ """Wrapper utility that posts messages to a queue."""
resp, body = cls.client.post_messages(queue_name, rbody)
return resp, body
@classmethod
def list_messages(cls, queue_name):
- '''Wrapper utility that lists the messages in a queue.'''
+ """Wrapper utility that lists the messages in a queue."""
resp, body = cls.client.list_messages(queue_name)
return resp, body
@classmethod
def get_single_message(cls, message_uri):
- '''Wrapper utility that gets a single message.'''
+ """Wrapper utility that gets a single message."""
resp, body = cls.client.get_single_message(message_uri)
return resp, body
@classmethod
def get_multiple_messages(cls, message_uri):
- '''Wrapper utility that gets multiple messages.'''
+ """Wrapper utility that gets multiple messages."""
resp, body = cls.client.get_multiple_messages(message_uri)
return resp, body
@classmethod
def delete_messages(cls, message_uri):
- '''Wrapper utility that deletes messages.'''
+ """Wrapper utility that deletes messages."""
resp, body = cls.client.delete_messages(message_uri)
return resp, body
@classmethod
def post_claims(cls, queue_name, rbody, url_params=False):
- '''Wrapper utility that claims messages.'''
+ """Wrapper utility that claims messages."""
resp, body = cls.client.post_claims(
queue_name, rbody, url_params=False)
@@ -136,33 +136,34 @@
@classmethod
def query_claim(cls, claim_uri):
- '''Wrapper utility that gets a claim.'''
+ """Wrapper utility that gets a claim."""
resp, body = cls.client.query_claim(claim_uri)
return resp, body
@classmethod
def update_claim(cls, claim_uri, rbody):
- '''Wrapper utility that updates a claim.'''
+ """Wrapper utility that updates a claim."""
resp, body = cls.client.update_claim(claim_uri, rbody)
return resp, body
@classmethod
def release_claim(cls, claim_uri):
- '''Wrapper utility that deletes a claim.'''
+ """Wrapper utility that deletes a claim."""
resp, body = cls.client.release_claim(claim_uri)
return resp, body
@classmethod
def generate_message_body(cls, repeat=1):
- '''Wrapper utility that sets the metadata of a queue.'''
- message_ttl = data_utils.rand_int_id(start=60,
- end=CONF.queuing.max_message_ttl)
+ """Wrapper utility that sets the metadata of a queue."""
+ message_ttl = data_utils.\
+ rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
- key = data_utils.arbitrary_string(size=20, base_text='QueuingKey')
- value = data_utils.arbitrary_string(size=20, base_text='QueuingValue')
+ key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
+ value = data_utils.arbitrary_string(size=20,
+ base_text='MessagingValue')
message_body = {key: value}
rbody = ([{'body': message_body, 'ttl': message_ttl}] * repeat)
diff --git a/tempest/api/queuing/test_claims.py b/tempest/api/messaging/test_claims.py
similarity index 87%
rename from tempest/api/queuing/test_claims.py
rename to tempest/api/messaging/test_claims.py
index a306623..1b004dd 100644
--- a/tempest/api/queuing/test_claims.py
+++ b/tempest/api/messaging/test_claims.py
@@ -16,7 +16,7 @@
import logging
import urlparse
-from tempest.api.queuing import base
+from tempest.api.messaging import base
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -26,12 +26,12 @@
CONF = config.CONF
-class TestClaims(base.BaseQueuingTest):
+class TestClaims(base.BaseMessagingTest):
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(TestClaims, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestClaims, cls).resource_setup()
cls.queue_name = data_utils.rand_name('Queues-Test')
# Create Queue
cls.create_queue(cls.queue_name)
@@ -44,9 +44,9 @@
# Post Claim
claim_ttl = data_utils.rand_int_id(start=60,
- end=CONF.queuing.max_claim_ttl)
- claim_grace = data_utils.rand_int_id(start=60,
- end=CONF.queuing.max_claim_grace)
+ end=CONF.messaging.max_claim_ttl)
+ claim_grace = data_utils.\
+ rand_int_id(start=60, end=CONF.messaging.max_claim_grace)
claim_body = {"ttl": claim_ttl, "grace": claim_grace}
resp, body = self.client.post_claims(queue_name=self.queue_name,
rbody=claim_body)
@@ -90,7 +90,7 @@
# Update Claim
claim_ttl = data_utils.rand_int_id(start=60,
- end=CONF.queuing.max_claim_ttl)
+ end=CONF.messaging.max_claim_ttl)
update_rbody = {"ttl": claim_ttl}
self.client.update_claim(claim_uri, rbody=update_rbody)
@@ -118,6 +118,6 @@
self.client.delete_messages(message_uri)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_queue(cls.queue_name)
- super(TestClaims, cls).tearDownClass()
+ super(TestClaims, cls).resource_cleanup()
diff --git a/tempest/api/queuing/test_messages.py b/tempest/api/messaging/test_messages.py
similarity index 92%
rename from tempest/api/queuing/test_messages.py
rename to tempest/api/messaging/test_messages.py
index 9546c91..3c27ac2 100644
--- a/tempest/api/queuing/test_messages.py
+++ b/tempest/api/messaging/test_messages.py
@@ -15,7 +15,7 @@
import logging
-from tempest.api.queuing import base
+from tempest.api.messaging import base
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
@@ -25,17 +25,17 @@
CONF = config.CONF
-class TestMessages(base.BaseQueuingTest):
+class TestMessages(base.BaseMessagingTest):
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(TestMessages, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestMessages, cls).resource_setup()
cls.queue_name = data_utils.rand_name('Queues-Test')
# Create Queue
cls.client.create_queue(cls.queue_name)
- def _post_messages(self, repeat=CONF.queuing.max_messages_per_page):
+ def _post_messages(self, repeat=CONF.messaging.max_messages_per_page):
message_body = self.generate_message_body(repeat=repeat)
resp, body = self.post_messages(queue_name=self.queue_name,
rbody=message_body)
@@ -117,6 +117,6 @@
self.assertEqual('204', resp['status'])
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_queue(cls.queue_name)
- super(TestMessages, cls).tearDownClass()
+ super(TestMessages, cls).resource_cleanup()
diff --git a/tempest/api/queuing/test_queues.py b/tempest/api/messaging/test_queues.py
similarity index 93%
rename from tempest/api/queuing/test_queues.py
rename to tempest/api/messaging/test_queues.py
index b340b60..ab099ff 100644
--- a/tempest/api/queuing/test_queues.py
+++ b/tempest/api/messaging/test_queues.py
@@ -18,7 +18,7 @@
from six import moves
from testtools import matchers
-from tempest.api.queuing import base
+from tempest.api.messaging import base
from tempest.common.utils import data_utils
from tempest import test
@@ -26,7 +26,7 @@
LOG = logging.getLogger(__name__)
-class TestQueues(base.BaseQueuingTest):
+class TestQueues(base.BaseMessagingTest):
@test.attr(type='smoke')
def test_create_queue(self):
@@ -40,12 +40,12 @@
self.assertEqual('', body)
-class TestManageQueue(base.BaseQueuingTest):
+class TestManageQueue(base.BaseMessagingTest):
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(TestManageQueue, cls).setUpClass()
+ def resource_setup(cls):
+ super(TestManageQueue, cls).resource_setup()
cls.queues = list()
for _ in moves.xrange(5):
queue_name = data_utils.rand_name('Queues-Test')
@@ -125,7 +125,7 @@
self.assertThat(body, matchers.Equals(req_body))
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for queue_name in cls.queues:
cls.client.delete_queue(queue_name)
- super(TestManageQueue, cls).tearDownClass()
+ super(TestManageQueue, cls).resource_cleanup()
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index f8782ad..0d27afa 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -21,8 +21,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(AgentManagementTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AgentManagementTestJSON, cls).resource_setup()
if not test.is_extension_enabled('agent', 'network'):
msg = "agent extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index c84d1a7..78f211d 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -20,9 +20,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(DHCPAgentSchedulersTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(DHCPAgentSchedulersTestJSON, cls).resource_setup()
if not test.is_extension_enabled('dhcp_agent_scheduler', 'network'):
msg = "dhcp_agent_scheduler extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 710c669..2e58dae 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -18,8 +18,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(ExternalNetworksTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ExternalNetworksTestJSON, cls).resource_setup()
cls.network = cls.create_network()
def _create_network(self, external=True):
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index 3718cb5..46c5e76 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -26,8 +26,8 @@
force_tenant_isolation = True
@classmethod
- def setUpClass(cls):
- super(FloatingIPAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPAdminTestJSON, cls).resource_setup()
cls.ext_net_id = CONF.network.public_network_id
cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
cls.alt_manager = clients.Manager(cls.isolated_creds.get_alt_creds())
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index d7de73b..567af24 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -34,8 +34,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(L3AgentSchedulerTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(L3AgentSchedulerTestJSON, cls).resource_setup()
if not test.is_extension_enabled('l3_agent_scheduler', 'network'):
msg = "L3 Agent Scheduler Extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
index d0c31b3..1476f30 100644
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -35,9 +35,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(LBaaSAgentSchedulerTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(LBaaSAgentSchedulerTestJSON, cls).resource_setup()
if not test.is_extension_enabled('lbaas_agent_scheduler', 'network'):
msg = "LBaaS Agent Scheduler Extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
index a97d275..6d115e8 100644
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -29,9 +29,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(LoadBalancerAdminTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(LoadBalancerAdminTestJSON, cls).resource_setup()
if not test.is_extension_enabled('lbaas', 'network'):
msg = "lbaas extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 9ac97f9..72aef36 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -39,8 +39,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(QuotasTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(QuotasTest, cls).resource_setup()
if not test.is_extension_enabled('quotas', 'network'):
msg = "quotas extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 1a23cb6..834c010 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -56,10 +56,10 @@
_ip_version = 4
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
# Create no network resources for these test.
cls.set_network_resources()
- super(BaseNetworkTest, cls).setUpClass()
+ super(BaseNetworkTest, cls).resource_setup()
if not CONF.service_available.neutron:
raise cls.skipException("Neutron support is required")
@@ -85,7 +85,7 @@
cls.ipsecpolicies = []
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if CONF.service_available.neutron:
# Clean up ipsec policies
for ipsecpolicy in cls.ipsecpolicies:
@@ -138,7 +138,7 @@
for network in cls.networks:
cls.client.delete_network(network['id'])
cls.clear_isolated_creds()
- super(BaseNetworkTest, cls).tearDownClass()
+ super(BaseNetworkTest, cls).resource_cleanup()
@classmethod
def create_network(cls, network_name=None):
@@ -363,8 +363,8 @@
class BaseAdminNetworkTest(BaseNetworkTest):
@classmethod
- def setUpClass(cls):
- super(BaseAdminNetworkTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseAdminNetworkTest, cls).resource_setup()
admin_username = CONF.compute_admin.username
admin_password = CONF.compute_admin.password
admin_tenant = CONF.compute_admin.tenant_name
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index f69e6fd..38985a0 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -22,8 +22,8 @@
# require admin credentials by default
@classmethod
- def setUpClass(cls):
- super(BaseRouterTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseRouterTest, cls).resource_setup()
def _delete_router(self, router_id):
self.client.delete_router(router_id)
diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py
index c2af2f2..622ed01 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -20,8 +20,8 @@
class BaseSecGroupTest(base.BaseNetworkTest):
@classmethod
- def setUpClass(cls):
- super(BaseSecGroupTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseSecGroupTest, cls).resource_setup()
def _create_security_group(self):
# Create a security group
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 86acc71..c085c39 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -37,9 +37,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(AllowedAddressPairTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(AllowedAddressPairTestJSON, cls).resource_setup()
if not test.is_extension_enabled('allowed-address-pairs', 'network'):
msg = "Allowed Address Pairs extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index c3607c8..715136c 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -33,8 +33,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(ExtensionsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ExtensionsTestJSON, cls).resource_setup()
@test.attr(type='smoke')
def test_list_show_extensions(self):
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 82ebc5a..86da9b7 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -36,9 +36,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ExtraDHCPOptionsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ExtraDHCPOptionsTestJSON, cls).resource_setup()
if not test.is_extension_enabled('extra_dhcp_opt', 'network'):
msg = "Extra DHCP Options extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 8b42a9e..52672ea 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -46,9 +46,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(FloatingIPTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FloatingIPTestJSON, cls).resource_setup()
if not test.is_extension_enabled('router', 'network'):
msg = "router extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 6eec79e..11588d6 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -46,8 +46,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(FWaaSExtensionTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(FWaaSExtensionTestJSON, cls).resource_setup()
if not test.is_extension_enabled('fwaas', 'network'):
msg = "FWaaS Extension not enabled."
raise cls.skipException(msg)
@@ -72,18 +72,20 @@
self.client.wait_for_resource_deletion('firewall', fw_id)
- def _wait_for_active(self, fw_id):
+ def _wait_until_ready(self, fw_id):
+ target_states = ('ACTIVE', 'CREATED')
+
def _wait():
_, firewall = self.client.show_firewall(fw_id)
firewall = firewall['firewall']
- return firewall['status'] == 'ACTIVE'
+ return firewall['status'] in target_states
if not test.call_until_true(_wait, CONF.network.build_timeout,
CONF.network.build_interval):
- m = 'Timed out waiting for firewall %s to become ACTIVE.' % fw_id
+ m = ("Timed out waiting for firewall %s to reach %s state(s)" %
+ (fw_id, target_states))
raise exceptions.TimeoutException(m)
- @test.attr(type='smoke')
def test_list_firewall_rules(self):
# List firewall rules
_, fw_rules = self.client.list_firewall_rules()
@@ -101,7 +103,6 @@
m['ip_version'],
m['enabled']) for m in fw_rules])
- @test.attr(type='smoke')
def test_create_update_delete_firewall_rule(self):
# Create firewall rule
_, body = self.client.create_firewall_rule(
@@ -122,14 +123,12 @@
self.assertNotIn(fw_rule_id,
[m['id'] for m in fw_rules['firewall_rules']])
- @test.attr(type='smoke')
def test_show_firewall_rule(self):
# show a created firewall rule
_, fw_rule = self.client.show_firewall_rule(self.fw_rule['id'])
for key, value in fw_rule['firewall_rule'].iteritems():
self.assertEqual(self.fw_rule[key], value)
- @test.attr(type='smoke')
def test_list_firewall_policies(self):
_, fw_policies = self.client.list_firewall_policies()
fw_policies = fw_policies['firewall_policies']
@@ -140,7 +139,6 @@
m['name'],
m['firewall_rules']) for m in fw_policies])
- @test.attr(type='smoke')
def test_create_update_delete_firewall_policy(self):
# Create firewall policy
_, body = self.client.create_firewall_policy(
@@ -163,7 +161,6 @@
fw_policies = fw_policies['firewall_policies']
self.assertNotIn(fw_policy_id, [m['id'] for m in fw_policies])
- @test.attr(type='smoke')
def test_show_firewall_policy(self):
# show a created firewall policy
_, fw_policy = self.client.show_firewall_policy(self.fw_policy['id'])
@@ -171,7 +168,6 @@
for key, value in fw_policy.iteritems():
self.assertEqual(self.fw_policy[key], value)
- @test.attr(type='smoke')
def test_create_show_delete_firewall(self):
# Create tenant network resources required for an ACTIVE firewall
network = self.create_network()
@@ -190,7 +186,8 @@
firewall_id = created_firewall['id']
self.addCleanup(self._try_delete_firewall, firewall_id)
- self._wait_for_active(firewall_id)
+ # Wait for the firewall resource to become ready
+ self._wait_until_ready(firewall_id)
# show a created firewall
_, firewall = self.client.show_firewall(firewall_id)
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index e3109ea..baa8cad 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -38,9 +38,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(LoadBalancerTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(LoadBalancerTestJSON, cls).resource_setup()
if not test.is_extension_enabled('lbaas', 'network'):
msg = "lbaas extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 0cc218b..2cfb841 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -35,9 +35,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(MeteringJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(MeteringJSON, cls).resource_setup()
if not test.is_extension_enabled('metering', 'network'):
msg = "metering extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index f3da614..986a2c8 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -17,6 +17,7 @@
import testtools
from tempest.api.network import base
+from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
@@ -59,20 +60,100 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(NetworksTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(NetworksTestJSON, cls).resource_setup()
cls.network = cls.create_network()
cls.name = cls.network['name']
cls.subnet = cls.create_subnet(cls.network)
cls.cidr = cls.subnet['cidr']
+ cls._subnet_data = {6: {'gateway':
+ str(cls._get_gateway_from_tempest_conf(6)),
+ 'allocation_pools':
+ cls._get_allocation_pools_from_gateway(6),
+ 'dns_nameservers': ['2001:4860:4860::8844',
+ '2001:4860:4860::8888'],
+ 'host_routes': [{'destination': '2001::/64',
+ 'nexthop': '2003::1'}],
+ 'new_host_routes': [{'destination':
+ '2001::/64',
+ 'nexthop': '2005::1'}],
+ 'new_dns_nameservers':
+ ['2001:4860:4860::7744',
+ '2001:4860:4860::7888']},
+ 4: {'gateway':
+ str(cls._get_gateway_from_tempest_conf(4)),
+ 'allocation_pools':
+ cls._get_allocation_pools_from_gateway(4),
+ 'dns_nameservers': ['8.8.4.4', '8.8.8.8'],
+ 'host_routes': [{'destination': '10.20.0.0/32',
+ 'nexthop': '10.100.1.1'}],
+ 'new_host_routes': [{'destination':
+ '10.20.0.0/32',
+ 'nexthop':
+ '10.100.1.2'}],
+ 'new_dns_nameservers': ['7.8.8.8', '7.8.4.4']}}
+
+ @classmethod
+ def _get_gateway_from_tempest_conf(cls, ip_version):
+ """Return first subnet gateway for configured CIDR """
+ if ip_version == 4:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
+ elif ip_version == 6:
+ cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
+ mask_bits = CONF.network.tenant_network_v6_mask_bits
+
+ if mask_bits >= cidr.prefixlen:
+ return netaddr.IPAddress(cidr) + 1
+ else:
+ for subnet in cidr.subnet(mask_bits):
+ return netaddr.IPAddress(subnet) + 1
+
+ @classmethod
+ def _get_allocation_pools_from_gateway(cls, ip_version):
+ """Return allocation range for subnet of given gateway"""
+ gateway = cls._get_gateway_from_tempest_conf(ip_version)
+ return [{'start': str(gateway + 2), 'end': str(gateway + 3)}]
+
+ def subnet_dict(self, include_keys):
+ """Return a subnet dict which has include_keys and their corresponding
+ value from self._subnet_data
+ """
+ return dict((key, self._subnet_data[self._ip_version][key])
+ for key in include_keys)
+
+ def _compare_resource_attrs(self, actual, expected):
+ exclude_keys = set(actual).symmetric_difference(expected)
+ self.assertThat(actual, custom_matchers.MatchesDictExceptForKeys(
+ expected, exclude_keys))
+
+ def _create_verify_delete_subnet(self, cidr=None, mask_bits=None,
+ **kwargs):
+ network = self.create_network()
+ net_id = network['id']
+ gateway = kwargs.pop('gateway', None)
+ subnet = self.create_subnet(network, gateway, cidr, mask_bits,
+ **kwargs)
+ compare_args_full = dict(gateway_ip=gateway, cidr=cidr,
+ mask_bits=mask_bits, **kwargs)
+ compare_args = dict((k, v) for k, v in compare_args_full.iteritems()
+ if v is not None)
+
+ if 'dns_nameservers' in set(subnet).intersection(compare_args):
+ self.assertEqual(sorted(compare_args['dns_nameservers']),
+ sorted(subnet['dns_nameservers']))
+ del subnet['dns_nameservers'], compare_args['dns_nameservers']
+
+ self._compare_resource_attrs(subnet, compare_args)
+ self.client.delete_network(net_id)
+ self.networks.pop()
+ self.subnets.pop()
@test.attr(type='smoke')
def test_create_update_delete_network_subnet(self):
# Create a network
name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
+ network = self.create_network(network_name=name)
net_id = network['id']
self.assertEqual('ACTIVE', network['status'])
# Verify network update
@@ -88,11 +169,6 @@
_, body = self.client.update_subnet(subnet_id, name=new_name)
updated_subnet = body['subnet']
self.assertEqual(updated_subnet['name'], new_name)
- # Delete subnet and network
- _, body = self.client.delete_subnet(subnet_id)
- # Remove subnet from cleanup list
- self.subnets.pop()
- _, body = self.client.delete_network(net_id)
@test.attr(type='smoke')
def test_show_network(self):
@@ -205,32 +281,65 @@
@test.attr(type='smoke')
def test_create_delete_subnet_with_gw(self):
- gateway = '10.100.0.13'
- name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
- net_id = network['id']
- subnet = self.create_subnet(network, gateway)
- # Verifies Subnet GW in IPv4
- self.assertEqual(subnet['gateway_ip'], gateway)
- # Delete network and subnet
- self.client.delete_network(net_id)
- self.subnets.pop()
+ self._create_verify_delete_subnet(
+ **self.subnet_dict(['gateway']))
@test.attr(type='smoke')
- def test_create_delete_subnet_without_gw(self):
- net = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
- gateway_ip = str(netaddr.IPAddress(net.first + 1))
- name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
- net_id = network['id']
- subnet = self.create_subnet(network)
- # Verifies Subnet GW in IPv4
- self.assertEqual(subnet['gateway_ip'], gateway_ip)
- # Delete network and subnet
- self.client.delete_network(net_id)
- self.subnets.pop()
+ def test_create_delete_subnet_with_allocation_pools(self):
+ self._create_verify_delete_subnet(
+ **self.subnet_dict(['allocation_pools']))
+
+ @test.attr(type='smoke')
+ def test_create_delete_subnet_with_gw_and_allocation_pools(self):
+ self._create_verify_delete_subnet(**self.subnet_dict(
+ ['gateway', 'allocation_pools']))
+
+ @test.attr(type='smoke')
+ def test_create_delete_subnet_with_host_routes_and_dns_nameservers(self):
+ self._create_verify_delete_subnet(
+ **self.subnet_dict(['host_routes', 'dns_nameservers']))
+
+ @test.attr(type='smoke')
+ def test_create_delete_subnet_with_dhcp_enabled(self):
+ self._create_verify_delete_subnet(enable_dhcp=True)
+
+ @test.attr(type='smoke')
+ def test_update_subnet_gw_dns_host_routes_dhcp(self):
+ network = self.create_network()
+
+ subnet = self.create_subnet(
+ network, **self.subnet_dict(['gateway', 'host_routes',
+ 'dns_nameservers',
+ 'allocation_pools']))
+ subnet_id = subnet['id']
+ new_gateway = str(netaddr.IPAddress(
+ self._subnet_data[self._ip_version]['gateway']) + 1)
+ # Verify subnet update
+ new_host_routes = self._subnet_data[self._ip_version][
+ 'new_host_routes']
+
+ new_dns_nameservers = self._subnet_data[self._ip_version][
+ 'new_dns_nameservers']
+ kwargs = {'host_routes': new_host_routes,
+ 'dns_nameservers': new_dns_nameservers,
+ 'gateway_ip': new_gateway, 'enable_dhcp': True}
+
+ new_name = "New_subnet"
+ _, body = self.client.update_subnet(subnet_id, name=new_name,
+ **kwargs)
+ updated_subnet = body['subnet']
+ kwargs['name'] = new_name
+ self.assertEqual(sorted(updated_subnet['dns_nameservers']),
+ sorted(kwargs['dns_nameservers']))
+ del subnet['dns_nameservers'], kwargs['dns_nameservers']
+
+ self._compare_resource_attrs(updated_subnet, kwargs)
+
+ @test.attr(type='smoke')
+ def test_create_delete_subnet_all_attributes(self):
+ self._create_verify_delete_subnet(
+ enable_dhcp=True,
+ **self.subnet_dict(['gateway', 'host_routes', 'dns_nameservers']))
class NetworksTestXML(NetworksTestJSON):
@@ -366,62 +475,41 @@
_ip_version = 6
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.network_feature_enabled.ipv6:
skip_msg = "IPv6 Tests are disabled."
raise cls.skipException(skip_msg)
- super(NetworksIpV6TestJSON, cls).setUpClass()
+ super(NetworksIpV6TestJSON, cls).resource_setup()
@test.attr(type='smoke')
def test_create_delete_subnet_with_gw(self):
net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
gateway = str(netaddr.IPAddress(net.first + 2))
name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
- net_id = network['id']
+ network = self.create_network(network_name=name)
subnet = self.create_subnet(network, gateway)
# Verifies Subnet GW in IPv6
self.assertEqual(subnet['gateway_ip'], gateway)
- # Delete network and subnet
- self.client.delete_network(net_id)
- self.subnets.pop()
@test.attr(type='smoke')
def test_create_delete_subnet_without_gw(self):
net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
gateway_ip = str(netaddr.IPAddress(net.first + 1))
name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
- net_id = network['id']
+ network = self.create_network(network_name=name)
subnet = self.create_subnet(network)
# Verifies Subnet GW in IPv6
self.assertEqual(subnet['gateway_ip'], gateway_ip)
- # Delete network and subnet
- _, body = self.client.delete_network(net_id)
- self.subnets.pop()
@testtools.skipUnless(CONF.network_feature_enabled.ipv6_subnet_attributes,
"IPv6 extended attributes for subnets not "
"available")
@test.attr(type='smoke')
def test_create_delete_subnet_with_v6_attributes(self):
- name = data_utils.rand_name('network-')
- _, body = self.client.create_network(name=name)
- network = body['network']
- net_id = network['id']
- subnet = self.create_subnet(network,
- gateway='fe80::1',
- ipv6_ra_mode='slaac',
- ipv6_address_mode='slaac')
- # Verifies Subnet GW in IPv6
- self.assertEqual(subnet['gateway_ip'], 'fe80::1')
- self.assertEqual(subnet['ipv6_ra_mode'], 'slaac')
- self.assertEqual(subnet['ipv6_address_mode'], 'slaac')
- # Delete network and subnet
- self.client.delete_network(net_id)
- self.subnets.pop()
+ self._create_verify_delete_subnet(
+ gateway=self._subnet_data[self._ip_version]['gateway'],
+ ipv6_ra_mode='slaac',
+ ipv6_address_mode='slaac')
class NetworksIpV6TestXML(NetworksIpV6TestJSON):
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index c6fe817..cdd3a29 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -38,9 +38,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(PortsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(PortsTestJSON, cls).resource_setup()
cls.network = cls.create_network()
cls.port = cls.create_port(cls.network)
@@ -161,9 +160,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(PortsAdminExtendedAttrsTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(PortsAdminExtendedAttrsTestJSON, cls).resource_setup()
cls.identity_client = cls._get_identity_admin_client()
cls.tenant = cls.identity_client.get_tenant_by_name(
CONF.identity.tenant_name)
@@ -244,9 +242,8 @@
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(PortsIpV6TestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(PortsIpV6TestJSON, cls).resource_setup()
if not CONF.network_feature_enabled.ipv6:
skip_msg = "IPv6 Tests are disabled."
raise cls.skipException(skip_msg)
@@ -262,11 +259,11 @@
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.network_feature_enabled.ipv6:
skip_msg = "IPv6 Tests are disabled."
raise cls.skipException(skip_msg)
- super(PortsAdminExtendedAttrsIpV6TestJSON, cls).setUpClass()
+ super(PortsAdminExtendedAttrsIpV6TestJSON, cls).resource_setup()
class PortsAdminExtendedAttrsIpV6TestXML(PortsAdminExtendedAttrsIpV6TestJSON):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index bcd8113..f3f25ac 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -28,8 +28,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(RoutersTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(RoutersTest, cls).resource_setup()
if not test.is_extension_enabled('router', 'network'):
msg = "router extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index feee51b..4c226af 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -28,9 +28,8 @@
_interface = 'json'
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(RoutersNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(RoutersNegativeTest, cls).resource_setup()
if not test.is_extension_enabled('router', 'network'):
msg = "router extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index cea8344..9764b4d 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -24,8 +24,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(SecGroupTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(SecGroupTest, cls).resource_setup()
if not test.is_extension_enabled('security-group', 'network'):
msg = "security-group extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 53c9d12..9c6c267 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -24,8 +24,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(NegativeSecGroupTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(NegativeSecGroupTest, cls).resource_setup()
if not test.is_extension_enabled('security-group', 'network'):
msg = "security-group extension not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index dbb72fb..302069f 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -18,8 +18,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(ServiceTypeManagementTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(ServiceTypeManagementTestJSON, cls).resource_setup()
if not test.is_extension_enabled('service-type', 'network'):
msg = "Neutron Service Type Management not enabled."
raise cls.skipException(msg)
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 09e9640..c61bf41 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -34,12 +34,11 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
+ def resource_setup(cls):
if not test.is_extension_enabled('vpnaas', 'network'):
msg = "vpnaas extension not enabled."
raise cls.skipException(msg)
- super(VPNaaSTestJSON, cls).setUpClass()
+ super(VPNaaSTestJSON, cls).resource_setup()
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
cls.router = cls.create_router(
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index ccc0067..6a5fd3d 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -28,9 +28,9 @@
class BaseObjectTest(tempest.test.BaseTestCase):
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
cls.set_network_resources()
- super(BaseObjectTest, cls).setUpClass()
+ super(BaseObjectTest, cls).resource_setup()
if not CONF.service_available.swift:
skip_msg = ("%s skipped as swift is not available" % cls.__name__)
raise cls.skipException(skip_msg)
@@ -69,12 +69,13 @@
cls.object_client_alt.auth_provider.clear_auth()
cls.container_client_alt.auth_provider.clear_auth()
- cls.data = base.DataGenerator(cls.identity_admin_client)
+ cls.data = SwiftDataGenerator(cls.identity_admin_client)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
+ cls.data.teardown_all()
cls.isolated_creds.clear_isolated_creds()
- super(BaseObjectTest, cls).tearDownClass()
+ super(BaseObjectTest, cls).resource_cleanup()
@classmethod
def delete_containers(cls, containers, container_client=None,
@@ -116,3 +117,28 @@
self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(
target, method))
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+
+
+class SwiftDataGenerator(base.DataGenerator):
+
+ def setup_test_user(self, reseller=False):
+ super(SwiftDataGenerator, self).setup_test_user()
+ if reseller:
+ role_name = CONF.object_storage.reseller_admin_role
+ else:
+ role_name = CONF.object_storage.operator_role
+ role_id = self._get_role_id(role_name)
+ self._assign_role(role_id)
+
+ def _get_role_id(self, role_name):
+ try:
+ _, roles = self.client.list_roles()
+ return next(r['id'] for r in roles if r['name'] == role_name)
+ except StopIteration:
+ msg = "Role name '%s' is not found" % role_name
+ raise exceptions.NotFound(msg)
+
+ def _assign_role(self, role_id):
+ self.client.assign_user_role(self.tenant['id'],
+ self.user['id'],
+ role_id)
diff --git a/tempest/api/object_storage/test_account_bulk.py b/tempest/api/object_storage/test_account_bulk.py
index a94c883..743f1aa 100644
--- a/tempest/api/object_storage/test_account_bulk.py
+++ b/tempest/api/object_storage/test_account_bulk.py
@@ -50,16 +50,27 @@
return tarpath.name, container_name, object_name
- @test.attr(type='gate')
- def test_extract_archive(self):
- # Test bulk operation of file upload with an archived file
- filepath, container_name, object_name = self._create_archive()
-
+ def _upload_archive(self, filepath):
+ # upload an archived file
params = {'extract-archive': 'tar'}
with open(filepath) as fh:
mydata = fh.read()
resp, body = self.account_client.create_account(data=mydata,
params=params)
+ return resp, body
+
+ def _check_contents_deleted(self, container_name):
+ param = {'format': 'txt'}
+ resp, body = self.account_client.list_account_containers(param)
+ self.assertHeaders(resp, 'Account', 'GET')
+ self.assertNotIn(container_name, body)
+
+ @test.attr(type='gate')
+ @test.requires_ext(extension='bulk', service='object')
+ def test_extract_archive(self):
+ # Test bulk operation of file upload with an archived file
+ filepath, container_name, object_name = self._create_archive()
+ resp, _ = self._upload_archive(filepath)
self.containers.append(container_name)
@@ -95,23 +106,17 @@
self.assertIn(object_name, [c['name'] for c in contents_list])
@test.attr(type='gate')
+ @test.requires_ext(extension='bulk', service='object')
def test_bulk_delete(self):
# Test bulk operation of deleting multiple files
filepath, container_name, object_name = self._create_archive()
-
- params = {'extract-archive': 'tar'}
- with open(filepath) as fh:
- mydata = fh.read()
- resp, body = self.account_client.create_account(data=mydata,
- params=params)
+ self._upload_archive(filepath)
data = '%s/%s\n%s' % (container_name, object_name, container_name)
params = {'bulk-delete': ''}
resp, body = self.account_client.delete_account(data=data,
params=params)
- self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
-
# When deleting multiple files using the bulk operation, the response
# does not contain 'content-length' header. This is the special case,
# therefore the existence of response headers is checked without
@@ -124,11 +129,33 @@
# Check only the format of common headers with custom matcher
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
- # Check if a container is deleted
- param = {'format': 'txt'}
- resp, body = self.account_client.list_account_containers(param)
+ # Check if uploaded contents are completely deleted
+ self._check_contents_deleted(container_name)
- self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
- self.assertHeaders(resp, 'Account', 'GET')
+ @test.attr(type='gate')
+ @test.requires_ext(extension='bulk', service='object')
+ def test_bulk_delete_by_POST(self):
+ # Test bulk operation of deleting multiple files
+ filepath, container_name, object_name = self._create_archive()
+ self._upload_archive(filepath)
- self.assertNotIn(container_name, body)
+ data = '%s/%s\n%s' % (container_name, object_name, container_name)
+ params = {'bulk-delete': ''}
+
+ resp, body = self.account_client.create_account_metadata(
+ {}, data=data, params=params)
+
+ # When deleting multiple files using the bulk operation, the response
+ # does not contain 'content-length' header. This is the special case,
+ # therefore the existence of response headers is checked without
+ # custom matcher.
+ self.assertIn('transfer-encoding', resp)
+ self.assertIn('content-type', resp)
+ self.assertIn('x-trans-id', resp)
+ self.assertIn('date', resp)
+
+ # Check only the format of common headers with custom matcher
+ self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+
+ # Check if uploaded contents are completely deleted
+ self._check_contents_deleted(container_name)
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index 19e3068..97e9195 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -18,7 +18,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
@@ -27,38 +26,15 @@
class AccountQuotasTest(base.BaseObjectTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(AccountQuotasTest, cls).setUpClass()
+ 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()
+ cls.data.setup_test_user(reseller=True)
cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
- # Retrieve the ResellerAdmin role id
- reseller_role_id = None
- try:
- _, roles = cls.os_admin.identity_client.list_roles()
- reseller_role_id = next(r['id'] for r in roles if r['name']
- == CONF.object_storage.reseller_admin_role)
- except StopIteration:
- msg = "No ResellerAdmin role found"
- raise exceptions.NotFound(msg)
-
- # Retrieve the ResellerAdmin user id
- reseller_user_id = cls.data.test_credentials.user_id
-
- # Retrieve the ResellerAdmin tenant id
- reseller_tenant_id = cls.data.test_credentials.tenant_id
-
- # Assign the newly created user the appropriate ResellerAdmin role
- cls.os_admin.identity_client.assign_user_role(
- reseller_tenant_id,
- reseller_user_id,
- reseller_role_id)
-
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
@@ -94,11 +70,10 @@
super(AccountQuotasTest, self).tearDown()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name])
- cls.data.teardown_all()
- super(AccountQuotasTest, cls).tearDownClass()
+ super(AccountQuotasTest, cls).resource_cleanup()
@test.attr(type="smoke")
@test.requires_ext(extension='account_quotas', service='object')
diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py
index 6afd381..6c1fb5a 100644
--- a/tempest/api/object_storage/test_account_quotas_negative.py
+++ b/tempest/api/object_storage/test_account_quotas_negative.py
@@ -27,38 +27,15 @@
class AccountQuotasNegativeTest(base.BaseObjectTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(AccountQuotasNegativeTest, cls).setUpClass()
+ 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()
+ cls.data.setup_test_user(reseller=True)
cls.os_reselleradmin = clients.Manager(cls.data.test_credentials)
- # Retrieve the ResellerAdmin role id
- reseller_role_id = None
- try:
- _, roles = cls.os_admin.identity_client.list_roles()
- reseller_role_id = next(r['id'] for r in roles if r['name']
- == CONF.object_storage.reseller_admin_role)
- except StopIteration:
- msg = "No ResellerAdmin role found"
- raise exceptions.NotFound(msg)
-
- # Retrieve the ResellerAdmin tenant id
- reseller_user_id = cls.data.test_credentials.user_id
-
- # Retrieve the ResellerAdmin tenant id
- reseller_tenant_id = cls.data.test_credentials.tenant_id
-
- # Assign the newly created user the appropriate ResellerAdmin role
- cls.os_admin.identity_client.assign_user_role(
- reseller_tenant_id,
- reseller_user_id,
- reseller_role_id)
-
# Retrieve a ResellerAdmin auth data and use it to set a quota
# on the client's account
cls.reselleradmin_auth_data = \
@@ -93,11 +70,10 @@
super(AccountQuotasNegativeTest, self).tearDown()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name])
- cls.data.teardown_all()
- super(AccountQuotasNegativeTest, cls).tearDownClass()
+ super(AccountQuotasNegativeTest, cls).resource_cleanup()
@test.attr(type=["negative", "smoke"])
@test.requires_ext(extension='account_quotas', service='object')
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index d615374..a0436ee 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -14,15 +14,14 @@
# under the License.
import random
-
from six import moves
+import testtools
from tempest.api.object_storage import base
from tempest import clients
from tempest.common import custom_matchers
from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
from tempest import test
CONF = config.CONF
@@ -33,9 +32,8 @@
containers = []
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(AccountTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(AccountTest, cls).resource_setup()
for i in moves.xrange(ord('a'), ord('f') + 1):
name = data_utils.rand_name(name='%s-' % chr(i))
cls.container_client.create_container(name)
@@ -43,10 +41,9 @@
cls.containers_count = len(cls.containers)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_containers(cls.containers)
- cls.data.teardown_all()
- super(AccountTest, cls).tearDownClass()
+ super(AccountTest, cls).resource_cleanup()
@test.attr(type='smoke')
def test_list_containers(self):
@@ -66,35 +63,7 @@
# the base user of this instance.
self.data.setup_test_user()
- os_test_user = clients.Manager(
- self.data.test_credentials)
-
- # Retrieve the id of an operator role of object storage
- test_role_id = None
- swift_role = CONF.object_storage.operator_role
- try:
- _, roles = self.os_admin.identity_client.list_roles()
- test_role_id = next(r['id'] for r in roles if r['name']
- == swift_role)
- except StopIteration:
- msg = "%s role found" % swift_role
- raise exceptions.NotFound(msg)
-
- # Retrieve the test_user id
- _, users = self.os_admin.identity_client.get_users()
- test_user_id = next(usr['id'] for usr in users if usr['name']
- == self.data.test_user)
-
- # Retrieve the test_tenant id
- _, tenants = self.os_admin.identity_client.list_tenants()
- test_tenant_id = next(tnt['id'] for tnt in tenants if tnt['name']
- == self.data.test_tenant)
-
- # Assign the newly created user the appropriate operator role
- self.os_admin.identity_client.assign_user_role(
- test_tenant_id,
- test_user_id,
- test_role_id)
+ os_test_user = clients.Manager(self.data.test_credentials)
resp, container_list = \
os_test_user.account_client.list_account_containers()
@@ -148,6 +117,9 @@
self.assertEqual(container_list.find(".//bytes").tag, 'bytes')
@test.attr(type='smoke')
+ @testtools.skipIf(
+ not CONF.object_storage_feature_enabled.discoverability,
+ 'Discoverability function is disabled')
def test_list_extensions(self):
resp, extensions = self.account_client.list_extensions()
diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py
index 490672d..e4c46e2 100644
--- a/tempest/api/object_storage/test_account_services_negative.py
+++ b/tempest/api/object_storage/test_account_services_negative.py
@@ -47,5 +47,3 @@
self.assertRaises(exceptions.Unauthorized,
self.custom_account_client.list_account_containers,
params=params)
- # delete the user which was created
- self.data.teardown_all()
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index fc51504..e816a9f 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -21,17 +21,12 @@
class ObjectTestACLs(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ObjectTestACLs, cls).setUpClass()
+ 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
- @classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- super(ObjectTestACLs, cls).tearDownClass()
-
def setUp(self):
super(ObjectTestACLs, self).setUp()
self.container_name = data_utils.rand_name(name='TestContainer')
diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py
index ca53876..9b49db3 100644
--- a/tempest/api/object_storage/test_container_acl_negative.py
+++ b/tempest/api/object_storage/test_container_acl_negative.py
@@ -23,17 +23,12 @@
class ObjectACLsNegativeTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ObjectACLsNegativeTest, cls).setUpClass()
+ 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
- @classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- super(ObjectACLsNegativeTest, cls).tearDownClass()
-
def setUp(self):
super(ObjectACLsNegativeTest, self).setUp()
self.container_name = data_utils.rand_name(name='TestContainer')
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 581c6d9..966a08d 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -23,9 +23,8 @@
class StaticWebTest(base.BaseObjectTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(StaticWebTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(StaticWebTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name="TestContainer")
# This header should be posted on the container before every test
@@ -45,11 +44,10 @@
metadata_prefix="X-Container-")
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
if hasattr(cls, "container_name"):
cls.delete_containers([cls.container_name])
- cls.data.teardown_all()
- super(StaticWebTest, cls).tearDownClass()
+ super(StaticWebTest, cls).resource_cleanup()
@test.requires_ext(extension='staticweb', service='object')
@test.attr('gate')
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index 5f46d01..aebcb5c 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import testtools
import time
import urlparse
@@ -34,9 +35,8 @@
clients = {}
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ContainerSyncTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ContainerSyncTest, cls).resource_setup()
cls.containers = []
cls.objects = []
@@ -61,13 +61,16 @@
cls.containers.append(cont_name)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for client in cls.clients.values():
cls.delete_containers(cls.containers, client[0], client[1])
- super(ContainerSyncTest, cls).tearDownClass()
+ super(ContainerSyncTest, cls).resource_cleanup()
@test.attr(type='slow')
@test.skip_because(bug='1317133')
+ @testtools.skipIf(
+ not CONF.object_storage_feature_enabled.container_sync,
+ 'Old-style container sync function is disabled')
def test_container_synchronization(self):
# container to container synchronization
# to allow/accept sync requests to/from other accounts
diff --git a/tempest/api/object_storage/test_crossdomain.py b/tempest/api/object_storage/test_crossdomain.py
index d1541b9..f6d1fb9 100644
--- a/tempest/api/object_storage/test_crossdomain.py
+++ b/tempest/api/object_storage/test_crossdomain.py
@@ -15,7 +15,6 @@
# under the License.
from tempest.api.object_storage import base
-from tempest import clients
from tempest.common import custom_matchers
from tempest import test
@@ -23,13 +22,8 @@
class CrossdomainTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(CrossdomainTest, cls).setUpClass()
- # creates a test user. The test user will set its base_url to the Swift
- # endpoint and test the healthcheck feature.
- cls.data.setup_test_user()
-
- cls.os_test_user = clients.Manager(cls.data.test_credentials)
+ def resource_setup(cls):
+ super(CrossdomainTest, cls).resource_setup()
cls.xml_start = '<?xml version="1.0"?>\n' \
'<!DOCTYPE cross-domain-policy SYSTEM ' \
@@ -38,29 +32,16 @@
cls.xml_end = "</cross-domain-policy>"
- @classmethod
- def tearDownClass(cls):
- cls.data.teardown_all()
- super(CrossdomainTest, cls).tearDownClass()
-
def setUp(self):
super(CrossdomainTest, self).setUp()
- client = self.os_test_user.account_client
# Turning http://.../v1/foobar into http://.../
- client.skip_path()
-
- def tearDown(self):
- # clear the base_url for subsequent requests
- self.os_test_user.account_client.reset_path()
-
- super(CrossdomainTest, self).tearDown()
+ self.account_client.skip_path()
@test.attr('gate')
@test.requires_ext(extension='crossdomain', service='object')
def test_get_crossdomain_policy(self):
- resp, body = self.os_test_user.account_client.get("crossdomain.xml",
- {})
+ resp, body = self.account_client.get("crossdomain.xml", {})
self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertTrue(body.startswith(self.xml_start) and
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index e27c7ef..a1138e6 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -23,8 +23,8 @@
class HealthcheckTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(HealthcheckTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(HealthcheckTest, cls).resource_setup()
def setUp(self):
super(HealthcheckTest, self).setUp()
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index 73b4f3b..8cec2fc 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -23,8 +23,8 @@
class ObjectExpiryTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ObjectExpiryTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectExpiryTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
@@ -36,9 +36,9 @@
self.object_name, '')
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_containers([cls.container_name])
- super(ObjectExpiryTest, cls).tearDownClass()
+ super(ObjectExpiryTest, cls).resource_cleanup()
def _test_object_expiry(self, metadata):
# update object metadata
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index dc5585e..05c8ff2 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -30,9 +30,8 @@
containers = []
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ObjectFormPostTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectFormPostTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.object_name = data_utils.rand_name(name='ObjectTemp')
@@ -56,11 +55,10 @@
self.key)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata)
cls.delete_containers(cls.containers)
- cls.data.teardown_all()
- super(ObjectFormPostTest, cls).tearDownClass()
+ super(ObjectFormPostTest, cls).resource_cleanup()
def get_multipart_form(self, expires=600):
path = "%s/%s/%s" % (
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index 878bf6d..32f5917 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -30,9 +30,8 @@
containers = []
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ObjectFormPostNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectFormPostNegativeTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.object_name = data_utils.rand_name(name='ObjectTemp')
@@ -56,11 +55,10 @@
self.key)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata)
cls.delete_containers(cls.containers)
- cls.data.teardown_all()
- super(ObjectFormPostNegativeTest, cls).tearDownClass()
+ super(ObjectFormPostNegativeTest, cls).resource_cleanup()
def get_multipart_form(self, expires=600):
path = "%s/%s/%s" % (
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 8b74b7e..56ab1fb 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -30,16 +30,16 @@
class ObjectTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ObjectTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
cls.containers = [cls.container_name]
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_containers(cls.containers)
- super(ObjectTest, cls).tearDownClass()
+ super(ObjectTest, cls).resource_cleanup()
def _create_object(self, metadata=None):
# setup object
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index 0443a80..159ad5c 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -59,23 +59,23 @@
object_name_base_1 = object_name + '_01'
object_name_base_2 = object_name + '_02'
data_size = MIN_SEGMENT_SIZE
- self.data = data_utils.arbitrary_string(data_size)
+ self.content = data_utils.arbitrary_string(data_size)
self._create_object(self.container_name,
object_name_base_1,
- self.data)
+ self.content)
self._create_object(self.container_name,
object_name_base_2,
- self.data)
+ self.content)
path_object_1 = '/%s/%s' % (self.container_name,
object_name_base_1)
path_object_2 = '/%s/%s' % (self.container_name,
object_name_base_2)
data_manifest = [{'path': path_object_1,
- 'etag': hashlib.md5(self.data).hexdigest(),
+ 'etag': hashlib.md5(self.content).hexdigest(),
'size_bytes': data_size},
{'path': path_object_2,
- 'etag': hashlib.md5(self.data).hexdigest(),
+ 'etag': hashlib.md5(self.content).hexdigest(),
'size_bytes': data_size}]
return json.dumps(data_manifest)
@@ -147,7 +147,7 @@
self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self._assertHeadersSLO(resp, 'GET')
- sum_data = self.data + self.data
+ sum_data = self.content + self.content
self.assertEqual(body, sum_data)
@test.attr(type='gate')
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 264a18a..e70bd9a 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -30,8 +30,8 @@
class ObjectTempUrlTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ObjectTempUrlTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectTempUrlTest, cls).resource_setup()
# create a container
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
@@ -52,16 +52,14 @@
cls.object_name, cls.content)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
for metadata in cls.metadatas:
cls.account_client.delete_account_metadata(
metadata=metadata)
cls.delete_containers(cls.containers)
- # delete the user setup created
- cls.data.teardown_all()
- super(ObjectTempUrlTest, cls).tearDownClass()
+ super(ObjectTempUrlTest, cls).resource_cleanup()
def setUp(self):
super(ObjectTempUrlTest, self).setUp()
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
index 7d26433..b752348 100644
--- a/tempest/api/object_storage/test_object_temp_url_negative.py
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -31,9 +31,8 @@
containers = []
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(ObjectTempUrlNegativeTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ObjectTempUrlNegativeTest, cls).resource_setup()
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
@@ -47,15 +46,13 @@
cls.account_client.list_account_metadata()
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
resp, _ = cls.account_client.delete_account_metadata(
metadata=cls.metadata)
cls.delete_containers(cls.containers)
- # delete the user setup created
- cls.data.teardown_all()
- super(ObjectTempUrlNegativeTest, cls).tearDownClass()
+ super(ObjectTempUrlNegativeTest, cls).resource_cleanup()
def setUp(self):
super(ObjectTempUrlNegativeTest, self).setUp()
@@ -69,10 +66,10 @@
# create object
self.object_name = data_utils.rand_name(name='ObjectTemp')
- self.data = data_utils.arbitrary_string(size=len(self.object_name),
- base_text=self.object_name)
+ self.content = data_utils.arbitrary_string(size=len(self.object_name),
+ base_text=self.object_name)
self.object_client.create_object(self.container_name,
- self.object_name, self.data)
+ self.object_name, self.content)
def _get_expiry_date(self, expiration_time=1000):
return int(time.time() + expiration_time)
diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index 8d2ff9b..5fe4fc8 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -13,21 +13,26 @@
# License for the specific language governing permissions and limitations
# under the License.
+import testtools
+
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
+from tempest import config
from tempest import test
+CONF = config.CONF
+
class ContainerTest(base.BaseObjectTest):
@classmethod
- def setUpClass(cls):
- super(ContainerTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(ContainerTest, cls).resource_setup()
cls.containers = []
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.delete_containers(cls.containers)
- super(ContainerTest, cls).tearDownClass()
+ super(ContainerTest, cls).resource_cleanup()
def assertContainer(self, container, count, byte, versioned):
resp, _ = self.container_client.list_container_metadata(container)
@@ -41,6 +46,9 @@
self.assertEqual(header_value, versioned)
@test.attr(type='smoke')
+ @testtools.skipIf(
+ not CONF.object_storage_feature_enabled.object_versioning,
+ 'Object-versioning is disabled')
def test_versioned_container(self):
# create container
vers_container_name = data_utils.rand_name(name='TestVersionContainer')
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 0b22de5..5a586fc 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -30,8 +30,8 @@
"""Base test case class for all Orchestration API tests."""
@classmethod
- def setUpClass(cls):
- super(BaseOrchestrationTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(BaseOrchestrationTest, cls).resource_setup()
cls.os = clients.Manager()
if not CONF.service_available.heat:
raise cls.skipException("Heat support is required")
@@ -146,11 +146,11 @@
return yaml.safe_load(f)
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls._clear_stacks()
cls._clear_keypairs()
cls._clear_images()
- super(BaseOrchestrationTest, cls).tearDownClass()
+ super(BaseOrchestrationTest, cls).resource_cleanup()
@staticmethod
def stack_output(stack, output_key):
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index ffadb16..f1a4f85 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -30,9 +30,8 @@
class NeutronResourcesTestJSON(base.BaseOrchestrationTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(NeutronResourcesTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(NeutronResourcesTestJSON, cls).resource_setup()
if not CONF.orchestration.image_ref:
raise cls.skipException("No image available to test")
os = clients.Manager()
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index 72ad5f5..759cbbe 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -25,8 +25,8 @@
class StacksTestJSON(base.BaseOrchestrationTest):
@classmethod
- def setUpClass(cls):
- super(StacksTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(StacksTestJSON, cls).resource_setup()
cls.stack_name = data_utils.rand_name('heat')
template = cls.read_template('non_empty_stack')
image_id = (CONF.orchestration.image_ref or
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index 2f58611..1da340c 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -27,8 +27,8 @@
_type = 'type'
@classmethod
- def setUpClass(cls):
- super(NovaKeyPairResourcesYAMLTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(NovaKeyPairResourcesYAMLTest, cls).resource_setup()
cls.stack_name = data_utils.rand_name('heat')
template = cls.read_template('nova_keypair', ext=cls._tpl_type)
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index 8023f2c..d7fbd65 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -23,8 +23,8 @@
empty_template = "HeatTemplateFormatVersion: '2012-12-12'\n"
@classmethod
- def setUpClass(cls):
- super(StacksTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(StacksTestJSON, cls).resource_setup()
@test.attr(type='smoke')
def test_stack_list_responds(self):
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index cbe62a1..307468e 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -26,9 +26,8 @@
class SwiftResourcesTestJSON(base.BaseOrchestrationTest):
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(SwiftResourcesTestJSON, cls).setUpClass()
+ 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()
@@ -66,9 +65,9 @@
params = {'format': 'json'}
_, container_list = \
self.account_client.list_account_containers(params=params)
- self.assertEqual(2, len(container_list))
- for cont in container_list:
- self.assertTrue(cont['name'].startswith(self.stack_name))
+ created_containers = [cont for cont in container_list
+ if cont['name'].startswith(self.stack_name)]
+ self.assertEqual(2, len(created_containers))
@test.services('object_storage')
def test_acl(self):
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 0d6060d..262c576 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -26,9 +26,8 @@
"""
@classmethod
- @test.safe_setup
- def setUpClass(cls):
- super(TemplateYAMLTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(TemplateYAMLTestJSON, cls).resource_setup()
cls.stack_name = data_utils.rand_name('heat')
cls.stack_identifier = cls.create_stack(cls.stack_name, cls.template)
cls.client.wait_for_stack_status(cls.stack_identifier,
diff --git a/tempest/api/orchestration/stacks/test_templates_negative.py b/tempest/api/orchestration/stacks/test_templates_negative.py
index b325104..9082107 100644
--- a/tempest/api/orchestration/stacks/test_templates_negative.py
+++ b/tempest/api/orchestration/stacks/test_templates_negative.py
@@ -30,8 +30,8 @@
invalid_template_url = 'http://www.example.com/template.yaml'
@classmethod
- def setUpClass(cls):
- super(TemplateYAMLNegativeTestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(TemplateYAMLNegativeTestJSON, cls).resource_setup()
cls.parameters = {}
@test.attr(type=['gate', 'negative'])
diff --git a/tempest/api/orchestration/stacks/test_update.py b/tempest/api/orchestration/stacks/test_update.py
index 791a19b..98761ac 100644
--- a/tempest/api/orchestration/stacks/test_update.py
+++ b/tempest/api/orchestration/stacks/test_update.py
@@ -61,7 +61,6 @@
self.list_resources(stack_identifier))
@test.attr(type='gate')
- @test.skip_because(bug='1308682')
def test_stack_update_add_remove(self):
stack_name = data_utils.rand_name('heat')
stack_identifier = self.create_stack(stack_name, self.template)
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index f371370..f47078c 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -26,8 +26,8 @@
class CinderResourcesTest(base.BaseOrchestrationTest):
@classmethod
- def setUpClass(cls):
- super(CinderResourcesTest, cls).setUpClass()
+ def resource_setup(cls):
+ super(CinderResourcesTest, cls).resource_setup()
if not CONF.service_available.cinder:
raise cls.skipException('Cinder support is required')
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 8c2f37b..769c201 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -26,11 +26,11 @@
"""Base test case class for all Telemetry API tests."""
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if not CONF.service_available.ceilometer:
raise cls.skipException("Ceilometer support is required")
cls.set_network_resources()
- super(BaseTelemetryTest, cls).setUpClass()
+ super(BaseTelemetryTest, cls).resource_setup()
os = cls.get_client_manager()
cls.telemetry_client = os.telemetry_client
cls.servers_client = os.servers_client
@@ -84,12 +84,12 @@
pass
@classmethod
- def tearDownClass(cls):
+ def resource_cleanup(cls):
cls.cleanup_resources(cls.telemetry_client.delete_alarm, cls.alarm_ids)
cls.cleanup_resources(cls.servers_client.delete_server, cls.server_ids)
cls.cleanup_resources(cls.image_client.delete_image, cls.image_ids)
cls.clear_isolated_creds()
- super(BaseTelemetryTest, cls).tearDownClass()
+ super(BaseTelemetryTest, cls).resource_cleanup()
def await_samples(self, metric, query):
"""
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index 95758e8..b45d545 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -20,8 +20,8 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
- super(TelemetryAlarmingAPITestJSON, cls).setUpClass()
+ def resource_setup(cls):
+ super(TelemetryAlarmingAPITestJSON, cls).resource_setup()
cls.rule = {'meter_name': 'cpu_util',
'comparison_operator': 'gt',
'threshold': 80.0,
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 9b15c51..3782b70 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -23,11 +23,11 @@
_interface = 'json'
@classmethod
- def setUpClass(cls):
+ def resource_setup(cls):
if CONF.telemetry.too_slow_to_test:
raise cls.skipException("Ceilometer feature for fast work mysql "
"is disabled")
- super(TelemetryNotificationAPITestJSON, cls).setUpClass()
+ super(TelemetryNotificationAPITestJSON, cls).resource_setup()
@test.attr(type="gate")
@testtools.skipIf(not CONF.service_available.nova,
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index f3b1ad5..769f5e0 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -67,13 +67,13 @@
_, self.volume = self.volume_client.create_volume(
size=1, display_name=vol_name, volume_type=type_name)
- self.volume_client.wait_for_volume_status(
- self.volume['id'], 'available')
if with_prefix:
self.volume_id_list_with_prefix.append(self.volume['id'])
else:
self.volume_id_list_without_prefix.append(
self.volume['id'])
+ self.volume_client.wait_for_volume_status(
+ self.volume['id'], 'available')
@classmethod
def tearDownClass(cls):
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 3cd0827..8aad058 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -69,6 +69,7 @@
if not CONF.volume_feature_enabled.api_v2:
msg = "Volume API v2 is disabled"
raise cls.skipException(msg)
+ cls.snapshots_client = cls.os.snapshots_v2_client
cls.volumes_client = cls.os.volumes_v2_client
cls.volumes_extension_client = cls.os.volumes_v2_extension_client
cls.availability_zone_client = (
@@ -148,11 +149,11 @@
_api_version = 1
-class BaseVolumeV1AdminTest(BaseVolumeV1Test):
+class BaseVolumeAdminTest(BaseVolumeTest):
"""Base test case class for all Volume Admin API tests."""
@classmethod
def setUpClass(cls):
- super(BaseVolumeV1AdminTest, cls).setUpClass()
+ super(BaseVolumeAdminTest, cls).setUpClass()
cls.adm_user = CONF.identity.admin_username
cls.adm_pass = CONF.identity.admin_password
cls.adm_tenant = CONF.identity.admin_tenant_name
@@ -160,11 +161,62 @@
msg = ("Missing Volume Admin API credentials "
"in configuration.")
raise cls.skipException(msg)
+
if CONF.compute.allow_tenant_isolation:
cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(),
interface=cls._interface)
else:
cls.os_adm = clients.AdminManager(interface=cls._interface)
+
+ cls.qos_specs = []
+
cls.client = cls.os_adm.volume_types_client
cls.hosts_client = cls.os_adm.volume_hosts_client
cls.quotas_client = cls.os_adm.volume_quotas_client
+ cls.volume_types_client = cls.os_adm.volume_types_client
+
+ if cls._api_version == 1:
+ if not CONF.volume_feature_enabled.api_v1:
+ msg = "Volume API v1 is disabled"
+ raise cls.skipException(msg)
+ cls.volume_qos_client = cls.os_adm.volume_qos_client
+ elif cls._api_version == 2:
+ if not CONF.volume_feature_enabled.api_v2:
+ msg = "Volume API v2 is disabled"
+ raise cls.skipException(msg)
+ cls.volume_qos_client = cls.os_adm.volume_qos_v2_client
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.clear_qos_specs()
+ super(BaseVolumeAdminTest, cls).tearDownClass()
+
+ @classmethod
+ def create_test_qos_specs(cls, name=None, consumer=None, **kwargs):
+ """create a test Qos-Specs."""
+ name = name or data_utils.rand_name(cls.__name__ + '-QoS')
+ consumer = consumer or 'front-end'
+ _, qos_specs = cls.volume_qos_client.create_qos(name, consumer,
+ **kwargs)
+ cls.qos_specs.append(qos_specs['id'])
+ return qos_specs
+
+ @classmethod
+ def clear_qos_specs(cls):
+ for qos_id in cls.qos_specs:
+ try:
+ cls.volume_qos_client.delete_qos(qos_id)
+ except exceptions.NotFound:
+ # The qos_specs may have already been deleted which is OK.
+ pass
+
+ for qos_id in cls.qos_specs:
+ try:
+ cls.volume_qos_client.wait_for_resource_deletion(qos_id)
+ except exceptions.NotFound:
+ # The qos_specs may have already been deleted which is OK.
+ pass
+
+
+class BaseVolumeV1AdminTest(BaseVolumeAdminTest):
+ _api_version = 1
diff --git a/tempest/api/volume/test_qos.py b/tempest/api/volume/test_qos.py
new file mode 100644
index 0000000..8b6ba49
--- /dev/null
+++ b/tempest/api/volume/test_qos.py
@@ -0,0 +1,176 @@
+# 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.volume import base
+from tempest.common.utils import data_utils as utils
+from tempest import test
+
+
+class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
+ """Test the Cinder QoS-specs.
+
+ Tests for create, list, delete, show, associate,
+ disassociate, set/unset key V2 APIs.
+ """
+
+ @classmethod
+ @test.safe_setup
+ def setUpClass(cls):
+ super(QosSpecsV2TestJSON, cls).setUpClass()
+ # Create admin qos client
+ # Create a test shared qos-specs for tests
+ cls.qos_name = utils.rand_name(cls.__name__ + '-QoS')
+ cls.qos_consumer = 'front-end'
+
+ cls.created_qos = cls.create_test_qos_specs(cls.qos_name,
+ cls.qos_consumer,
+ read_iops_sec='2000')
+
+ def _create_delete_test_qos_with_given_consumer(self, consumer):
+ name = utils.rand_name('qos')
+ qos = {'name': name, 'consumer': consumer}
+ body = self.create_test_qos_specs(name, consumer)
+ for key in ['name', 'consumer']:
+ self.assertEqual(qos[key], body[key])
+
+ self.volume_qos_client.delete_qos(body['id'])
+ self.volume_qos_client.wait_for_resource_deletion(body['id'])
+
+ # validate the deletion
+ _, list_qos = self.volume_qos_client.list_qos()
+ self.assertNotIn(body, list_qos)
+
+ def _create_test_volume_type(self):
+ vol_type_name = utils.rand_name("volume-type")
+ _, vol_type = self.volume_types_client.create_volume_type(
+ vol_type_name)
+ self.addCleanup(self.volume_types_client.delete_volume_type,
+ vol_type['id'])
+ return vol_type
+
+ def _test_associate_qos(self, vol_type_id):
+ self.volume_qos_client.associate_qos(
+ self.created_qos['id'], vol_type_id)
+
+ def _test_get_association_qos(self):
+ _, body = self.volume_qos_client.get_association_qos(
+ self.created_qos['id'])
+
+ associations = []
+ for association in body:
+ associations.append(association['id'])
+
+ return associations
+
+ def test_create_delete_qos_with_front_end_consumer(self):
+ """Tests the creation and deletion of QoS specs
+
+ With consumer as front end
+ """
+ self._create_delete_test_qos_with_given_consumer('front-end')
+
+ def test_create_delete_qos_with_back_end_consumer(self):
+ """Tests the creation and deletion of QoS specs
+
+ With consumer as back-end
+ """
+ self._create_delete_test_qos_with_given_consumer('back-end')
+
+ @test.attr(type='smoke')
+ def test_create_delete_qos_with_both_consumer(self):
+ """Tests the creation and deletion of QoS specs
+
+ With consumer as both front end and back end
+ """
+ self._create_delete_test_qos_with_given_consumer('both')
+
+ @test.attr(type='smoke')
+ def test_get_qos(self):
+ """Tests the detail of a given qos-specs"""
+ _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ self.assertEqual(self.qos_name, body['name'])
+ self.assertEqual(self.qos_consumer, body['consumer'])
+
+ @test.attr(type='smoke')
+ def test_list_qos(self):
+ """Tests the list of all qos-specs"""
+ _, body = self.volume_qos_client.list_qos()
+ self.assertIn(self.created_qos, body)
+
+ @test.attr(type='smoke')
+ def test_set_unset_qos_key(self):
+ """Test the addition of a specs key to qos-specs"""
+ args = {'iops_bytes': '500'}
+ _, body = self.volume_qos_client.set_qos_key(self.created_qos['id'],
+ iops_bytes='500')
+ self.assertEqual(args, body)
+ _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ self.assertEqual(args['iops_bytes'], body['specs']['iops_bytes'])
+
+ # test the deletion of a specs key from qos-specs
+ keys = ['iops_bytes']
+ self.volume_qos_client.unset_qos_key(self.created_qos['id'], keys)
+ operation = 'qos-key-unset'
+ self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],
+ operation, keys)
+ _, body = self.volume_qos_client.get_qos(self.created_qos['id'])
+ self.assertNotIn(keys[0], body['specs'])
+
+ @test.attr(type='smoke')
+ def test_associate_disassociate_qos(self):
+ """Test the following operations :
+
+ 1. associate_qos
+ 2. get_association_qos
+ 3. disassociate_qos
+ 4. disassociate_all_qos
+ """
+
+ # create a test volume-type
+ vol_type = []
+ for _ in range(0, 3):
+ vol_type.append(self._create_test_volume_type())
+
+ # associate the qos-specs with volume-types
+ for i in range(0, 3):
+ self._test_associate_qos(vol_type[i]['id'])
+
+ # get the association of the qos-specs
+ associations = self._test_get_association_qos()
+
+ for i in range(0, 3):
+ self.assertIn(vol_type[i]['id'], associations)
+
+ # disassociate a volume-type with qos-specs
+ self.volume_qos_client.disassociate_qos(
+ self.created_qos['id'], vol_type[0]['id'])
+ operation = 'disassociate'
+ self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],
+ operation,
+ vol_type[0]['id'])
+ associations = self._test_get_association_qos()
+ self.assertNotIn(vol_type[0]['id'], associations)
+
+ # disassociate all volume-types from qos-specs
+ self.volume_qos_client.disassociate_all_qos(
+ self.created_qos['id'])
+ operation = 'disassociate-all'
+ self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],
+ operation)
+ associations = self._test_get_association_qos()
+ self.assertEmpty(associations)
+
+
+class QosSpecsV1TestJSON(QosSpecsV2TestJSON):
+ _api_version = 1
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 94ba095..7040891 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -17,13 +17,12 @@
from tempest import test
-class SnapshotMetadataTest(base.BaseVolumeV1Test):
- _interface = "json"
+class SnapshotV2MetadataTestJSON(base.BaseVolumeTest):
@classmethod
@test.safe_setup
def setUpClass(cls):
- super(SnapshotMetadataTest, cls).setUpClass()
+ super(SnapshotV2MetadataTestJSON, cls).setUpClass()
cls.client = cls.snapshots_client
# Create a volume
cls.volume = cls.create_volume()
@@ -34,7 +33,7 @@
def tearDown(self):
# Update the metadata to {}
self.client.update_snapshot_metadata(self.snapshot_id, {})
- super(SnapshotMetadataTest, self).tearDown()
+ super(SnapshotV2MetadataTestJSON, self).tearDown()
@test.attr(type='gate')
def test_create_get_delete_snapshot_metadata(self):
@@ -100,5 +99,13 @@
self.assertEqual(expect, body)
-class SnapshotMetadataTestXML(SnapshotMetadataTest):
+class SnapshotV2MetadataTestXML(SnapshotV2MetadataTestJSON):
+ _interface = "xml"
+
+
+class SnapshotV1MetadataTestJSON(SnapshotV2MetadataTestJSON):
+ _api_version = 1
+
+
+class SnapshotV1MetadataTestXML(SnapshotV1MetadataTestJSON):
_interface = "xml"
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 7db1ef1..8390f03 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -20,21 +20,19 @@
CONF = config.CONF
-class VolumesSnapshotTest(base.BaseVolumeV1Test):
- _interface = "json"
+class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
@classmethod
@test.safe_setup
def setUpClass(cls):
- super(VolumesSnapshotTest, cls).setUpClass()
+ super(VolumesV2SnapshotTestJSON, cls).setUpClass()
cls.volume_origin = cls.create_volume()
if not CONF.volume_feature_enabled.snapshot:
raise cls.skipException("Cinder volume snapshots are disabled")
- @classmethod
- def tearDownClass(cls):
- super(VolumesSnapshotTest, cls).tearDownClass()
+ cls.name_field = cls.special_fields['name_field']
+ cls.descrip_field = cls.special_fields['descrip_field']
def _detach(self, volume_id):
"""Detach volume."""
@@ -90,8 +88,8 @@
def test_snapshot_create_get_list_update_delete(self):
# Create a snapshot
s_name = data_utils.rand_name('snap')
- snapshot = self.create_snapshot(self.volume_origin['id'],
- display_name=s_name)
+ params = {self.name_field: s_name}
+ snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Get the snap and check for some of its details
_, snap_get = self.snapshots_client.get_snapshot(snapshot['id'])
@@ -100,26 +98,26 @@
"Referred volume origin mismatch")
# Compare also with the output from the list action
- tracking_data = (snapshot['id'], snapshot['display_name'])
+ tracking_data = (snapshot['id'], snapshot[self.name_field])
_, snaps_list = self.snapshots_client.list_snapshots()
- snaps_data = [(f['id'], f['display_name']) for f in snaps_list]
+ snaps_data = [(f['id'], f[self.name_field]) for f in snaps_list]
self.assertIn(tracking_data, snaps_data)
# Updates snapshot with new values
new_s_name = data_utils.rand_name('new-snap')
new_desc = 'This is the new description of snapshot.'
+ params = {self.name_field: new_s_name,
+ self.descrip_field: new_desc}
_, update_snapshot = \
- self.snapshots_client.update_snapshot(snapshot['id'],
- display_name=new_s_name,
- display_description=new_desc)
+ self.snapshots_client.update_snapshot(snapshot['id'], **params)
# Assert response body for update_snapshot method
- self.assertEqual(new_s_name, update_snapshot['display_name'])
- self.assertEqual(new_desc, update_snapshot['display_description'])
+ self.assertEqual(new_s_name, update_snapshot[self.name_field])
+ self.assertEqual(new_desc, update_snapshot[self.descrip_field])
# Assert response body for get_snapshot method
_, updated_snapshot = \
self.snapshots_client.get_snapshot(snapshot['id'])
- self.assertEqual(new_s_name, updated_snapshot['display_name'])
- self.assertEqual(new_desc, updated_snapshot['display_description'])
+ self.assertEqual(new_s_name, updated_snapshot[self.name_field])
+ self.assertEqual(new_desc, updated_snapshot[self.descrip_field])
# Delete the snapshot
self.snapshots_client.delete_snapshot(snapshot['id'])
@@ -131,11 +129,11 @@
"""list snapshots with params."""
# Create a snapshot
display_name = data_utils.rand_name('snap')
- snapshot = self.create_snapshot(self.volume_origin['id'],
- display_name=display_name)
+ params = {self.name_field: display_name}
+ snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Verify list snapshots by display_name filter
- params = {'display_name': snapshot['display_name']}
+ params = {self.name_field: snapshot[self.name_field]}
self._list_by_param_values_and_assert(params)
# Verify list snapshots by status filter
@@ -144,7 +142,7 @@
# Verify list snapshots by status and display name filter
params = {'status': 'available',
- 'display_name': snapshot['display_name']}
+ self.name_field: snapshot[self.name_field]}
self._list_by_param_values_and_assert(params)
@test.attr(type='gate')
@@ -152,18 +150,18 @@
"""list snapshot details with params."""
# Create a snapshot
display_name = data_utils.rand_name('snap')
- snapshot = self.create_snapshot(self.volume_origin['id'],
- display_name=display_name)
+ params = {self.name_field: display_name}
+ snapshot = self.create_snapshot(self.volume_origin['id'], **params)
# Verify list snapshot details by display_name filter
- params = {'display_name': snapshot['display_name']}
+ params = {self.name_field: snapshot[self.name_field]}
self._list_by_param_values_and_assert(params, with_detail=True)
# Verify list snapshot details by status filter
params = {'status': 'available'}
self._list_by_param_values_and_assert(params, with_detail=True)
# Verify list snapshot details by status and display name filter
params = {'status': 'available',
- 'display_name': snapshot['display_name']}
+ self.name_field: snapshot[self.name_field]}
self._list_by_param_values_and_assert(params, with_detail=True)
@test.attr(type='gate')
@@ -181,5 +179,13 @@
self.clear_snapshots()
-class VolumesSnapshotTestXML(VolumesSnapshotTest):
+class VolumesV2SnapshotTestXML(VolumesV2SnapshotTestJSON):
+ _interface = "xml"
+
+
+class VolumesV1SnapshotTestJSON(VolumesV2SnapshotTestJSON):
+ _api_version = 1
+
+
+class VolumesV1SnapshotTestXML(VolumesV1SnapshotTestJSON):
_interface = "xml"
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 61aa307..ddecda8 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -21,12 +21,11 @@
CONF = config.CONF
-class VolumesSnapshotNegativeTest(base.BaseVolumeV1Test):
- _interface = "json"
+class VolumesV2SnapshotNegativeTestJSON(base.BaseVolumeTest):
@classmethod
def setUpClass(cls):
- super(VolumesSnapshotNegativeTest, cls).setUpClass()
+ super(VolumesV2SnapshotNegativeTestJSON, cls).setUpClass()
if not CONF.volume_feature_enabled.snapshot:
raise cls.skipException("Cinder volume snapshots are disabled")
@@ -48,5 +47,13 @@
None, display_name=s_name)
-class VolumesSnapshotNegativeTestXML(VolumesSnapshotNegativeTest):
+class VolumesV2SnapshotNegativeTestXML(VolumesV2SnapshotNegativeTestJSON):
+ _interface = "xml"
+
+
+class VolumesV1SnapshotNegativeTestJSON(VolumesV2SnapshotNegativeTestJSON):
+ _api_version = 1
+
+
+class VolumesV1SnapshotNegativeTestXML(VolumesV1SnapshotNegativeTestJSON):
_interface = "xml"
diff --git a/tempest/api_schema/response/compute/v2/hypervisors.py b/tempest/api_schema/response/compute/v2/hypervisors.py
index 1878881..cbb7698 100644
--- a/tempest/api_schema/response/compute/v2/hypervisors.py
+++ b/tempest/api_schema/response/compute/v2/hypervisors.py
@@ -26,11 +26,7 @@
'items': {
'type': 'object',
'properties': {
- # NOTE: Now the type of 'id' is integer,
- # but here allows 'string' also because we
- # will be able to change it to 'uuid' in
- # the future.
- 'id': {'type': ['integer', 'string']},
+ 'uuid': {'type': 'string'},
'name': {'type': 'string'}
}
}
diff --git a/tempest/api_schema/response/compute/v2/security_group_default_rule.py b/tempest/api_schema/response/compute/v2/security_group_default_rule.py
new file mode 100644
index 0000000..9246ab8
--- /dev/null
+++ b/tempest/api_schema/response/compute/v2/security_group_default_rule.py
@@ -0,0 +1,61 @@
+# Copyright 2014 NEC Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+common_security_group_default_rule_info = {
+ 'type': 'object',
+ 'properties': {
+ 'from_port': {'type': 'integer'},
+ 'id': {'type': 'integer'},
+ 'ip_protocol': {'type': 'string'},
+ 'ip_range': {
+ 'type': 'object',
+ 'properties': {
+ 'cidr': {'type': 'string'}
+ },
+ 'required': ['cidr'],
+ },
+ 'to_port': {'type': 'integer'},
+ },
+ 'required': ['from_port', 'id', 'ip_protocol', 'ip_range', 'to_port'],
+}
+
+create_get_security_group_default_rule = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'security_group_default_rule':
+ common_security_group_default_rule_info
+ },
+ 'required': ['security_group_default_rule']
+ }
+}
+
+delete_security_group_default_rule = {
+ 'status_code': [204]
+}
+
+list_security_group_default_rules = {
+ 'status_code': [200],
+ 'response_body': {
+ 'type': 'object',
+ 'properties': {
+ 'security_group_default_rules': {
+ 'type': 'array',
+ 'items': common_security_group_default_rule_info
+ }
+ },
+ 'required': ['security_group_default_rules']
+ }
+}
diff --git a/tempest/api_schema/response/queuing/__init__.py b/tempest/api_schema/response/messaging/__init__.py
similarity index 100%
rename from tempest/api_schema/response/queuing/__init__.py
rename to tempest/api_schema/response/messaging/__init__.py
diff --git a/tempest/api_schema/response/queuing/v1/__init__.py b/tempest/api_schema/response/messaging/v1/__init__.py
similarity index 100%
rename from tempest/api_schema/response/queuing/v1/__init__.py
rename to tempest/api_schema/response/messaging/v1/__init__.py
diff --git a/tempest/api_schema/response/queuing/v1/queues.py b/tempest/api_schema/response/messaging/v1/queues.py
similarity index 100%
rename from tempest/api_schema/response/queuing/v1/queues.py
rename to tempest/api_schema/response/messaging/v1/queues.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/compute/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/compute/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/data_processing/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/data_processing/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/identity/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/identity/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/image/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/image/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/network/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/network/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/object_storage/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/object_storage/__init__.py
diff --git a/tempest/services/queuing/json/__init__.py b/tempest/cli/simple_read_only/orchestration/__init__.py
similarity index 100%
copy from tempest/services/queuing/json/__init__.py
copy to tempest/cli/simple_read_only/orchestration/__init__.py
diff --git a/tempest/cli/simple_read_only/orchestration/test_heat.py b/tempest/cli/simple_read_only/orchestration/test_heat.py
index 8e413a9..430cdf1 100644
--- a/tempest/cli/simple_read_only/orchestration/test_heat.py
+++ b/tempest/cli/simple_read_only/orchestration/test_heat.py
@@ -38,6 +38,9 @@
"not available")
raise cls.skipException(msg)
super(SimpleReadOnlyHeatClientTest, cls).setUpClass()
+ cls.heat_template_path = os.path.join(os.path.dirname(
+ os.path.dirname(os.path.realpath(__file__))),
+ 'heat_templates/heat_minimal.yaml')
def test_heat_stack_list(self):
self.heat('stack-list')
@@ -56,7 +59,7 @@
def test_heat_resource_template_fmt_arg_long_json(self):
ret = self.heat('resource-template --format json OS::Nova::Server')
- self.assertIn('"Type": "OS::Nova::Server",', ret)
+ self.assertIn('"Type": "OS::Nova::Server"', ret)
self.assertIsInstance(json.loads(ret), dict)
def test_heat_resource_type_list(self):
@@ -70,17 +73,13 @@
self.assertIsInstance(json.loads(rsrc_schema), dict)
def test_heat_template_validate_yaml(self):
- filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
- 'heat_templates/heat_minimal.yaml')
- ret = self.heat('template-validate -f %s' % filepath)
+ ret = self.heat('template-validate -f %s' % self.heat_template_path)
# On success template-validate returns a json representation
# of the template parameters
self.assertIsInstance(json.loads(ret), dict)
def test_heat_template_validate_hot(self):
- filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
- 'heat_templates/heat_minimal_hot.yaml')
- ret = self.heat('template-validate -f %s' % filepath)
+ ret = self.heat('template-validate -f %s' % self.heat_template_path)
self.assertIsInstance(json.loads(ret), dict)
def test_heat_help(self):
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/telemetry/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/telemetry/__init__.py
diff --git a/tempest/api/queuing/__init__.py b/tempest/cli/simple_read_only/volume/__init__.py
similarity index 100%
copy from tempest/api/queuing/__init__.py
copy to tempest/cli/simple_read_only/volume/__init__.py
diff --git a/tempest/cli/simple_read_only/volume/test_cinder.py b/tempest/cli/simple_read_only/volume/test_cinder.py
index 3a9a7a6..e44a577 100644
--- a/tempest/cli/simple_read_only/volume/test_cinder.py
+++ b/tempest/cli/simple_read_only/volume/test_cinder.py
@@ -121,8 +121,12 @@
self.assertTableStruct(zone_list, ['Name', 'Status'])
def test_cinder_endpoints(self):
- endpoints = self.parser.listing(self.cinder('endpoints'))
- self.assertTableStruct(endpoints, ['nova', 'Value'])
+ out = self.cinder('endpoints')
+ tables = self.parser.tables(out)
+ for table in tables:
+ headers = table['headers']
+ self.assertTrue(2 >= len(headers))
+ self.assertEqual('Value', headers[1])
def test_cinder_service_list(self):
service_list = self.parser.listing(self.cinder('service-list'))
diff --git a/tempest/clients.py b/tempest/clients.py
index 2b8b6fb..89cffba 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -151,6 +151,8 @@
from tempest.services.identity.xml.identity_client import TokenClientXML
from tempest.services.image.v1.json.image_client import ImageClientJSON
from tempest.services.image.v2.json.image_client import ImageClientV2JSON
+from tempest.services.messaging.json.messaging_client import \
+ MessagingClientJSON
from tempest.services.network.json.network_client import NetworkClientJSON
from tempest.services.network.xml.network_client import NetworkClientXML
from tempest.services.object_storage.account_client import AccountClient
@@ -162,7 +164,6 @@
ObjectClientCustomizedHeader
from tempest.services.orchestration.json.orchestration_client import \
OrchestrationClient
-from tempest.services.queuing.json.queuing_client import QueuingClientJSON
from tempest.services.telemetry.json.telemetry_client import \
TelemetryClientJSON
from tempest.services.telemetry.xml.telemetry_client import \
@@ -180,17 +181,23 @@
from tempest.services.volume.json.backups_client import BackupsClientJSON
from tempest.services.volume.json.extensions_client import \
ExtensionsClientJSON as VolumeExtensionClientJSON
+from tempest.services.volume.json.qos_client import QosSpecsClientJSON
from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
from tempest.services.volume.json.volumes_client import VolumesClientJSON
from tempest.services.volume.v2.json.availability_zone_client import \
VolumeV2AvailabilityZoneClientJSON
from tempest.services.volume.v2.json.extensions_client import \
ExtensionsV2ClientJSON as VolumeV2ExtensionClientJSON
+from tempest.services.volume.v2.json.qos_client import QosSpecsV2ClientJSON
+from tempest.services.volume.v2.json.snapshots_client import \
+ SnapshotsV2ClientJSON
from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
from tempest.services.volume.v2.xml.availability_zone_client import \
VolumeV2AvailabilityZoneClientXML
from tempest.services.volume.v2.xml.extensions_client import \
ExtensionsV2ClientXML as VolumeV2ExtensionClientXML
+from tempest.services.volume.v2.xml.snapshots_client import \
+ SnapshotsV2ClientXML
from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
from tempest.services.volume.xml.admin.volume_hosts_client import \
VolumeHostsClientXML
@@ -243,6 +250,7 @@
self.auth_provider)
self.backups_client = BackupsClientXML(self.auth_provider)
self.snapshots_client = SnapshotsClientXML(self.auth_provider)
+ self.snapshots_v2_client = SnapshotsV2ClientXML(self.auth_provider)
self.volumes_client = VolumesClientXML(self.auth_provider)
self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
self.volume_types_client = VolumeTypesClientXML(
@@ -322,6 +330,8 @@
self.auth_provider)
self.backups_client = BackupsClientJSON(self.auth_provider)
self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
+ self.snapshots_v2_client = SnapshotsV2ClientJSON(
+ self.auth_provider)
self.volumes_client = VolumesClientJSON(self.auth_provider)
self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider)
self.volume_types_client = VolumeTypesClientJSON(
@@ -382,7 +392,7 @@
self.auth_provider)
self.database_versions_client = DatabaseVersionsClientJSON(
self.auth_provider)
- self.queuing_client = QueuingClientJSON(self.auth_provider)
+ self.messaging_client = MessagingClientJSON(self.auth_provider)
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientJSON(
self.auth_provider)
@@ -428,6 +438,13 @@
self.security_group_default_rules_client = (
SecurityGroupDefaultRulesClientJSON(self.auth_provider))
self.networks_client = NetworksClientJSON(self.auth_provider)
+ # NOTE : As XML clients are not implemented for Qos-specs.
+ # So, setting the qos_client here. Once client are implemented,
+ # qos_client would be moved to its respective if/else.
+ # Bug : 1312553
+ self.volume_qos_client = QosSpecsClientJSON(self.auth_provider)
+ self.volume_qos_v2_client = QosSpecsV2ClientJSON(
+ self.auth_provider)
class AltManager(Manager):
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 436162e..3c41dd9 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -21,7 +21,6 @@
import argparse
import datetime
-import logging
import os
import sys
import unittest
@@ -31,6 +30,7 @@
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
from tempest.services.compute.json import servers_client
@@ -184,7 +184,9 @@
def destroy_users(users):
admin = keystone_admin()
for user in users:
- user_id = admin.identity.get_user_by_name(user['name'])['id']
+ tenant_id = admin.identity.get_tenant_by_name(user['tenant'])['id']
+ user_id = admin.identity.get_user_by_username(tenant_id,
+ user['name'])['id']
r, body = admin.identity.delete_user(user_id)
@@ -213,9 +215,7 @@
self.check_users()
self.check_objects()
self.check_servers()
- # TODO(sdague): Volumes not yet working, bring it back once the
- # code is self testing.
- # self.check_volumes()
+ self.check_volumes()
self.check_telemetry()
def check_users(self):
@@ -300,15 +300,15 @@
LOG.info("checking volumes")
for volume in self.res['volumes']:
client = client_for_user(volume['owner'])
- found = _get_volume_by_name(client, volume['name'])
+ vol_body = _get_volume_by_name(client, volume['name'])
self.assertIsNotNone(
- found,
+ vol_body,
"Couldn't find expected volume %s" % volume['name'])
# Verify that a volume's attachment retrieved
server_id = _get_server_by_name(client, volume['server'])['id']
- attachment = self.client.get_attachment_from_volume(volume)
- self.assertEqual(volume['id'], attachment['volume_id'])
+ attachment = client.volumes.get_attachment_from_volume(vol_body)
+ self.assertEqual(vol_body['id'], attachment['volume_id'])
self.assertEqual(server_id, attachment['server_id'])
def _confirm_telemetry_sample(self, server, sample):
@@ -362,7 +362,7 @@
for obj in objects:
client = client_for_user(obj['owner'])
r, body = client.objects.delete_object(obj['container'], obj['name'])
- if not (200 >= int(r['status']) < 299):
+ if not (200 <= int(r['status']) < 299):
raise ValueError("unable to destroy object: [%s] %s" % (r, body))
@@ -501,8 +501,8 @@
def _get_volume_by_name(client, name):
r, body = client.volumes.list_volumes()
- for volume in body['volumes']:
- if name == volume['name']:
+ for volume in body:
+ if name == volume['display_name']:
return volume
return None
@@ -512,26 +512,32 @@
client = client_for_user(volume['owner'])
# only create a volume if the name isn't here
- r, body = client.volumes.list_volumes()
- if any(item['name'] == volume['name'] for item in body):
+ if _get_volume_by_name(client, volume['name']):
+ LOG.info("volume '%s' already exists" % volume['name'])
continue
- client.volumes.create_volume(volume['name'], volume['size'])
+ size = volume['gb']
+ v_name = volume['name']
+ resp, body = client.volumes.create_volume(size=size,
+ display_name=v_name)
+ client.volumes.wait_for_volume_status(body['id'], 'available')
def destroy_volumes(volumes):
for volume in volumes:
client = client_for_user(volume['owner'])
volume_id = _get_volume_by_name(client, volume['name'])['id']
- r, body = client.volumes.delete_volume(volume_id)
+ client.volumes.detach_volume(volume_id)
+ client.volumes.delete_volume(volume_id)
def attach_volumes(volumes):
for volume in volumes:
client = client_for_user(volume['owner'])
-
server_id = _get_server_by_name(client, volume['server'])['id']
- client.volumes.attach_volume(volume['name'], server_id)
+ volume_id = _get_volume_by_name(client, volume['name'])['id']
+ device = volume['device']
+ client.volumes.attach_volume(volume_id, server_id, device)
#######################
@@ -552,10 +558,8 @@
create_objects(RES['objects'])
create_images(RES['images'])
create_servers(RES['servers'])
- # TODO(sdague): volumes definition doesn't work yet, bring it
- # back once we're actually executing the code
- # create_volumes(RES['volumes'])
- # attach_volumes(RES['volumes'])
+ create_volumes(RES['volumes'])
+ attach_volumes(RES['volumes'])
def destroy_resources():
@@ -564,7 +568,6 @@
destroy_servers(RES['servers'])
destroy_images(RES['images'])
destroy_objects(RES['objects'])
- destroy_servers(RES['servers'])
destroy_volumes(RES['volumes'])
destroy_users(RES['users'])
destroy_tenants(RES['tenants'])
@@ -617,21 +620,10 @@
config.CONF.set_config_path(OPTS.config_file)
-def setup_logging(debug=True):
+def setup_logging():
global LOG
+ logging.setup(__name__)
LOG = logging.getLogger(__name__)
- if debug:
- LOG.setLevel(logging.DEBUG)
- else:
- LOG.setLevel(logging.INFO)
-
- ch = logging.StreamHandler(sys.stdout)
- ch.setLevel(logging.DEBUG)
- formatter = logging.Formatter(
- datefmt='%Y-%m-%d %H:%M:%S',
- fmt='%(asctime)s.%(msecs).03d - %(levelname)s - %(message)s')
- ch.setFormatter(formatter)
- LOG.addHandler(ch)
def main():
diff --git a/tempest/cmd/resources.yaml b/tempest/cmd/resources.yaml
index 3450e1f..19ee6d5 100644
--- a/tempest/cmd/resources.yaml
+++ b/tempest/cmd/resources.yaml
@@ -36,11 +36,13 @@
- name: assegai
server: peltast
owner: javelin
- size: 1
+ gb: 1
+ device: /dev/vdb
- name: pifpouf
server: hoplite
owner: javelin
- size: 2
+ gb: 2
+ device: /dev/vdb
servers:
- name: peltast
owner: javelin
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index cd696a9..5046bff 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -247,7 +247,7 @@
'data_processing': 'sahara',
'baremetal': 'ironic',
'identity': 'keystone',
- 'queuing': 'zaqar',
+ 'messaging': 'zaqar',
'database': 'trove'
}
# Get catalog list for endpoints to use for validation
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index b31c19a..7423c17 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -38,7 +38,12 @@
def __init__(self, name):
super(Accounts, self).__init__(name)
- accounts = read_accounts_yaml(CONF.auth.test_accounts_file)
+ if os.path.isfile(CONF.auth.test_accounts_file):
+ accounts = read_accounts_yaml(CONF.auth.test_accounts_file)
+ self.use_default_creds = False
+ else:
+ accounts = {}
+ self.use_default_creds = True
self.hash_dict = self.get_hash_dict(accounts)
self.accounts_dir = os.path.join(CONF.lock_path, 'test_accounts')
self.isolated_creds = {}
@@ -77,6 +82,9 @@
raise exceptions.InvalidConfiguration(msg)
def _get_creds(self):
+ if self.use_default_creds:
+ raise exceptions.InvalidConfiguration(
+ "Account file %s doesn't exist" % CONF.auth.test_accounts_file)
free_hash = self._get_free_hash(self.hash_dict.keys())
return self.hash_dict[free_hash]
@@ -127,3 +135,50 @@
msg = ('If admin credentials are available tenant_isolation should be'
' used instead')
raise NotImplementedError(msg)
+
+
+class NotLockingAccounts(Accounts):
+ """Credentials provider which always returns the first and second
+ configured accounts as primary and alt users.
+ This credential provider can be used in case of serial test execution
+ to preserve the current behaviour of the serial tempest run.
+ """
+
+ def get_creds(self, id):
+ try:
+ # No need to sort the dict as within the same python process
+ # the HASH seed won't change, so subsequent calls to keys()
+ # will return the same result
+ _hash = self.hash_dict.keys()[id]
+ except IndexError:
+ msg = 'Insufficient number of users provided'
+ raise exceptions.InvalidConfiguration(msg)
+ return self.hash_dict[_hash]
+
+ def get_primary_creds(self):
+ if self.isolated_creds.get('primary'):
+ return self.isolated_creds.get('primary')
+ if not self.use_default_creds:
+ creds = self.get_creds(0)
+ primary_credential = auth.get_credentials(**creds)
+ else:
+ primary_credential = auth.get_default_credentials('user')
+ self.isolated_creds['primary'] = primary_credential
+ return primary_credential
+
+ def get_alt_creds(self):
+ if self.isolated_creds.get('alt'):
+ return self.isolated_creds.get('alt')
+ if not self.use_default_creds:
+ creds = self.get_creds(1)
+ alt_credential = auth.get_credentials(**creds)
+ else:
+ alt_credential = auth.get_default_credentials('alt_user')
+ self.isolated_creds['alt'] = alt_credential
+ return alt_credential
+
+ def clear_isolated_creds(self):
+ self.isolated_creds = {}
+
+ def get_admin_creds(self):
+ return auth.get_default_credentials("identity_admin", fill_in=False)
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index 9808ed1..56d34a5 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -24,8 +24,8 @@
@six.add_metaclass(abc.ABCMeta)
class CredentialProvider(object):
- def __init__(self, name, tempest_client=True, interface='json',
- password='pass', network_resources=None):
+ def __init__(self, name, interface='json', password='pass',
+ network_resources=None):
self.name = name
@abc.abstractmethod
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index dca1f86..b2edfee 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -13,7 +13,6 @@
# under the License.
import netaddr
-from neutronclient.common import exceptions as n_exc
from tempest import auth
from tempest import clients
@@ -29,15 +28,14 @@
class IsolatedCreds(cred_provider.CredentialProvider):
- def __init__(self, name, tempest_client=True, interface='json',
- password='pass', network_resources=None):
- super(IsolatedCreds, self).__init__(name, tempest_client, interface,
- password, network_resources)
+ def __init__(self, name, interface='json', password='pass',
+ network_resources=None):
+ super(IsolatedCreds, self).__init__(name, interface, password,
+ network_resources)
self.network_resources = network_resources
self.isolated_creds = {}
self.isolated_net_resources = {}
self.ports = []
- self.tempest_client = tempest_client
self.interface = interface
self.password = password
self.identity_admin_client, self.network_admin_client = (
@@ -50,94 +48,50 @@
identity
network
"""
- if self.tempest_client:
- os = clients.AdminManager(interface=self.interface)
- else:
- os = clients.OfficialClientManager(
- auth.get_default_credentials('identity_admin')
- )
+ os = clients.AdminManager(interface=self.interface)
return os.identity_client, os.network_client
def _create_tenant(self, name, description):
- if self.tempest_client:
- _, tenant = self.identity_admin_client.create_tenant(
- name=name, description=description)
- else:
- tenant = self.identity_admin_client.tenants.create(
- name,
- description=description)
+ _, tenant = self.identity_admin_client.create_tenant(
+ name=name, description=description)
return tenant
def _get_tenant_by_name(self, name):
- if self.tempest_client:
- _, tenant = self.identity_admin_client.get_tenant_by_name(name)
- else:
- tenants = self.identity_admin_client.tenants.list()
- for ten in tenants:
- if ten['name'] == name:
- tenant = ten
- break
- else:
- raise exceptions.NotFound('No such tenant')
+ _, tenant = self.identity_admin_client.get_tenant_by_name(name)
return tenant
def _create_user(self, username, password, tenant, email):
- if self.tempest_client:
- _, user = self.identity_admin_client.create_user(username,
- password,
- tenant['id'],
- email)
- else:
- user = self.identity_admin_client.users.create(username, password,
- email,
- tenant_id=tenant.id)
+ _, user = self.identity_admin_client.create_user(
+ username, password, tenant['id'], email)
return user
def _get_user(self, tenant, username):
- if self.tempest_client:
- _, user = self.identity_admin_client.get_user_by_username(
- tenant['id'],
- username)
- else:
- user = self.identity_admin_client.users.get(username)
+ _, user = self.identity_admin_client.get_user_by_username(
+ tenant['id'], username)
return user
def _list_roles(self):
- if self.tempest_client:
- _, roles = self.identity_admin_client.list_roles()
- else:
- roles = self.identity_admin_client.roles.list()
+ _, roles = self.identity_admin_client.list_roles()
return roles
def _assign_user_role(self, tenant, user, role_name):
role = None
try:
roles = self._list_roles()
- if self.tempest_client:
- role = next(r for r in roles if r['name'] == role_name)
- else:
- role = next(r for r in roles if r.name == role_name)
+ role = next(r for r in roles if r['name'] == role_name)
except StopIteration:
msg = 'No "%s" role found' % role_name
raise exceptions.NotFound(msg)
- if self.tempest_client:
- self.identity_admin_client.assign_user_role(tenant['id'],
- user['id'], role['id'])
- else:
- self.identity_admin_client.roles.add_user_role(user.id, role.id,
- tenant.id)
+ self.identity_admin_client.assign_user_role(tenant['id'], user['id'],
+ role['id'])
def _delete_user(self, user):
- if self.tempest_client:
- self.identity_admin_client.delete_user(user)
- else:
- self.identity_admin_client.users.delete(user)
+ self.identity_admin_client.delete_user(user)
def _delete_tenant(self, tenant):
- if self.tempest_client:
- self.identity_admin_client.delete_tenant(tenant)
- else:
- self.identity_admin_client.tenants.delete(tenant)
+ if CONF.service_available.neutron:
+ self._cleanup_default_secgroup(tenant)
+ self.identity_admin_client.delete_tenant(tenant)
def _create_creds(self, suffix="", admin=False):
"""Create random credentials under the following schema.
@@ -173,15 +127,9 @@
return self._get_credentials(user, tenant)
def _get_credentials(self, user, tenant):
- if self.tempest_client:
- user_get = user.get
- tenant_get = tenant.get
- else:
- user_get = user.__dict__.get
- tenant_get = tenant.__dict__.get
return auth.get_credentials(
- username=user_get('name'), user_id=user_get('id'),
- tenant_name=tenant_get('name'), tenant_id=tenant_get('id'),
+ username=user['name'], user_id=user['id'],
+ tenant_name=tenant['name'], tenant_id=tenant['id'],
password=self.password)
def _create_network_resources(self, tenant_id):
@@ -226,45 +174,32 @@
return network, subnet, router
def _create_network(self, name, tenant_id):
- if self.tempest_client:
- resp, resp_body = self.network_admin_client.create_network(
- name=name, tenant_id=tenant_id)
- else:
- body = {'network': {'tenant_id': tenant_id, 'name': name}}
- resp_body = self.network_admin_client.create_network(body)
+ _, resp_body = self.network_admin_client.create_network(
+ name=name, tenant_id=tenant_id)
return resp_body['network']
def _create_subnet(self, subnet_name, tenant_id, network_id):
- if not self.tempest_client:
- body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
- 'network_id': network_id, 'ip_version': 4}}
- if self.network_resources:
- body['enable_dhcp'] = self.network_resources['dhcp']
base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
- if self.tempest_client:
- if self.network_resources:
- resp, resp_body = self.network_admin_client.\
- create_subnet(
- network_id=network_id, cidr=str(subnet_cidr),
- name=subnet_name,
- tenant_id=tenant_id,
- enable_dhcp=self.network_resources['dhcp'],
- ip_version=4)
- else:
- resp, resp_body = self.network_admin_client.\
- create_subnet(network_id=network_id,
- cidr=str(subnet_cidr),
- name=subnet_name,
- tenant_id=tenant_id,
- ip_version=4)
+ if self.network_resources:
+ _, resp_body = self.network_admin_client.\
+ create_subnet(
+ network_id=network_id, cidr=str(subnet_cidr),
+ name=subnet_name,
+ tenant_id=tenant_id,
+ enable_dhcp=self.network_resources['dhcp'],
+ ip_version=4)
else:
- body['subnet']['cidr'] = str(subnet_cidr)
- resp_body = self.network_admin_client.create_subnet(body)
+ _, resp_body = self.network_admin_client.\
+ create_subnet(network_id=network_id,
+ cidr=str(subnet_cidr),
+ name=subnet_name,
+ tenant_id=tenant_id,
+ ip_version=4)
break
- except (n_exc.BadRequest, exceptions.BadRequest) as e:
+ except exceptions.BadRequest as e:
if 'overlaps with another subnet' not in str(e):
raise
else:
@@ -276,25 +211,15 @@
def _create_router(self, router_name, tenant_id):
external_net_id = dict(
network_id=CONF.network.public_network_id)
- if self.tempest_client:
- resp, resp_body = self.network_admin_client.create_router(
- router_name,
- external_gateway_info=external_net_id,
- tenant_id=tenant_id)
- else:
- body = {'router': {'name': router_name, 'tenant_id': tenant_id,
- 'external_gateway_info': external_net_id,
- 'admin_state_up': True}}
- resp_body = self.network_admin_client.create_router(body)
+ _, resp_body = self.network_admin_client.create_router(
+ router_name,
+ external_gateway_info=external_net_id,
+ tenant_id=tenant_id)
return resp_body['router']
def _add_router_interface(self, router_id, subnet_id):
- if self.tempest_client:
- self.network_admin_client.add_router_interface_with_subnet_id(
- router_id, subnet_id)
- else:
- body = {'subnet_id': subnet_id}
- self.network_admin_client.add_interface_router(router_id, body)
+ self.network_admin_client.add_router_interface_with_subnet_id(
+ router_id, subnet_id)
def get_primary_network(self):
return self.isolated_net_resources.get('primary')[0]
@@ -376,6 +301,18 @@
LOG.warn('network with name: %s not found for delete' %
network_name)
+ def _cleanup_default_secgroup(self, tenant):
+ net_client = self.network_admin_client
+ _, resp_body = net_client.list_security_groups(tenant_id=tenant,
+ name="default")
+ secgroups_to_delete = resp_body['security_groups']
+ for secgroup in secgroups_to_delete:
+ try:
+ net_client.delete_security_group(secgroup['id'])
+ except exceptions.NotFound:
+ LOG.warn('Security group %s, id %s not found for clean-up' %
+ (secgroup['name'], secgroup['id']))
+
def _clear_isolated_net_resources(self):
net_client = self.network_admin_client
for cred in self.isolated_net_resources:
@@ -386,12 +323,8 @@
if (not self.network_resources or
self.network_resources.get('router')):
try:
- if self.tempest_client:
- net_client.remove_router_interface_with_subnet_id(
- router['id'], subnet['id'])
- else:
- body = {'subnet_id': subnet['id']}
- net_client.remove_interface_router(router['id'], body)
+ net_client.remove_router_interface_with_subnet_id(
+ router['id'], subnet['id'])
except exceptions.NotFound:
LOG.warn('router with name: %s not found for delete' %
router['name'])
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 132d0a6..00fe8d2 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -17,11 +17,11 @@
import collections
import json
import re
-import string
import time
import jsonschema
from lxml import etree
+import six
from tempest.common import http
from tempest.common.utils import misc as misc_utils
@@ -40,6 +40,19 @@
HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
+# convert a structure into a string safely
+def safe_body(body, maxlen=2048):
+ try:
+ text = six.text_type(body)
+ except UnicodeDecodeError:
+ # if this isn't actually text, return marker that
+ return "<BinaryData: removed>"
+ if len(text) > maxlen:
+ return text[:maxlen]
+ else:
+ return text
+
+
class RestClient(object):
TYPE = "json"
@@ -258,6 +271,31 @@
self.LOG.debug('Starting Request (%s): %s %s' %
(caller_name, method, req_url))
+ def _log_request_full(self, method, req_url, resp,
+ secs="", req_headers=None,
+ req_body=None, resp_body=None,
+ caller_name=None, extra=None):
+ if 'X-Auth-Token' in req_headers:
+ req_headers['X-Auth-Token'] = '<omitted>'
+ log_fmt = """Request (%s): %s %s %s%s
+ Request - Headers: %s
+ Body: %s
+ Response - Headers: %s
+ Body: %s"""
+
+ self.LOG.debug(
+ log_fmt % (
+ caller_name,
+ resp['status'],
+ method,
+ req_url,
+ secs,
+ str(req_headers),
+ safe_body(req_body),
+ str(resp),
+ safe_body(resp_body)),
+ extra=extra)
+
def _log_request(self, method, req_url, resp,
secs="", req_headers=None,
req_body=None, resp_body=None):
@@ -281,32 +319,10 @@
secs),
extra=extra)
- # We intentionally duplicate the info content because in a parallel
- # world this is important to match
- trace_regex = CONF.debug.trace_requests
- if trace_regex and re.search(trace_regex, caller_name):
- if 'X-Auth-Token' in req_headers:
- req_headers['X-Auth-Token'] = '<omitted>'
- log_fmt = """Request (%s): %s %s %s%s
- Request - Headers: %s
- Body: %s
- Response - Headers: %s
- Body: %s"""
-
- self.LOG.debug(
- log_fmt % (
- caller_name,
- resp['status'],
- method,
- req_url,
- secs,
- str(req_headers),
- filter(lambda x: x in string.printable,
- str(req_body)[:2048]),
- str(resp),
- filter(lambda x: x in string.printable,
- str(resp_body)[:2048])),
- extra=extra)
+ # Also look everything at DEBUG if you want to filter this
+ # out, don't run at debug.
+ self._log_request_full(method, req_url, resp, secs, req_headers,
+ req_body, resp_body, caller_name, extra)
def _parse_resp(self, body):
if self._get_type() is "json":
@@ -552,7 +568,13 @@
if self.is_resource_deleted(id):
return
if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
+ message = ('Failed to delete resource %(id)s within the '
+ 'required time (%(timeout)s s).' %
+ {'id': id, 'timeout': self.build_timeout})
+ caller = misc_utils.find_test_caller()
+ if caller:
+ message = '(%s) %s' % (caller, message)
+ raise exceptions.TimeoutException(message)
time.sleep(self.build_interval)
def is_resource_deleted(self, id):
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index c4f1214..52568cb 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -131,3 +131,31 @@
if caller:
message = '(%s) %s' % (caller, message)
raise exceptions.TimeoutException(message)
+
+
+def wait_for_bm_node_status(client, node_id, attr, status):
+ """Waits for a baremetal node attribute to reach given status.
+
+ The client should have a show_node(node_uuid) method to get the node.
+ """
+ _, node = client.show_node(node_id)
+ start = int(time.time())
+
+ while node[attr] != status:
+ time.sleep(client.build_interval)
+ _, node = client.show_node(node_id)
+ if node[attr] == status:
+ return
+
+ if int(time.time()) - start >= client.build_timeout:
+ message = ('Node %(node_id)s failed to reach %(attr)s=%(status)s '
+ 'within the required time (%(timeout)s s).' %
+ {'node_id': node_id,
+ 'attr': attr,
+ 'status': status,
+ 'timeout': client.build_timeout})
+ message += ' Current state of %s: %s.' % (attr, node[attr])
+ caller = misc_utils.find_test_caller()
+ if caller:
+ message = '(%s) %s' % (caller, message)
+ raise exceptions.TimeoutException(message)
diff --git a/tempest/config.py b/tempest/config.py
index 93d4874..cea9dec 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -419,10 +419,10 @@
default=28,
help="The mask bits for tenant ipv4 subnets"),
cfg.StrOpt('tenant_network_v6_cidr',
- default="2003::/64",
+ default="2003::/48",
help="The cidr block to allocate tenant ipv6 subnets from"),
cfg.IntOpt('tenant_network_v6_mask_bits',
- default=96,
+ default=64,
help="The mask bits for tenant ipv6 subnets"),
cfg.BoolOpt('tenant_networks_reachable',
default=False,
@@ -470,13 +470,13 @@
)
]
-queuing_group = cfg.OptGroup(name='queuing',
- title='Queuing Service')
+messaging_group = cfg.OptGroup(name='messaging',
+ title='Messaging Service')
-QueuingGroup = [
+MessagingGroup = [
cfg.StrOpt('catalog_type',
- default='queuing',
- help='Catalog type of the Queuing service.'),
+ default='messaging',
+ help='Catalog type of the Messaging service.'),
cfg.IntOpt('max_queues_per_page',
default=20,
help='The maximum number of queue records per page when '
@@ -622,6 +622,15 @@
help="A list of the enabled optional discoverable apis. "
"A single entry, all, indicates that all of these "
"features are expected to be enabled"),
+ cfg.BoolOpt('container_sync',
+ default=True,
+ help="Execute (old style) container-sync tests"),
+ cfg.BoolOpt('object_versioning',
+ default=True,
+ help="Execute object-versioning tests"),
+ cfg.BoolOpt('discoverability',
+ default=True,
+ help="Execute discoverability tests"),
]
database_group = cfg.OptGroup(name='database',
@@ -1025,7 +1034,7 @@
register_opt_group(cfg.CONF, network_group, NetworkGroup)
register_opt_group(cfg.CONF, network_feature_group,
NetworkFeaturesGroup)
- register_opt_group(cfg.CONF, queuing_group, QueuingGroup)
+ register_opt_group(cfg.CONF, messaging_group, MessagingGroup)
register_opt_group(cfg.CONF, volume_group, VolumeGroup)
register_opt_group(cfg.CONF, volume_feature_group,
VolumeFeaturesGroup)
@@ -1082,7 +1091,7 @@
'object-storage-feature-enabled']
self.database = cfg.CONF.database
self.orchestration = cfg.CONF.orchestration
- self.queuing = cfg.CONF.queuing
+ self.messaging = cfg.CONF.messaging
self.telemetry = cfg.CONF.telemetry
self.dashboard = cfg.CONF.dashboard
self.data_processing = cfg.CONF.data_processing
diff --git a/tempest/manager.py b/tempest/manager.py
index fb2842f..75aee96 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -51,17 +51,17 @@
self.client_attr_names = []
@classmethod
- def get_auth_provider_class(cls, auth_version):
- if auth_version == 'v2':
- return auth.KeystoneV2AuthProvider
- else:
+ def get_auth_provider_class(cls, credentials):
+ if isinstance(credentials, auth.KeystoneV3Credentials):
return auth.KeystoneV3AuthProvider
+ else:
+ return auth.KeystoneV2AuthProvider
def get_auth_provider(self, credentials):
if credentials is None:
raise exceptions.InvalidCredentials(
'Credentials must be specified')
- auth_provider_class = self.get_auth_provider_class(self.auth_version)
+ auth_provider_class = self.get_auth_provider_class(credentials)
return auth_provider_class(
client_type=getattr(self, 'client_type', None),
interface=getattr(self, 'interface', None),
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index dfd4658..559f3d5 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -16,16 +16,9 @@
import logging
import os
-import re
import subprocess
-import time
-from cinderclient import exceptions as cinder_exceptions
-import glanceclient
-from heatclient import exc as heat_exceptions
import netaddr
-from neutronclient.common import exceptions as exc
-from novaclient import exceptions as nova_exceptions
import six
from tempest.api.network import common as net_common
@@ -38,7 +31,6 @@
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log
-from tempest.openstack.common import timeutils
from tempest.services.network import resources as net_resources
import tempest.test
@@ -70,13 +62,13 @@
super(ScenarioTest, cls).setUpClass()
# Using tempest client for isolated credentials as well
cls.isolated_creds = isolated_creds.IsolatedCreds(
- cls.__name__, tempest_client=True,
- network_resources=cls.network_resources)
+ cls.__name__, network_resources=cls.network_resources)
cls.manager = clients.Manager(
credentials=cls.credentials()
)
cls.admin_manager = clients.Manager(cls.admin_credentials())
# Clients (in alphabetical order)
+ cls.flavors_client = cls.manager.flavors_client
cls.floating_ips_client = cls.manager.floating_ips_client
# Glance image client v1
cls.image_client = cls.manager.image_client
@@ -92,13 +84,8 @@
cls.interface_client = cls.manager.interfaces_client
# Neutron network client
cls.network_client = cls.manager.network_client
-
- @classmethod
- def tearDownClass(cls):
- # Isolated creds also manages network resources, which should
- # be cleaned up at the end of the test case
- cls.isolated_creds.clear_isolated_creds()
- super(ScenarioTest, cls).tearDownClass()
+ # Heat client
+ cls.orchestration_client = cls.manager.orchestration_client
@classmethod
def _get_credentials(cls, get_creds, ctype):
@@ -114,6 +101,11 @@
'user')
@classmethod
+ def alt_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_alt_creds,
+ 'alt_user')
+
+ @classmethod
def admin_credentials(cls):
return cls._get_credentials(cls.isolated_creds.get_admin_creds,
'identity_admin')
@@ -150,7 +142,7 @@
def addCleanup_with_wait(self, waiter_callable, thing_id, thing_id_param,
cleanup_callable, cleanup_args=None,
cleanup_kwargs=None, ignore_error=True):
- """Adds wait for ansyc resource deletion at the end of cleanups
+ """Adds wait for async resource deletion at the end of cleanups
@param waiter_callable: callable to wait for the resource to delete
@param thing_id: the id of the resource to be cleaned-up
@@ -188,11 +180,13 @@
# The create_[resource] functions only return body and discard the
# resp part which is not used in scenario tests
- def create_keypair(self):
+ def create_keypair(self, client=None):
+ if not client:
+ client = self.keypairs_client
name = data_utils.rand_name(self.__class__.__name__)
# We don't need to create a keypair by pubkey in scenario
- resp, body = self.keypairs_client.create_keypair(name)
- self.addCleanup(self.keypairs_client.delete_keypair, name)
+ resp, body = client.create_keypair(name)
+ self.addCleanup(client.delete_keypair, name)
return body
def create_server(self, name=None, image=None, flavor=None,
@@ -215,26 +209,6 @@
if create_kwargs is None:
create_kwargs = {}
- fixed_network_name = CONF.compute.fixed_network_name
- if 'nics' not in create_kwargs and fixed_network_name:
- _, networks = self.networks_client.list_networks()
- # If several networks found, set the NetID on which to connect the
- # server to avoid the following error "Multiple possible networks
- # found, use a Network ID to be more specific."
- # See Tempest #1250866
- if len(networks) > 1:
- for network in networks:
- if network['label'] == fixed_network_name:
- create_kwargs['nics'] = [{'net-id': network['id']}]
- break
- # If we didn't find the network we were looking for :
- else:
- msg = ("The network on which the NIC of the server must "
- "be connected can not be found : "
- "fixed_network_name=%s. Starting instance without "
- "specifying a network.") % fixed_network_name
- LOG.info(msg)
-
LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
name, image, flavor)
_, server = self.servers_client.create_server(name, image, flavor,
@@ -264,14 +238,18 @@
_, volume = self.volumes_client.create_volume(
size=size, display_name=name, snapshot_id=snapshot_id,
imageRef=imageRef, volume_type=volume_type)
+
if wait_on_delete:
self.addCleanup(self.volumes_client.wait_for_resource_deletion,
volume['id'])
- self.addCleanup_with_wait(
- waiter_callable=self.volumes_client.wait_for_resource_deletion,
- thing_id=volume['id'], thing_id_param='id',
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.volumes_client.delete_volume, volume['id']])
+ self.addCleanup(self.delete_wrapper,
+ self.volumes_client.delete_volume, volume['id'])
+ else:
+ self.addCleanup_with_wait(
+ waiter_callable=self.volumes_client.wait_for_resource_deletion,
+ thing_id=volume['id'], thing_id_param='id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[self.volumes_client.delete_volume, volume['id']])
self.assertEqual(name, volume['display_name'])
self.volumes_client.wait_for_volume_status(volume['id'], 'available')
@@ -339,8 +317,9 @@
if isinstance(server_or_ip, six.string_types):
ip = server_or_ip
else:
- network_name_for_ssh = CONF.compute.network_for_ssh
- ip = server_or_ip.networks[network_name_for_ssh][0]
+ addr = server_or_ip['addresses'][CONF.compute.network_for_ssh][0]
+ ip = addr['addr']
+
if username is None:
username = CONF.scenario.ssh_user
if private_key is None:
@@ -439,10 +418,55 @@
image_name, server['name'])
return snapshot_image
+ def nova_volume_attach(self):
+ # TODO(andreaf) Device should be here CONF.compute.volume_device_name
+ _, volume_attachment = self.servers_client.attach_volume(
+ self.server['id'], self.volume['id'], '/dev/vdb')
+ volume = volume_attachment['volumeAttachment']
+ self.assertEqual(self.volume['id'], volume['id'])
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+ # Refresh the volume after the attachment
+ _, self.volume = self.volumes_client.get_volume(volume['id'])
-# TODO(yfried): change this class name to NetworkScenarioTest once client
-# migration is complete
-class NeutronScenarioTest(ScenarioTest):
+ def nova_volume_detach(self):
+ self.servers_client.detach_volume(self.server['id'], self.volume['id'])
+ self.volumes_client.wait_for_volume_status(self.volume['id'],
+ 'available')
+
+ _, volume = self.volumes_client.get_volume(self.volume['id'])
+ self.assertEqual('available', volume['status'])
+
+ def rebuild_server(self, server_id, image=None,
+ preserve_ephemeral=False, wait=True,
+ rebuild_kwargs=None):
+ if image is None:
+ image = CONF.compute.image_ref
+
+ rebuild_kwargs = rebuild_kwargs or {}
+
+ LOG.debug("Rebuilding server (id: %s, image: %s, preserve eph: %s)",
+ server_id, image, preserve_ephemeral)
+ self.servers_client.rebuild(server_id=server_id, image_ref=image,
+ preserve_ephemeral=preserve_ephemeral,
+ **rebuild_kwargs)
+ if wait:
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+
+ def ping_ip_address(self, ip_address, should_succeed=True):
+ cmd = ['ping', '-c1', '-w1', ip_address]
+
+ def ping():
+ proc = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ proc.communicate()
+ return (proc.returncode == 0) == should_succeed
+
+ return tempest.test.call_until_true(
+ ping, CONF.compute.ping_timeout, 1)
+
+
+class NetworkScenarioTest(ScenarioTest):
"""Base class for network scenario tests.
This class provide helpers for network scenario tests, using the neutron
API. Helpers from ancestor which use the nova network API are overridden
@@ -455,30 +479,24 @@
@classmethod
def check_preconditions(cls):
- if CONF.service_available.neutron:
- cls.enabled = True
- # verify that neutron_available is telling the truth
- try:
- cls.network_client.list_networks()
- except exc.EndpointNotFound:
- cls.enabled = False
- raise
- else:
- cls.enabled = False
- msg = 'Neutron not available'
- raise cls.skipException(msg)
+ if not CONF.service_available.neutron:
+ raise cls.skipException('Neutron not available')
@classmethod
def setUpClass(cls):
- super(NeutronScenarioTest, cls).setUpClass()
+ super(NetworkScenarioTest, cls).setUpClass()
cls.tenant_id = cls.manager.identity_client.tenant_id
cls.check_preconditions()
- def _create_network(self, tenant_id, namestart='network-smoke-'):
+ def _create_network(self, client=None, tenant_id=None,
+ namestart='network-smoke-'):
+ if not client:
+ client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
name = data_utils.rand_name(namestart)
- _, result = self.network_client.create_network(name=name,
- tenant_id=tenant_id)
- network = net_resources.DeletableNetwork(client=self.network_client,
+ _, result = client.create_network(name=name, tenant_id=tenant_id)
+ network = net_resources.DeletableNetwork(client=client,
**result['network'])
self.assertEqual(network.name, name)
self.addCleanup(self.delete_wrapper, network.delete)
@@ -508,11 +526,14 @@
return resource_list[resource_type]
return temp
- def _create_subnet(self, network, namestart='subnet-smoke-', **kwargs):
+ def _create_subnet(self, network, client=None, namestart='subnet-smoke',
+ **kwargs):
"""
Create a subnet for the given network within the cidr block
configured for tenant networks.
"""
+ if not client:
+ client = self.network_client
def cidr_in_use(cidr, tenant_id):
"""
@@ -541,27 +562,29 @@
**kwargs
)
try:
- _, result = self.network_client.create_subnet(**subnet)
+ _, result = client.create_subnet(**subnet)
break
- except exc.NeutronClientException as e:
+ except exceptions.Conflict as e:
is_overlapping_cidr = 'overlaps with another subnet' in str(e)
if not is_overlapping_cidr:
raise
self.assertIsNotNone(result, 'Unable to allocate tenant network')
- subnet = net_resources.DeletableSubnet(client=self.network_client,
+ subnet = net_resources.DeletableSubnet(client=client,
**result['subnet'])
self.assertEqual(subnet.cidr, str_cidr)
self.addCleanup(self.delete_wrapper, subnet.delete)
return subnet
- def _create_port(self, network, namestart='port-quotatest'):
+ def _create_port(self, network, client=None, namestart='port-quotatest'):
+ if not client:
+ client = self.network_client
name = data_utils.rand_name(namestart)
- _, result = self.network_client.create_port(
+ _, result = client.create_port(
name=name,
network_id=network.id,
tenant_id=network.tenant_id)
self.assertIsNotNone(result, 'Unable to allocate port')
- port = net_resources.DeletablePort(client=self.network_client,
+ port = net_resources.DeletablePort(client=client,
**result['port'])
self.addCleanup(self.delete_wrapper, port.delete)
return port
@@ -577,16 +600,19 @@
net = self._list_networks(name=network_name)
return net_common.AttributeDict(net[0])
- def _create_floating_ip(self, thing, external_network_id, port_id=None):
+ def _create_floating_ip(self, thing, external_network_id, port_id=None,
+ client=None):
+ if not client:
+ client = self.network_client
if not port_id:
port_id = self._get_server_port_id(thing)
- _, result = self.network_client.create_floatingip(
+ _, result = client.create_floatingip(
floating_network_id=external_network_id,
port_id=port_id,
tenant_id=thing['tenant_id']
)
floating_ip = net_resources.DeletableFloatingIp(
- client=self.network_client,
+ client=client,
**result['floatingip'])
self.addCleanup(self.delete_wrapper, floating_ip.delete)
return floating_ip
@@ -605,19 +631,6 @@
self.assertIsNone(floating_ip.port_id)
return floating_ip
- def _ping_ip_address(self, ip_address, should_succeed=True):
- cmd = ['ping', '-c1', '-w1', ip_address]
-
- def ping():
- proc = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- proc.wait()
- return (proc.returncode == 0) == should_succeed
-
- return tempest.test.call_until_true(
- ping, CONF.compute.ping_timeout, 1)
-
def _check_vm_connectivity(self, ip_address,
username=None,
private_key=None,
@@ -637,8 +650,8 @@
msg = "Timed out waiting for %s to become reachable" % ip_address
else:
msg = "ip address %s is reachable" % ip_address
- self.assertTrue(self._ping_ip_address(ip_address,
- should_succeed=should_connect),
+ self.assertTrue(self.ping_ip_address(ip_address,
+ should_succeed=should_connect),
msg=msg)
if should_connect:
# no need to check ssh for negative connectivity
@@ -716,10 +729,12 @@
CONF.compute.ping_timeout,
1)
- def _create_security_group(self, tenant_id, client=None,
+ def _create_security_group(self, client=None, tenant_id=None,
namestart='secgroup-smoke'):
if client is None:
client = self.network_client
+ if tenant_id is None:
+ tenant_id = client.rest_client.tenant_id
secgroup = self._create_empty_security_group(namestart=namestart,
client=client,
tenant_id=tenant_id)
@@ -731,7 +746,7 @@
self.assertEqual(secgroup.id, rule.security_group_id)
return secgroup
- def _create_empty_security_group(self, tenant_id, client=None,
+ def _create_empty_security_group(self, client=None, tenant_id=None,
namestart='secgroup-smoke'):
"""Create a security group without rules.
@@ -744,6 +759,8 @@
"""
if client is None:
client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
sg_name = data_utils.rand_name(namestart)
sg_desc = sg_name + " description"
sg_dict = dict(name=sg_name,
@@ -760,26 +777,25 @@
self.addCleanup(self.delete_wrapper, secgroup.delete)
return secgroup
- def _default_security_group(self, tenant_id, client=None):
+ def _default_security_group(self, client=None, tenant_id=None):
"""Get default secgroup for given tenant_id.
:returns: DeletableSecurityGroup -- default secgroup for given tenant
"""
if client is None:
client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
sgs = [
sg for sg in client.list_security_groups().values()[0]
if sg['tenant_id'] == tenant_id and sg['name'] == 'default'
]
msg = "No default security group for tenant %s." % (tenant_id)
self.assertTrue(len(sgs) > 0, msg)
- if len(sgs) > 1:
- msg = "Found %d default security groups" % len(sgs)
- raise exc.NeutronClientNoUniqueMatch(msg=msg)
return net_resources.DeletableSecurityGroup(client=client,
**sgs[0])
- def _create_security_group_rule(self, client=None, secgroup=None,
+ def _create_security_group_rule(self, secgroup=None, client=None,
tenant_id=None, **kwargs):
"""Create a rule from a dictionary of rule parameters.
@@ -787,8 +803,6 @@
default secgroup in tenant_id.
:param secgroup: type DeletableSecurityGroup.
- :param secgroup_id: search for secgroup by id
- default -- choose default secgroup for given tenant_id
:param tenant_id: if secgroup not passed -- the tenant in which to
search for default secgroup
:param kwargs: a dictionary containing rule parameters:
@@ -802,8 +816,11 @@
"""
if client is None:
client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
if secgroup is None:
- secgroup = self._default_security_group(tenant_id)
+ secgroup = self._default_security_group(client=client,
+ tenant_id=tenant_id)
ruleset = dict(security_group_id=secgroup.id,
tenant_id=secgroup.tenant_id)
@@ -859,13 +876,48 @@
return rules
+ def _create_pool(self, lb_method, protocol, subnet_id):
+ """Wrapper utility that returns a test pool."""
+ client = self.network_client
+ name = data_utils.rand_name('pool')
+ _, resp_pool = client.create_pool(protocol=protocol, name=name,
+ subnet_id=subnet_id,
+ lb_method=lb_method)
+ pool = net_resources.DeletablePool(client=client, **resp_pool['pool'])
+ self.assertEqual(pool['name'], name)
+ self.addCleanup(self.delete_wrapper, pool.delete)
+ return pool
+
+ def _create_member(self, address, protocol_port, pool_id):
+ """Wrapper utility that returns a test member."""
+ client = self.network_client
+ _, resp_member = client.create_member(protocol_port=protocol_port,
+ pool_id=pool_id,
+ address=address)
+ member = net_resources.DeletableMember(client=client,
+ **resp_member['member'])
+ self.addCleanup(self.delete_wrapper, member.delete)
+ return member
+
+ def _create_vip(self, protocol, protocol_port, subnet_id, pool_id):
+ """Wrapper utility that returns a test vip."""
+ client = self.network_client
+ name = data_utils.rand_name('vip')
+ _, resp_vip = client.create_vip(protocol=protocol, name=name,
+ subnet_id=subnet_id, pool_id=pool_id,
+ protocol_port=protocol_port)
+ vip = net_resources.DeletableVip(client=client, **resp_vip['vip'])
+ self.assertEqual(vip['name'], name)
+ self.addCleanup(self.delete_wrapper, vip.delete)
+ return vip
+
def _ssh_to_server(self, server, private_key):
ssh_login = CONF.compute.image_ssh_user
return self.get_remote_client(server,
username=ssh_login,
private_key=private_key)
- def _get_router(self, tenant_id):
+ def _get_router(self, client=None, tenant_id=None):
"""Retrieve a router for the given tenant id.
If a public router has been configured, it will be returned.
@@ -874,31 +926,40 @@
network has, a tenant router will be created and returned that
routes traffic to the public network.
"""
+ if not client:
+ client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
router_id = CONF.network.public_router_id
network_id = CONF.network.public_network_id
if router_id:
- result = self.network_client.show_router(router_id)
+ result = client.show_router(router_id)
return net_resources.AttributeDict(**result['router'])
elif network_id:
- router = self._create_router(tenant_id)
+ router = self._create_router(client, tenant_id)
router.set_gateway(network_id)
return router
else:
raise Exception("Neither of 'public_router_id' or "
"'public_network_id' has been defined.")
- def _create_router(self, tenant_id, namestart='router-smoke-'):
+ def _create_router(self, client=None, tenant_id=None,
+ namestart='router-smoke'):
+ if not client:
+ client = self.network_client
+ if not tenant_id:
+ tenant_id = client.rest_client.tenant_id
name = data_utils.rand_name(namestart)
- _, result = self.network_client.create_router(name=name,
- admin_state_up=True,
- tenant_id=tenant_id, )
- router = net_resources.DeletableRouter(client=self.network_client,
+ _, result = client.create_router(name=name,
+ admin_state_up=True,
+ tenant_id=tenant_id)
+ router = net_resources.DeletableRouter(client=client,
**result['router'])
self.assertEqual(router.name, name)
self.addCleanup(self.delete_wrapper, router.delete)
return router
- def create_networks(self, tenant_id=None):
+ def create_networks(self, client=None, tenant_id=None):
"""Create a network with a subnet connected to a router.
The baremetal driver is a special case since all nodes are
@@ -917,525 +978,13 @@
router = None
subnet = None
else:
- if tenant_id is None:
- tenant_id = self.tenant_id
- network = self._create_network(tenant_id)
- router = self._get_router(tenant_id)
- subnet = self._create_subnet(network)
+ network = self._create_network(client=client, tenant_id=tenant_id)
+ router = self._get_router(client=client, tenant_id=tenant_id)
+ subnet = self._create_subnet(network=network, client=client)
subnet.add_to_router(router.id)
return network, subnet, router
-class OfficialClientTest(tempest.test.BaseTestCase):
- """
- Official Client test base class for scenario testing.
-
- Official Client tests are tests that have the following characteristics:
-
- * Test basic operations of an API, typically in an order that
- a regular user would perform those operations
- * Test only the correct inputs and action paths -- no fuzz or
- random input data is sent, only valid inputs.
- * Use only the default client tool for calling an API
- """
-
- @classmethod
- def setUpClass(cls):
- super(OfficialClientTest, cls).setUpClass()
- cls.isolated_creds = isolated_creds.IsolatedCreds(
- cls.__name__, tempest_client=False,
- network_resources=cls.network_resources)
-
- cls.manager = clients.OfficialClientManager(
- credentials=cls.credentials())
- cls.compute_client = cls.manager.compute_client
- cls.image_client = cls.manager.image_client
- cls.baremetal_client = cls.manager.baremetal_client
- cls.identity_client = cls.manager.identity_client
- cls.network_client = cls.manager.network_client
- cls.volume_client = cls.manager.volume_client
- cls.object_storage_client = cls.manager.object_storage_client
- cls.orchestration_client = cls.manager.orchestration_client
- cls.data_processing_client = cls.manager.data_processing_client
- cls.ceilometer_client = cls.manager.ceilometer_client
-
- @classmethod
- def tearDownClass(cls):
- cls.isolated_creds.clear_isolated_creds()
- super(OfficialClientTest, cls).tearDownClass()
-
- @classmethod
- def _get_credentials(cls, get_creds, ctype):
- if CONF.compute.allow_tenant_isolation:
- creds = get_creds()
- else:
- creds = auth.get_default_credentials(ctype)
- return creds
-
- @classmethod
- def credentials(cls):
- return cls._get_credentials(cls.isolated_creds.get_primary_creds,
- 'user')
-
- @classmethod
- def alt_credentials(cls):
- return cls._get_credentials(cls.isolated_creds.get_alt_creds,
- 'alt_user')
-
- @classmethod
- def admin_credentials(cls):
- return cls._get_credentials(cls.isolated_creds.get_admin_creds,
- 'identity_admin')
-
- def setUp(self):
- super(OfficialClientTest, self).setUp()
- self.cleanup_waits = []
- # NOTE(mtreinish) This is safe to do in setUp instead of setUp class
- # because scenario tests in the same test class should not share
- # resources. If resources were shared between test cases then it
- # should be a single scenario test instead of multiples.
-
- # NOTE(yfried): this list is cleaned at the end of test_methods and
- # not at the end of the class
- self.addCleanup(self._wait_for_cleanups)
-
- @staticmethod
- def not_found_exception(exception):
- """
- @return: True if exception is of NotFound type
- """
- NOT_FOUND_LIST = ['NotFound', 'HTTPNotFound']
- return (exception.__class__.__name__ in NOT_FOUND_LIST
- or
- hasattr(exception, 'status_code') and
- exception.status_code == 404)
-
- def delete_wrapper(self, thing):
- """Ignores NotFound exceptions for delete operations.
-
- @param thing: object with delete() method.
- OpenStack resources are assumed to have a delete() method which
- destroys the resource
- """
-
- try:
- thing.delete()
- except Exception as e:
- # If the resource is already missing, mission accomplished.
- if not self.not_found_exception(e):
- raise
-
- def _wait_for_cleanups(self):
- """To handle async delete actions, a list of waits is added
- which will be iterated over as the last step of clearing the
- cleanup queue. That way all the delete calls are made up front
- and the tests won't succeed unless the deletes are eventually
- successful. This is the same basic approach used in the api tests to
- limit cleanup execution time except here it is multi-resource,
- because of the nature of the scenario tests.
- """
- for wait in self.cleanup_waits:
- self.delete_timeout(**wait)
-
- def addCleanup_with_wait(self, things, thing_id,
- error_status='ERROR',
- exc_type=nova_exceptions.NotFound,
- cleanup_callable=None, cleanup_args=None,
- cleanup_kwargs=None):
- """Adds wait for ansyc resource deletion at the end of cleanups
-
- @param things: type of the resource to delete
- @param thing_id:
- @param error_status: see manager.delete_timeout()
- @param exc_type: see manager.delete_timeout()
- @param cleanup_callable: method to load pass to self.addCleanup with
- the following *cleanup_args, **cleanup_kwargs.
- usually a delete method. if not used, will try to use:
- things.delete(thing_id)
- """
- if cleanup_args is None:
- cleanup_args = []
- if cleanup_kwargs is None:
- cleanup_kwargs = {}
- if cleanup_callable is None:
- LOG.debug("no delete method passed. using {rclass}.delete({id}) as"
- " default".format(rclass=things, id=thing_id))
- self.addCleanup(things.delete, thing_id)
- else:
- self.addCleanup(cleanup_callable, *cleanup_args, **cleanup_kwargs)
- wait_dict = {
- 'things': things,
- 'thing_id': thing_id,
- 'error_status': error_status,
- 'not_found_exception': exc_type,
- }
- self.cleanup_waits.append(wait_dict)
-
- def status_timeout(self, things, thing_id, expected_status,
- error_status='ERROR',
- not_found_exception=nova_exceptions.NotFound):
- """
- Given a thing and an expected status, do a loop, sleeping
- for a configurable amount of time, checking for the
- expected status to show. At any time, if the returned
- status of the thing is ERROR, fail out.
- """
- self._status_timeout(things, thing_id,
- expected_status=expected_status,
- error_status=error_status,
- not_found_exception=not_found_exception)
-
- def delete_timeout(self, things, thing_id,
- error_status='ERROR',
- not_found_exception=nova_exceptions.NotFound):
- """
- Given a thing, do a loop, sleeping
- for a configurable amount of time, checking for the
- deleted status to show. At any time, if the returned
- status of the thing is ERROR, fail out.
- """
- self._status_timeout(things,
- thing_id,
- allow_notfound=True,
- error_status=error_status,
- not_found_exception=not_found_exception)
-
- def _status_timeout(self,
- things,
- thing_id,
- expected_status=None,
- allow_notfound=False,
- error_status='ERROR',
- not_found_exception=nova_exceptions.NotFound):
-
- log_status = expected_status if expected_status else ''
- if allow_notfound:
- log_status += ' or NotFound' if log_status != '' else 'NotFound'
-
- def check_status():
- # python-novaclient has resources available to its client
- # that all implement a get() method taking an identifier
- # for the singular resource to retrieve.
- try:
- thing = things.get(thing_id)
- except not_found_exception:
- if allow_notfound:
- return True
- raise
- except Exception as e:
- if allow_notfound and self.not_found_exception(e):
- return True
- raise
-
- new_status = thing.status
-
- # Some components are reporting error status in lower case
- # so case sensitive comparisons can really mess things
- # up.
- if new_status.lower() == error_status.lower():
- message = ("%s failed to get to expected status (%s). "
- "In %s state.") % (thing, expected_status,
- new_status)
- raise exceptions.BuildErrorException(message,
- server_id=thing_id)
- elif new_status == expected_status and expected_status is not None:
- return True # All good.
- LOG.debug("Waiting for %s to get to %s status. "
- "Currently in %s status",
- thing, log_status, new_status)
- if not tempest.test.call_until_true(
- check_status,
- CONF.compute.build_timeout,
- CONF.compute.build_interval):
- message = ("Timed out waiting for thing %s "
- "to become %s") % (thing_id, log_status)
- raise exceptions.TimeoutException(message)
-
- def _create_loginable_secgroup_rule_nova(self, client=None,
- secgroup_id=None):
- if client is None:
- client = self.compute_client
- if secgroup_id is None:
- sgs = client.security_groups.list()
- for sg in sgs:
- if sg.name == 'default':
- secgroup_id = sg.id
-
- # These rules are intended to permit inbound ssh and icmp
- # traffic from all sources, so no group_id is provided.
- # Setting a group_id would only permit traffic from ports
- # belonging to the same security group.
- rulesets = [
- {
- # ssh
- 'ip_protocol': 'tcp',
- 'from_port': 22,
- 'to_port': 22,
- 'cidr': '0.0.0.0/0',
- },
- {
- # ssh -6
- 'ip_protocol': 'tcp',
- 'from_port': 22,
- 'to_port': 22,
- 'cidr': '::/0',
- },
- {
- # ping
- 'ip_protocol': 'icmp',
- 'from_port': -1,
- 'to_port': -1,
- 'cidr': '0.0.0.0/0',
- },
- {
- # ping6
- 'ip_protocol': 'icmp',
- 'from_port': -1,
- 'to_port': -1,
- 'cidr': '::/0',
- }
- ]
- rules = list()
- for ruleset in rulesets:
- sg_rule = client.security_group_rules.create(secgroup_id,
- **ruleset)
- self.addCleanup(self.delete_wrapper, sg_rule)
- rules.append(sg_rule)
- return rules
-
- def _create_security_group_nova(self, client=None,
- namestart='secgroup-smoke-'):
- if client is None:
- client = self.compute_client
- # Create security group
- sg_name = data_utils.rand_name(namestart)
- sg_desc = sg_name + " description"
- secgroup = client.security_groups.create(sg_name, sg_desc)
- self.assertEqual(secgroup.name, sg_name)
- self.assertEqual(secgroup.description, sg_desc)
- self.addCleanup(self.delete_wrapper, secgroup)
-
- # Add rules to the security group
- self._create_loginable_secgroup_rule_nova(client, secgroup.id)
-
- return secgroup
-
- def rebuild_server(self, server, client=None, image=None,
- preserve_ephemeral=False, wait=True,
- rebuild_kwargs=None):
- if client is None:
- client = self.compute_client
- if image is None:
- image = CONF.compute.image_ref
- rebuild_kwargs = rebuild_kwargs or {}
-
- LOG.debug("Rebuilding server (name: %s, image: %s, preserve eph: %s)",
- server.name, image, preserve_ephemeral)
- server.rebuild(image, preserve_ephemeral=preserve_ephemeral,
- **rebuild_kwargs)
- if wait:
- self.status_timeout(client.servers, server.id, 'ACTIVE')
-
- def create_server(self, client=None, name=None, image=None, flavor=None,
- wait_on_boot=True, wait_on_delete=True,
- create_kwargs=None):
- """Creates VM instance.
-
- @param client: compute client to create the instance
- @param image: image from which to create the instance
- @param wait_on_boot: wait for status ACTIVE before continue
- @param wait_on_delete: force synchronous delete on cleanup
- @param create_kwargs: additional details for instance creation
- @return: client.server object
- """
- if client is None:
- client = self.compute_client
- if name is None:
- name = data_utils.rand_name('scenario-server-')
- if image is None:
- image = CONF.compute.image_ref
- if flavor is None:
- flavor = CONF.compute.flavor_ref
- if create_kwargs is None:
- create_kwargs = {}
-
- fixed_network_name = CONF.compute.fixed_network_name
- if 'nics' not in create_kwargs and fixed_network_name:
- networks = client.networks.list()
- # If several networks found, set the NetID on which to connect the
- # server to avoid the following error "Multiple possible networks
- # found, use a Network ID to be more specific."
- # See Tempest #1250866
- if len(networks) > 1:
- for network in networks:
- if network.label == fixed_network_name:
- create_kwargs['nics'] = [{'net-id': network.id}]
- break
- # If we didn't find the network we were looking for :
- else:
- msg = ("The network on which the NIC of the server must "
- "be connected can not be found : "
- "fixed_network_name=%s. Starting instance without "
- "specifying a network.") % fixed_network_name
- LOG.info(msg)
-
- LOG.debug("Creating a server (name: %s, image: %s, flavor: %s)",
- name, image, flavor)
- server = client.servers.create(name, image, flavor, **create_kwargs)
- self.assertEqual(server.name, name)
- if wait_on_delete:
- self.addCleanup(self.delete_timeout,
- self.compute_client.servers,
- server.id)
- self.addCleanup_with_wait(self.compute_client.servers, server.id,
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[server])
- if wait_on_boot:
- self.status_timeout(client.servers, server.id, 'ACTIVE')
- # The instance retrieved on creation is missing network
- # details, necessitating retrieval after it becomes active to
- # ensure correct details.
- server = client.servers.get(server.id)
- LOG.debug("Created server: %s", server)
- return server
-
- def create_volume(self, client=None, size=1, name=None,
- snapshot_id=None, imageRef=None, volume_type=None,
- wait_on_delete=True):
- if client is None:
- client = self.volume_client
- if name is None:
- name = data_utils.rand_name('scenario-volume-')
- LOG.debug("Creating a volume (size: %s, name: %s)", size, name)
- volume = client.volumes.create(size=size, display_name=name,
- snapshot_id=snapshot_id,
- imageRef=imageRef,
- volume_type=volume_type)
- if wait_on_delete:
- self.addCleanup(self.delete_timeout,
- self.volume_client.volumes,
- volume.id)
- self.addCleanup_with_wait(self.volume_client.volumes, volume.id,
- exc_type=cinder_exceptions.NotFound)
- self.assertEqual(name, volume.display_name)
- self.status_timeout(client.volumes, volume.id, 'available')
- LOG.debug("Created volume: %s", volume)
- return volume
-
- def create_server_snapshot(self, server, compute_client=None,
- image_client=None, name=None):
- if compute_client is None:
- compute_client = self.compute_client
- if image_client is None:
- image_client = self.image_client
- if name is None:
- name = data_utils.rand_name('scenario-snapshot-')
- LOG.debug("Creating a snapshot image for server: %s", server.name)
- image_id = compute_client.servers.create_image(server, name)
- self.addCleanup_with_wait(self.image_client.images, image_id,
- exc_type=glanceclient.exc.HTTPNotFound)
- self.status_timeout(image_client.images, image_id, 'active')
- snapshot_image = image_client.images.get(image_id)
- self.assertEqual(name, snapshot_image.name)
- LOG.debug("Created snapshot image %s for server %s",
- snapshot_image.name, server.name)
- return snapshot_image
-
- def create_keypair(self, client=None, name=None):
- if client is None:
- client = self.compute_client
- if name is None:
- name = data_utils.rand_name('scenario-keypair-')
- keypair = client.keypairs.create(name)
- self.assertEqual(keypair.name, name)
- self.addCleanup(self.delete_wrapper, keypair)
- return keypair
-
- def get_remote_client(self, server_or_ip, username=None, private_key=None):
- if isinstance(server_or_ip, six.string_types):
- ip = server_or_ip
- else:
- network_name_for_ssh = CONF.compute.network_for_ssh
- ip = server_or_ip.networks[network_name_for_ssh][0]
- if username is None:
- username = CONF.scenario.ssh_user
- if private_key is None:
- private_key = self.keypair.private_key
- linux_client = remote_client.RemoteClient(ip, username,
- pkey=private_key)
- try:
- linux_client.validate_authentication()
- except exceptions.SSHTimeout:
- LOG.exception('ssh connection to %s failed' % ip)
- debug.log_net_debug()
- raise
-
- return linux_client
-
- def _log_console_output(self, servers=None):
- if not CONF.compute_feature_enabled.console_output:
- LOG.debug('Console output not supported, cannot log')
- return
- if not servers:
- servers = self.compute_client.servers.list()
- for server in servers:
- LOG.debug('Console output for %s', server.id)
- LOG.debug(server.get_console_output())
-
- def wait_for_volume_status(self, status):
- volume_id = self.volume.id
- self.status_timeout(
- self.volume_client.volumes, volume_id, status)
-
- def _image_create(self, name, fmt, path, properties=None):
- if properties is None:
- properties = {}
- name = data_utils.rand_name('%s-' % name)
- image_file = open(path, 'rb')
- self.addCleanup(image_file.close)
- params = {
- 'name': name,
- 'container_format': fmt,
- 'disk_format': fmt,
- 'is_public': 'False',
- }
- params.update(properties)
- image = self.image_client.images.create(**params)
- self.addCleanup(self.image_client.images.delete, image)
- self.assertEqual("queued", image.status)
- image.update(data=image_file)
- return image.id
-
- def glance_image_create(self):
- img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
- aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
- ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
- ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
- img_container_format = CONF.scenario.img_container_format
- img_disk_format = CONF.scenario.img_disk_format
- LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, "
- "ami: %s, ari: %s, aki: %s" %
- (img_path, img_container_format, img_disk_format,
- ami_img_path, ari_img_path, aki_img_path))
- try:
- self.image = self._image_create('scenario-img',
- img_container_format,
- img_path,
- properties={'disk_format':
- img_disk_format})
- except IOError:
- LOG.debug("A qcow2 image was not found. Try to get a uec image.")
- kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
- ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
- properties = {
- 'properties': {'kernel_id': kernel, 'ramdisk_id': ramdisk}
- }
- self.image = self._image_create('scenario-ami', 'ami',
- path=ami_img_path,
- properties=properties)
- LOG.debug("image:%s" % self.image)
-
-
# power/provision states as of icehouse
class BaremetalPowerStates(object):
"""Possible power states of an Ironic node."""
@@ -1460,7 +1009,7 @@
ERROR = 'error'
-class BaremetalScenarioTest(OfficialClientTest):
+class BaremetalScenarioTest(ScenarioTest):
@classmethod
def setUpClass(cls):
super(BaremetalScenarioTest, cls).setUpClass()
@@ -1471,12 +1020,13 @@
raise cls.skipException(msg)
# use an admin client manager for baremetal client
- admin_creds = cls.admin_credentials()
- manager = clients.OfficialClientManager(credentials=admin_creds)
+ manager = clients.Manager(
+ credentials=cls.admin_credentials()
+ )
cls.baremetal_client = manager.baremetal_client
# allow any issues obtaining the node list to raise early
- cls.baremetal_client.node.list()
+ cls.baremetal_client.list_nodes()
def _node_state_timeout(self, node_id, state_attr,
target_states, timeout=10, interval=1):
@@ -1485,7 +1035,7 @@
def check_state():
node = self.get_node(node_id=node_id)
- if getattr(node, state_attr) in target_states:
+ if node.get(state_attr) in target_states:
return True
return False
@@ -1507,13 +1057,12 @@
def wait_node(self, instance_id):
"""Waits for a node to be associated with instance_id."""
- from ironicclient import exc as ironic_exceptions
def _get_node():
node = None
try:
node = self.get_node(instance_id=instance_id)
- except ironic_exceptions.HTTPNotFound:
+ except exceptions.NotFound:
pass
return node is not None
@@ -1525,14 +1074,20 @@
def get_node(self, node_id=None, instance_id=None):
if node_id:
- return self.baremetal_client.node.get(node_id)
+ _, body = self.baremetal_client.show_node(node_id)
+ return body
elif instance_id:
- return self.baremetal_client.node.get_by_instance_uuid(instance_id)
+ _, body = self.baremetal_client.show_node_by_instance_uuid(
+ instance_id)
+ if body['nodes']:
+ return body['nodes'][0]
- def get_ports(self, node_id):
+ def get_ports(self, node_uuid):
ports = []
- for port in self.baremetal_client.node.list_ports(node_id):
- ports.append(self.baremetal_client.port.get(port.uuid))
+ _, body = self.baremetal_client.list_node_ports(node_uuid)
+ for port in body['ports']:
+ _, p = self.baremetal_client.show_port(port['uuid'])
+ ports.append(p)
return ports
def add_keypair(self):
@@ -1547,47 +1102,42 @@
def boot_instance(self):
create_kwargs = {
- 'key_name': self.keypair.id
+ 'key_name': self.keypair['name']
}
self.instance = self.create_server(
wait_on_boot=False, create_kwargs=create_kwargs)
- self.addCleanup_with_wait(self.compute_client.servers,
- self.instance.id,
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.instance])
+ self.wait_node(self.instance['id'])
+ self.node = self.get_node(instance_id=self.instance['id'])
- self.wait_node(self.instance.id)
- self.node = self.get_node(instance_id=self.instance.id)
-
- self.wait_power_state(self.node.uuid, BaremetalPowerStates.POWER_ON)
+ self.wait_power_state(self.node['uuid'], BaremetalPowerStates.POWER_ON)
self.wait_provisioning_state(
- self.node.uuid,
+ self.node['uuid'],
[BaremetalProvisionStates.DEPLOYWAIT,
BaremetalProvisionStates.ACTIVE],
timeout=15)
- self.wait_provisioning_state(self.node.uuid,
+ self.wait_provisioning_state(self.node['uuid'],
BaremetalProvisionStates.ACTIVE,
timeout=CONF.baremetal.active_timeout)
- self.status_timeout(
- self.compute_client.servers, self.instance.id, 'ACTIVE')
-
- self.node = self.get_node(instance_id=self.instance.id)
- self.instance = self.compute_client.servers.get(self.instance.id)
+ self.servers_client.wait_for_server_status(self.instance['id'],
+ 'ACTIVE')
+ self.node = self.get_node(instance_id=self.instance['id'])
+ _, self.instance = self.servers_client.get_server(self.instance['id'])
def terminate_instance(self):
- self.instance.delete()
- self.wait_power_state(self.node.uuid, BaremetalPowerStates.POWER_OFF)
+ self.servers_client.delete_server(self.instance['id'])
+ self.wait_power_state(self.node['uuid'],
+ BaremetalPowerStates.POWER_OFF)
self.wait_provisioning_state(
- self.node.uuid,
+ self.node['uuid'],
BaremetalProvisionStates.NOSTATE,
timeout=CONF.baremetal.unprovision_timeout)
-class EncryptionScenarioTest(OfficialClientTest):
+class EncryptionScenarioTest(ScenarioTest):
"""
Base class for encryption scenario tests
"""
@@ -1595,11 +1145,7 @@
@classmethod
def setUpClass(cls):
super(EncryptionScenarioTest, cls).setUpClass()
-
- # use admin credentials to create encrypted volume types
- admin_creds = cls.admin_credentials()
- manager = clients.OfficialClientManager(credentials=admin_creds)
- cls.admin_volume_client = manager.volume_client
+ cls.admin_volume_types_client = cls.admin_manager.volume_types_client
def _wait_for_volume_status(self, status):
self.status_timeout(
@@ -1607,620 +1153,38 @@
def nova_boot(self):
self.keypair = self.create_keypair()
- create_kwargs = {'key_name': self.keypair.name}
- self.server = self.create_server(self.compute_client,
- image=self.image,
+ create_kwargs = {'key_name': self.keypair['name']}
+ self.server = self.create_server(image=self.image,
create_kwargs=create_kwargs)
def create_volume_type(self, client=None, name=None):
if not client:
- client = self.admin_volume_client
+ client = self.admin_volume_types_client
if not name:
name = 'generic'
randomized_name = data_utils.rand_name('scenario-type-' + name + '-')
LOG.debug("Creating a volume type: %s", randomized_name)
- volume_type = client.volume_types.create(randomized_name)
- self.addCleanup(client.volume_types.delete, volume_type.id)
- return volume_type
+ _, body = client.create_volume_type(
+ randomized_name)
+ self.assertIn('id', body)
+ self.addCleanup(client.delete_volume_type, body['id'])
+ return body
def create_encryption_type(self, client=None, type_id=None, provider=None,
key_size=None, cipher=None,
control_location=None):
if not client:
- client = self.admin_volume_client
+ client = self.admin_volume_types_client
if not type_id:
volume_type = self.create_volume_type()
- type_id = volume_type.id
+ type_id = volume_type['id']
LOG.debug("Creating an encryption type for volume type: %s", type_id)
- client.volume_encryption_types.create(type_id,
- {'provider': provider,
- 'key_size': key_size,
- 'cipher': cipher,
- 'control_location':
- control_location})
+ client.create_encryption_type(
+ type_id, provider=provider, key_size=key_size, cipher=cipher,
+ control_location=control_location)
- def nova_volume_attach(self):
- attach_volume_client = self.compute_client.volumes.create_server_volume
- volume = attach_volume_client(self.server.id,
- self.volume.id,
- '/dev/vdb')
- self.assertEqual(self.volume.id, volume.id)
- self._wait_for_volume_status('in-use')
- def nova_volume_detach(self):
- detach_volume_client = self.compute_client.volumes.delete_server_volume
- detach_volume_client(self.server.id, self.volume.id)
- self._wait_for_volume_status('available')
-
- volume = self.volume_client.volumes.get(self.volume.id)
- self.assertEqual('available', volume.status)
-
-
-class NetworkScenarioTest(OfficialClientTest):
- """
- Base class for network scenario tests
- """
-
- @classmethod
- def check_preconditions(cls):
- if (CONF.service_available.neutron):
- cls.enabled = True
- # verify that neutron_available is telling the truth
- try:
- cls.network_client.list_networks()
- except exc.EndpointNotFound:
- cls.enabled = False
- raise
- else:
- cls.enabled = False
- msg = 'Neutron not available'
- raise cls.skipException(msg)
-
- @classmethod
- def setUpClass(cls):
- super(NetworkScenarioTest, cls).setUpClass()
- cls.tenant_id = cls.manager.identity_client.tenant_id
-
- def _create_network(self, tenant_id, namestart='network-smoke-'):
- name = data_utils.rand_name(namestart)
- body = dict(
- network=dict(
- name=name,
- tenant_id=tenant_id,
- ),
- )
- result = self.network_client.create_network(body=body)
- network = net_common.DeletableNetwork(client=self.network_client,
- **result['network'])
- self.assertEqual(network.name, name)
- self.addCleanup(self.delete_wrapper, network)
- return network
-
- def _list_networks(self, **kwargs):
- nets = self.network_client.list_networks(**kwargs)
- return nets['networks']
-
- def _list_subnets(self, **kwargs):
- subnets = self.network_client.list_subnets(**kwargs)
- return subnets['subnets']
-
- def _list_routers(self, **kwargs):
- routers = self.network_client.list_routers(**kwargs)
- return routers['routers']
-
- def _list_ports(self, **kwargs):
- ports = self.network_client.list_ports(**kwargs)
- return ports['ports']
-
- def _get_tenant_own_network_num(self, tenant_id):
- nets = self._list_networks(tenant_id=tenant_id)
- return len(nets)
-
- def _get_tenant_own_subnet_num(self, tenant_id):
- subnets = self._list_subnets(tenant_id=tenant_id)
- return len(subnets)
-
- def _get_tenant_own_port_num(self, tenant_id):
- ports = self._list_ports(tenant_id=tenant_id)
- return len(ports)
-
- def _create_subnet(self, network, namestart='subnet-smoke-', **kwargs):
- """
- Create a subnet for the given network within the cidr block
- configured for tenant networks.
- """
-
- def cidr_in_use(cidr, tenant_id):
- """
- :return True if subnet with cidr already exist in tenant
- False else
- """
- cidr_in_use = self._list_subnets(tenant_id=tenant_id, cidr=cidr)
- return len(cidr_in_use) != 0
-
- tenant_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
- result = None
- # Repeatedly attempt subnet creation with sequential cidr
- # blocks until an unallocated block is found.
- for subnet_cidr in tenant_cidr.subnet(
- CONF.network.tenant_network_mask_bits):
- str_cidr = str(subnet_cidr)
- if cidr_in_use(str_cidr, tenant_id=network.tenant_id):
- continue
-
- body = dict(
- subnet=dict(
- name=data_utils.rand_name(namestart),
- ip_version=4,
- network_id=network.id,
- tenant_id=network.tenant_id,
- cidr=str_cidr,
- ),
- )
- body['subnet'].update(kwargs)
- try:
- result = self.network_client.create_subnet(body=body)
- break
- except exc.NeutronClientException as e:
- is_overlapping_cidr = 'overlaps with another subnet' in str(e)
- if not is_overlapping_cidr:
- raise
- self.assertIsNotNone(result, 'Unable to allocate tenant network')
- subnet = net_common.DeletableSubnet(client=self.network_client,
- **result['subnet'])
- self.assertEqual(subnet.cidr, str_cidr)
- self.addCleanup(self.delete_wrapper, subnet)
- return subnet
-
- def _create_port(self, network, namestart='port-quotatest-'):
- name = data_utils.rand_name(namestart)
- body = dict(
- port=dict(name=name,
- network_id=network.id,
- tenant_id=network.tenant_id))
- result = self.network_client.create_port(body=body)
- self.assertIsNotNone(result, 'Unable to allocate port')
- port = net_common.DeletablePort(client=self.network_client,
- **result['port'])
- self.addCleanup(self.delete_wrapper, port)
- return port
-
- def _get_server_port_id(self, server, ip_addr=None):
- ports = self._list_ports(device_id=server.id, fixed_ip=ip_addr)
- self.assertEqual(len(ports), 1,
- "Unable to determine which port to target.")
- return ports[0]['id']
-
- def _get_network_by_name(self, network_name):
- net = self._list_networks(name=network_name)
- return net_common.AttributeDict(net[0])
-
- def _create_floating_ip(self, thing, external_network_id, port_id=None):
- if not port_id:
- port_id = self._get_server_port_id(thing)
- body = dict(
- floatingip=dict(
- floating_network_id=external_network_id,
- port_id=port_id,
- tenant_id=thing.tenant_id,
- )
- )
- result = self.network_client.create_floatingip(body=body)
- floating_ip = net_common.DeletableFloatingIp(
- client=self.network_client,
- **result['floatingip'])
- self.addCleanup(self.delete_wrapper, floating_ip)
- return floating_ip
-
- def _associate_floating_ip(self, floating_ip, server):
- port_id = self._get_server_port_id(server)
- floating_ip.update(port_id=port_id)
- self.assertEqual(port_id, floating_ip.port_id)
- return floating_ip
-
- def _disassociate_floating_ip(self, floating_ip):
- """
- :param floating_ip: type DeletableFloatingIp
- """
- floating_ip.update(port_id=None)
- self.assertIsNone(floating_ip.port_id)
- return floating_ip
-
- def _ping_ip_address(self, ip_address, should_succeed=True):
- cmd = ['ping', '-c1', '-w1', ip_address]
-
- def ping():
- proc = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- proc.wait()
- return (proc.returncode == 0) == should_succeed
-
- return tempest.test.call_until_true(
- ping, CONF.compute.ping_timeout, 1)
-
- def _create_pool(self, lb_method, protocol, subnet_id):
- """Wrapper utility that returns a test pool."""
- name = data_utils.rand_name('pool-')
- body = {
- "pool": {
- "protocol": protocol,
- "name": name,
- "subnet_id": subnet_id,
- "lb_method": lb_method
- }
- }
- resp = self.network_client.create_pool(body=body)
- pool = net_common.DeletablePool(client=self.network_client,
- **resp['pool'])
- self.assertEqual(pool['name'], name)
- self.addCleanup(self.delete_wrapper, pool)
- return pool
-
- def _create_member(self, address, protocol_port, pool_id):
- """Wrapper utility that returns a test member."""
- body = {
- "member": {
- "protocol_port": protocol_port,
- "pool_id": pool_id,
- "address": address
- }
- }
- resp = self.network_client.create_member(body)
- member = net_common.DeletableMember(client=self.network_client,
- **resp['member'])
- self.addCleanup(self.delete_wrapper, member)
- return member
-
- def _create_vip(self, protocol, protocol_port, subnet_id, pool_id):
- """Wrapper utility that returns a test vip."""
- name = data_utils.rand_name('vip-')
- body = {
- "vip": {
- "protocol": protocol,
- "name": name,
- "subnet_id": subnet_id,
- "pool_id": pool_id,
- "protocol_port": protocol_port
- }
- }
- resp = self.network_client.create_vip(body)
- vip = net_common.DeletableVip(client=self.network_client,
- **resp['vip'])
- self.assertEqual(vip['name'], name)
- self.addCleanup(self.delete_wrapper, vip)
- return vip
-
- def _check_vm_connectivity(self, ip_address,
- username=None,
- private_key=None,
- should_connect=True):
- """
- :param ip_address: server to test against
- :param username: server's ssh username
- :param private_key: server's ssh private key to be used
- :param should_connect: True/False indicates positive/negative test
- positive - attempt ping and ssh
- negative - attempt ping and fail if succeed
-
- :raises: AssertError if the result of the connectivity check does
- not match the value of the should_connect param
- """
- if should_connect:
- msg = "Timed out waiting for %s to become reachable" % ip_address
- else:
- msg = "ip address %s is reachable" % ip_address
- self.assertTrue(self._ping_ip_address(ip_address,
- should_succeed=should_connect),
- msg=msg)
- if should_connect:
- # no need to check ssh for negative connectivity
- self.get_remote_client(ip_address, username, private_key)
-
- def _check_public_network_connectivity(self, ip_address, username,
- private_key, should_connect=True,
- msg=None, servers=None):
- # The target login is assumed to have been configured for
- # key-based authentication by cloud-init.
- LOG.debug('checking network connections to IP %s with user: %s' %
- (ip_address, username))
- try:
- self._check_vm_connectivity(ip_address,
- username,
- private_key,
- should_connect=should_connect)
- except Exception as e:
- ex_msg = 'Public network connectivity check failed'
- if msg:
- ex_msg += ": " + msg
- LOG.exception(ex_msg)
- self._log_console_output(servers)
- # network debug is called as part of ssh init
- if not isinstance(e, exceptions.SSHTimeout):
- debug.log_net_debug()
- raise
-
- def _check_tenant_network_connectivity(self, server,
- username,
- private_key,
- should_connect=True,
- servers_for_debug=None):
- if not CONF.network.tenant_networks_reachable:
- msg = 'Tenant networks not configured to be reachable.'
- LOG.info(msg)
- return
- # The target login is assumed to have been configured for
- # key-based authentication by cloud-init.
- try:
- for net_name, ip_addresses in server.networks.iteritems():
- for ip_address in ip_addresses:
- self._check_vm_connectivity(ip_address,
- username,
- private_key,
- should_connect=should_connect)
- except Exception as e:
- LOG.exception('Tenant network connectivity check failed')
- self._log_console_output(servers_for_debug)
- # network debug is called as part of ssh init
- if not isinstance(e, exceptions.SSHTimeout):
- debug.log_net_debug()
- raise
-
- def _check_remote_connectivity(self, source, dest, should_succeed=True):
- """
- check ping server via source ssh connection
-
- :param source: RemoteClient: an ssh connection from which to ping
- :param dest: and IP to ping against
- :param should_succeed: boolean should ping succeed or not
- :returns: boolean -- should_succeed == ping
- :returns: ping is false if ping failed
- """
- def ping_remote():
- try:
- source.ping_host(dest)
- except exceptions.SSHExecCommandFailed:
- LOG.warn('Failed to ping IP: %s via a ssh connection from: %s.'
- % (dest, source.ssh_client.host))
- return not should_succeed
- return should_succeed
-
- return tempest.test.call_until_true(ping_remote,
- CONF.compute.ping_timeout,
- 1)
-
- def _create_security_group_neutron(self, tenant_id, client=None,
- namestart='secgroup-smoke-'):
- if client is None:
- client = self.network_client
- secgroup = self._create_empty_security_group(namestart=namestart,
- client=client,
- tenant_id=tenant_id)
-
- # Add rules to the security group
- rules = self._create_loginable_secgroup_rule_neutron(secgroup=secgroup)
- for rule in rules:
- self.assertEqual(tenant_id, rule.tenant_id)
- self.assertEqual(secgroup.id, rule.security_group_id)
- return secgroup
-
- def _create_empty_security_group(self, tenant_id, client=None,
- namestart='secgroup-smoke-'):
- """Create a security group without rules.
-
- Default rules will be created:
- - IPv4 egress to any
- - IPv6 egress to any
-
- :param tenant_id: secgroup will be created in this tenant
- :returns: DeletableSecurityGroup -- containing the secgroup created
- """
- if client is None:
- client = self.network_client
- sg_name = data_utils.rand_name(namestart)
- sg_desc = sg_name + " description"
- sg_dict = dict(name=sg_name,
- description=sg_desc)
- sg_dict['tenant_id'] = tenant_id
- body = dict(security_group=sg_dict)
- result = client.create_security_group(body=body)
- secgroup = net_common.DeletableSecurityGroup(
- client=client,
- **result['security_group']
- )
- self.assertEqual(secgroup.name, sg_name)
- self.assertEqual(tenant_id, secgroup.tenant_id)
- self.assertEqual(secgroup.description, sg_desc)
- self.addCleanup(self.delete_wrapper, secgroup)
- return secgroup
-
- def _default_security_group(self, tenant_id, client=None):
- """Get default secgroup for given tenant_id.
-
- :returns: DeletableSecurityGroup -- default secgroup for given tenant
- """
- if client is None:
- client = self.network_client
- sgs = [
- sg for sg in client.list_security_groups().values()[0]
- if sg['tenant_id'] == tenant_id and sg['name'] == 'default'
- ]
- msg = "No default security group for tenant %s." % (tenant_id)
- self.assertTrue(len(sgs) > 0, msg)
- if len(sgs) > 1:
- msg = "Found %d default security groups" % len(sgs)
- raise exc.NeutronClientNoUniqueMatch(msg=msg)
- return net_common.DeletableSecurityGroup(client=client,
- **sgs[0])
-
- def _create_security_group_rule(self, client=None, secgroup=None,
- tenant_id=None, **kwargs):
- """Create a rule from a dictionary of rule parameters.
-
- Create a rule in a secgroup. if secgroup not defined will search for
- default secgroup in tenant_id.
-
- :param secgroup: type DeletableSecurityGroup.
- :param secgroup_id: search for secgroup by id
- default -- choose default secgroup for given tenant_id
- :param tenant_id: if secgroup not passed -- the tenant in which to
- search for default secgroup
- :param kwargs: a dictionary containing rule parameters:
- for example, to allow incoming ssh:
- rule = {
- direction: 'ingress'
- protocol:'tcp',
- port_range_min: 22,
- port_range_max: 22
- }
- """
- if client is None:
- client = self.network_client
- if secgroup is None:
- secgroup = self._default_security_group(tenant_id)
-
- ruleset = dict(security_group_id=secgroup.id,
- tenant_id=secgroup.tenant_id,
- )
- ruleset.update(kwargs)
-
- body = dict(security_group_rule=dict(ruleset))
- sg_rule = client.create_security_group_rule(body=body)
- sg_rule = net_common.DeletableSecurityGroupRule(
- client=client,
- **sg_rule['security_group_rule']
- )
- self.addCleanup(self.delete_wrapper, sg_rule)
- self.assertEqual(secgroup.tenant_id, sg_rule.tenant_id)
- self.assertEqual(secgroup.id, sg_rule.security_group_id)
-
- return sg_rule
-
- def _create_loginable_secgroup_rule_neutron(self, client=None,
- secgroup=None):
- """These rules are intended to permit inbound ssh and icmp
- traffic from all sources, so no group_id is provided.
- Setting a group_id would only permit traffic from ports
- belonging to the same security group.
- """
-
- if client is None:
- client = self.network_client
- rules = []
- rulesets = [
- dict(
- # ssh
- protocol='tcp',
- port_range_min=22,
- port_range_max=22,
- ),
- dict(
- # ping
- protocol='icmp',
- )
- ]
- for ruleset in rulesets:
- for r_direction in ['ingress', 'egress']:
- ruleset['direction'] = r_direction
- try:
- sg_rule = self._create_security_group_rule(
- client=client, secgroup=secgroup, **ruleset)
- except exc.NeutronClientException as ex:
- # if rule already exist - skip rule and continue
- if not (ex.status_code is 409 and 'Security group rule'
- ' already exists' in ex.message):
- raise ex
- else:
- self.assertEqual(r_direction, sg_rule.direction)
- rules.append(sg_rule)
-
- return rules
-
- def _ssh_to_server(self, server, private_key):
- ssh_login = CONF.compute.image_ssh_user
- return self.get_remote_client(server,
- username=ssh_login,
- private_key=private_key)
-
- def _show_quota_network(self, tenant_id):
- quota = self.network_client.show_quota(tenant_id)
- return quota['quota']['network']
-
- def _show_quota_subnet(self, tenant_id):
- quota = self.network_client.show_quota(tenant_id)
- return quota['quota']['subnet']
-
- def _show_quota_port(self, tenant_id):
- quota = self.network_client.show_quota(tenant_id)
- return quota['quota']['port']
-
- def _get_router(self, tenant_id):
- """Retrieve a router for the given tenant id.
-
- If a public router has been configured, it will be returned.
-
- If a public router has not been configured, but a public
- network has, a tenant router will be created and returned that
- routes traffic to the public network.
- """
- router_id = CONF.network.public_router_id
- network_id = CONF.network.public_network_id
- if router_id:
- result = self.network_client.show_router(router_id)
- return net_common.AttributeDict(**result['router'])
- elif network_id:
- router = self._create_router(tenant_id)
- router.add_gateway(network_id)
- return router
- else:
- raise Exception("Neither of 'public_router_id' or "
- "'public_network_id' has been defined.")
-
- def _create_router(self, tenant_id, namestart='router-smoke-'):
- name = data_utils.rand_name(namestart)
- body = dict(
- router=dict(
- name=name,
- admin_state_up=True,
- tenant_id=tenant_id,
- ),
- )
- result = self.network_client.create_router(body=body)
- router = net_common.DeletableRouter(client=self.network_client,
- **result['router'])
- self.assertEqual(router.name, name)
- self.addCleanup(self.delete_wrapper, router)
- return router
-
- def create_networks(self, tenant_id=None):
- """Create a network with a subnet connected to a router.
-
- The baremetal driver is a special case since all nodes are
- on the same shared network.
-
- :returns: network, subnet, router
- """
- if CONF.baremetal.driver_enabled:
- # NOTE(Shrews): This exception is for environments where tenant
- # credential isolation is available, but network separation is
- # not (the current baremetal case). Likely can be removed when
- # test account mgmt is reworked:
- # https://blueprints.launchpad.net/tempest/+spec/test-accounts
- network = self._get_network_by_name(
- CONF.compute.fixed_network_name)
- router = None
- subnet = None
- else:
- if tenant_id is None:
- tenant_id = self.tenant_id
- network = self._create_network(tenant_id)
- router = self._get_router(tenant_id)
- subnet = self._create_subnet(network)
- subnet.add_to_router(router.id)
- return network, subnet, router
-
-
-class OrchestrationScenarioTest(OfficialClientTest):
+class OrchestrationScenarioTest(ScenarioTest):
"""
Base class for orchestration scenario tests
"""
@@ -2250,106 +1214,17 @@
@classmethod
def _get_default_network(cls):
- networks = cls.network_client.list_networks()
- for net in networks['networks']:
- if net['name'] == CONF.compute.fixed_network_name:
+ _, networks = cls.networks_client.list_networks()
+ for net in networks:
+ if net['label'] == CONF.compute.fixed_network_name:
return net
@staticmethod
def _stack_output(stack, output_key):
"""Return a stack output value for a given key."""
- return next((o['output_value'] for o in stack.outputs
+ return next((o['output_value'] for o in stack['outputs']
if o['output_key'] == output_key), None)
- def _ping_ip_address(self, ip_address, should_succeed=True):
- cmd = ['ping', '-c1', '-w1', ip_address]
-
- def ping():
- proc = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- proc.wait()
- return (proc.returncode == 0) == should_succeed
-
- return tempest.test.call_until_true(
- ping, CONF.orchestration.build_timeout, 1)
-
- def _wait_for_resource_status(self, stack_identifier, resource_name,
- status, failure_pattern='^.*_FAILED$'):
- """Waits for a Resource to reach a given status."""
- fail_regexp = re.compile(failure_pattern)
- build_timeout = CONF.orchestration.build_timeout
- build_interval = CONF.orchestration.build_interval
-
- start = timeutils.utcnow()
- while timeutils.delta_seconds(start,
- timeutils.utcnow()) < build_timeout:
- try:
- res = self.client.resources.get(
- stack_identifier, resource_name)
- except heat_exceptions.HTTPNotFound:
- # ignore this, as the resource may not have
- # been created yet
- pass
- else:
- if res.resource_status == status:
- return
- if fail_regexp.search(res.resource_status):
- raise exceptions.StackResourceBuildErrorException(
- resource_name=res.resource_name,
- stack_identifier=stack_identifier,
- resource_status=res.resource_status,
- resource_status_reason=res.resource_status_reason)
- time.sleep(build_interval)
-
- message = ('Resource %s failed to reach %s status within '
- 'the required time (%s s).' %
- (res.resource_name, status, build_timeout))
- raise exceptions.TimeoutException(message)
-
- def _wait_for_stack_status(self, stack_identifier, status,
- failure_pattern='^.*_FAILED$'):
- """
- Waits for a Stack to reach a given status.
-
- Note this compares the full $action_$status, e.g
- CREATE_COMPLETE, not just COMPLETE which is exposed
- via the status property of Stack in heatclient
- """
- fail_regexp = re.compile(failure_pattern)
- build_timeout = CONF.orchestration.build_timeout
- build_interval = CONF.orchestration.build_interval
-
- start = timeutils.utcnow()
- while timeutils.delta_seconds(start,
- timeutils.utcnow()) < build_timeout:
- try:
- stack = self.client.stacks.get(stack_identifier)
- except heat_exceptions.HTTPNotFound:
- # ignore this, as the stackource may not have
- # been created yet
- pass
- else:
- if stack.stack_status == status:
- return
- if fail_regexp.search(stack.stack_status):
- raise exceptions.StackBuildErrorException(
- stack_identifier=stack_identifier,
- stack_status=stack.stack_status,
- stack_status_reason=stack.stack_status_reason)
- time.sleep(build_interval)
-
- message = ('Stack %s failed to reach %s status within '
- 'the required time (%s s).' %
- (stack.stack_name, status, build_timeout))
- raise exceptions.TimeoutException(message)
-
- def _stack_delete(self, stack_identifier):
- try:
- self.client.stacks.delete(stack_identifier)
- except heat_exceptions.HTTPNotFound:
- pass
-
class SwiftScenarioTest(ScenarioTest):
"""
@@ -2372,38 +1247,38 @@
cls.container_client = cls.manager.container_client
cls.object_client = cls.manager.object_client
- def _get_swift_stat(self):
+ def get_swift_stat(self):
"""get swift status for our user account."""
self.account_client.list_account_containers()
LOG.debug('Swift status information obtained successfully')
- def _create_container(self, container_name=None):
+ def create_container(self, container_name=None):
name = container_name or data_utils.rand_name(
'swift-scenario-container')
self.container_client.create_container(name)
# look for the container to assure it is created
- self._list_and_check_container_objects(name)
+ self.list_and_check_container_objects(name)
LOG.debug('Container %s created' % (name))
return name
- def _delete_container(self, container_name):
+ def delete_container(self, container_name):
self.container_client.delete_container(container_name)
LOG.debug('Container %s deleted' % (container_name))
- def _upload_object_to_container(self, container_name, obj_name=None):
+ def upload_object_to_container(self, container_name, obj_name=None):
obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
obj_data = data_utils.arbitrary_string()
self.object_client.create_object(container_name, obj_name, obj_data)
return obj_name, obj_data
- def _delete_object(self, container_name, filename):
+ def delete_object(self, container_name, filename):
self.object_client.delete_object(container_name, filename)
- self._list_and_check_container_objects(container_name,
- not_present_obj=[filename])
+ self.list_and_check_container_objects(container_name,
+ not_present_obj=[filename])
- def _list_and_check_container_objects(self, container_name,
- present_obj=None,
- not_present_obj=None):
+ def list_and_check_container_objects(self, container_name,
+ present_obj=None,
+ not_present_obj=None):
"""
List objects for a given container and assert which are present and
which are not.
@@ -2421,7 +1296,7 @@
for obj in not_present_obj:
self.assertNotIn(obj, object_list)
- def _change_container_acl(self, container_name, acl):
+ def change_container_acl(self, container_name, acl):
metadata_param = {'metadata_prefix': 'x-container-',
'metadata': {'read': acl}}
self.container_client.update_container_metadata(container_name,
@@ -2429,6 +1304,6 @@
resp, _ = self.container_client.list_container_metadata(container_name)
self.assertEqual(resp['x-container-read'], acl)
- def _download_and_verify(self, container_name, obj_name, expected_data):
+ def download_and_verify(self, container_name, obj_name, expected_data):
_, obj = self.object_client.get_object(container_name, obj_name)
self.assertEqual(obj, expected_data)
diff --git a/tempest/scenario/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py
deleted file mode 100644
index 8894106..0000000
--- a/tempest/scenario/orchestration/test_autoscaling.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# 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 time
-
-import heatclient.exc as heat_exceptions
-
-from tempest import config
-from tempest.scenario import manager
-from tempest import test
-
-CONF = config.CONF
-
-
-class AutoScalingTest(manager.OrchestrationScenarioTest):
-
- def setUp(self):
- super(AutoScalingTest, self).setUp()
- if not CONF.orchestration.image_ref:
- raise self.skipException("No image available to test")
- self.client = self.orchestration_client
-
- def assign_keypair(self):
- self.stack_name = self._stack_rand_name()
- if CONF.orchestration.keypair_name:
- self.keypair_name = CONF.orchestration.keypair_name
- else:
- self.keypair = self.create_keypair()
- self.keypair_name = self.keypair.id
-
- def launch_stack(self):
- net = self._get_default_network()
- self.parameters = {
- 'KeyName': self.keypair_name,
- 'InstanceType': CONF.orchestration.instance_type,
- 'ImageId': CONF.orchestration.image_ref,
- 'StackStart': str(time.time()),
- 'Subnet': net['subnets'][0]
- }
-
- # create the stack
- self.template = self._load_template(__file__, 'test_autoscaling.yaml')
- self.client.stacks.create(
- stack_name=self.stack_name,
- template=self.template,
- parameters=self.parameters)
-
- self.stack = self.client.stacks.get(self.stack_name)
- self.stack_identifier = '%s/%s' % (self.stack_name, self.stack.id)
-
- # if a keypair was set, do not delete the stack on exit to allow
- # for manual post-mortums
- if not CONF.orchestration.keypair_name:
- self.addCleanup(self.client.stacks.delete, self.stack)
-
- @test.skip_because(bug="1257575")
- @test.attr(type='slow')
- @test.services('orchestration', 'compute')
- def test_scale_up_then_down(self):
-
- self.assign_keypair()
- self.launch_stack()
-
- sid = self.stack_identifier
- timeout = CONF.orchestration.build_timeout
- interval = 10
-
- self.assertEqual('CREATE', self.stack.action)
- # wait for create to complete.
- self.status_timeout(self.client.stacks, sid, 'COMPLETE',
- error_status='FAILED')
-
- self.stack.get()
- self.assertEqual('CREATE_COMPLETE', self.stack.stack_status)
-
- # the resource SmokeServerGroup is implemented as a nested
- # stack, so servers can be counted by counting the resources
- # inside that nested stack
- resource = self.client.resources.get(sid, 'SmokeServerGroup')
- nested_stack_id = resource.physical_resource_id
-
- def server_count():
- # the number of servers is the number of resources
- # in the nested stack
- self.server_count = len(
- self.client.resources.list(nested_stack_id))
- return self.server_count
-
- def assertScale(from_servers, to_servers):
- test.call_until_true(lambda: server_count() == to_servers,
- timeout, interval)
- self.assertEqual(to_servers, self.server_count,
- 'Failed scaling from %d to %d servers. '
- 'Current server count: %s' % (
- from_servers, to_servers,
- self.server_count))
-
- # he marched them up to the top of the hill
- assertScale(1, 2)
- assertScale(2, 3)
-
- # and he marched them down again
- assertScale(3, 2)
- assertScale(2, 1)
-
- # delete stack on completion
- self.stack.delete()
- self.status_timeout(self.client.stacks, sid, 'COMPLETE',
- error_status='FAILED',
- not_found_exception=heat_exceptions.NotFound)
-
- try:
- self.stack.get()
- self.assertEqual('DELETE_COMPLETE', self.stack.stack_status)
- except heat_exceptions.NotFound:
- pass
diff --git a/tempest/scenario/orchestration/test_autoscaling.yaml b/tempest/scenario/orchestration/test_autoscaling.yaml
deleted file mode 100644
index 4651284..0000000
--- a/tempest/scenario/orchestration/test_autoscaling.yaml
+++ /dev/null
@@ -1,185 +0,0 @@
-HeatTemplateFormatVersion: '2012-12-12'
-Description: |
- Template which tests autoscaling and load balancing
-Parameters:
- KeyName:
- Type: String
- InstanceType:
- Type: String
- ImageId:
- Type: String
- Subnet:
- Type: String
- StackStart:
- Description: Epoch seconds when the stack was launched
- Type: Number
- ConsumeStartSeconds:
- Description: Seconds after invocation when memory should be consumed
- Type: Number
- Default: '60'
- ConsumeStopSeconds:
- Description: Seconds after StackStart when memory should be released
- Type: Number
- Default: '420'
- ScaleUpThreshold:
- Description: Memory percentage threshold to scale up on
- Type: String
- Default: '70'
- ScaleDownThreshold:
- Description: Memory percentage threshold to scale down on
- Type: String
- Default: '60'
- ConsumeMemoryLimit:
- Description: Memory percentage threshold to consume
- Type: Number
- Default: '71'
-Resources:
- SmokeServerGroup:
- Type: AWS::AutoScaling::AutoScalingGroup
- Properties:
- AvailabilityZones: {'Fn::GetAZs': ''}
- LaunchConfigurationName: {Ref: LaunchConfig}
- MinSize: '1'
- MaxSize: '3'
- VPCZoneIdentifier: [{Ref: Subnet}]
- SmokeServerScaleUpPolicy:
- Type: AWS::AutoScaling::ScalingPolicy
- Properties:
- AdjustmentType: ChangeInCapacity
- AutoScalingGroupName: {Ref: SmokeServerGroup}
- Cooldown: '60'
- ScalingAdjustment: '1'
- SmokeServerScaleDownPolicy:
- Type: AWS::AutoScaling::ScalingPolicy
- Properties:
- AdjustmentType: ChangeInCapacity
- AutoScalingGroupName: {Ref: SmokeServerGroup}
- Cooldown: '60'
- ScalingAdjustment: '-1'
- MEMAlarmHigh:
- Type: AWS::CloudWatch::Alarm
- Properties:
- AlarmDescription: Scale-up if MEM > ScaleUpThreshold% for 10 seconds
- MetricName: MemoryUtilization
- Namespace: system/linux
- Statistic: Average
- Period: '10'
- EvaluationPeriods: '1'
- Threshold: {Ref: ScaleUpThreshold}
- AlarmActions: [{Ref: SmokeServerScaleUpPolicy}]
- Dimensions:
- - Name: AutoScalingGroupName
- Value: {Ref: SmokeServerGroup}
- ComparisonOperator: GreaterThanThreshold
- MEMAlarmLow:
- Type: AWS::CloudWatch::Alarm
- Properties:
- AlarmDescription: Scale-down if MEM < ScaleDownThreshold% for 10 seconds
- MetricName: MemoryUtilization
- Namespace: system/linux
- Statistic: Average
- Period: '10'
- EvaluationPeriods: '1'
- Threshold: {Ref: ScaleDownThreshold}
- AlarmActions: [{Ref: SmokeServerScaleDownPolicy}]
- Dimensions:
- - Name: AutoScalingGroupName
- Value: {Ref: SmokeServerGroup}
- ComparisonOperator: LessThanThreshold
- CfnUser:
- Type: AWS::IAM::User
- SmokeKeys:
- Type: AWS::IAM::AccessKey
- Properties:
- UserName: {Ref: CfnUser}
- SmokeSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Standard firewall rules
- SecurityGroupIngress:
- - {IpProtocol: tcp, FromPort: '22', ToPort: '22', CidrIp: 0.0.0.0/0}
- - {IpProtocol: tcp, FromPort: '80', ToPort: '80', CidrIp: 0.0.0.0/0}
- LaunchConfig:
- Type: AWS::AutoScaling::LaunchConfiguration
- Metadata:
- AWS::CloudFormation::Init:
- config:
- files:
- /etc/cfn/cfn-credentials:
- content:
- Fn::Replace:
- - $AWSAccessKeyId: {Ref: SmokeKeys}
- $AWSSecretKey: {'Fn::GetAtt': [SmokeKeys, SecretAccessKey]}
- - |
- AWSAccessKeyId=$AWSAccessKeyId
- AWSSecretKey=$AWSSecretKey
- mode: '000400'
- owner: root
- group: root
- /root/watch_loop:
- content:
- Fn::Replace:
- - _hi_: {Ref: MEMAlarmHigh}
- _lo_: {Ref: MEMAlarmLow}
- - |
- #!/bin/bash
- while :
- do
- /opt/aws/bin/cfn-push-stats --watch _hi_ --mem-util
- /opt/aws/bin/cfn-push-stats --watch _lo_ --mem-util
- sleep 4
- done
- mode: '000700'
- owner: root
- group: root
- /root/consume_memory:
- content:
- Fn::Replace:
- - StackStart: {Ref: StackStart}
- ConsumeStopSeconds: {Ref: ConsumeStopSeconds}
- ConsumeStartSeconds: {Ref: ConsumeStartSeconds}
- ConsumeMemoryLimit: {Ref: ConsumeMemoryLimit}
- - |
- #!/usr/bin/env python
- import psutil
- import time
- import datetime
- import sys
- a = []
- sleep_until_consume = ConsumeStartSeconds
- stack_start = StackStart
- consume_stop_time = stack_start + ConsumeStopSeconds
- memory_limit = ConsumeMemoryLimit
- if sleep_until_consume > 0:
- sys.stdout.flush()
- time.sleep(sleep_until_consume)
- while psutil.virtual_memory().percent < memory_limit:
- sys.stdout.flush()
- a.append(' ' * 10**5)
- time.sleep(0.1)
- sleep_until_exit = consume_stop_time - time.time()
- if sleep_until_exit > 0:
- time.sleep(sleep_until_exit)
- mode: '000700'
- owner: root
- group: root
- Properties:
- ImageId: {Ref: ImageId}
- InstanceType: {Ref: InstanceType}
- KeyName: {Ref: KeyName}
- SecurityGroups: [{Ref: SmokeSecurityGroup}]
- UserData:
- Fn::Base64:
- Fn::Replace:
- - ConsumeStopSeconds: {Ref: ConsumeStopSeconds}
- ConsumeStartSeconds: {Ref: ConsumeStartSeconds}
- ConsumeMemoryLimit: {Ref: ConsumeMemoryLimit}
- - |
- #!/bin/bash -v
- /opt/aws/bin/cfn-init
- # report on memory consumption every 4 seconds
- /root/watch_loop &
- # wait ConsumeStartSeconds then ramp up memory consumption
- # until it is over ConsumeMemoryLimit%
- # then exits ConsumeStopSeconds seconds after stack launch
- /root/consume_memory > /root/consume_memory.log &
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index 36e6126..0ab4311 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -38,7 +38,7 @@
self.keypair_name = CONF.orchestration.keypair_name
else:
self.keypair = self.create_keypair()
- self.keypair_name = self.keypair.id
+ self.keypair_name = self.keypair['name']
def launch_stack(self):
net = self._get_default_network()
@@ -52,40 +52,45 @@
# create the stack
self.template = self._load_template(__file__, self.template_name)
- self.client.stacks.create(
- stack_name=self.stack_name,
+ _, stack = self.client.create_stack(
+ name=self.stack_name,
template=self.template,
parameters=self.parameters)
+ stack = stack['stack']
- self.stack = self.client.stacks.get(self.stack_name)
- self.stack_identifier = '%s/%s' % (self.stack_name, self.stack.id)
- self.addCleanup(self._stack_delete, self.stack_identifier)
+ _, self.stack = self.client.get_stack(stack['id'])
+ self.stack_identifier = '%s/%s' % (self.stack_name, self.stack['id'])
+ self.addCleanup(self.delete_wrapper,
+ self.orchestration_client.delete_stack,
+ self.stack_identifier)
def check_stack(self):
sid = self.stack_identifier
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'WaitHandle', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'SmokeSecurityGroup', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'SmokeKeys', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'CfnUser', 'CREATE_COMPLETE')
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'SmokeServer', 'CREATE_COMPLETE')
- server_resource = self.client.resources.get(sid, 'SmokeServer')
- server_id = server_resource.physical_resource_id
- server = self.compute_client.servers.get(server_id)
- server_ip = server.networks[CONF.compute.network_for_ssh][0]
+ _, server_resource = self.client.get_resource(sid, 'SmokeServer')
+ server_id = server_resource['physical_resource_id']
+ _, server = self.servers_client.get_server(server_id)
+ server_ip =\
+ server['addresses'][CONF.compute.network_for_ssh][0]['addr']
- if not self._ping_ip_address(server_ip):
+ if not self.ping_ip_address(server_ip):
self._log_console_output(servers=[server])
self.fail(
- "Timed out waiting for %s to become reachable" % server_ip)
+ "(CfnInitScenarioTest:test_server_cfn_init) Timed out waiting "
+ "for %s to become reachable" % server_ip)
try:
- self._wait_for_resource_status(
+ self.client.wait_for_resource_status(
sid, 'WaitCondition', 'CREATE_COMPLETE')
except (exceptions.StackResourceBuildErrorException,
exceptions.TimeoutException) as e:
@@ -96,9 +101,9 @@
# logs to be compared
self._log_console_output(servers=[server])
- self._wait_for_stack_status(sid, 'CREATE_COMPLETE')
+ self.client.wait_for_stack_status(sid, 'CREATE_COMPLETE')
- stack = self.client.stacks.get(sid)
+ _, stack = self.client.get_stack(sid)
# This is an assert of great significance, as it means the following
# has happened:
diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py
index 9ad6bc4..35571c6 100644
--- a/tempest/scenario/test_baremetal_basic_ops.py
+++ b/tempest/scenario/test_baremetal_basic_ops.py
@@ -41,26 +41,23 @@
expected state transitions
"""
def rebuild_instance(self, preserve_ephemeral=False):
- self.rebuild_server(self.instance,
+ self.rebuild_server(server_id=self.instance['id'],
preserve_ephemeral=preserve_ephemeral,
wait=False)
- node = self.get_node(instance_id=self.instance.id)
- self.instance = self.compute_client.servers.get(self.instance.id)
-
- self.addCleanup_with_wait(self.compute_client.servers,
- self.instance.id,
- cleanup_callable=self.delete_wrapper,
- cleanup_args=[self.instance])
+ node = self.get_node(instance_id=self.instance['id'])
# We should remain on the same node
- self.assertEqual(self.node.uuid, node.uuid)
+ self.assertEqual(self.node['uuid'], node['uuid'])
self.node = node
- self.status_timeout(self.compute_client.servers, self.instance.id,
- 'REBUILD')
- self.status_timeout(self.compute_client.servers, self.instance.id,
- 'ACTIVE')
+ self.servers_client.wait_for_server_status(
+ server_id=self.instance['id'],
+ status='REBUILD',
+ ready_wait=False)
+ self.servers_client.wait_for_server_status(
+ server_id=self.instance['id'],
+ status='ACTIVE')
def create_remote_file(self, client, filename):
"""Create a file on the remote client connection.
@@ -99,23 +96,26 @@
def get_flavor_ephemeral_size(self):
"""Returns size of the ephemeral partition in GiB."""
- f_id = self.instance.flavor['id']
- ephemeral = self.compute_client.flavors.get(f_id).ephemeral
- if ephemeral != 'N/A':
- return int(ephemeral)
- return None
+ f_id = self.instance['flavor']['id']
+ _, flavor = self.flavors_client.get_flavor_details(f_id)
+ ephemeral = flavor.get('OS-FLV-EXT-DATA:ephemeral')
+ if not ephemeral or ephemeral == 'N/A':
+ return None
+ return int(ephemeral)
def add_floating_ip(self):
- floating_ip = self.compute_client.floating_ips.create()
- self.instance.add_floating_ip(floating_ip)
- return floating_ip.ip
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], self.instance['id'])
+ return floating_ip['ip']
def validate_ports(self):
- for port in self.get_ports(self.node.uuid):
- n_port_id = port.extra['vif_port_id']
- n_port = self.network_client.show_port(n_port_id)['port']
- self.assertEqual(n_port['device_id'], self.instance.id)
- self.assertEqual(n_port['mac_address'], port.address)
+ for port in self.get_ports(self.node['uuid']):
+ n_port_id = port['extra']['vif_port_id']
+ _, body = self.network_client.show_port(n_port_id)
+ n_port = body['port']
+ self.assertEqual(n_port['device_id'], self.instance['id'])
+ self.assertEqual(n_port['mac_address'], port['address'])
@test.services('baremetal', 'compute', 'image', 'network')
def test_baremetal_server_ops(self):
@@ -133,18 +133,23 @@
# the same size as our flavor definition.
eph_size = self.get_flavor_ephemeral_size()
self.assertIsNotNone(eph_size)
- self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
+ if eph_size > 0:
+ preserve_ephemeral = True
- # Create the test file
- self.create_remote_file(vm_client, test_filename)
+ self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
+ # Create the test file
+ self.create_remote_file(vm_client, test_filename)
+ else:
+ preserve_ephemeral = False
- # Rebuild and preserve the ephemeral partition
- self.rebuild_instance(True)
+ # Rebuild and preserve the ephemeral partition if it exists
+ self.rebuild_instance(preserve_ephemeral)
self.verify_connectivity()
# Check that we maintained our data
- vm_client = self.get_remote_client(self.instance)
- self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
- vm_client.exec_command('ls ' + test_filename)
+ if eph_size > 0:
+ vm_client = self.get_remote_client(self.instance)
+ self.verify_partition(vm_client, 'ephemeral0', '/mnt', eph_size)
+ vm_client.exec_command('ls ' + test_filename)
self.terminate_instance()
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index 366cd93..ac2ef8a 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -37,12 +37,12 @@
def create_encrypted_volume(self, encryption_provider):
volume_type = self.create_volume_type(name='luks')
- self.create_encryption_type(type_id=volume_type.id,
+ self.create_encryption_type(type_id=volume_type['id'],
provider=encryption_provider,
key_size=512,
cipher='aes-xts-plain64',
control_location='front-end')
- self.volume = self.create_volume(volume_type=volume_type.name)
+ self.volume = self.create_volume(volume_type=volume_type['name'])
def attach_detach_volume(self):
self.nova_volume_attach()
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 15cf13b..71b8a7f 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -25,7 +25,7 @@
LOG = logging.getLogger(__name__)
-class TestLargeOpsScenario(manager.NetworkScenarioTest):
+class TestLargeOpsScenario(manager.ScenarioTest):
"""
Test large operations.
@@ -39,39 +39,45 @@
@classmethod
def setUpClass(cls):
+ if CONF.scenario.large_ops_number < 1:
+ raise cls.skipException("large_ops_number not set to multiple "
+ "instances")
cls.set_network_resources()
super(TestLargeOpsScenario, cls).setUpClass()
def _wait_for_server_status(self, status):
for server in self.servers:
- self.status_timeout(
- self.compute_client.servers, server.id, status)
+ self.servers_client.wait_for_server_status(server['id'], status)
def nova_boot(self):
name = data_utils.rand_name('scenario-server-')
- client = self.compute_client
flavor_id = CONF.compute.flavor_ref
- secgroup = self._create_security_group_nova()
- self.servers = client.servers.create(
- name=name, image=self.image,
- flavor=flavor_id,
+ secgroup = self._create_security_group()
+ self.servers_client.create_server(
+ name,
+ self.image,
+ flavor_id,
min_count=CONF.scenario.large_ops_number,
- security_groups=[secgroup.name])
+ security_groups=[secgroup])
# needed because of bug 1199788
- self.servers = [x for x in client.servers.list() if name in x.name]
+ params = {'name': name}
+ _, server_list = self.servers_client.list_servers(params)
+ self.servers = server_list['servers']
for server in self.servers:
# after deleting all servers - wait for all servers to clear
# before cleanup continues
- self.addCleanup(self.delete_timeout,
- self.compute_client.servers,
- server.id)
+ self.addCleanup(self.servers_client.wait_for_server_termination,
+ server['id'])
for server in self.servers:
- self.addCleanup_with_wait(self.compute_client.servers, server.id)
+ self.addCleanup_with_wait(
+ waiter_callable=(self.servers_client.
+ wait_for_server_termination),
+ thing_id=server['id'], thing_id_param='server_id',
+ cleanup_callable=self.delete_wrapper,
+ cleanup_args=[self.servers_client.delete_server, server['id']])
self._wait_for_server_status('ACTIVE')
def _large_ops_scenario(self):
- if CONF.scenario.large_ops_number < 1:
- return
self.glance_image_create()
self.nova_boot()
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 35e50e8..6ab870e 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -72,7 +72,7 @@
super(TestLoadBalancerBasic, self).setUp()
self.server_ips = {}
self.server_fixed_ips = {}
- self._create_security_group()
+ self._create_security_group_for_test()
self._set_net_and_subnet()
def _set_net_and_subnet(self):
@@ -103,8 +103,8 @@
subnet = self._list_subnets(network_id=self.network['id'])[0]
self.subnet = net_common.AttributeDict(subnet)
- def _create_security_group(self):
- self.security_group = self._create_security_group_neutron(
+ def _create_security_group_for_test(self):
+ self.security_group = self._create_security_group(
tenant_id=self.tenant_id)
self._create_security_group_rules_for_port(self.port1)
self._create_security_group_rules_for_port(self.port2)
@@ -117,35 +117,35 @@
'port_range_max': port,
}
self._create_security_group_rule(
- client=self.network_client,
secgroup=self.security_group,
tenant_id=self.tenant_id,
**rule)
def _create_server(self, name):
- keypair = self.create_keypair(name='keypair-%s' % name)
- security_groups = [self.security_group.name]
+ keypair = self.create_keypair()
+ security_groups = [self.security_group]
create_kwargs = {
'nics': [
{'net-id': self.network['id']},
],
- 'key_name': keypair.name,
+ 'key_name': keypair['name'],
'security_groups': security_groups,
}
- server = self.create_server(name=name,
- create_kwargs=create_kwargs)
- self.servers_keypairs[server.id] = keypair
net_name = self.network['name']
+ server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.servers_keypairs[server['id']] = keypair
if (config.network.public_network_id and not
config.network.tenant_networks_reachable):
public_network_id = config.network.public_network_id
floating_ip = self._create_floating_ip(
server, public_network_id)
self.floating_ips[floating_ip] = server
- self.server_ips[server.id] = floating_ip.floating_ip_address
+ self.server_ips[server['id']] = floating_ip.floating_ip_address
else:
- self.server_ips[server.id] = server.networks[net_name][0]
- self.server_fixed_ips[server.id] = server.networks[net_name][0]
+ self.server_ips[server['id']] =\
+ server['addresses'][net_name][0]['addr']
+ self.server_fixed_ips[server['id']] =\
+ server['addresses'][net_name][0]['addr']
self.assertTrue(self.servers_keypairs)
return server
@@ -162,8 +162,8 @@
2. Start two http backends listening on ports 80 and 88 respectively
"""
for server_id, ip in self.server_ips.iteritems():
- private_key = self.servers_keypairs[server_id].private_key
- server_name = self.compute_client.servers.get(server_id).name
+ private_key = self.servers_keypairs[server_id]['private_key']
+ server_name = self.servers_client.get_server(server_id)[1]['name']
username = config.scenario.ssh_user
ssh_client = self.get_remote_client(
server_or_ip=ip,
@@ -269,11 +269,7 @@
protocol_port=80,
subnet_id=self.subnet.id,
pool_id=self.pool.id)
- self.status_timeout(NeutronRetriever(self.network_client,
- self.network_client.vip_path,
- net_common.DeletableVip),
- self.vip.id,
- expected_status='ACTIVE')
+ self.vip.wait_for_status('ACTIVE')
if (config.network.public_network_id and not
config.network.tenant_networks_reachable):
self._assign_floating_ip_to_vip(self.vip)
@@ -286,8 +282,8 @@
# vip port - see https://bugs.launchpad.net/neutron/+bug/1163569
# However the linuxbridge-agent does, and it is necessary to add a
# security group with a rule that allows tcp port 80 to the vip port.
- body = {'port': {'security_groups': [self.security_group.id]}}
- self.network_client.update_port(self.vip.port_id, body)
+ self.network_client.update_port(
+ self.vip.port_id, security_groups=[self.security_group.id])
def _check_load_balancing(self):
"""
@@ -318,27 +314,3 @@
self._start_servers()
self._create_load_balancer()
self._check_load_balancing()
-
-
-class NeutronRetriever(object):
- """
- Helper class to make possible handling neutron objects returned by GET
- requests as attribute dicts.
-
- Whet get() method is called, the returned dictionary is wrapped into
- a corresponding DeletableResource class which provides attribute access
- to dictionary values.
-
- Usage:
- This retriever is used to allow using status_timeout from
- tempest.manager with Neutron objects.
- """
-
- def __init__(self, network_client, path, resource):
- self.network_client = network_client
- self.path = path
- self.resource = resource
-
- def get(self, thing_id):
- obj = self.network_client.get(self.path % thing_id)
- return self.resource(client=self.network_client, **obj.values()[0])
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 47f2f1a..0277593 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -40,9 +40,8 @@
"""
@classmethod
- def setUpClass(cls):
- super(TestNetworkAdvancedServerOps, cls).setUpClass()
- cls.check_preconditions()
+ def check_preconditions(cls):
+ super(TestNetworkAdvancedServerOps, cls).check_preconditions()
if not (CONF.network.tenant_networks_reachable
or CONF.network.public_network_id):
msg = ('Either tenant_networks_reachable must be "true", or '
@@ -50,20 +49,23 @@
cls.enabled = False
raise cls.skipException(msg)
- def _setup_network_and_servers(self):
- key_name = data_utils.rand_name('keypair-smoke-')
- self.keypair = self.create_keypair(name=key_name)
- security_group =\
- self._create_security_group_neutron(tenant_id=self.tenant_id)
- network, subnet, router = self.create_networks(self.tenant_id)
+ @classmethod
+ def setUpClass(cls):
+ # Create no network resources for these tests.
+ cls.set_network_resources()
+ super(TestNetworkAdvancedServerOps, cls).setUpClass()
+ def _setup_network_and_servers(self):
+ self.keypair = self.create_keypair()
+ security_group = self._create_security_group()
+ network, subnet, router = self.create_networks()
public_network_id = CONF.network.public_network_id
create_kwargs = {
- 'nics': [
- {'net-id': network.id},
+ 'networks': [
+ {'uuid': network.id},
],
- 'key_name': self.keypair.name,
- 'security_groups': [security_group.name],
+ 'key_name': self.keypair['name'],
+ 'security_groups': [security_group],
}
server_name = data_utils.rand_name('server-smoke')
self.server = self.create_server(name=server_name,
@@ -76,9 +78,10 @@
def _check_network_connectivity(self, should_connect=True):
username = CONF.compute.image_ssh_user
- private_key = self.keypair.private_key
+ private_key = self.keypair['private_key']
self._check_tenant_network_connectivity(
- self.server, username, private_key, should_connect=should_connect,
+ self.server, username, private_key,
+ should_connect=should_connect,
servers_for_debug=[self.server])
floating_ip = self.floating_ip.floating_ip_address
self._check_public_network_connectivity(floating_ip, username,
@@ -86,31 +89,32 @@
servers=[self.server])
def _wait_server_status_and_check_network_connectivity(self):
- self.status_timeout(self.compute_client.servers, self.server.id,
- 'ACTIVE')
+ self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
self._check_network_connectivity()
+ @test.skip_because(bug="1323658")
@test.services('compute', 'network')
def test_server_connectivity_stop_start(self):
self._setup_network_and_servers()
- self.server.stop()
- self.status_timeout(self.compute_client.servers, self.server.id,
- 'SHUTOFF')
+ self.servers_client.stop(self.server['id'])
+ self.servers_client.wait_for_server_status(self.server['id'],
+ 'SHUTOFF')
self._check_network_connectivity(should_connect=False)
- self.server.start()
+ self.servers_client.start(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
@test.services('compute', 'network')
def test_server_connectivity_reboot(self):
self._setup_network_and_servers()
- self.server.reboot()
+ self.servers_client.reboot(self.server['id'], reboot_type='SOFT')
self._wait_server_status_and_check_network_connectivity()
@test.services('compute', 'network')
def test_server_connectivity_rebuild(self):
self._setup_network_and_servers()
image_ref_alt = CONF.compute.image_ref_alt
- self.server.rebuild(image_ref_alt)
+ self.servers_client.rebuild(self.server['id'],
+ image_ref=image_ref_alt)
self._wait_server_status_and_check_network_connectivity()
@testtools.skipUnless(CONF.compute_feature_enabled.pause,
@@ -118,11 +122,10 @@
@test.services('compute', 'network')
def test_server_connectivity_pause_unpause(self):
self._setup_network_and_servers()
- self.server.pause()
- self.status_timeout(self.compute_client.servers, self.server.id,
- 'PAUSED')
+ self.servers_client.pause_server(self.server['id'])
+ self.servers_client.wait_for_server_status(self.server['id'], 'PAUSED')
self._check_network_connectivity(should_connect=False)
- self.server.unpause()
+ self.servers_client.unpause_server(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
@testtools.skipUnless(CONF.compute_feature_enabled.suspend,
@@ -130,13 +133,14 @@
@test.services('compute', 'network')
def test_server_connectivity_suspend_resume(self):
self._setup_network_and_servers()
- self.server.suspend()
- self.status_timeout(self.compute_client.servers, self.server.id,
- 'SUSPENDED')
+ self.servers_client.suspend_server(self.server['id'])
+ self.servers_client.wait_for_server_status(self.server['id'],
+ 'SUSPENDED')
self._check_network_connectivity(should_connect=False)
- self.server.resume()
+ self.servers_client.resume_server(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
+ @test.skip_because(bug="1323658")
@testtools.skipUnless(CONF.compute_feature_enabled.resize,
'Resize is not available.')
@test.services('compute', 'network')
@@ -146,9 +150,8 @@
msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
raise self.skipException(msg)
self._setup_network_and_servers()
- resize_flavor = CONF.compute.flavor_ref_alt
- self.server.resize(resize_flavor)
- self.status_timeout(self.compute_client.servers, self.server.id,
- 'VERIFY_RESIZE')
- self.server.confirm_resize()
+ self.servers_client.resize(self.server['id'], flavor_ref=resize_flavor)
+ self.servers_client.wait_for_server_status(self.server['id'],
+ 'VERIFY_RESIZE')
+ self.servers_client.confirm_resize(self.server['id'])
self._wait_server_status_and_check_network_connectivity()
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 21a5d1b..904f248 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -34,7 +34,7 @@
['floating_ip', 'server'])
-class TestNetworkBasicOps(manager.NeutronScenarioTest):
+class TestNetworkBasicOps(manager.NetworkScenarioTest):
"""
This smoke test suite assumes that Nova has been configured to
@@ -147,8 +147,8 @@
self.keypairs[keypair['name']] = keypair
security_groups = [self.security_group]
create_kwargs = {
- 'nics': [
- {'net-id': network.id},
+ 'networks': [
+ {'uuid': network.id},
],
'key_name': keypair['name'],
'security_groups': security_groups,
@@ -203,7 +203,7 @@
floating_ip, server)
def _create_new_network(self):
- self.new_net = self._create_network(self.tenant_id)
+ self.new_net = self._create_network(tenant_id=self.tenant_id)
self.new_subnet = self._create_subnet(
network=self.new_net,
gateway_ip=None)
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index e9ca770..658d336 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -99,7 +99,7 @@
"""
def __init__(self, credentials):
- self.manager = clients.OfficialClientManager(credentials)
+ self.manager = clients.Manager(credentials)
# Credentials from manager are filled with both names and IDs
self.creds = self.manager.credentials
self.network = None
@@ -113,13 +113,18 @@
self.subnet = subnet
self.router = router
- def _get_tenant_credentials(self):
- # FIXME(andreaf) Unused method
- return self.creds
-
@classmethod
def check_preconditions(cls):
+ if CONF.baremetal.driver_enabled:
+ msg = ('Not currently supported by baremetal.')
+ cls.enabled = False
+ raise cls.skipException(msg)
super(TestSecurityGroupsBasicOps, cls).check_preconditions()
+ # need alt_creds here to check preconditions
+ cls.alt_creds = cls.alt_credentials()
+ cls.alt_manager = clients.Manager(cls.alt_creds)
+ # Credentials from the manager are filled with both IDs and Names
+ cls.alt_creds = cls.alt_manager.credentials
if (cls.alt_creds is None) or \
(cls.tenant_id is cls.alt_creds.tenant_id):
msg = 'No alt_tenant defined'
@@ -131,21 +136,12 @@
'public_network_id must be defined.')
cls.enabled = False
raise cls.skipException(msg)
- if CONF.baremetal.driver_enabled:
- msg = ('Not currently supported by baremetal.')
- cls.enabled = False
- raise cls.skipException(msg)
@classmethod
def setUpClass(cls):
# Create no network resources for these tests.
cls.set_network_resources()
super(TestSecurityGroupsBasicOps, cls).setUpClass()
- cls.alt_creds = cls.alt_credentials()
- cls.alt_manager = clients.OfficialClientManager(cls.alt_creds)
- # Credentials from the manager are filled with both IDs and Names
- cls.alt_creds = cls.alt_manager.credentials
- cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
# of storing them as collections on the class.
cls.floating_ips = {}
@@ -166,21 +162,22 @@
self._verify_network_details(self.primary_tenant)
self._verify_mac_addr(self.primary_tenant)
- def _create_tenant_keypairs(self, tenant_id):
- keypair = self.create_keypair(
- name=data_utils.rand_name('keypair-smoke-'))
- self.tenants[tenant_id].keypair = keypair
+ def _create_tenant_keypairs(self, tenant):
+ keypair = self.create_keypair(tenant.manager.keypairs_client)
+ tenant.keypair = keypair
def _create_tenant_security_groups(self, tenant):
access_sg = self._create_empty_security_group(
namestart='secgroup_access-',
- tenant_id=tenant.creds.tenant_id
+ tenant_id=tenant.creds.tenant_id,
+ client=tenant.manager.network_client
)
# don't use default secgroup since it allows in-tenant traffic
def_sg = self._create_empty_security_group(
namestart='secgroup_general-',
- tenant_id=tenant.creds.tenant_id
+ tenant_id=tenant.creds.tenant_id,
+ client=tenant.manager.network_client
)
tenant.security_groups.update(access=access_sg, default=def_sg)
ssh_rule = dict(
@@ -189,7 +186,9 @@
port_range_max=22,
direction='ingress',
)
- self._create_security_group_rule(secgroup=access_sg, **ssh_rule)
+ self._create_security_group_rule(secgroup=access_sg,
+ client=tenant.manager.network_client,
+ **ssh_rule)
def _verify_network_details(self, tenant):
# Checks that we see the newly created network/subnet/router via
@@ -216,7 +215,7 @@
myport = (tenant.router.id, tenant.subnet.id)
router_ports = [(i['device_id'], i['fixed_ips'][0]['subnet_id']) for i
- in self.network_client.list_ports()['ports']
+ in self._list_ports()
if self._is_router_port(i)]
self.assertIn(myport, router_ports)
@@ -233,17 +232,16 @@
"""
self._set_compute_context(tenant)
if security_groups is None:
- security_groups = [tenant.security_groups['default'].name]
+ security_groups = [tenant.security_groups['default']]
create_kwargs = {
- 'nics': [
- {'net-id': tenant.network.id},
+ 'networks': [
+ {'uuid': tenant.network.id},
],
- 'key_name': tenant.keypair.name,
+ 'key_name': tenant.keypair['name'],
'security_groups': security_groups,
'tenant_id': tenant.creds.tenant_id
}
- server = self.create_server(name=name, create_kwargs=create_kwargs)
- return server
+ return self.create_server(name=name, create_kwargs=create_kwargs)
def _create_tenant_servers(self, tenant, num=1):
for i in range(num):
@@ -261,27 +259,30 @@
in order to access tenant internal network
workaround ip namespace
"""
- secgroups = [sg.name for sg in tenant.security_groups.values()]
+ secgroups = tenant.security_groups.values()
name = 'server-{tenant}-access_point-'.format(
tenant=tenant.creds.tenant_name)
name = data_utils.rand_name(name)
server = self._create_server(name, tenant,
security_groups=secgroups)
tenant.access_point = server
- self._assign_floating_ips(server)
+ self._assign_floating_ips(tenant, server)
- def _assign_floating_ips(self, server):
+ def _assign_floating_ips(self, tenant, server):
public_network_id = CONF.network.public_network_id
- floating_ip = self._create_floating_ip(server, public_network_id)
- self.floating_ips.setdefault(server, floating_ip)
+ floating_ip = self._create_floating_ip(
+ server, public_network_id,
+ client=tenant.manager.network_client)
+ self.floating_ips.setdefault(server['id'], floating_ip)
def _create_tenant_network(self, tenant):
- network, subnet, router = self.create_networks(tenant.creds.tenant_id)
+ network, subnet, router = self.create_networks(
+ client=tenant.manager.network_client)
tenant.set_network(network, subnet, router)
def _set_compute_context(self, tenant):
- self.compute_client = tenant.manager.compute_client
- return self.compute_client
+ self.servers_client = tenant.manager.servers_client
+ return self.servers_client
def _deploy_tenant(self, tenant_or_id):
"""
@@ -294,12 +295,10 @@
"""
if not isinstance(tenant_or_id, self.TenantProperties):
tenant = self.tenants[tenant_or_id]
- tenant_id = tenant_or_id
else:
tenant = tenant_or_id
- tenant_id = tenant.creds.tenant_id
self._set_compute_context(tenant)
- self._create_tenant_keypairs(tenant_id)
+ self._create_tenant_keypairs(tenant)
self._create_tenant_network(tenant)
self._create_tenant_security_groups(tenant)
self._set_access_point(tenant)
@@ -309,12 +308,12 @@
returns the ip (floating/internal) of a server
"""
if floating:
- server_ip = self.floating_ips[server].floating_ip_address
+ server_ip = self.floating_ips[server['id']].floating_ip_address
else:
server_ip = None
- network_name = self.tenants[server.tenant_id].network.name
- if network_name in server.networks:
- server_ip = server.networks[network_name][0]
+ network_name = self.tenants[server['tenant_id']].network.name
+ if network_name in server['addresses']:
+ server_ip = server['addresses'][network_name][0]['addr']
return server_ip
def _connect_to_access_point(self, tenant):
@@ -322,8 +321,8 @@
create ssh connection to tenant access point
"""
access_point_ssh = \
- self.floating_ips[tenant.access_point].floating_ip_address
- private_key = tenant.keypair.private_key
+ self.floating_ips[tenant.access_point['id']].floating_ip_address
+ private_key = tenant.keypair['private_key']
access_point_ssh = self._ssh_to_server(access_point_ssh,
private_key=private_key)
return access_point_ssh
@@ -387,6 +386,7 @@
)
self._create_security_group_rule(
secgroup=dest_tenant.security_groups['default'],
+ client=dest_tenant.manager.network_client,
**ruleset
)
access_point_ssh = self._connect_to_access_point(source_tenant)
@@ -400,6 +400,7 @@
# allow reverse traffic and check
self._create_security_group_rule(
secgroup=source_tenant.security_groups['default'],
+ client=source_tenant.manager.network_client,
**ruleset
)
@@ -418,8 +419,7 @@
mac_addr = mac_addr.strip().lower()
# Get the fixed_ips and mac_address fields of all ports. Select
# only those two columns to reduce the size of the response.
- port_list = self.network_client.list_ports(
- fields=['fixed_ips', 'mac_address'])['ports']
+ port_list = self._list_ports(fields=['fixed_ips', 'mac_address'])
port_detail_list = [
(port['fixed_ips'][0]['subnet_id'],
port['fixed_ips'][0]['ip_address'],
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 4783273..f2c3dcd 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -15,7 +15,6 @@
import time
-from cinderclient import exceptions as cinder_exceptions
import testtools
from tempest.common.utils import data_utils
@@ -30,7 +29,7 @@
LOG = logging.getLogger(__name__)
-class TestStampPattern(manager.OfficialClientTest):
+class TestStampPattern(manager.ScenarioTest):
"""
This test is for snapshotting an instance/volume and attaching the volume
created from snapshot to the instance booted from snapshot.
@@ -59,13 +58,13 @@
raise cls.skipException("Cinder volume snapshots are disabled")
def _wait_for_volume_snapshot_status(self, volume_snapshot, status):
- self.status_timeout(self.volume_client.volume_snapshots,
- volume_snapshot.id, status)
+ self.snapshots_client.wait_for_snapshot_status(volume_snapshot['id'],
+ status)
def _boot_image(self, image_id):
- security_groups = [self.security_group.name]
+ security_groups = [self.security_group]
create_kwargs = {
- 'key_name': self.keypair.name,
+ 'key_name': self.keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
@@ -74,53 +73,54 @@
self.keypair = self.create_keypair()
def _create_floating_ip(self):
- floating_ip = self.compute_client.floating_ips.create()
- self.addCleanup(self.delete_wrapper, floating_ip)
+ _, floating_ip = self.floating_ips_client.create_floating_ip()
+ self.addCleanup(self.delete_wrapper,
+ self.floating_ips_client.delete_floating_ip,
+ floating_ip['id'])
return floating_ip
def _add_floating_ip(self, server, floating_ip):
- server.add_floating_ip(floating_ip)
+ self.floating_ips_client.associate_floating_ip_to_server(
+ floating_ip['ip'], server['id'])
def _ssh_to_server(self, server_or_ip):
return self.get_remote_client(server_or_ip)
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot-')
- volume_snapshots = self.volume_client.volume_snapshots
- snapshot = volume_snapshots.create(
- volume.id, display_name=snapshot_name)
+ _, snapshot = self.snapshots_client.create_snapshot(
+ volume['id'], display_name=snapshot_name)
def cleaner():
- volume_snapshots.delete(snapshot)
+ self.snapshots_client.delete_snapshot(snapshot['id'])
try:
- while volume_snapshots.get(snapshot.id):
+ while self.snapshots_client.get_snapshot(snapshot['id']):
time.sleep(1)
- except cinder_exceptions.NotFound:
+ except exceptions.NotFound:
pass
self.addCleanup(cleaner)
self._wait_for_volume_status(volume, 'available')
- self._wait_for_volume_snapshot_status(snapshot, 'available')
- self.assertEqual(snapshot_name, snapshot.display_name)
+ self.snapshots_client.wait_for_snapshot_status(snapshot['id'],
+ 'available')
+ self.assertEqual(snapshot_name, snapshot['display_name'])
return snapshot
def _wait_for_volume_status(self, volume, status):
- self.status_timeout(
- self.volume_client.volumes, volume.id, status)
+ self.volumes_client.wait_for_volume_status(volume['id'], status)
def _create_volume(self, snapshot_id=None):
return self.create_volume(snapshot_id=snapshot_id)
def _attach_volume(self, server, volume):
- attach_volume_client = self.compute_client.volumes.create_server_volume
- attached_volume = attach_volume_client(server.id,
- volume.id,
- '/dev/vdb')
- self.assertEqual(volume.id, attached_volume.id)
+ # TODO(andreaf) we should use device from config instead if vdb
+ _, attached_volume = self.servers_client.attach_volume(
+ server['id'], volume['id'], device='/dev/vdb')
+ attached_volume = attached_volume['volumeAttachment']
+ self.assertEqual(volume['id'], attached_volume['id'])
self._wait_for_volume_status(attached_volume, 'in-use')
def _detach_volume(self, server, volume):
- detach_volume_client = self.compute_client.volumes.delete_server_volume
- detach_volume_client(server.id, volume.id)
+ self.servers_client.detach_volume(server['id'], volume['id'])
self._wait_for_volume_status(volume, 'available')
def _wait_for_volume_available_on_the_system(self, server_or_ip):
@@ -157,7 +157,7 @@
def test_stamp_pattern(self):
# prepare for booting a instance
self._add_keypair()
- self.security_group = self._create_security_group_nova()
+ self.security_group = self._create_security_group()
# boot an instance and create a timestamp file in it
volume = self._create_volume()
@@ -167,7 +167,7 @@
if CONF.compute.use_floatingip_for_ssh:
floating_ip_for_server = self._create_floating_ip()
self._add_floating_ip(server, floating_ip_for_server)
- ip_for_server = floating_ip_for_server.ip
+ ip_for_server = floating_ip_for_server['ip']
else:
ip_for_server = server
@@ -184,17 +184,17 @@
# create second volume from the snapshot(volume2)
volume_from_snapshot = self._create_volume(
- snapshot_id=volume_snapshot.id)
+ snapshot_id=volume_snapshot['id'])
# boot second instance from the snapshot(instance2)
- server_from_snapshot = self._boot_image(snapshot_image.id)
+ server_from_snapshot = self._boot_image(snapshot_image['id'])
# create and add floating IP to server_from_snapshot
if CONF.compute.use_floatingip_for_ssh:
floating_ip_for_snapshot = self._create_floating_ip()
self._add_floating_ip(server_from_snapshot,
floating_ip_for_snapshot)
- ip_for_snapshot = floating_ip_for_snapshot.ip
+ ip_for_snapshot = floating_ip_for_snapshot['ip']
else:
ip_for_snapshot = server_from_snapshot
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
index ad74ec4..9e0fee0 100644
--- a/tempest/scenario/test_swift_basic_ops.py
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -41,13 +41,13 @@
@test.services('object_storage')
def test_swift_basic_ops(self):
- self._get_swift_stat()
- container_name = self._create_container()
- obj_name, obj_data = self._upload_object_to_container(container_name)
- self._list_and_check_container_objects(container_name, [obj_name])
- self._download_and_verify(container_name, obj_name, obj_data)
- self._delete_object(container_name, obj_name)
- self._delete_container(container_name)
+ self.get_swift_stat()
+ container_name = self.create_container()
+ obj_name, obj_data = self.upload_object_to_container(container_name)
+ self.list_and_check_container_objects(container_name, [obj_name])
+ self.download_and_verify(container_name, obj_name, obj_data)
+ self.delete_object(container_name, obj_name)
+ self.delete_container(container_name)
@test.services('object_storage')
def test_swift_acl_anonymous_download(self):
@@ -58,15 +58,15 @@
4. Check if the object can be download by anonymous user
5. Delete the object and container
"""
- container_name = self._create_container()
- obj_name, _ = self._upload_object_to_container(container_name)
+ container_name = self.create_container()
+ obj_name, _ = self.upload_object_to_container(container_name)
obj_url = '%s/%s/%s' % (self.object_client.base_url,
container_name, obj_name)
http_client = http.ClosingHttp()
resp, _ = http_client.request(obj_url, 'GET')
self.assertEqual(resp.status, 401)
- self._change_container_acl(container_name, '.r:*')
+ self.change_container_acl(container_name, '.r:*')
resp, _ = http_client.request(obj_url, 'GET')
self.assertEqual(resp.status, 200)
- self._delete_object(container_name, obj_name)
- self._delete_container(container_name)
+ self.delete_object(container_name, obj_name)
+ self.delete_container(container_name)
diff --git a/tempest/scenario/utils.py b/tempest/scenario/utils.py
index e2adb34..c20f20c 100644
--- a/tempest/scenario/utils.py
+++ b/tempest/scenario/utils.py
@@ -40,33 +40,33 @@
self.non_ssh_image_pattern = \
CONF.input_scenario.non_ssh_image_regex
# Setup clients
- ocm = clients.OfficialClientManager(
- auth.get_default_credentials('user'))
- self.client = ocm.compute_client
+ os = clients.Manager()
+ self.images_client = os.images_client
+ self.flavors_client = os.flavors_client
def ssh_user(self, image_id):
- _image = self.client.images.get(image_id)
+ _, _image = self.images_client.get_image(image_id)
for regex, user in self.ssh_users:
# First match wins
- if re.match(regex, _image.name) is not None:
+ if re.match(regex, _image['name']) is not None:
return user
else:
return self.default_ssh_user
def _is_sshable_image(self, image):
return not re.search(pattern=self.non_ssh_image_pattern,
- string=str(image.name))
+ string=str(image['name']))
def is_sshable_image(self, image_id):
- _image = self.client.images.get(image_id)
+ _, _image = self.images_client.get_image(image_id)
return self._is_sshable_image(_image)
def _is_flavor_enough(self, flavor, image):
- return image.minDisk <= flavor.disk
+ return image['minDisk'] <= flavor['disk']
def is_flavor_enough(self, flavor_id, image_id):
- _image = self.client.images.get(image_id)
- _flavor = self.client.flavors.get(flavor_id)
+ _, _image = self.images_client.get_image(image_id)
+ _, _flavor = self.flavors_client.get_flavor_details(flavor_id)
return self._is_flavor_enough(_flavor, _image)
@@ -81,7 +81,7 @@
load_tests = testscenarios.load_tests_apply_scenarios
- class TestInputScenario(manager.OfficialClientTest):
+ class TestInputScenario(manager.ScenarioTest):
scenario_utils = utils.InputScenarioUtils()
scenario_flavor = scenario_utils.scenario_flavors
@@ -91,17 +91,18 @@
def test_create_server_metadata(self):
name = rand_name('instance')
- _ = self.compute_client.servers.create(name=name,
- flavor=self.flavor_ref,
- image=self.image_ref)
+ self.servers_client.create_server(name=name,
+ flavor_ref=self.flavor_ref,
+ image_ref=self.image_ref)
"""
validchars = "-_.{ascii}{digit}".format(ascii=string.ascii_letters,
digit=string.digits)
def __init__(self):
- ocm = clients.OfficialClientManager(
+ os = clients.Manager(
auth.get_default_credentials('user', fill_in=False))
- self.client = ocm.compute_client
+ self.images_client = os.images_client
+ self.flavors_client = os.flavors_client
self.image_pattern = CONF.input_scenario.image_regex
self.flavor_pattern = CONF.input_scenario.flavor_regex
@@ -118,10 +119,11 @@
if not CONF.service_available.glance:
return []
if not hasattr(self, '_scenario_images'):
- images = self.client.images.list(detailed=False)
+ _, images = self.images_client.list_images()
self._scenario_images = [
- (self._normalize_name(i.name), dict(image_ref=i.id))
- for i in images if re.search(self.image_pattern, str(i.name))
+ (self._normalize_name(i['name']), dict(image_ref=i['id']))
+ for i in images if re.search(self.image_pattern,
+ str(i['name']))
]
return self._scenario_images
@@ -131,10 +133,11 @@
:return: a scenario with name and uuid of flavors
"""
if not hasattr(self, '_scenario_flavors'):
- flavors = self.client.flavors.list(detailed=False)
+ _, flavors = self.flavors_client.list_flavors()
self._scenario_flavors = [
- (self._normalize_name(f.name), dict(flavor_ref=f.id))
- for f in flavors if re.search(self.flavor_pattern, str(f.name))
+ (self._normalize_name(f['name']), dict(flavor_ref=f['id']))
+ for f in flavors if re.search(self.flavor_pattern,
+ str(f['name']))
]
return self._scenario_flavors
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
index 0b97f74..4933300 100644
--- a/tempest/services/baremetal/base.py
+++ b/tempest/services/baremetal/base.py
@@ -95,9 +95,13 @@
for ch in get_change(value, path + '%s/' % name):
yield ch
else:
- yield {'path': path + name,
- 'value': value,
- 'op': 'replace'}
+ if value is None:
+ yield {'path': path + name,
+ 'op': 'remove'}
+ else:
+ yield {'path': path + name,
+ 'value': value,
+ 'op': 'replace'}
patch = [ch for ch in get_change(kw)
if ch['path'].lstrip('/') in allowed_attributes]
diff --git a/tempest/services/baremetal/v1/base_v1.py b/tempest/services/baremetal/v1/base_v1.py
index 07eee8a..9359808 100644
--- a/tempest/services/baremetal/v1/base_v1.py
+++ b/tempest/services/baremetal/v1/base_v1.py
@@ -27,9 +27,9 @@
self.uri_prefix = 'v%s' % self.version
@base.handle_errors
- def list_nodes(self):
+ def list_nodes(self, **kwargs):
"""List all existing nodes."""
- return self._list_request('nodes')
+ return self._list_request('nodes', **kwargs)
@base.handle_errors
def list_chassis(self):
@@ -37,11 +37,21 @@
return self._list_request('chassis')
@base.handle_errors
+ def list_chassis_nodes(self, chassis_uuid):
+ """List all nodes associated with a chassis."""
+ return self._list_request('/chassis/%s/nodes' % chassis_uuid)
+
+ @base.handle_errors
def list_ports(self, **kwargs):
"""List all existing ports."""
return self._list_request('ports', **kwargs)
@base.handle_errors
+ def list_node_ports(self, uuid):
+ """List all ports associated with the node."""
+ return self._list_request('/nodes/%s/ports' % uuid)
+
+ @base.handle_errors
def list_nodestates(self, uuid):
"""List all existing states."""
return self._list_request('/nodes/%s/states' % uuid)
@@ -68,6 +78,21 @@
return self._show_request('nodes', uuid)
@base.handle_errors
+ def show_node_by_instance_uuid(self, instance_uuid):
+ """
+ Gets a node associated with given instance uuid.
+
+ :param uuid: Unique identifier of the node in UUID format.
+ :return: Serialized node as a dictionary.
+
+ """
+ uri = '/nodes/detail?instance_uuid=%s' % instance_uuid
+
+ return self._show_request('nodes',
+ uuid=None,
+ uri=uri)
+
+ @base.handle_errors
def show_chassis(self, uuid):
"""
Gets a specific chassis.
@@ -203,7 +228,8 @@
'properties/cpu_num',
'properties/storage',
'properties/memory',
- 'driver')
+ 'driver',
+ 'instance_uuid')
patch = self._make_patch(node_attributes, **kwargs)
@@ -308,3 +334,33 @@
resp, body = self._list_request(path)
self.expected_success(200, resp.status)
return body
+
+ @base.handle_errors
+ def get_console(self, node_uuid):
+ """
+ Get connection information about the console.
+
+ :param node_uuid: Unique identifier of the node in UUID format.
+
+ """
+
+ resp, body = self._show_request('nodes/states/console', node_uuid)
+ self.expected_success(200, resp.status)
+ return resp, body
+
+ @base.handle_errors
+ def set_console_mode(self, node_uuid, enabled):
+ """
+ Start and stop the node console.
+
+ :param node_uuid: Unique identifier of the node in UUID format.
+ :param enabled: Boolean value; whether to enable or disable the
+ console.
+
+ """
+
+ enabled = {'enabled': enabled}
+ resp, body = self._put_request('nodes/%s/states/console' % node_uuid,
+ enabled)
+ self.expected_success(202, resp.status)
+ return resp, body
diff --git a/tempest/services/compute/json/security_group_default_rules_client.py b/tempest/services/compute/json/security_group_default_rules_client.py
index 6d29837..7743f9c 100644
--- a/tempest/services/compute/json/security_group_default_rules_client.py
+++ b/tempest/services/compute/json/security_group_default_rules_client.py
@@ -15,6 +15,8 @@
import json
+from tempest.api_schema.response.compute.v2 import \
+ security_group_default_rule as schema
from tempest.common import rest_client
from tempest import config
@@ -46,8 +48,9 @@
post_body = json.dumps({'security_group_default_rule': post_body})
url = 'os-security-group-default-rules'
resp, body = self.post(url, post_body)
- self.expected_success(200, resp.status)
body = json.loads(body)
+ self.validate_response(schema.create_get_security_group_default_rule,
+ resp, body)
return resp, body['security_group_default_rule']
def delete_security_group_default_rule(self,
@@ -55,20 +58,23 @@
"""Deletes the provided Security Group default rule."""
resp, body = self.delete('os-security-group-default-rules/%s' % str(
security_group_default_rule_id))
- self.expected_success(204, resp.status)
+ self.validate_response(schema.delete_security_group_default_rule,
+ resp, body)
return resp, body
def list_security_group_default_rules(self):
"""List all Security Group default rules."""
resp, body = self.get('os-security-group-default-rules')
- self.expected_success(200, resp.status)
body = json.loads(body)
+ self.validate_response(schema.list_security_group_default_rules,
+ resp, body)
return resp, body['security_group_default_rules']
def get_security_group_default_rule(self, security_group_default_rule_id):
"""Return the details of provided Security Group default rule."""
resp, body = self.get('os-security-group-default-rules/%s' % str(
security_group_default_rule_id))
- self.expected_success(200, resp.status)
body = json.loads(body)
+ self.validate_response(schema.create_get_security_group_default_rule,
+ resp, body)
return resp, body['security_group_default_rule']
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 88b68d3..947ba7a 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -175,11 +175,12 @@
return resp, body
def wait_for_server_status(self, server_id, status, extra_timeout=0,
- raise_on_error=True):
+ raise_on_error=True, ready_wait=True):
"""Waits for a server to reach a given status."""
return waiters.wait_for_server_status(self, server_id, status,
extra_timeout=extra_timeout,
- raise_on_error=raise_on_error)
+ raise_on_error=raise_on_error,
+ ready_wait=ready_wait)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index ac65f81..e76c1bd 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -309,6 +309,7 @@
body = json.dumps(creds)
resp, body = self.post(self.auth_url, body=body)
+ self.expected_success(200, resp.status)
return resp, body['access']
@@ -326,6 +327,7 @@
body = json.dumps(creds)
resp, body = self.post(self.auth_url, body=body)
+ self.expected_success(200, resp.status)
return resp, body['access']
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index f795c7b..d424f4c 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -41,13 +41,14 @@
}
post_body = json.dumps({'credential': post_body})
resp, body = self.post('credentials', post_body)
+ self.expected_success(201, resp.status)
body = json.loads(body)
body['credential']['blob'] = json.loads(body['credential']['blob'])
return resp, body['credential']
def update_credential(self, credential_id, **kwargs):
"""Updates a credential."""
- resp, body = self.get_credential(credential_id)
+ _, body = self.get_credential(credential_id)
cred_type = kwargs.get('type', body['type'])
access_key = kwargs.get('access_key', body['blob']['access'])
secret_key = kwargs.get('secret_key', body['blob']['secret'])
@@ -63,6 +64,7 @@
}
post_body = json.dumps({'credential': post_body})
resp, body = self.patch('credentials/%s' % credential_id, post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
body['credential']['blob'] = json.loads(body['credential']['blob'])
return resp, body['credential']
@@ -70,6 +72,7 @@
def get_credential(self, credential_id):
"""To GET Details of a credential."""
resp, body = self.get('credentials/%s' % credential_id)
+ self.expected_success(200, resp.status)
body = json.loads(body)
body['credential']['blob'] = json.loads(body['credential']['blob'])
return resp, body['credential']
@@ -77,10 +80,12 @@
def list_credentials(self):
"""Lists out all the available credentials."""
resp, body = self.get('credentials')
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['credentials']
def delete_credential(self, credential_id):
"""Deletes a credential."""
resp, body = self.delete('credentials/%s' % credential_id)
+ self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index f7a894b..c3fedb2 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -32,6 +32,7 @@
def list_endpoints(self):
"""GET endpoints."""
resp, body = self.get('endpoints')
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['endpoints']
@@ -56,6 +57,7 @@
}
post_body = json.dumps({'endpoint': post_body})
resp, body = self.post('endpoints', post_body)
+ self.expected_success(201, resp.status)
body = json.loads(body)
return resp, body['endpoint']
@@ -82,10 +84,12 @@
post_body['enabled'] = enabled
post_body = json.dumps({'endpoint': post_body})
resp, body = self.patch('endpoints/%s' % endpoint_id, post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['endpoint']
def delete_endpoint(self, endpoint_id):
"""Delete endpoint."""
resp_header, resp_body = self.delete('endpoints/%s' % endpoint_id)
+ self.expected_success(204, resp_header.status)
return resp_header, resp_body
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 0522f37..df424ca 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -588,6 +588,7 @@
body = json.dumps(creds)
resp, body = self.post(self.auth_url, body=body)
+ self.expected_success(201, resp.status)
return resp, body
def request(self, method, url, extra_headers=False, headers=None,
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 3c90fa1..e093260 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -37,12 +37,14 @@
}
post_body = json.dumps({'policy': post_body})
resp, body = self.post('policies', post_body)
+ self.expected_success(201, resp.status)
body = json.loads(body)
return resp, body['policy']
def list_policies(self):
"""Lists the policies."""
resp, body = self.get('policies')
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['policies']
@@ -50,12 +52,12 @@
"""Lists out the given policy."""
url = 'policies/%s' % policy_id
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['policy']
def update_policy(self, policy_id, **kwargs):
"""Updates a policy."""
- resp, body = self.get_policy(policy_id)
type = kwargs.get('type')
post_body = {
'type': type
@@ -63,10 +65,13 @@
post_body = json.dumps({'policy': post_body})
url = 'policies/%s' % policy_id
resp, body = self.patch(url, post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['policy']
def delete_policy(self, policy_id):
"""Deletes the policy."""
url = "policies/%s" % policy_id
- return self.delete(url)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return resp, body
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index c078765..becea6b 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -43,6 +43,7 @@
'regions/%s' % kwargs.get('unique_region_id'), req_body)
else:
resp, body = self.post('regions', req_body)
+ self.expected_success(201, resp.status)
body = json.loads(body)
return resp, body['region']
@@ -55,6 +56,7 @@
post_body['parent_region_id'] = kwargs.get('parent_region_id')
post_body = json.dumps({'region': post_body})
resp, body = self.patch('regions/%s' % region_id, post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['region']
@@ -62,6 +64,7 @@
"""Get region."""
url = 'regions/%s' % region_id
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['region']
@@ -71,10 +74,12 @@
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['regions']
def delete_region(self, region_id):
"""Delete region."""
resp, body = self.delete('regions/%s' % region_id)
+ self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index 82e8aad..8e89957 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -57,10 +57,10 @@
def create_service(self, serv_type, name=None, description=None,
enabled=True):
body_dict = {
- "name": name,
+ 'name': name,
'type': serv_type,
'enabled': enabled,
- "description": description,
+ 'description': description,
}
body = json.dumps({'service': body_dict})
resp, body = self.post("services", body)
@@ -73,3 +73,9 @@
resp, body = self.delete(url)
self.expected_success(204, resp.status)
return resp, body
+
+ def list_services(self):
+ resp, body = self.get('services')
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return resp, body['services']
diff --git a/tempest/services/identity/v3/xml/credentials_client.py b/tempest/services/identity/v3/xml/credentials_client.py
index 3c44188..37513d0 100644
--- a/tempest/services/identity/v3/xml/credentials_client.py
+++ b/tempest/services/identity/v3/xml/credentials_client.py
@@ -60,13 +60,14 @@
type=cred_type, user_id=user_id)
credential.append(blob)
resp, body = self.post('credentials', str(common.Document(credential)))
+ self.expected_success(201, resp.status)
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
def update_credential(self, credential_id, **kwargs):
"""Updates a credential."""
- resp, body = self.get_credential(credential_id)
+ _, body = self.get_credential(credential_id)
cred_type = kwargs.get('type', body['type'])
access_key = kwargs.get('access_key', body['blob']['access'])
secret_key = kwargs.get('secret_key', body['blob']['secret'])
@@ -83,6 +84,7 @@
credential.append(blob)
resp, body = self.patch('credentials/%s' % credential_id,
str(common.Document(credential)))
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
@@ -90,6 +92,7 @@
def get_credential(self, credential_id):
"""To GET Details of a credential."""
resp, body = self.get('credentials/%s' % credential_id)
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
body['blob'] = json.loads(body['blob'])
return resp, body
@@ -97,10 +100,12 @@
def list_credentials(self):
"""Lists out all the available credentials."""
resp, body = self.get('credentials')
+ self.expected_success(200, resp.status)
body = self._parse_creds(etree.fromstring(body))
return resp, body
def delete_credential(self, credential_id):
"""Deletes a credential."""
resp, body = self.delete('credentials/%s' % credential_id)
+ self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/identity/v3/xml/endpoints_client.py b/tempest/services/identity/v3/xml/endpoints_client.py
index 6490e34..892fb58 100644
--- a/tempest/services/identity/v3/xml/endpoints_client.py
+++ b/tempest/services/identity/v3/xml/endpoints_client.py
@@ -65,6 +65,7 @@
def list_endpoints(self):
"""Get the list of endpoints."""
resp, body = self.get("endpoints")
+ self.expected_success(200, resp.status)
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -90,6 +91,7 @@
enabled=enabled)
resp, body = self.post('endpoints',
str(common.Document(create_endpoint)))
+ self.expected_success(201, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -120,10 +122,12 @@
endpoint.add_attr("enabled", str(enabled).lower())
resp, body = self.patch('endpoints/%s' % str(endpoint_id), str(doc))
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_endpoint(self, endpoint_id):
"""Delete endpoint."""
resp_header, resp_body = self.delete('endpoints/%s' % endpoint_id)
+ self.expected_success(204, resp_header.status)
return resp_header, resp_body
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index 5b761b3..5c43692 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -590,6 +590,7 @@
auth.append(scope)
resp, body = self.post(self.auth_url, body=str(common.Document(auth)))
+ self.expected_success(201, resp.status)
return resp, body
def request(self, method, url, extra_headers=False, headers=None,
diff --git a/tempest/services/identity/v3/xml/policy_client.py b/tempest/services/identity/v3/xml/policy_client.py
index 73d831b..41bbfe5 100644
--- a/tempest/services/identity/v3/xml/policy_client.py
+++ b/tempest/services/identity/v3/xml/policy_client.py
@@ -67,12 +67,14 @@
create_policy = common.Element("policy", xmlns=XMLNS,
blob=blob, type=type)
resp, body = self.post('policies', str(common.Document(create_policy)))
+ self.expected_success(201, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
def list_policies(self):
"""Lists the policies."""
resp, body = self.get('policies')
+ self.expected_success(200, resp.status)
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -80,20 +82,23 @@
"""Lists out the given policy."""
url = 'policies/%s' % policy_id
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
def update_policy(self, policy_id, **kwargs):
"""Updates a policy."""
- resp, body = self.get_policy(policy_id)
type = kwargs.get('type')
update_policy = common.Element("policy", xmlns=XMLNS, type=type)
url = 'policies/%s' % policy_id
resp, body = self.patch(url, str(common.Document(update_policy)))
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
def delete_policy(self, policy_id):
"""Deletes the policy."""
url = "policies/%s" % policy_id
- return self.delete(url)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return resp, body
diff --git a/tempest/services/identity/v3/xml/region_client.py b/tempest/services/identity/v3/xml/region_client.py
index f854138..7669678 100644
--- a/tempest/services/identity/v3/xml/region_client.py
+++ b/tempest/services/identity/v3/xml/region_client.py
@@ -79,6 +79,7 @@
else:
resp, body = self.post('regions',
str(common.Document(create_region)))
+ self.expected_success(201, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -95,6 +96,7 @@
resp, body = self.patch('regions/%s' % str(region_id),
str(common.Document(update_region)))
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -102,6 +104,7 @@
"""Get Region."""
url = 'regions/%s' % region_id
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = self._parse_body(etree.fromstring(body))
return resp, body
@@ -111,10 +114,12 @@
if params:
url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = self._parse_array(etree.fromstring(body))
return resp, body
def delete_region(self, region_id):
"""Delete region."""
resp, body = self.delete('regions/%s' % region_id)
+ self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/identity/v3/xml/service_client.py b/tempest/services/identity/v3/xml/service_client.py
index 3beeb89..14adfac 100644
--- a/tempest/services/identity/v3/xml/service_client.py
+++ b/tempest/services/identity/v3/xml/service_client.py
@@ -37,6 +37,14 @@
data = common.xml_to_json(body)
return data
+ def _parse_array(self, node):
+ array = []
+ for child in node.getchildren():
+ tag_list = child.tag.split('}', 1)
+ if tag_list[1] == "service":
+ array.append(common.xml_to_json(child))
+ return array
+
def update_service(self, service_id, **kwargs):
"""Updates a service_id."""
resp, body = self.get_service(service_id)
@@ -79,3 +87,9 @@
resp, body = self.delete(url)
self.expected_success(204, resp.status)
return resp, body
+
+ def list_services(self):
+ resp, body = self.get('services')
+ self.expected_success(200, resp.status)
+ body = self._parse_array(etree.fromstring(body))
+ return resp, body
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
index 4ada46c..eaf9390 100644
--- a/tempest/services/identity/xml/identity_client.py
+++ b/tempest/services/identity/xml/identity_client.py
@@ -157,6 +157,7 @@
auth = xml.Element('auth', **auth_kwargs)
auth.append(passwordCreds)
resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
+ self.expected_success(200, resp.status)
return resp, body['access']
def auth_token(self, token_id, tenant=None):
@@ -167,4 +168,5 @@
auth = xml.Element('auth', **auth_kwargs)
auth.append(tokenCreds)
resp, body = self.post(self.auth_url, body=str(xml.Document(auth)))
+ self.expected_success(200, resp.status)
return resp, body['access']
diff --git a/tempest/services/queuing/__init__.py b/tempest/services/messaging/__init__.py
similarity index 100%
rename from tempest/services/queuing/__init__.py
rename to tempest/services/messaging/__init__.py
diff --git a/tempest/services/queuing/json/__init__.py b/tempest/services/messaging/json/__init__.py
similarity index 100%
rename from tempest/services/queuing/json/__init__.py
rename to tempest/services/messaging/json/__init__.py
diff --git a/tempest/services/queuing/json/queuing_client.py b/tempest/services/messaging/json/messaging_client.py
similarity index 95%
rename from tempest/services/queuing/json/queuing_client.py
rename to tempest/services/messaging/json/messaging_client.py
index 14960ad..3e82399 100644
--- a/tempest/services/queuing/json/queuing_client.py
+++ b/tempest/services/messaging/json/messaging_client.py
@@ -16,7 +16,7 @@
import json
import urllib
-from tempest.api_schema.response.queuing.v1 import queues as queues_schema
+from tempest.api_schema.response.messaging.v1 import queues as queues_schema
from tempest.common import rest_client
from tempest.common.utils import data_utils
from tempest import config
@@ -25,11 +25,11 @@
CONF = config.CONF
-class QueuingClientJSON(rest_client.RestClient):
+class MessagingClientJSON(rest_client.RestClient):
def __init__(self, auth_provider):
- super(QueuingClientJSON, self).__init__(auth_provider)
- self.service = CONF.queuing.catalog_type
+ super(MessagingClientJSON, self).__init__(auth_provider)
+ self.service = CONF.messaging.catalog_type
self.version = '1'
self.uri_prefix = 'v{0}'.format(self.version)
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index 94ba5aa..5ad5f37 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -13,6 +13,7 @@
import time
import urllib
+from tempest.common.utils import misc
from tempest import config
from tempest import exceptions
@@ -227,3 +228,39 @@
except exceptions.NotFound:
return True
return False
+
+ def wait_for_resource_status(self, fetch, status, interval=None,
+ timeout=None):
+ """
+ @summary: Waits for a network resource to reach a status
+ @param fetch: the callable to be used to query the resource status
+ @type fecth: callable that takes no parameters and returns the resource
+ @param status: the status that the resource has to reach
+ @type status: String
+ @param interval: the number of seconds to wait between each status
+ query
+ @type interval: Integer
+ @param timeout: the maximum number of seconds to wait for the resource
+ to reach the desired status
+ @type timeout: Integer
+ """
+ if not interval:
+ interval = self.build_interval
+ if not timeout:
+ timeout = self.build_timeout
+ start_time = time.time()
+
+ while time.time() - start_time <= timeout:
+ resource = fetch()
+ if resource['status'] == status:
+ return
+ time.sleep(interval)
+
+ # At this point, the wait has timed out
+ message = 'Resource %s' % (str(resource))
+ message += ' failed to reach status %s' % status
+ message += ' within the required time %s' % timeout
+ caller = misc.find_test_caller()
+ if caller:
+ message = '(%s) %s' % (caller, message)
+ raise exceptions.TimeoutException(message)
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
index b2feb87..2b182d0 100644
--- a/tempest/services/network/resources.py
+++ b/tempest/services/network/resources.py
@@ -51,9 +51,19 @@
def delete(self):
return
+ @abc.abstractmethod
+ def show(self):
+ return
+
def __hash__(self):
return hash(self.id)
+ def wait_for_status(self, status):
+ if not hasattr(self, 'status'):
+ return
+
+ return self.client.wait_for_resource_status(self.show, status)
+
class DeletableNetwork(DeletableResource):
@@ -161,3 +171,8 @@
def delete(self):
self.client.delete_vip(self.id)
+
+ def show(self):
+ _, result = self.client.show_vip(self.id)
+ super(DeletableVip, self).update(**result['vip'])
+ return self
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index eca57c0..4dc588f 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -58,8 +58,6 @@
"""Delete an account."""
url = ''
if params:
- if 'bulk-delete' in params:
- url += 'bulk-delete&'
url = '?%s%s' % (url, urllib.urlencode(params))
resp, body = self.delete(url, headers={}, body=data)
@@ -74,13 +72,19 @@
return resp, body
def create_account_metadata(self, metadata,
- metadata_prefix='X-Account-Meta-'):
+ metadata_prefix='X-Account-Meta-',
+ data=None, params=None):
"""Creates an account metadata entry."""
headers = {}
- for key in metadata:
- headers[metadata_prefix + key] = metadata[key]
+ if metadata:
+ for key in metadata:
+ headers[metadata_prefix + key] = metadata[key]
- resp, body = self.post('', headers=headers, body=None)
+ url = ''
+ if params:
+ url = '?%s%s' % (url, urllib.urlencode(params))
+
+ resp, body = self.post(url, headers=headers, body=data)
return resp, body
def delete_account_metadata(self, metadata,
diff --git a/tempest/services/volume/json/qos_client.py b/tempest/services/volume/json/qos_client.py
new file mode 100644
index 0000000..6e0bee9
--- /dev/null
+++ b/tempest/services/volume/json/qos_client.py
@@ -0,0 +1,161 @@
+# 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 time
+
+from tempest.common import rest_client
+from tempest import config
+from tempest import exceptions
+
+CONF = config.CONF
+
+
+class BaseQosSpecsClientJSON(rest_client.RestClient):
+ """Client class to send CRUD QoS API requests"""
+
+ def __init__(self, auth_provider):
+ super(BaseQosSpecsClientJSON, self).__init__(auth_provider)
+ self.service = CONF.volume.catalog_type
+ self.build_interval = CONF.volume.build_interval
+ self.build_timeout = CONF.volume.build_timeout
+
+ def is_resource_deleted(self, qos_id):
+ try:
+ self.get_qos(qos_id)
+ except exceptions.NotFound:
+ return True
+ return False
+
+ def wait_for_qos_operations(self, qos_id, operation, args=None):
+ """Waits for a qos operations to be completed.
+
+ NOTE : operation value is required for wait_for_qos_operations()
+ operation = 'qos-key' / 'disassociate' / 'disassociate-all'
+ args = keys[] when operation = 'qos-key'
+ args = volume-type-id disassociated when operation = 'disassociate'
+ args = None when operation = 'disassociate-all'
+ """
+ start_time = int(time.time())
+ while True:
+ if operation == 'qos-key-unset':
+ resp, body = self.get_qos(qos_id)
+ self.expected_success(200, resp.status)
+ if not any(key in body['specs'] for key in args):
+ return
+ elif operation == 'disassociate':
+ resp, body = self.get_association_qos(qos_id)
+ self.expected_success(200, resp.status)
+ if not any(args in body[i]['id'] for i in range(0, len(body))):
+ return
+ elif operation == 'disassociate-all':
+ resp, body = self.get_association_qos(qos_id)
+ self.expected_success(200, resp.status)
+ if not body:
+ return
+ else:
+ msg = (" operation value is either not defined or incorrect.")
+ raise exceptions.UnprocessableEntity(msg)
+
+ if int(time.time()) - start_time >= self.build_timeout:
+ raise exceptions.TimeoutException
+ time.sleep(self.build_interval)
+
+ def create_qos(self, name, consumer, **kwargs):
+ """Create a QoS Specification.
+
+ name : name of the QoS specifications
+ consumer : conumer of Qos ( front-end / back-end / both )
+ """
+ post_body = {'name': name, 'consumer': consumer}
+ post_body.update(kwargs)
+ post_body = json.dumps({'qos_specs': post_body})
+ resp, body = self.post('qos-specs', post_body)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return resp, body['qos_specs']
+
+ def delete_qos(self, qos_id, force=False):
+ """Delete the specified QoS specification."""
+ resp, body = self.delete(
+ "qos-specs/%s?force=%s" % (str(qos_id), force))
+ self.expected_success(202, resp.status)
+
+ def list_qos(self):
+ """List all the QoS specifications created."""
+ url = 'qos-specs'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['qos_specs']
+
+ def get_qos(self, qos_id):
+ """Get the specified QoS specification."""
+ url = "qos-specs/%s" % str(qos_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['qos_specs']
+
+ def set_qos_key(self, qos_id, **kwargs):
+ """Set the specified keys/values of QoS specification.
+
+ kwargs : it is the dictionary of the key=value pairs to set
+ """
+ put_body = json.dumps({"qos_specs": kwargs})
+ resp, body = self.put('qos-specs/%s' % qos_id, put_body)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['qos_specs']
+
+ def unset_qos_key(self, qos_id, keys):
+ """Unset the specified keys of QoS specification.
+
+ keys : it is the array of the keys to unset
+ """
+ put_body = json.dumps({'keys': keys})
+ resp, _ = self.put('qos-specs/%s/delete_keys' % qos_id, put_body)
+ self.expected_success(202, resp.status)
+
+ def associate_qos(self, qos_id, vol_type_id):
+ """Associate the specified QoS with specified volume-type."""
+ url = "qos-specs/%s/associate" % str(qos_id)
+ url += "?vol_type_id=%s" % vol_type_id
+ resp, _ = self.get(url)
+ self.expected_success(202, resp.status)
+
+ def get_association_qos(self, qos_id):
+ """Get the association of the specified QoS specification."""
+ url = "qos-specs/%s/associations" % str(qos_id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ self.expected_success(200, resp.status)
+ return resp, body['qos_associations']
+
+ def disassociate_qos(self, qos_id, vol_type_id):
+ """Disassociate the specified QoS with specified volume-type."""
+ url = "qos-specs/%s/disassociate" % str(qos_id)
+ url += "?vol_type_id=%s" % vol_type_id
+ resp, _ = self.get(url)
+ self.expected_success(202, resp.status)
+
+ def disassociate_all_qos(self, qos_id):
+ """Disassociate the specified QoS with all associations."""
+ url = "qos-specs/%s/disassociate_all" % str(qos_id)
+ resp, _ = self.get(url)
+ self.expected_success(202, resp.status)
+
+
+class QosSpecsClientJSON(BaseQosSpecsClientJSON):
+ """Volume V1 QoS client."""
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index f50ba2f..1f8065b 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -24,15 +24,16 @@
LOG = logging.getLogger(__name__)
-class SnapshotsClientJSON(rest_client.RestClient):
- """Client class to send CRUD Volume API requests."""
+class BaseSnapshotsClientJSON(rest_client.RestClient):
+ """Base Client class to send CRUD Volume API requests."""
def __init__(self, auth_provider):
- super(SnapshotsClientJSON, self).__init__(auth_provider)
+ super(BaseSnapshotsClientJSON, self).__init__(auth_provider)
self.service = CONF.volume.catalog_type
self.build_interval = CONF.volume.build_interval
self.build_timeout = CONF.volume.build_timeout
+ self.create_resp = 200
def list_snapshots(self, params=None):
"""List all the snapshot."""
@@ -77,7 +78,7 @@
post_body = json.dumps({'snapshot': post_body})
resp, body = self.post('snapshots', post_body)
body = json.loads(body)
- self.expected_success(200, resp.status)
+ self.expected_success(self.create_resp, resp.status)
return resp, body['snapshot']
def update_snapshot(self, snapshot_id, **kwargs):
@@ -203,3 +204,7 @@
resp, body = self.post('snapshots/%s/action' % snapshot_id, post_body)
self.expected_success(202, resp.status)
return resp, body
+
+
+class SnapshotsClientJSON(BaseSnapshotsClientJSON):
+ """Client class to send CRUD Volume V1 API requests."""
diff --git a/tempest/services/volume/v2/json/qos_client.py b/tempest/services/volume/v2/json/qos_client.py
new file mode 100644
index 0000000..a734df8
--- /dev/null
+++ b/tempest/services/volume/v2/json/qos_client.py
@@ -0,0 +1,23 @@
+# 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.services.volume.json import qos_client
+
+
+class QosSpecsV2ClientJSON(qos_client.BaseQosSpecsClientJSON):
+
+ def __init__(self, auth_provider):
+ super(QosSpecsV2ClientJSON, self).__init__(auth_provider)
+
+ self.api_version = "v2"
diff --git a/tempest/services/volume/v2/json/snapshots_client.py b/tempest/services/volume/v2/json/snapshots_client.py
new file mode 100644
index 0000000..553176b
--- /dev/null
+++ b/tempest/services/volume/v2/json/snapshots_client.py
@@ -0,0 +1,23 @@
+# 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.services.volume.json import snapshots_client
+
+
+class SnapshotsV2ClientJSON(snapshots_client.BaseSnapshotsClientJSON):
+ """Client class to send CRUD Volume V2 API requests."""
+
+ def __init__(self, auth_provider):
+ super(SnapshotsV2ClientJSON, self).__init__(auth_provider)
+
+ self.api_version = "v2"
+ self.create_resp = 202
diff --git a/tempest/services/volume/v2/xml/snapshots_client.py b/tempest/services/volume/v2/xml/snapshots_client.py
new file mode 100644
index 0000000..b29d86c
--- /dev/null
+++ b/tempest/services/volume/v2/xml/snapshots_client.py
@@ -0,0 +1,23 @@
+# 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.services.volume.xml import snapshots_client
+
+
+class SnapshotsV2ClientXML(snapshots_client.BaseSnapshotsClientXML):
+ """Client class to send CRUD Volume V2 API requests."""
+
+ def __init__(self, auth_provider):
+ super(SnapshotsV2ClientXML, self).__init__(auth_provider)
+
+ self.api_version = "v2"
+ self.create_resp = 202
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 7636707..ce98eea 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -26,16 +26,17 @@
LOG = logging.getLogger(__name__)
-class SnapshotsClientXML(rest_client.RestClient):
- """Client class to send CRUD Volume API requests."""
+class BaseSnapshotsClientXML(rest_client.RestClient):
+ """Base Client class to send CRUD Volume API requests."""
TYPE = "xml"
def __init__(self, auth_provider):
- super(SnapshotsClientXML, self).__init__(auth_provider)
+ super(BaseSnapshotsClientXML, self).__init__(auth_provider)
self.service = CONF.volume.catalog_type
self.build_interval = CONF.volume.build_interval
self.build_timeout = CONF.volume.build_timeout
+ self.create_resp = 200
def list_snapshots(self, params=None):
"""List all snapshot."""
@@ -90,7 +91,7 @@
resp, body = self.post('snapshots',
str(common.Document(snapshot)))
body = common.xml_to_json(etree.fromstring(body))
- self.expected_success(200, resp.status)
+ self.expected_success(self.create_resp, resp.status)
return resp, body
def update_snapshot(self, snapshot_id, **kwargs):
@@ -243,3 +244,7 @@
body = common.xml_to_json(etree.fromstring(body))
self.expected_success(202, resp.status)
return resp, body
+
+
+class SnapshotsClientXML(BaseSnapshotsClientXML):
+ """Client class to send CRUD Volume V1 API requests."""
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 478cd07..d78112c 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -30,7 +30,7 @@
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- proc.wait()
+ proc.communicate()
success = proc.returncode == 0
return success
diff --git a/tempest/test.py b/tempest/test.py
index f34933e..4a22b1b 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -69,6 +69,9 @@
def safe_setup(f):
"""A decorator used to wrap the setUpClass for cleaning up resources
when setUpClass failed.
+
+ Deprecated, see:
+ http://specs.openstack.org/openstack/qa-specs/specs/resource-cleanup.html
"""
@functools.wraps(f)
def decorator(cls):
@@ -76,7 +79,10 @@
f(cls)
except Exception as se:
etype, value, trace = sys.exc_info()
- LOG.exception("setUpClass failed: %s" % se)
+ if etype is cls.skipException:
+ LOG.info("setUpClass skipped: %s:" % se)
+ else:
+ LOG.exception("setUpClass failed: %s" % se)
try:
cls.tearDownClass()
except Exception as te:
@@ -89,12 +95,7 @@
return decorator
-def services(*args, **kwargs):
- """A decorator used to set an attr for each service used in a test case
-
- This decorator applies a testtools attr for each service that gets
- exercised by a test case.
- """
+def get_service_list():
service_list = {
'compute': CONF.service_available.nova,
'image': CONF.service_available.glance,
@@ -110,16 +111,29 @@
'telemetry': CONF.service_available.ceilometer,
'data_processing': CONF.service_available.sahara
}
+ return service_list
+
+def services(*args, **kwargs):
+ """A decorator used to set an attr for each service used in a test case
+
+ This decorator applies a testtools attr for each service that gets
+ exercised by a test case.
+ """
def decorator(f):
+ services = ['compute', 'image', 'baremetal', 'volume', 'orchestration',
+ 'network', 'identity', 'object_storage', 'dashboard',
+ 'ceilometer', 'data_processing']
for service in args:
- if service not in service_list:
- raise exceptions.InvalidServiceTag('%s is not a valid service'
- % service)
+ if service not in services:
+ raise exceptions.InvalidServiceTag('%s is not a valid '
+ 'service' % service)
attr(type=list(args))(f)
@functools.wraps(f)
def wrapper(self, *func_args, **func_kwargs):
+ service_list = get_service_list()
+
for service in args:
if not service_list[service]:
msg = 'Skipped because the %s service is not available' % (
@@ -268,15 +282,51 @@
@classmethod
def setUpClass(cls):
+ # It should never be overridden by descendants
if hasattr(super(BaseTestCase, cls), 'setUpClass'):
super(BaseTestCase, cls).setUpClass()
cls.setUpClassCalled = True
+ # No test resource is allocated until here
+ try:
+ # TODO(andreaf) Split-up resource_setup in stages:
+ # skip checks, pre-hook, credentials, clients, resources, post-hook
+ cls.resource_setup()
+ except Exception:
+ etype, value, trace = sys.exc_info()
+ LOG.info("%s in resource setup. Invoking tearDownClass." % etype)
+ # Catch any exception in tearDown so we can re-raise the original
+ # exception at the end
+ try:
+ cls.tearDownClass()
+ except Exception as te:
+ LOG.exception("tearDownClass failed: %s" % te)
+ try:
+ raise etype(value), None, trace
+ finally:
+ del trace # for avoiding circular refs
@classmethod
def tearDownClass(cls):
at_exit_set.discard(cls)
+ # It should never be overridden by descendants
if hasattr(super(BaseTestCase, cls), 'tearDownClass'):
super(BaseTestCase, cls).tearDownClass()
+ try:
+ cls.resource_cleanup()
+ finally:
+ cls.clear_isolated_creds()
+
+ @classmethod
+ def resource_setup(cls):
+ """Class level setup steps for test cases.
+ Recommended order: skip checks, credentials, clients, resources.
+ """
+ pass
+
+ @classmethod
+ def resource_cleanup(cls):
+ """Class level resource cleanup for test cases. """
+ pass
def setUp(self):
super(BaseTestCase, self).setUp()
@@ -344,7 +394,7 @@
"""
Clears isolated creds if set
"""
- if getattr(cls, 'isolated_creds'):
+ if hasattr(cls, 'isolated_creds'):
cls.isolated_creds.clear_isolated_creds()
@classmethod
diff --git a/tempest/tests/common/test_accounts.py b/tempest/tests/common/test_accounts.py
index feafbf5..cf7ce65 100644
--- a/tempest/tests/common/test_accounts.py
+++ b/tempest/tests/common/test_accounts.py
@@ -57,6 +57,7 @@
'tempest.common.accounts.read_accounts_yaml',
return_value=self.test_accounts))
cfg.CONF.set_default('test_accounts_file', '', group='auth')
+ self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
def _get_hash_list(self, accounts_list):
hash_list = []
@@ -197,3 +198,37 @@
return_value=self.test_accounts))
test_accounts_class = accounts.Accounts('test_name')
self.assertFalse(test_accounts_class.is_multi_user())
+
+
+class TestNotLockingAccount(base.TestCase):
+
+ def setUp(self):
+ super(TestNotLockingAccount, self).setUp()
+ self.useFixture(fake_config.ConfigFixture())
+ self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate)
+ self.temp_dir = tempfile.mkdtemp()
+ cfg.CONF.set_default('lock_path', self.temp_dir)
+ self.addCleanup(os.rmdir, self.temp_dir)
+ self.test_accounts = [
+ {'username': 'test_user1', 'tenant_name': 'test_tenant1',
+ 'password': 'p'},
+ {'username': 'test_user2', 'tenant_name': 'test_tenant2',
+ 'password': 'p'},
+ {'username': 'test_user3', 'tenant_name': 'test_tenant3',
+ 'password': 'p'},
+ ]
+ self.useFixture(mockpatch.Patch(
+ 'tempest.common.accounts.read_accounts_yaml',
+ return_value=self.test_accounts))
+ cfg.CONF.set_default('test_accounts_file', '', group='auth')
+ self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True))
+
+ def test_get_creds(self):
+ test_accounts_class = accounts.NotLockingAccounts('test_name')
+ for i in xrange(len(self.test_accounts)):
+ creds = test_accounts_class.get_creds(i)
+ msg = "Empty credentials returned for ID %s" % str(i)
+ self.assertIsNotNone(creds, msg)
+ self.assertRaises(exceptions.InvalidConfiguration,
+ test_accounts_class.get_creds,
+ id=len(self.test_accounts))
diff --git a/tempest/tests/test_tenant_isolation.py b/tempest/tests/test_tenant_isolation.py
index eddbb1d..27c45c2 100644
--- a/tempest/tests/test_tenant_isolation.py
+++ b/tempest/tests/test_tenant_isolation.py
@@ -12,12 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import keystoneclient.v2_0.client as keystoneclient
import mock
-import neutronclient.v2_0.client as neutronclient
from oslo.config import cfg
-from tempest import clients
from tempest.common import http
from tempest.common import isolated_creds
from tempest import config
@@ -52,24 +49,6 @@
self.assertTrue(isinstance(iso_creds.network_admin_client,
json_network_client.NetworkClientJSON))
- def test_official_client(self):
- self.useFixture(mockpatch.PatchObject(keystoneclient.Client,
- 'authenticate'))
- self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
- '_get_image_client'))
- self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
- '_get_object_storage_client'))
- self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
- '_get_orchestration_client'))
- self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
- '_get_ceilometer_client'))
- iso_creds = isolated_creds.IsolatedCreds('test class',
- tempest_client=False)
- self.assertTrue(isinstance(iso_creds.identity_admin_client,
- keystoneclient.Client))
- self.assertTrue(isinstance(iso_creds.network_admin_client,
- neutronclient.Client))
-
def test_tempest_client_xml(self):
iso_creds = isolated_creds.IsolatedCreds('test class', interface='xml')
self.assertEqual(iso_creds.interface, 'xml')
@@ -272,6 +251,13 @@
@mock.patch('tempest.common.rest_client.RestClient')
def test_network_cleanup(self, MockRestClient):
+ def side_effect(**args):
+ return ({'status': 200},
+ {"security_groups": [{"tenant_id": args['tenant_id'],
+ "name": args['name'],
+ "description": args['name'],
+ "security_group_rules": [],
+ "id": "sg-%s" % args['tenant_id']}]})
iso_creds = isolated_creds.IsolatedCreds('test class',
password='fake_password')
# Create primary tenant and network
@@ -341,7 +327,23 @@
return_value=return_values)
port_list_mock.start()
+ secgroup_list_mock = mock.patch.object(iso_creds.network_admin_client,
+ 'list_security_groups',
+ side_effect=side_effect)
+ secgroup_list_mock.start()
+
+ return_values = (fake_http.fake_httplib({}, status=204), {})
+ remove_secgroup_mock = self.patch(
+ 'tempest.services.network.network_client_base.'
+ 'NetworkClientBase.delete', return_value=return_values)
iso_creds.clear_isolated_creds()
+ # Verify default security group delete
+ calls = remove_secgroup_mock.mock_calls
+ self.assertEqual(len(calls), 3)
+ args = map(lambda x: x[1][0], calls)
+ self.assertIn('v2.0/security-groups/sg-1234', args)
+ self.assertIn('v2.0/security-groups/sg-12345', args)
+ self.assertIn('v2.0/security-groups/sg-123456', args)
# Verify remove router interface calls
calls = remove_router_interface_mock.mock_calls
self.assertEqual(len(calls), 3)
diff --git a/tempest/tests/test_wrappers.py b/tempest/tests/test_wrappers.py
index bba4012..0fd41f9 100644
--- a/tempest/tests/test_wrappers.py
+++ b/tempest/tests/test_wrappers.py
@@ -62,21 +62,18 @@
p = subprocess.Popen(
"bash %s" % cmd, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- # wait in the general case is dangerous, however the amount of
- # data coming back on those pipes is small enough it shouldn't be
- # a problem.
- p.wait()
+ out, err = p.communicate()
self.assertEqual(
p.returncode, expected,
- "Stdout: %s; Stderr: %s" % (p.stdout, p.stderr))
+ "Stdout: %s; Stderr: %s" % (out, err))
def test_pretty_tox(self):
# Git init is required for the pbr testr command. pbr requires a git
# version or an sdist to work. so make the test directory a git repo
# too.
subprocess.call(['git', 'init'], stderr=DEVNULL)
- self.assertRunExit('pretty_tox.sh tests.passing', 0)
+ self.assertRunExit('pretty_tox.sh passing', 0)
def test_pretty_tox_fails(self):
# Git init is required for the pbr testr command. pbr requires a git
@@ -86,7 +83,7 @@
self.assertRunExit('pretty_tox.sh', 1)
def test_pretty_tox_serial(self):
- self.assertRunExit('pretty_tox_serial.sh tests.passing', 0)
+ self.assertRunExit('pretty_tox_serial.sh passing', 0)
def test_pretty_tox_serial_fails(self):
self.assertRunExit('pretty_tox_serial.sh', 1)
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 4bf71f3..f94d880 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -108,8 +108,8 @@
CODE_RE = '.*' # regexp makes sense in group match
def match(self, exc):
- """:returns: Retruns with an error string if not matches,
- returns with None when matches.
+ """:returns: Returns with an error string if it does not match,
+ returns with None when it matches.
"""
if not isinstance(exc, exception.BotoServerError):
return "%r not an BotoServerError instance" % exc
@@ -485,7 +485,7 @@
@classmethod
def destroy_volume_wait(cls, volume):
- """Delete volume, tryies to detach first.
+ """Delete volume, tries to detach first.
Use just for teardown!
"""
exc_num = 0
@@ -518,7 +518,7 @@
@classmethod
def destroy_snapshot_wait(cls, snapshot):
- """delete snaphot, wait until not exists."""
+ """delete snapshot, wait until it ceases to exist."""
snapshot.delete()
def _update():
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index 2c68d6b..ee904c7 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from boto import exception
-
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
@@ -82,6 +80,13 @@
raise exceptions.EC2RegisterImageException(
image_id=image["image_id"])
+ def _terminate_reservation(self, reservation, rcuk):
+ for instance in reservation.instances:
+ instance.terminate()
+ for instance in reservation.instances:
+ self.assertInstanceStateWait(instance, '_GONE')
+ self.cancelResourceCleanUp(rcuk)
+
def test_run_idempotent_instances(self):
# EC2 run instances idempotently
@@ -96,11 +101,6 @@
reservation)
return (reservation, rcuk)
- def _terminate_reservation(reservation, rcuk):
- for instance in reservation.instances:
- instance.terminate()
- self.cancelResourceCleanUp(rcuk)
-
reservation_1, rcuk_1 = _run_instance('token_1')
reservation_2, rcuk_2 = _run_instance('token_2')
reservation_1a, rcuk_1a = _run_instance('token_1')
@@ -116,8 +116,8 @@
# handled by rcuk1
self.cancelResourceCleanUp(rcuk_1a)
- _terminate_reservation(reservation_1, rcuk_1)
- _terminate_reservation(reservation_2, rcuk_2)
+ self._terminate_reservation(reservation_1, rcuk_1)
+ self._terminate_reservation(reservation_2, rcuk_2)
def test_run_stop_terminate_instance(self):
# EC2 run, stop and terminate instance
@@ -139,9 +139,7 @@
if instance.state != "stopped":
self.assertInstanceStateWait(instance, "stopped")
- for instance in reservation.instances:
- instance.terminate()
- self.cancelResourceCleanUp(rcuk)
+ self._terminate_reservation(reservation, rcuk)
def test_run_stop_terminate_instance_with_tags(self):
# EC2 run, stop and terminate instance with tags
@@ -188,9 +186,7 @@
if instance.state != "stopped":
self.assertInstanceStateWait(instance, "stopped")
- for instance in reservation.instances:
- instance.terminate()
- self.cancelResourceCleanUp(rcuk)
+ self._terminate_reservation(reservation, rcuk)
def test_run_terminate_instance(self):
# EC2 run, terminate immediately
@@ -202,18 +198,30 @@
for instance in reservation.instances:
instance.terminate()
- try:
- instance.update(validate=True)
- except ValueError:
- pass
- except exception.EC2ResponseError as exc:
- if self.ec2_error_code.\
- client.InvalidInstanceID.NotFound.match(exc) is None:
- pass
- else:
- raise
- else:
- self.assertNotEqual(instance.state, "running")
+ self.assertInstanceStateWait(instance, '_GONE')
+
+ def test_run_reboot_terminate_instance(self):
+ # EC2 run, await till it reaches to running state, then reboot,
+ # and wait untill its state is running, and then terminate
+ image_ami = self.ec2_client.get_image(self.images["ami"]
+ ["image_id"])
+ reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
+ ramdisk_id=self.images["ari"]["image_id"],
+ instance_type=self.instance_type)
+
+ self.assertEqual(1, len(reservation.instances))
+
+ instance = reservation.instances[0]
+ if instance.state != "running":
+ self.assertInstanceStateWait(instance, "running")
+
+ instance.reboot()
+ if instance.state != "running":
+ self.assertInstanceStateWait(instance, "running")
+ LOG.debug("Instance rebooted - state: %s", instance.state)
+
+ instance.terminate()
+ self.assertInstanceStateWait(instance, '_GONE')
def test_compute_with_volumes(self):
# EC2 1. integration test (not strict)
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index 3a8dc89..1576492 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -14,7 +14,6 @@
# under the License.
from tempest.common.utils import data_utils
-from tempest import test
from tempest.thirdparty.boto import test as boto_test
@@ -25,7 +24,6 @@
super(S3BucketsTest, cls).setUpClass()
cls.client = cls.os.s3_client
- @test.skip_because(bug="1076965")
def test_create_and_get_delete_bucket(self):
# S3 Create, get and delete bucket
bucket_name = data_utils.rand_name("s3bucket-")
diff --git a/test-requirements.txt b/test-requirements.txt
index cd8154b..ba70259 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,10 +1,13 @@
+# The order of packages is significant, because pip processes them in the order
+# of appearance. Changing the order has an impact on the overall integration
+# process, which may cause wedges in the gate later.
hacking>=0.9.2,<0.10
# needed for doc build
sphinx>=1.1.2,!=1.2.0,<1.3
python-subunit>=0.0.18
-oslosphinx
+oslosphinx>=2.2.0 # Apache-2.0
mox>=0.5.3
mock>=1.0
coverage>=3.6
-oslotest
-stevedore>=0.14
+oslotest>=1.1.0 # Apache-2.0
+stevedore>=1.0.0 # Apache-2.0
diff --git a/tools/check_logs.py b/tools/check_logs.py
index 917aaaf..7cf9d85 100755
--- a/tools/check_logs.py
+++ b/tools/check_logs.py
@@ -80,7 +80,6 @@
def scan_content(name, content, regexp, whitelist):
had_errors = False
- print_log_name = True
for line in content:
if not line.startswith("Stderr:") and regexp.match(line):
whitelisted = False
@@ -91,13 +90,8 @@
whitelisted = True
break
if not whitelisted or dump_all_errors:
- if print_log_name:
- print("\nLog File Has Errors: %s" % name)
- print_log_name = False
if not whitelisted:
had_errors = True
- print("*** Not Whitelisted ***"),
- print(line.rstrip())
return had_errors
@@ -151,17 +145,21 @@
whitelists = loaded
logs_with_errors = process_files(files_to_process, urls_to_process,
whitelists)
- if logs_with_errors:
- print("Logs have errors")
- if is_grenade:
- print("Currently not failing grenade runs with errors")
- return 0
+
failed = False
- for log in logs_with_errors:
- if log not in allowed_dirty:
- print("Log: %s not allowed to have ERRORS or TRACES" % log)
- failed = True
+ if logs_with_errors:
+ log_files = set(logs_with_errors)
+ for log in log_files:
+ msg = '%s log file has errors' % log
+ if log not in allowed_dirty:
+ msg += ' and is not allowed to have them'
+ failed = True
+ print(msg)
+ print("\nPlease check the respective log files to see the errors")
if failed:
+ if is_grenade:
+ print("Currently not failing grenade runs with errors")
+ return 0
return 1
print("ok")
return 0
diff --git a/tools/subunit-trace.py b/tools/subunit-trace.py
index 8ad59bb..57e58f2 100755
--- a/tools/subunit-trace.py
+++ b/tools/subunit-trace.py
@@ -23,7 +23,6 @@
import re
import sys
-import mimeparse
import subunit
import testtools
@@ -32,55 +31,6 @@
RESULTS = {}
-class Starts(testtools.StreamResult):
-
- def __init__(self, output):
- super(Starts, self).__init__()
- self._output = output
-
- def startTestRun(self):
- self._neednewline = False
- self._emitted = set()
-
- def status(self, test_id=None, test_status=None, test_tags=None,
- runnable=True, file_name=None, file_bytes=None, eof=False,
- mime_type=None, route_code=None, timestamp=None):
- super(Starts, self).status(
- test_id, test_status,
- test_tags=test_tags, runnable=runnable, file_name=file_name,
- file_bytes=file_bytes, eof=eof, mime_type=mime_type,
- route_code=route_code, timestamp=timestamp)
- if not test_id:
- if not file_bytes:
- return
- if not mime_type or mime_type == 'test/plain;charset=utf8':
- mime_type = 'text/plain; charset=utf-8'
- primary, sub, parameters = mimeparse.parse_mime_type(mime_type)
- content_type = testtools.content_type.ContentType(
- primary, sub, parameters)
- content = testtools.content.Content(
- content_type, lambda: [file_bytes])
- text = content.as_text()
- if text and text[-1] not in '\r\n':
- self._neednewline = True
- self._output.write(text)
- elif test_status == 'inprogress' and test_id not in self._emitted:
- if self._neednewline:
- self._neednewline = False
- self._output.write('\n')
- worker = ''
- for tag in test_tags or ():
- if tag.startswith('worker-'):
- worker = '(' + tag[7:] + ') '
- if timestamp:
- timestr = timestamp.isoformat()
- else:
- timestr = ''
- self._output.write('%s: %s%s [start]\n' %
- (timestr, worker, test_id))
- self._emitted.add(test_id)
-
-
def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
"""Clean up the test name for display.
@@ -274,17 +224,19 @@
args = parse_args()
stream = subunit.ByteStreamToStreamResult(
sys.stdin, non_subunit_name='stdout')
- starts = Starts(sys.stdout)
outcomes = testtools.StreamToDict(
functools.partial(show_outcome, sys.stdout,
print_failures=args.print_failures))
summary = testtools.StreamSummary()
- result = testtools.CopyStreamResult([starts, outcomes, summary])
+ result = testtools.CopyStreamResult([outcomes, summary])
result.startTestRun()
try:
stream.run(result)
finally:
result.stopTestRun()
+ if count_tests('status', '.*') == 0:
+ print("The test run didn't actually run any tests")
+ return 1
if args.post_fails:
print_fails(sys.stdout)
print_summary(sys.stdout)
diff --git a/tox.ini b/tox.ini
index a071d4b..cab59a8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,29 +6,33 @@
[testenv]
setenv = VIRTUAL_ENV={envdir}
OS_TEST_PATH=./tempest/test_discover
- PYTHONHASHSEED=0
usedevelop = True
install_command = pip install -U {opts} {packages}
+whitelist_externals = bash
+
[testenv:py26]
setenv = OS_TEST_PATH=./tempest/tests
- PYTHONHASHSEED=0
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:py33]
setenv = OS_TEST_PATH=./tempest/tests
+commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
+
+[testenv:py34]
+setenv = OS_TEST_PATH=./tempest/tests
PYTHONHASHSEED=0
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:py27]
setenv = OS_TEST_PATH=./tempest/tests
- PYTHONHASHSEED=0
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:cover]
setenv = OS_TEST_PATH=./tempest/tests
- PYTHONHASHSEED=0
commands = python setup.py testr --coverage --testr-arg='tempest\.tests {posargs}'
+deps = -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
[testenv:all]
sitepackages = True
@@ -94,6 +98,7 @@
-r{toxinidir}/test-requirements.txt
[testenv:pep8]
+setenv = PYTHONHASHSEED=0
commands =
flake8 {posargs}
{toxinidir}/tools/config/check_uptodate.sh