Merge "Placeholder log check script to be called by devstack-gate"
diff --git a/HACKING.rst b/HACKING.rst
index 499b436..7871f60 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -8,16 +8,6 @@
Tempest Specific Commandments
------------------------------
-[T101] If a test is broken because of a bug it is appropriate to skip the test until
-bug has been fixed. However, the skip message should be formatted so that
-Tempest's skip tracking tool can watch the bug status. The skip message should
-contain the string 'Bug' immediately followed by a space. Then the bug number
-should be included in the message '#' in front of the number.
-
-Example::
-
- @testtools.skip("Skipped until the Bug #980688 is resolved")
-
- [T102] Cannot import OpenStack python clients in tempest/api tests
- [T103] tempest/tests is deprecated
- [T104] Scenario tests require a services decorator
@@ -115,6 +105,19 @@
in tempest.api.compute would require a service tag for those services, however
they do not need to be tagged as compute.
+Test skips because of Known Bugs
+--------------------------------
+
+If a test is broken because of a bug it is appropriate to skip the test until
+bug has been fixed. You should use the skip_because decorator so that
+Tempest's skip tracking tool can watch the bug status.
+
+Example::
+
+ @skip_because(bug="980688")
+ def test_this_and_that(self):
+ ...
+
Guidelines
----------
- Do not submit changesets with only testcases which are skipped as
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index 3ef75ba..004268e 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_int_id
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class FlavorsAdminTestJSON(base.BaseComputeAdminTest):
@@ -195,7 +194,7 @@
flag = True
self.assertTrue(flag)
- @testtools.skip("Skipped until the Bug #1209101 is resolved")
+ @skip_because(bug="1209101")
@attr(type='gate')
def test_list_non_public_flavor(self):
# Create a flavor with os-flavor-access:is_public false should
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 7df9010..800b2de 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -24,6 +24,7 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ImagesOneServerTestJSON(base.BaseComputeTest):
@@ -64,7 +65,7 @@
cls.alt_manager = clients.AltManager()
cls.alt_client = cls.alt_manager.images_client
- @testtools.skip("Skipped until the Bug #1006725 is resolved.")
+ @skip_because(bug="1006725")
@attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
# Return an error if the image name has multi-byte characters
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 61db61d..cbc0080 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -15,13 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class SecurityGroupRulesTestJSON(base.BaseComputeTest):
@@ -94,8 +93,8 @@
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
self.assertEqual(200, resp.status)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_rules_create_with_invalid_id(self):
# Negative test: Creation of Security Group rule should FAIL
@@ -186,8 +185,8 @@
self.client.create_security_group_rule,
secgroup_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_rules_delete_with_invalid_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 5cca3b2..fba2f53 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -22,6 +22,7 @@
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class SecurityGroupsTestJSON(base.BaseComputeTest):
@@ -107,8 +108,8 @@
"The fetched Security Group is different "
"from the created Group")
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_get_nonexistant_group(self):
# Negative test:Should not be able to GET the details
@@ -125,8 +126,8 @@
self.assertRaises(exceptions.NotFound, self.client.get_security_group,
non_exist_id)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1161411 is resolved")
+ @skip_because(bug="1161411",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_name(self):
# Negative test: Security Group should not be created with group name
@@ -145,8 +146,8 @@
self.client.create_security_group, s_name,
s_description)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1161411 is resolved")
+ @skip_because(bug="1161411",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_security_group_create_with_invalid_group_description(self):
# Negative test:Security Group should not be created with description
@@ -197,8 +198,8 @@
self.client.delete_security_group,
default_security_group_id)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182384 is resolved")
+ @skip_because(bug="1182384",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type=['negative', 'gate'])
def test_delete_nonexistant_security_group(self):
# Negative test:Deletion of a non-existent Security Group should Fail
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index a56bdf3..c469827 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -15,14 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.compute import base
from tempest.api import utils
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ListServerFiltersTestJSON(base.BaseComputeTest):
@@ -205,7 +204,7 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @testtools.skip('Skipped until the Bug #1170718 is resolved.')
+ @skip_because(bug="1170718")
@attr(type='gate')
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
@@ -219,8 +218,8 @@
self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
- "Skipped until the Bug #1182883 is resolved")
+ @skip_because(bug="1182883",
+ condition=config.TempestConfig().service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 7f5ccf9..983258d 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -28,6 +28,26 @@
_interface = 'json'
@classmethod
+ def _ensure_no_servers(cls, servers, username, tenant_name):
+ """
+ If there are servers and there is tenant isolation then a
+ skipException is raised to skip the test since it requires no servers
+ to already exist for the given user/tenant.
+ If there are servers and there is not tenant isolation then the test
+ blocks while the servers are being deleted.
+ """
+ if len(servers):
+ if not compute.MULTI_USER:
+ for srv in servers:
+ cls.client.wait_for_server_termination(srv['id'],
+ ignore_error=True)
+ else:
+ msg = ("User/tenant %(u)s/%(t)s already have "
+ "existing server instances. Skipping test." %
+ {'u': username, 't': tenant_name})
+ raise cls.skipException(msg)
+
+ @classmethod
def setUpClass(cls):
super(ListServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
@@ -54,26 +74,14 @@
# start of the test instead of destroying any existing
# servers.
resp, body = cls.client.list_servers()
- servers = body['servers']
- num_servers = len(servers)
- if num_servers > 0:
- username = cls.os.username
- tenant_name = cls.os.tenant_name
- msg = ("User/tenant %(u)s/%(t)s already have "
- "existing server instances. Skipping test." %
- {'u': username, 't': tenant_name})
- raise cls.skipException(msg)
+ cls._ensure_no_servers(body['servers'],
+ cls.os.username,
+ cls.os.tenant_name)
resp, body = cls.alt_client.list_servers()
- servers = body['servers']
- num_servers = len(servers)
- if num_servers > 0:
- username = cls.alt_manager.username
- tenant_name = cls.alt_manager.tenant_name
- msg = ("Alt User/tenant %(u)s/%(t)s already have "
- "existing server instances. Skipping test." %
- {'u': username, 't': tenant_name})
- raise cls.skipException(msg)
+ cls._ensure_no_servers(body['servers'],
+ cls.alt_manager.username,
+ cls.alt_manager.tenant_name)
# The following servers are created for use
# by the test methods in this class. These
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 0d5a8fa..e9defe5 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -27,6 +27,7 @@
import tempest.config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ServerActionsTestJSON(base.BaseComputeTest):
@@ -86,7 +87,7 @@
new_boot_time = linux_client.get_boot_time()
self.assertGreater(new_boot_time, boot_time)
- @testtools.skip('Skipped until the Bug #1014647 is resolved.')
+ @skip_because(bug="1014647")
@attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
@@ -250,7 +251,7 @@
self.servers_client.get_console_output,
'!@#$%^&*()', 10)
- @testtools.skip('Skipped until the Bug #1014683 is resolved.')
+ @skip_because(bug="1014683")
@attr(type='gate')
def test_get_console_output_server_id_in_reboot_status(self):
# Positive test:Should be able to GET the console output
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index b743a85..2c7ff32 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -16,13 +16,13 @@
# under the License.
import netaddr
-import testtools
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_name
from tempest import config
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class VirtualInterfacesTestJSON(base.BaseComputeTest):
@@ -37,8 +37,8 @@
resp, server = cls.create_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @testtools.skipIf(CONF.service_available.neutron, "Not implemented by " +
- "Neutron. Skipped until the Bug #1183436 is resolved.")
+ @skip_because(bug="1183436",
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_virtual_interfaces(self):
# Positive test:Should be able to GET the virtual interfaces list
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 017864f..ca2c879 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -20,7 +20,7 @@
from tempest.test import attr
-class FloatingIPTest(base.BaseNetworkTest):
+class FloatingIPTestJSON(base.BaseNetworkTest):
_interface = 'json'
"""
@@ -41,7 +41,7 @@
@classmethod
def setUpClass(cls):
- super(FloatingIPTest, cls).setUpClass()
+ super(FloatingIPTestJSON, cls).setUpClass()
cls.ext_net_id = cls.config.network.public_network_id
# Create network, subnet, router and add interface
@@ -67,7 +67,7 @@
for i in range(2):
cls.client.delete_port(cls.port[i]['id'])
cls.client.delete_router(cls.router['id'])
- super(FloatingIPTest, cls).tearDownClass()
+ super(FloatingIPTestJSON, cls).tearDownClass()
def _delete_floating_ip(self, floating_ip_id):
# Deletes a floating IP and verifies if it is deleted or not
@@ -133,3 +133,7 @@
self.assertIsNone(update_floating_ip['port_id'])
self.assertIsNone(update_floating_ip['fixed_ip_address'])
self.assertIsNone(update_floating_ip['router_id'])
+
+
+class FloatingIPTestXML(FloatingIPTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index a43b2b5..ff9f7bf 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -17,11 +17,10 @@
import time
-import testtools
-
from tempest.api.object_storage import base
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
class ContainerSyncTest(base.BaseObjectTest):
@@ -52,7 +51,7 @@
cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass()
- @testtools.skip('Skipped until the Bug #1093743 is resolved.')
+ @skip_because(bug="1093743")
@attr(type='gate')
def test_container_synchronization(self):
# container to container synchronization
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index db38401..cb52d88 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -17,13 +17,12 @@
import time
-import testtools
-
from tempest.api.object_storage import base
from tempest.common.utils.data_utils import arbitrary_string
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
+from tempest.test import skip_because
class ObjectExpiryTest(base.BaseObjectTest):
@@ -43,7 +42,7 @@
cls.delete_containers([cls.container_name])
super(ObjectExpiryTest, cls).tearDownClass()
- @testtools.skip('Skipped until the Bug #1069849 is resolved.')
+ @skip_because(bug="1069849")
@attr(type='gate')
def test_get_object_after_expiry_time(self):
# TODO(harika-vakadi): similar test case has to be created for
diff --git a/tempest/config.py b/tempest/config.py
index eadbe9a..af78381 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -372,7 +372,7 @@
object_storage_group = cfg.OptGroup(name='object-storage',
title='Object Storage Service Options')
-ObjectStoreConfig = [
+ObjectStoreGroup = [
cfg.StrOpt('catalog_type',
default='object-store',
help="Catalog type of the Object-Storage service."),
@@ -406,7 +406,7 @@
def register_object_storage_opts(conf):
conf.register_group(object_storage_group)
- for opt in ObjectStoreConfig:
+ for opt in ObjectStoreGroup:
conf.register_opt(opt, group='object-storage')
@@ -472,14 +472,14 @@
def register_dashboard_opts(conf):
- conf.register_group(scenario_group)
+ conf.register_group(dashboard_group)
for opt in DashboardGroup:
conf.register_opt(opt, group='dashboard')
boto_group = cfg.OptGroup(name='boto',
title='EC2/S3 options')
-BotoConfig = [
+BotoGroup = [
cfg.StrOpt('ec2_url',
default="http://localhost:8773/services/Cloud",
help="EC2 URL"),
@@ -526,7 +526,7 @@
def register_boto_opts(conf):
conf.register_group(boto_group)
- for opt in BotoConfig:
+ for opt in BotoGroup:
conf.register_opt(opt, group='boto')
stress_group = cfg.OptGroup(name='stress', title='Stress Test Options')
@@ -631,7 +631,7 @@
def register_service_available_opts(conf):
- conf.register_group(scenario_group)
+ conf.register_group(service_available_group)
for opt in ServiceAvailableGroup:
conf.register_opt(opt, group='service_available')
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index aa97211..4c1c107 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -19,28 +19,11 @@
PYTHON_CLIENTS = ['cinder', 'glance', 'keystone', 'nova', 'swift', 'neutron']
-SKIP_DECORATOR_RE = re.compile(r'\s*@testtools.skip\((.*)\)')
-SKIP_STR_RE = re.compile(r'.*Bug #\d+.*')
PYTHON_CLIENT_RE = re.compile('import (%s)client' % '|'.join(PYTHON_CLIENTS))
TEST_DEFINITION = re.compile(r'^\s*def test.*')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\(')
-def skip_bugs(physical_line):
- """Check skip lines for proper bug entries
-
- T101: skips must contain "Bug #<bug_number>"
- """
-
- res = SKIP_DECORATOR_RE.match(physical_line)
- if res:
- content = res.group(1)
- res = SKIP_STR_RE.match(content)
- if not res:
- return (physical_line.find(content),
- 'T101: skips must contain "Bug #<bug_number>"')
-
-
def import_no_clients_in_api(physical_line, filename):
"""Check for client imports from tempest/api tests
@@ -70,6 +53,5 @@
def factory(register):
- register(skip_bugs)
register(import_no_clients_in_api)
register(scenario_tests_need_service_tags)
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index cb24917..84b56c2 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import collections
+
XMLNS_11 = "http://docs.openstack.org/compute/api/v1.1"
@@ -110,3 +112,19 @@
ns, tag = tag.split("}", 1)
json[tag] = xml_to_json(child)
return json
+
+
+def deep_dict_to_xml(dest, source):
+ """Populates the ``dest`` xml element with the ``source`` ``Mapping``
+ elements, if the source Mapping's value is also a ``Mapping``
+ they will be recursively added as a child elements.
+ :param source: A python ``Mapping`` (dict)
+ :param dest: XML child element will be added to the ``dest``
+ """
+ for element, content in source.iteritems():
+ if isinstance(content, collections.Mapping):
+ xml_element = Element(element)
+ deep_dict_to_xml(xml_element, content)
+ dest.append(xml_element)
+ else:
+ dest.append(Element(element, content))
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 1523ed0..cf8154a 100755
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -16,6 +16,7 @@
import xml.etree.ElementTree as ET
from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import deep_dict_to_xml
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import xml_to_json
@@ -441,6 +442,111 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
+ def create_router(self, name, **kwargs):
+ uri = '%s/routers' % (self.uri_prefix)
+ router = Element("router")
+ router.append(Element("name", name))
+ deep_dict_to_xml(router, kwargs)
+ resp, body = self.post(uri, str(Document(router)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def delete_router(self, router_id):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ resp, body = self.delete(uri, self.headers)
+ return resp, body
+
+ def show_router(self, router_id):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def update_router(self, router_id, **kwargs):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ router = Element("router")
+ for element, content in kwargs.iteritems():
+ router.append(Element(element, content))
+ resp, body = self.put(uri, str(Document(router)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def add_router_interface_with_subnet_id(self, router_id, subnet_id):
+ uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
+ router_id)
+ subnet = Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def add_router_interface_with_port_id(self, router_id, port_id):
+ uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
+ router_id)
+ port = Element("port_id", port_id)
+ resp, body = self.put(uri, str(Document(port)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def remove_router_interface_with_subnet_id(self, router_id, subnet_id):
+ uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
+ router_id)
+ subnet = Element("subnet_id", subnet_id)
+ resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def remove_router_interface_with_port_id(self, router_id, port_id):
+ uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
+ router_id)
+ port = Element("port_id", port_id)
+ resp, body = self.put(uri, str(Document(port)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def create_floating_ip(self, ext_network_id, **kwargs):
+ uri = '%s/floatingips' % (self.uri_prefix)
+ floatingip = Element('floatingip')
+ floatingip.append(Element("floating_network_id", ext_network_id))
+ for element, content in kwargs.iteritems():
+ floatingip.append(Element(element, content))
+ resp, body = self.post(uri, str(Document(floatingip)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def show_floating_ip(self, floating_ip_id):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ resp, body = self.get(uri, self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def list_floating_ips(self):
+ uri = '%s/floatingips' % (self.uri_prefix)
+ resp, body = self.get(uri, self.headers)
+ floatingips = self._parse_array(etree.fromstring(body))
+ floatingips = {"floatingips": floatingips}
+ return resp, floatingips
+
+ def delete_floating_ip(self, floating_ip_id):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ resp, body = self.delete(uri, self.headers)
+ return resp, body
+
+ def update_floating_ip(self, floating_ip_id, **kwargs):
+ uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
+ floatingip = Element('floatingip')
+ floatingip.add_attr('xmlns:xsi',
+ 'http://www.w3.org/2001/XMLSchema-instance')
+ for element, content in kwargs.iteritems():
+ if content is None:
+ xml_elem = Element(element)
+ xml_elem.add_attr("xsi:nil", "true")
+ floatingip.append(xml_elem)
+ else:
+ floatingip.append(Element(element, content))
+ resp, body = self.put(uri, str(Document(floatingip)), self.headers)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
body = ET.fromstring(xml_returned_body)
@@ -448,5 +554,10 @@
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
body = xml_to_json(etree.fromstring(xml_returned_body))
+ nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
+ for key, val in body.iteritems():
+ if isinstance(val, dict):
+ if (nil in val and val[nil] == 'true'):
+ body[key] = None
body = {root_tag: body}
return body
diff --git a/tempest/test.py b/tempest/test.py
index 6acb1c9..8ce7af8 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -16,6 +16,7 @@
# under the License.
import atexit
+import functools
import os
import time
@@ -103,6 +104,24 @@
return decorator
+def skip_because(*args, **kwargs):
+ """A decorator useful to skip tests hitting known bugs
+
+ @param bug: bug number causing the test to skip
+ @param condition: optional condition to be True for the skip to have place
+ """
+ def decorator(f):
+ @functools.wraps(f)
+ def wrapper(*func_args, **func_kwargs):
+ if "bug" in kwargs:
+ if "condition" not in kwargs or kwargs["condition"] is True:
+ msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
+ raise testtools.TestCase.skipException(msg)
+ return f(*func_args, **func_kwargs)
+ return wrapper
+ return decorator
+
+
# there is a mis-match between nose and testtools for older pythons.
# testtools will set skipException to be either
# unittest.case.SkipTest, unittest2.case.SkipTest or an internal skip
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index bce544a..0f455e1 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -16,7 +16,6 @@
# under the License.
from boto import exception
-import testtools
from tempest import clients
from tempest.common.utils.data_utils import rand_name
@@ -24,6 +23,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
from tempest.thirdparty.boto.utils.s3 import s3_upload_dir
from tempest.thirdparty.boto.utils.wait import re_search_wait
@@ -206,8 +206,8 @@
instance.terminate()
self.cancelResourceCleanUp(rcuk)
+ @skip_because(bug="1098891")
@attr(type='smoke')
- @testtools.skip("Skipped until the Bug #1098891 is resolved")
def test_run_terminate_instance(self):
# EC2 run, terminate immediately
image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -233,7 +233,7 @@
# NOTE(afazekas): doctored test case,
# with normal validation it would fail
- @testtools.skip("Skipped until the Bug #1182679 is resolved.")
+ @skip_because(bug="1182679")
@attr(type='smoke')
def test_integration_1(self):
# EC2 1. integration test (not strict)
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index 85a99c0..5592d8c 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -15,11 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -47,8 +46,8 @@
self.assertTrue(compare_key_pairs(keypair,
self.client.get_key_pair(key_name)))
+ @skip_because(bug="1072318")
@attr(type='smoke')
- @testtools.skip("Skipped until the Bug #1072318 is resolved")
def test_delete_ec2_keypair(self):
# EC2 delete KeyPair
key_name = rand_name("keypair-")
diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py
index ae8c3c2..b4949c8 100644
--- a/tempest/thirdparty/boto/test_ec2_network.py
+++ b/tempest/thirdparty/boto/test_ec2_network.py
@@ -15,10 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -30,8 +29,8 @@
cls.os = clients.Manager()
cls.client = cls.os.ec2api_client
-# Note(afazekas): these tests for things duable without an instance
- @testtools.skip("Skipped until the Bug #1080406 is resolved")
+ # Note(afazekas): these tests for things duable without an instance
+ @skip_because(bug="1080406")
@attr(type='smoke')
def test_disassociate_not_associated_floating_ip(self):
# EC2 disassociate not associated floating ip
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index e43cbaa..1a8fbe0 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -15,11 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
+from tempest.test import skip_because
from tempest.thirdparty.boto.test import BotoTestCase
@@ -31,7 +30,7 @@
cls.os = clients.Manager()
cls.client = cls.os.s3_client
- @testtools.skip("Skipped until the Bug #1076965 is resolved")
+ @skip_because(bug="1076965")
@attr(type='smoke')
def test_create_and_get_delete_bucket(self):
# S3 Create, get and delete bucket
diff --git a/tools/skip_tracker.py b/tools/skip_tracker.py
index c38ccdb..ffaf134 100755
--- a/tools/skip_tracker.py
+++ b/tools/skip_tracker.py
@@ -61,8 +61,8 @@
"""
Return the skip tuples in a test file
"""
- BUG_RE = re.compile(r'.*skip.*bug:*\s*\#*(\d+)', re.IGNORECASE)
- DEF_RE = re.compile(r'.*def (\w+)\(')
+ BUG_RE = re.compile(r'\s*@.*skip_because\(bug=[\'"](\d+)[\'"]')
+ DEF_RE = re.compile(r'\s*def (\w+)\(')
bug_found = False
results = []
lines = open(path, 'rb').readlines()