Merge "Update documentation for clarity"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index eeb1375..0f2b2cf 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -432,7 +432,7 @@
# Does the test environment support live migration available? (boolean
# value)
-#live_migration = false
+#live_migration = true
# Does the test environment support pausing? (boolean value)
#pause = true
@@ -632,6 +632,9 @@
# (boolean value)
#trust = true
+# If false, skip all identity api tests with xml (boolean value)
+#xml_api = false
+
[image]
diff --git a/requirements.txt b/requirements.txt
index a856d09..1e4c40b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -20,7 +20,6 @@
python-ironicclient>=0.2.1
python-saharaclient>=0.7.5
python-swiftclient>=2.2.0
-testresources>=0.2.4
testrepository>=0.0.18
oslo.config>=1.4.0 # Apache-2.0
six>=1.7.0
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 ba66ab9..3bb7d19 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -130,7 +130,8 @@
# Make sure no longer associated with old server
self.assertRaises((exceptions.NotFound,
- exceptions.UnprocessableEntity),
+ exceptions.UnprocessableEntity,
+ exceptions.Conflict),
self.client.disassociate_floating_ip_from_server,
self.floating_ip, self.server_id)
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 6c29f51..a494896 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -14,11 +14,8 @@
# under the License.
from tempest.api.compute import base
-from tempest import config
from tempest import test
-CONF = config.CONF
-
class ServerAddressesTestJSON(base.BaseV2ComputeTest):
@@ -31,8 +28,6 @@
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
- @test.skip_because(bug="1210483",
- condition=CONF.service_available.neutron)
@test.attr(type='smoke')
@test.services('network')
def test_list_server_addresses(self):
diff --git a/tempest/api/compute/v3/servers/test_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index 0590146..7b41d71 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -14,11 +14,8 @@
# under the License.
from tempest.api.compute import base
-from tempest import config
from tempest import test
-CONF = config.CONF
-
class ServerAddressesV3Test(base.BaseV3ComputeTest):
@@ -31,8 +28,6 @@
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
- @test.skip_because(bug="1210483",
- condition=CONF.service_available.neutron)
@test.attr(type='smoke')
def test_list_server_addresses(self):
# All public and private addresses for
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 1e4973b..244323e 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -31,6 +31,9 @@
@classmethod
def resource_setup(cls):
super(BaseIdentityAdminTest, cls).resource_setup()
+ if getattr(cls, '_interface', None) == 'xml':
+ if not CONF.identity_feature_enabled.xml_api:
+ raise cls.skipException('XML API is not enabled')
cls.os_adm = clients.AdminManager(interface=cls._interface)
cls.os = clients.Manager(interface=cls._interface)
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 738e498..5e6d8f3 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -12,7 +12,6 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest import exceptions
class ExternalNetworksTestJSON(base.BaseAdminNetworkTest):
@@ -32,26 +31,6 @@
self.addCleanup(self.admin_client.delete_network, network['id'])
return network
- def _try_delete_resource(self, delete_callable, *args, **kwargs):
- """Cleanup resources in case of test-failure
-
- Some resources should be explicitly deleted by the test. if the test
- fails, these resources remain.
- If the test failed to delete a resource, this method will execute
- the appropriate delete methods. Otherwise, the method ignores NotFound
- exceptions thrown for resources that were correctly deleted by the
- test.
-
- :param delete_callable: delete method
- :param args: arguments for delete method
- :param kwargs: keyword arguments for delete method
- """
- try:
- delete_callable(*args, **kwargs)
- # if resource is not found, this means it was deleted in the test
- except exceptions.NotFound:
- pass
-
def test_create_external_network(self):
# Create a network as an admin user specifying the
# external network extension attribute
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 7cd18cd..4b5f107 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -65,6 +65,8 @@
if getattr(cls, '_interface', None) == 'xml':
if not CONF.network_feature_enabled.xml_api:
raise cls.skipException('XML API is not enabled')
+ if cls._ip_version == 6 and not CONF.network_feature_enabled.ipv6:
+ raise cls.skipException("IPv6 Tests are disabled.")
os = cls.get_client_manager()
@@ -93,58 +95,95 @@
if CONF.service_available.neutron:
# Clean up ipsec policies
for ipsecpolicy in cls.ipsecpolicies:
- cls.client.delete_ipsecpolicy(ipsecpolicy['id'])
+ cls._try_delete_resource(cls.client.delete_ipsecpolicy,
+ ipsecpolicy['id'])
# Clean up firewall policies
for fw_policy in cls.fw_policies:
- cls.client.delete_firewall_policy(fw_policy['id'])
+ cls._try_delete_resource(cls.client.delete_firewall_policy,
+ fw_policy['id'])
# Clean up firewall rules
for fw_rule in cls.fw_rules:
- cls.client.delete_firewall_rule(fw_rule['id'])
+ cls._try_delete_resource(cls.client.delete_firewall_rule,
+ fw_rule['id'])
# Clean up ike policies
for ikepolicy in cls.ikepolicies:
- cls.client.delete_ikepolicy(ikepolicy['id'])
+ cls._try_delete_resource(cls.client.delete_ikepolicy,
+ ikepolicy['id'])
# Clean up vpn services
for vpnservice in cls.vpnservices:
- cls.client.delete_vpnservice(vpnservice['id'])
+ cls._try_delete_resource(cls.client.delete_vpnservice,
+ vpnservice['id'])
# Clean up floating IPs
for floating_ip in cls.floating_ips:
- cls.client.delete_floatingip(floating_ip['id'])
+ cls._try_delete_resource(cls.client.delete_floatingip,
+ floating_ip['id'])
# Clean up routers
for router in cls.routers:
- cls.delete_router(router)
+ cls._try_delete_resource(cls.delete_router,
+ router)
# Clean up health monitors
for health_monitor in cls.health_monitors:
- cls.client.delete_health_monitor(health_monitor['id'])
+ cls._try_delete_resource(cls.client.delete_health_monitor,
+ health_monitor['id'])
# Clean up members
for member in cls.members:
- cls.client.delete_member(member['id'])
+ cls._try_delete_resource(cls.client.delete_member,
+ member['id'])
# Clean up vips
for vip in cls.vips:
- cls.client.delete_vip(vip['id'])
+ cls._try_delete_resource(cls.client.delete_vip,
+ vip['id'])
# Clean up pools
for pool in cls.pools:
- cls.client.delete_pool(pool['id'])
+ cls._try_delete_resource(cls.client.delete_pool,
+ pool['id'])
# Clean up metering label rules
for metering_label_rule in cls.metering_label_rules:
- cls.admin_client.delete_metering_label_rule(
+ cls._try_delete_resource(
+ cls.admin_client.delete_metering_label_rule,
metering_label_rule['id'])
# Clean up metering labels
for metering_label in cls.metering_labels:
- cls.admin_client.delete_metering_label(metering_label['id'])
+ cls._try_delete_resource(
+ cls.admin_client.delete_metering_label,
+ metering_label['id'])
# Clean up ports
for port in cls.ports:
- cls.client.delete_port(port['id'])
+ cls._try_delete_resource(cls.client.delete_port,
+ port['id'])
# Clean up subnets
for subnet in cls.subnets:
- cls.client.delete_subnet(subnet['id'])
+ cls._try_delete_resource(cls.client.delete_subnet,
+ subnet['id'])
# Clean up networks
for network in cls.networks:
- cls.client.delete_network(network['id'])
+ cls._try_delete_resource(cls.client.delete_network,
+ network['id'])
cls.clear_isolated_creds()
super(BaseNetworkTest, cls).resource_cleanup()
@classmethod
+ def _try_delete_resource(self, delete_callable, *args, **kwargs):
+ """Cleanup resources in case of test-failure
+
+ Some resources are explicitly deleted by the test.
+ If the test failed to delete a resource, this method will execute
+ the appropriate delete methods. Otherwise, the method ignores NotFound
+ exceptions thrown for resources that were correctly deleted by the
+ test.
+
+ :param delete_callable: delete method
+ :param args: arguments for delete method
+ :param kwargs: keyword arguments for delete method
+ """
+ try:
+ delete_callable(*args, **kwargs)
+ # if resource is not found, this means it was deleted in the test
+ except exceptions.NotFound:
+ pass
+
+ @classmethod
def create_network(cls, network_name=None):
"""Wrapper utility that returns a test network."""
network_name = network_name or data_utils.rand_name('test-network-')
@@ -276,9 +315,11 @@
return vip
@classmethod
- def create_member(cls, protocol_port, pool):
+ def create_member(cls, protocol_port, pool, ip_version=None):
"""Wrapper utility that returns a test member."""
- resp, body = cls.client.create_member(address="10.0.9.46",
+ ip_version = ip_version if ip_version is not None else cls._ip_version
+ member_address = "fd00::abcd" if ip_version == 6 else "10.0.9.46"
+ resp, body = cls.client.create_member(address=member_address,
protocol_port=protocol_port,
pool_id=pool['id'])
member = body['member']
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 6a772f1..a1166c8 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -127,5 +127,9 @@
self.assertEqual(mac_address, self.mac_address)
+class AllowedAddressPairIpV6TestJSON(AllowedAddressPairTestJSON):
+ _ip_version = 6
+
+
class AllowedAddressPairTestXML(AllowedAddressPairTestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 86da9b7..6d083b3 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -44,17 +44,22 @@
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
cls.port = cls.create_port(cls.network)
+ cls.ip_tftp = ('123.123.123.123' if cls._ip_version == 4
+ else '2015::dead')
+ cls.ip_server = ('123.123.123.45' if cls._ip_version == 4
+ else '2015::badd')
+ cls.extra_dhcp_opts = [
+ {'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'},
+ {'opt_value': cls.ip_tftp, 'opt_name': 'tftp-server'},
+ {'opt_value': cls.ip_server, 'opt_name': 'server-ip-address'}
+ ]
@test.attr(type='smoke')
def test_create_list_port_with_extra_dhcp_options(self):
# Create a port with Extra DHCP Options
- extra_dhcp_opts = [
- {'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'},
- {'opt_value': '123.123.123.123', 'opt_name': 'tftp-server'},
- {'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
- ]
- _, body = self.client.create_port(network_id=self.network['id'],
- extra_dhcp_opts=extra_dhcp_opts)
+ _, body = self.client.create_port(
+ network_id=self.network['id'],
+ extra_dhcp_opts=self.extra_dhcp_opts)
port_id = body['port']['id']
self.addCleanup(self.client.delete_port, port_id)
@@ -63,23 +68,19 @@
ports = body['ports']
port = [p for p in ports if p['id'] == port_id]
self.assertTrue(port)
- self._confirm_extra_dhcp_options(port[0], extra_dhcp_opts)
+ self._confirm_extra_dhcp_options(port[0], self.extra_dhcp_opts)
@test.attr(type='smoke')
def test_update_show_port_with_extra_dhcp_options(self):
# Update port with extra dhcp options
- extra_dhcp_opts = [
- {'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'},
- {'opt_value': '123.123.123.123', 'opt_name': 'tftp-server'},
- {'opt_value': '123.123.123.45', 'opt_name': 'server-ip-address'}
- ]
name = data_utils.rand_name('new-port-name')
- _, body = self.client.update_port(self.port['id'], name=name,
- extra_dhcp_opts=extra_dhcp_opts)
-
+ _, body = self.client.update_port(
+ self.port['id'],
+ name=name,
+ extra_dhcp_opts=self.extra_dhcp_opts)
# Confirm extra dhcp options were added to the port
_, body = self.client.show_port(self.port['id'])
- self._confirm_extra_dhcp_options(body['port'], extra_dhcp_opts)
+ self._confirm_extra_dhcp_options(body['port'], self.extra_dhcp_opts)
def _confirm_extra_dhcp_options(self, port, extra_dhcp_opts):
retrieved = port['extra_dhcp_opts']
@@ -92,3 +93,7 @@
else:
self.fail('Extra DHCP option not found in port %s' %
str(retrieved_option))
+
+
+class ExtraDHCPOptionsIpV6TestJSON(ExtraDHCPOptionsTestJSON):
+ _ip_version = 6
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index baa8cad..8b8e3b1 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -55,7 +55,9 @@
protocol_port=80,
subnet=cls.subnet,
pool=cls.pool)
- cls.member = cls.create_member(80, cls.pool)
+ cls.member = cls.create_member(80, cls.pool, cls._ip_version)
+ cls.member_address = ("10.0.9.47" if cls._ip_version == 4
+ else "2015::beef")
cls.health_monitor = cls.create_health_monitor(delay=4,
max_retries=3,
Type="TCP",
@@ -213,13 +215,14 @@
def test_list_members_with_filters(self):
attr_exceptions = ['status', 'status_description']
self._check_list_with_filter('member', attr_exceptions,
- address="10.0.9.47", protocol_port=80,
+ address=self.member_address,
+ protocol_port=80,
pool_id=self.pool['id'])
@test.attr(type='smoke')
def test_create_update_delete_member(self):
# Creates a member
- _, body = self.client.create_member(address="10.0.9.47",
+ _, body = self.client.create_member(address=self.member_address,
protocol_port=80,
pool_id=self.pool['id'])
member = body['member']
@@ -419,5 +422,9 @@
self.assertEqual(2, member['weight'])
+class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
+ _ip_version = 6
+
+
class LoadBalancerTestXML(LoadBalancerTestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 2cfb841..07ebd8c 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -43,7 +43,8 @@
description = "metering label created by tempest"
name = data_utils.rand_name("metering-label")
cls.metering_label = cls.create_metering_label(name, description)
- remote_ip_prefix = "10.0.0.0/24"
+ remote_ip_prefix = ("10.0.0.0/24" if cls._ip_version == 4
+ else "fd02::/64")
direction = "ingress"
cls.metering_label_rule = cls.create_metering_label_rule(
remote_ip_prefix, direction,
@@ -112,8 +113,10 @@
@test.attr(type='smoke')
def test_create_delete_metering_label_rule_with_filters(self):
# Creates a rule
+ remote_ip_prefix = ("10.0.1.0/24" if self._ip_version == 4
+ else "fd03::/64")
_, body = (self.admin_client.create_metering_label_rule(
- remote_ip_prefix="10.0.1.0/24",
+ remote_ip_prefix=remote_ip_prefix,
direction="ingress",
metering_label_id=self.metering_label['id']))
metering_label_rule = body['metering_label_rule']
@@ -142,5 +145,9 @@
self.assertFalse(metering_label_rule['excluded'])
+class MeteringIpV6JSON(MeteringJSON):
+ _ip_version = 6
+
+
class MeteringXML(MeteringJSON):
interface = 'xml'
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index b9086cc..be23a82 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -502,13 +502,6 @@
class NetworksIpV6TestJSON(NetworksTestJSON):
_ip_version = 6
- @classmethod
- 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).resource_setup()
-
@test.attr(type='smoke')
def test_create_delete_subnet_with_gw(self):
net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index d6db64d..7c5bdfe 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -276,13 +276,6 @@
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
- @classmethod
- 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)
-
class PortsIpV6TestXML(PortsIpV6TestJSON):
_interface = 'xml'
@@ -293,13 +286,6 @@
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
_tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
- @classmethod
- 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).resource_setup()
-
class PortsAdminExtendedAttrsIpV6TestXML(PortsAdminExtendedAttrsIpV6TestJSON):
_interface = 'xml'
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index f3f25ac..2b4e60a 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -35,6 +35,9 @@
raise cls.skipException(msg)
admin_manager = clients.AdminManager()
cls.identity_admin_client = admin_manager.identity_client
+ cls.tenant_cidr = (CONF.network.tenant_network_cidr
+ if cls._ip_version == 4 else
+ CONF.network.tenant_network_v6_cidr)
def _cleanup_router(self, router):
self.delete_router(router)
@@ -319,7 +322,7 @@
network02 = self.create_network(
network_name=data_utils.rand_name('router-network02-'))
subnet01 = self.create_subnet(network01)
- sub02_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr).next()
+ sub02_cidr = netaddr.IPNetwork(self.tenant_cidr).next()
subnet02 = self.create_subnet(network02, cidr=sub02_cidr)
router = self._create_router(data_utils.rand_name('router-'))
interface01 = self._add_router_interface_with_subnet_id(router['id'],
@@ -337,3 +340,7 @@
self.assertEqual(router_id, interface_port['device_id'])
self.assertEqual(subnet_id,
interface_port['fixed_ips'][0]['subnet_id'])
+
+
+class RoutersIpV6Test(RoutersTest):
+ _ip_version = 6
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index 4c226af..88aa3c9 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -36,6 +36,9 @@
cls.router = cls.create_router(data_utils.rand_name('router-'))
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
+ cls.tenant_cidr = (CONF.network.tenant_network_cidr
+ if cls._ip_version == 4 else
+ CONF.network.tenant_network_v6_cidr)
@test.attr(type=['negative', 'smoke'])
def test_router_add_gateway_invalid_network_returns_404(self):
@@ -49,7 +52,7 @@
def test_router_add_gateway_net_not_external_returns_400(self):
alt_network = self.create_network(
network_name=data_utils.rand_name('router-negative-'))
- sub_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr).next()
+ sub_cidr = netaddr.IPNetwork(self.tenant_cidr).next()
self.create_subnet(alt_network, cidr=sub_cidr)
self.assertRaises(exceptions.BadRequest,
self.client.update_router,
@@ -79,3 +82,7 @@
self.assertRaises(exceptions.Conflict,
self.client.delete_router,
self.router['id'])
+
+
+class RoutersNegativeIpV6Test(RoutersNegativeTest):
+ _ip_version = 6
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index e20b58e..47f2b52 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -221,13 +221,6 @@
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
- @classmethod
- def resource_setup(cls):
- if not CONF.network_feature_enabled.ipv6:
- skip_msg = "IPv6 Tests are disabled."
- raise cls.skipException(skip_msg)
- super(SecGroupIPv6Test, cls).resource_setup()
-
class SecGroupIPv6TestXML(SecGroupIPv6Test):
_interface = 'xml'
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 97e4cb7..42f7f71 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -197,13 +197,6 @@
_ip_version = 6
_tenant_network_cidr = CONF.network.tenant_network_v6_cidr
- @classmethod
- def resource_setup(cls):
- if not CONF.network_feature_enabled.ipv6:
- skip_msg = "IPv6 Tests are disabled."
- raise cls.skipException(skip_msg)
- super(NegativeSecGroupIPv6Test, cls).resource_setup()
-
class NegativeSecGroupIPv6TestXML(NegativeSecGroupIPv6Test):
_interface = 'xml'
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 720734b..02a2526 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -18,29 +18,28 @@
from tempest import test
-class SnapshotsActionsTest(base.BaseVolumeV1AdminTest):
+class SnapshotsActionsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(SnapshotsActionsTest, cls).resource_setup()
+ super(SnapshotsActionsV2Test, cls).resource_setup()
cls.client = cls.snapshots_client
- # Create admin volume client
- cls.admin_snapshots_client = cls.os_adm.snapshots_client
-
# Create a test shared volume for tests
vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
+ cls.name_field = cls.special_fields['name_field']
+ params = {cls.name_field: vol_name}
_, cls.volume = \
- cls.volumes_client.create_volume(size=1, display_name=vol_name)
+ cls.volumes_client.create_volume(size=1, **params)
cls.volumes_client.wait_for_volume_status(cls.volume['id'],
'available')
# Create a test shared snapshot for tests
snap_name = data_utils.rand_name(cls.__name__ + '-Snapshot-')
+ params = {cls.name_field: snap_name}
_, cls.snapshot = \
- cls.client.create_snapshot(cls.volume['id'],
- display_name=snap_name)
+ cls.client.create_snapshot(cls.volume['id'], **params)
cls.client.wait_for_snapshot_status(cls.snapshot['id'],
'available')
@@ -54,7 +53,7 @@
cls.volumes_client.delete_volume(cls.volume['id'])
cls.volumes_client.wait_for_resource_deletion(cls.volume['id'])
- super(SnapshotsActionsTest, cls).resource_cleanup()
+ super(SnapshotsActionsV2Test, cls).resource_cleanup()
def tearDown(self):
# Set snapshot's status to available after test
@@ -62,7 +61,7 @@
snapshot_id = self.snapshot['id']
self.admin_snapshots_client.reset_snapshot_status(snapshot_id,
status)
- super(SnapshotsActionsTest, self).tearDown()
+ super(SnapshotsActionsV2Test, self).tearDown()
def _create_reset_and_force_delete_temp_snapshot(self, status=None):
# Create snapshot, reset snapshot status,
@@ -127,7 +126,11 @@
self._create_reset_and_force_delete_temp_snapshot('error_deleting')
-class SnapshotsActionsTestXML(SnapshotsActionsTest):
+class SnapshotsActionsV1Test(SnapshotsActionsV2Test):
+ _api_version = 1
+
+
+class SnapshotsActionsV1TestXML(SnapshotsActionsV1Test):
_interface = "xml"
def _get_progress_alias(self):
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index a154821..3b9f6bb 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -18,12 +18,12 @@
from tempest import test
-class VolumeTypesExtraSpecsTest(base.BaseVolumeV1AdminTest):
+class VolumeTypesExtraSpecsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(VolumeTypesExtraSpecsTest, cls).resource_setup()
+ super(VolumeTypesExtraSpecsV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
_, cls.volume_type = cls.volume_types_client.create_volume_type(
vol_type_name)
@@ -31,7 +31,7 @@
@classmethod
def resource_cleanup(cls):
cls.volume_types_client.delete_volume_type(cls.volume_type['id'])
- super(VolumeTypesExtraSpecsTest, cls).resource_cleanup()
+ super(VolumeTypesExtraSpecsV2Test, cls).resource_cleanup()
@test.attr(type='smoke')
def test_volume_type_extra_specs_list(self):
@@ -83,3 +83,7 @@
self.volume_types_client.delete_volume_type_extra_specs(
self.volume_type['id'],
extra_specs.keys()[0])
+
+
+class VolumeTypesExtraSpecsV1Test(VolumeTypesExtraSpecsV2Test):
+ _api_version = 1
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 8734b16..e474aa0 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -21,12 +21,12 @@
from tempest import test
-class ExtraSpecsNegativeTest(base.BaseVolumeV1AdminTest):
+class ExtraSpecsNegativeV2Test(base.BaseVolumeAdminTest):
_interface = 'json'
@classmethod
def resource_setup(cls):
- super(ExtraSpecsNegativeTest, cls).resource_setup()
+ super(ExtraSpecsNegativeV2Test, cls).resource_setup()
vol_type_name = data_utils.rand_name('Volume-type-')
cls.extra_specs = {"spec1": "val1"}
_, cls.volume_type = cls.volume_types_client.create_volume_type(
@@ -36,7 +36,7 @@
@classmethod
def resource_cleanup(cls):
cls.volume_types_client.delete_volume_type(cls.volume_type['id'])
- super(ExtraSpecsNegativeTest, cls).resource_cleanup()
+ super(ExtraSpecsNegativeV2Test, cls).resource_cleanup()
@test.attr(type='gate')
def test_update_no_body(self):
@@ -140,5 +140,9 @@
self.volume_type['id'], str(uuid.uuid4()))
-class ExtraSpecsNegativeTestXML(ExtraSpecsNegativeTest):
+class ExtraSpecsNegativeV1Test(ExtraSpecsNegativeV2Test):
+ _api_version = 1
+
+
+class ExtraSpecsNegativeV1TestXML(ExtraSpecsNegativeV1Test):
_interface = 'xml'
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index 3857fdb..1c3e04a 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -18,19 +18,21 @@
from tempest import test
-class VolumesActionsTest(base.BaseVolumeV1AdminTest):
+class VolumesActionsV2Test(base.BaseVolumeAdminTest):
_interface = "json"
@classmethod
def resource_setup(cls):
- super(VolumesActionsTest, cls).resource_setup()
+ super(VolumesActionsV2Test, cls).resource_setup()
cls.client = cls.volumes_client
# Create a test shared volume for tests
vol_name = utils.rand_name(cls.__name__ + '-Volume-')
+ cls.name_field = cls.special_fields['name_field']
+ params = {cls.name_field: vol_name}
_, cls.volume = cls.client.create_volume(size=1,
- display_name=vol_name)
+ **params)
cls.client.wait_for_volume_status(cls.volume['id'], 'available')
@classmethod
@@ -39,7 +41,7 @@
cls.client.delete_volume(cls.volume['id'])
cls.client.wait_for_resource_deletion(cls.volume['id'])
- super(VolumesActionsTest, cls).resource_cleanup()
+ super(VolumesActionsV2Test, cls).resource_cleanup()
def _reset_volume_status(self, volume_id, status):
# Reset the volume status
@@ -50,13 +52,14 @@
def tearDown(self):
# Set volume's status to available after test
self._reset_volume_status(self.volume['id'], 'available')
- super(VolumesActionsTest, self).tearDown()
+ super(VolumesActionsV2Test, self).tearDown()
def _create_temp_volume(self):
# Create a temp volume for force delete tests
vol_name = utils.rand_name('Volume')
+ params = {self.name_field: vol_name}
_, temp_volume = self.client.create_volume(size=1,
- display_name=vol_name)
+ **params)
self.client.wait_for_volume_status(temp_volume['id'], 'available')
return temp_volume
@@ -92,5 +95,9 @@
self._create_reset_and_force_delete_temp_volume('error')
-class VolumesActionsTestXML(VolumesActionsTest):
+class VolumesActionsV1Test(VolumesActionsV2Test):
+ _api_version = 1
+
+
+class VolumesActionsV1TestXML(VolumesActionsV1Test):
_interface = "xml"
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 638f76c..f9f03ac 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -175,6 +175,7 @@
cls.volume_types_client = cls.os_adm.volume_types_client
cls.admin_volume_client = cls.os_adm.volumes_client
cls.hosts_client = cls.os_adm.volume_hosts_client
+ cls.admin_snapshots_client = cls.os_adm.snapshots_client
elif cls._api_version == 2:
if not CONF.volume_feature_enabled.api_v2:
msg = "Volume API v2 is disabled"
@@ -183,6 +184,7 @@
cls.volume_types_client = cls.os_adm.volume_types_v2_client
cls.admin_volume_client = cls.os_adm.volumes_v2_client
cls.hosts_client = cls.os_adm.volume_hosts_v2_client
+ cls.admin_snapshots_client = cls.os_adm.snapshots_v2_client
@classmethod
def resource_cleanup(cls):
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index 8dd2df2..4782129 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -16,6 +16,7 @@
import functools
from tempest_lib.cli import base
+from tempest_lib.cli import output_parser
import testtools
from tempest.common import credentials
@@ -66,7 +67,7 @@
return decorator
-class ClientTestBase(base.ClientTestBase, test.BaseTestCase):
+class ClientTestBase(test.BaseTestCase):
@classmethod
def resource_setup(cls):
if not CONF.cli.enabled:
@@ -82,3 +83,36 @@
self.creds.tenant_name,
CONF.identity.uri, CONF.cli.cli_dir)
return clients
+
+ # TODO(mtreinish): The following code is basically copied from tempest-lib.
+ # The base cli test class in tempest-lib 0.0.1 doesn't work as a mixin like
+ # is needed here. The code below should be removed when tempest-lib
+ # provides a way to provide this functionality
+ def setUp(self):
+ super(ClientTestBase, self).setUp()
+ self.clients = self._get_clients()
+ self.parser = output_parser
+
+ def assertTableStruct(self, items, field_names):
+ """Verify that all items has keys listed in field_names.
+
+ :param items: items to assert are field names in the output table
+ :type items: list
+ :param field_names: field names from the output table of the cmd
+ :type field_names: list
+ """
+ for item in items:
+ for field in field_names:
+ self.assertIn(field, item)
+
+ def assertFirstLineStartsWith(self, lines, beginning):
+ """Verify that the first line starts with a string
+
+ :param lines: strings for each line of output
+ :type lines: list
+ :param beginning: verify this is at the beginning of the first line
+ :type beginning: string
+ """
+ self.assertTrue(lines[0].startswith(beginning),
+ msg=('Beginning of first line has invalid content: %s'
+ % lines[:3]))
diff --git a/tempest/clients.py b/tempest/clients.py
index 6f50730..9546502 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -233,81 +233,18 @@
super(Manager, self).__init__(credentials=credentials)
self._set_compute_clients(self.interface)
+ self._set_identity_clients(self.interface)
+ self._set_volume_clients(self.interface)
if self.interface == 'xml':
- 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(
- self.auth_provider)
- self.identity_client = IdentityClientXML(self.auth_provider)
- self.identity_v3_client = IdentityV3ClientXML(
- self.auth_provider)
- self.endpoints_client = EndPointClientXML(self.auth_provider)
- self.service_client = ServiceClientXML(self.auth_provider)
- self.volume_services_client = VolumesServicesClientXML(
- self.auth_provider)
- self.policy_client = PolicyClientXML(self.auth_provider)
- self.region_client = RegionClientXML(self.auth_provider)
self.network_client = NetworkClientXML(self.auth_provider)
- self.credentials_client = CredentialsClientXML(
- self.auth_provider)
- self.volume_hosts_client = VolumeHostsClientXML(
- self.auth_provider)
- self.volume_quotas_client = VolumeQuotasClientXML(
- self.auth_provider)
- self.volumes_extension_client = VolumeExtensionClientXML(
- self.auth_provider)
- self.volumes_v2_extension_client = VolumeV2ExtensionClientXML(
- self.auth_provider)
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientXML(
self.auth_provider)
- self.token_client = TokenClientXML()
- if CONF.identity_feature_enabled.api_v3:
- self.token_v3_client = V3TokenClientXML()
- self.volume_availability_zone_client = \
- VolumeAvailabilityZoneClientXML(self.auth_provider)
- self.volume_v2_availability_zone_client = \
- VolumeV2AvailabilityZoneClientXML(self.auth_provider)
elif self.interface == 'json':
self.baremetal_client = BaremetalClientJSON(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(
- self.auth_provider)
- self.volume_types_v2_client = VolumeTypesV2ClientJSON(
- self.auth_provider)
- self.identity_client = IdentityClientJSON(self.auth_provider)
- self.identity_v3_client = IdentityV3ClientJSON(
- self.auth_provider)
- self.endpoints_client = EndPointClientJSON(self.auth_provider)
- self.service_client = ServiceClientJSON(self.auth_provider)
- self.volume_services_client = VolumesServicesClientJSON(
- self.auth_provider)
- self.policy_client = PolicyClientJSON(self.auth_provider)
- self.region_client = RegionClientJSON(self.auth_provider)
self.network_client = NetworkClientJSON(self.auth_provider)
- self.credentials_client = CredentialsClientJSON(
- self.auth_provider)
- self.volume_hosts_client = VolumeHostsClientJSON(
- self.auth_provider)
- self.volume_hosts_v2_client = VolumeHostsV2ClientJSON(
- self.auth_provider)
- self.volume_quotas_client = VolumeQuotasClientJSON(
- self.auth_provider)
- self.volumes_extension_client = VolumeExtensionClientJSON(
- self.auth_provider)
- self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
- self.auth_provider)
-
self.database_flavors_client = DatabaseFlavorsClientJSON(
self.auth_provider)
self.database_versions_client = DatabaseVersionsClientJSON(
@@ -316,16 +253,9 @@
if CONF.service_available.ceilometer:
self.telemetry_client = TelemetryClientJSON(
self.auth_provider)
- self.token_client = TokenClientJSON()
- if CONF.identity_feature_enabled.api_v3:
- self.token_v3_client = V3TokenClientJSON()
self.negative_client = rest_client.NegativeRestClient(
self.auth_provider)
self.negative_client.service = service
- self.volume_availability_zone_client = \
- VolumeAvailabilityZoneClientJSON(self.auth_provider)
- self.volume_v2_availability_zone_client = \
- VolumeV2AvailabilityZoneClientJSON(self.auth_provider)
else:
msg = "Unsupported interface type `%s'" % interface
@@ -339,7 +269,6 @@
# common clients
self.account_client = AccountClient(self.auth_provider)
- self.agents_client = AgentsClientJSON(self.auth_provider)
if CONF.service_available.glance:
self.image_client = ImageClientJSON(self.auth_provider)
self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
@@ -355,17 +284,6 @@
AccountClientCustomizedHeader(self.auth_provider)
self.data_processing_client = DataProcessingClient(
self.auth_provider)
- self.migrations_client = MigrationsClientJSON(self.auth_provider)
- 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)
def _set_compute_clients(self, type):
if type == 'json':
@@ -373,6 +291,13 @@
else:
self._set_compute_xml_clients()
+ # Common compute clients
+ self.agents_client = AgentsClientJSON(self.auth_provider)
+ self.networks_client = NetworksClientJSON(self.auth_provider)
+ self.migrations_client = MigrationsClientJSON(self.auth_provider)
+ self.security_group_default_rules_client = (
+ SecurityGroupDefaultRulesClientJSON(self.auth_provider))
+
def _set_compute_xml_clients(self):
self.certificates_client = CertificatesClientXML(self.auth_provider)
self.servers_client = ServersClientXML(self.auth_provider)
@@ -444,6 +369,95 @@
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientJSON(self.auth_provider)
+ def _set_identity_clients(self, type):
+ if type == 'json':
+ self._set_identity_json_clients()
+ else:
+ self._set_identity_xml_clients()
+
+ def _set_identity_xml_clients(self):
+ self.identity_client = IdentityClientXML(self.auth_provider)
+ self.identity_v3_client = IdentityV3ClientXML(self.auth_provider)
+ self.endpoints_client = EndPointClientXML(self.auth_provider)
+ self.service_client = ServiceClientXML(self.auth_provider)
+ self.policy_client = PolicyClientXML(self.auth_provider)
+ self.region_client = RegionClientXML(self.auth_provider)
+ self.token_client = TokenClientXML()
+ if CONF.identity_feature_enabled.api_v3:
+ self.token_v3_client = V3TokenClientXML()
+ self.credentials_client = CredentialsClientXML(self.auth_provider)
+
+ def _set_identity_json_clients(self):
+ self.identity_client = IdentityClientJSON(self.auth_provider)
+ self.identity_v3_client = IdentityV3ClientJSON(self.auth_provider)
+ self.endpoints_client = EndPointClientJSON(self.auth_provider)
+ self.service_client = ServiceClientJSON(self.auth_provider)
+ self.policy_client = PolicyClientJSON(self.auth_provider)
+ self.region_client = RegionClientJSON(self.auth_provider)
+ self.token_client = TokenClientJSON()
+ if CONF.identity_feature_enabled.api_v3:
+ self.token_v3_client = V3TokenClientJSON()
+ self.credentials_client = CredentialsClientJSON(self.auth_provider)
+
+ def _set_volume_clients(self, type):
+ if type == 'json':
+ self._set_volume_json_clients()
+ else:
+ self._set_volume_xml_clients()
+
+ # Common volume clients
+ # 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)
+
+ def _set_volume_xml_clients(self):
+ 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(self.auth_provider)
+ self.volume_services_client = VolumesServicesClientXML(
+ self.auth_provider)
+ self.volume_hosts_client = VolumeHostsClientXML(self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientXML(self.auth_provider)
+ self.volumes_extension_client = VolumeExtensionClientXML(
+ self.auth_provider)
+ self.volumes_v2_extension_client = VolumeV2ExtensionClientXML(
+ self.auth_provider)
+ self.volume_availability_zone_client = \
+ VolumeAvailabilityZoneClientXML(self.auth_provider)
+ self.volume_v2_availability_zone_client = \
+ VolumeV2AvailabilityZoneClientXML(self.auth_provider)
+
+ def _set_volume_json_clients(self):
+ 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(self.auth_provider)
+ self.volume_services_client = VolumesServicesClientJSON(
+ self.auth_provider)
+ self.volume_hosts_client = VolumeHostsClientJSON(self.auth_provider)
+ self.volume_hosts_v2_client = VolumeHostsV2ClientJSON(
+ self.auth_provider)
+ self.volume_quotas_client = VolumeQuotasClientJSON(self.auth_provider)
+ self.volumes_extension_client = VolumeExtensionClientJSON(
+ self.auth_provider)
+ self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
+ self.auth_provider)
+ self.volume_availability_zone_client = \
+ VolumeAvailabilityZoneClientJSON(self.auth_provider)
+ self.volume_v2_availability_zone_client = \
+ VolumeV2AvailabilityZoneClientJSON(self.auth_provider)
+ self.volume_types_v2_client = VolumeTypesV2ClientJSON(
+ self.auth_provider)
+
class AdminManager(Manager):
diff --git a/tempest/config.py b/tempest/config.py
index 365f8ca..616a476 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -143,6 +143,9 @@
cfg.BoolOpt('api_v3',
default=True,
help='Is the v3 identity API enabled'),
+ cfg.BoolOpt('xml_api',
+ default=False,
+ help='If false, skip all identity api tests with xml'),
]
compute_group = cfg.OptGroup(name='compute',
@@ -316,7 +319,7 @@
default=True,
help="Does the test environment support suspend/resume?"),
cfg.BoolOpt('live_migration',
- default=False,
+ default=True,
help="Does the test environment support live migration "
"available?"),
cfg.BoolOpt('block_migration_for_live_migration',
diff --git a/tempest/scenario/test_swift_telemetry_middleware.py b/tempest/scenario/test_swift_telemetry_middleware.py
new file mode 100644
index 0000000..e8eb45c
--- /dev/null
+++ b/tempest/scenario/test_swift_telemetry_middleware.py
@@ -0,0 +1,103 @@
+#
+# Copyright 2014 Red Hat
+#
+# Author: Chris Dent <chdent@redhat.com>
+# 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 import config
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest import test
+
+CONF = config.CONF
+
+LOG = logging.getLogger(__name__)
+
+# Loop for up to 120 seconds waiting on notifications
+# NOTE(chdent): The choice of 120 seconds is fairly
+# arbitrary: Long enough to give the notifications the
+# chance to travel across a highly latent bus but not
+# so long as to allow excessive latency to never be visible.
+# TODO(chdent): Ideally this value would come from configuration.
+NOTIFICATIONS_WAIT = 120
+NOTIFICATIONS_SLEEP = 1
+
+
+class TestSwiftTelemetry(manager.SwiftScenarioTest):
+ """
+ Test that swift uses the ceilometer middleware.
+ * create container.
+ * upload a file to the created container.
+ * retrieve the file from the created container.
+ * wait for notifications from ceilometer.
+ """
+
+ @classmethod
+ def resource_setup(cls):
+ if not CONF.service_available.ceilometer:
+ skip_msg = ("%s skipped as ceilometer is not available" %
+ cls.__name__)
+ raise cls.skipException(skip_msg)
+ elif CONF.telemetry.too_slow_to_test:
+ skip_msg = "Ceilometer feature for fast work mysql is disabled"
+ raise cls.skipException(skip_msg)
+ super(TestSwiftTelemetry, cls).resource_setup()
+ cls.telemetry_client = cls.manager.telemetry_client
+
+ def _confirm_notifications(self, container_name, obj_name):
+ """
+ Loop seeking for appropriate notifications about the containers
+ and objects sent to swift.
+ """
+
+ def _check_samples():
+ """
+ Return True only if we have notifications about some
+ containers and some objects and the notifications are about
+ the expected containers and objects.
+ Otherwise returning False will case _check_samples to be
+ called again.
+ """
+ _, results = self.telemetry_client.list_samples(
+ 'storage.api.request')
+ LOG.debug('got samples %s', results)
+
+ # Extract container info from samples.
+ containers = [sample['resource_metadata']['container']
+ for sample in results
+ if sample['resource_metadata']['container']
+ != 'None']
+ # Extract object info from samples.
+ objects = [sample['resource_metadata']['object']
+ for sample in results
+ if sample['resource_metadata']['object'] != 'None']
+
+ return (containers
+ and objects
+ and container_name in containers
+ and obj_name in objects)
+
+ self.assertTrue(test.call_until_true(_check_samples,
+ NOTIFICATIONS_WAIT,
+ NOTIFICATIONS_SLEEP),
+ 'Correct notifications were not received after '
+ '%s seconds.' % NOTIFICATIONS_WAIT)
+
+ @test.services('object_storage', 'telemetry')
+ def test_swift_middleware_notifies(self):
+ container_name = self.create_container()
+ obj_name, _ = self.upload_object_to_container(container_name)
+ self._confirm_notifications(container_name, obj_name)
diff --git a/tempest/services/object_storage/account_client.py b/tempest/services/object_storage/account_client.py
index a23e173..4417e3b 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -230,7 +230,7 @@
url = '?format=%s' % self.format
if params:
- url += '&%s' + urllib.urlencode(params)
+ url += '&%s' % urllib.urlencode(params)
headers = {}
if metadata:
diff --git a/tempest/test.py b/tempest/test.py
index db8736e..14cf3bb 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -24,7 +24,6 @@
import uuid
import fixtures
-import testresources
import testscenarios
import testtools
@@ -222,23 +221,9 @@
atexit.register(validate_tearDownClass)
-if sys.version_info >= (2, 7):
- class BaseDeps(testtools.TestCase,
- testtools.testcase.WithAttributes,
- testresources.ResourcedTestCase):
- pass
-else:
- # Define asserts for py26
- import unittest2
- class BaseDeps(testtools.TestCase,
- testtools.testcase.WithAttributes,
- testresources.ResourcedTestCase,
- unittest2.TestCase):
- pass
-
-
-class BaseTestCase(BaseDeps):
+class BaseTestCase(testtools.testcase.WithAttributes,
+ testtools.TestCase):
setUpClassCalled = False
_service = None