Merge "Add expected response checks of secgroup rules"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index dfcbaba..003a7f7 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -115,6 +115,24 @@
# to use for running tests (string value)
#test_accounts_file=etc/accounts.yaml
+# Allows test cases to create/destroy tenants and users. This
+# option requires that OpenStack Identity API admin
+# credentials are known. If false, isolated test cases and
+# parallel execution, can still be achieved configuring a list
+# of test accounts (boolean value)
+# Deprecated group/name - [compute]/allow_tenant_isolation
+# Deprecated group/name - [orchestration]/allow_tenant_isolation
+#allow_tenant_isolation=false
+
+# If set to True it enables the Accounts provider, which locks
+# credentials to allow for parallel execution with pre-
+# provisioned accounts. It can only be used to run tests that
+# ensure credentials cleanup happens. It requires at least `2
+# * CONC` distinct accounts configured in
+# `test_accounts_file`, with CONC == the number of concurrent
+# test processes. (boolean value)
+#locking_credentials_provider=false
+
[baremetal]
@@ -229,12 +247,6 @@
# Options defined in tempest.config
#
-# Allows test cases to create/destroy tenants and users. This
-# option enables isolated test cases and better parallel
-# execution, but also requires that OpenStack Identity API
-# admin credentials are known. (boolean value)
-#allow_tenant_isolation=false
-
# Valid primary image reference to be used in tests. This is a
# required option (string value)
#image_ref=<None>
@@ -356,12 +368,6 @@
# value)
#floating_ip_range=10.0.0.0/29
-# Allows test cases to create/destroy tenants and users. This
-# option enables isolated test cases and better parallel
-# execution, but also requires that OpenStack Identity API
-# admin credentials are known. (boolean value)
-#allow_tenant_isolation=false
-
# Time in seconds between build status checks. (integer value)
#build_interval=1
@@ -1100,7 +1106,7 @@
# value)
#build_interval=1
-# Timeout in seconds to wait for a volume to becomeavailable.
+# Timeout in seconds to wait for a volume to become available.
# (integer value)
#build_timeout=300
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
index 90be820..8d6a7fc 100644
--- a/tempest/api/compute/admin/test_fixed_ips_negative.py
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -68,7 +68,10 @@
# NOTE(maurosr): since this exercises the same code snippet, we do it
# only for reserve action
body = {"reserve": "None"}
- self.assertRaises(exceptions.NotFound,
+ # NOTE(eliqiao): in Juno, the exception is NotFound, but in master, we
+ # change the error code to BadRequest, both exceptions should be
+ # accepted by tempest
+ self.assertRaises((exceptions.NotFound, exceptions.BadRequest),
self.client.reserve_fixed_ip,
"my.invalid.ip", body)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 6c93d33..6496176 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -44,9 +44,9 @@
# TODO(andreaf) WE should care also for the alt_manager here
# but only once client lazy load in the manager is done
- os = cls.get_client_manager()
+ cls.os = cls.get_client_manager()
+ cls.multi_user = cls.check_multi_user()
- cls.os = os
cls.build_interval = CONF.compute.build_interval
cls.build_timeout = CONF.compute.build_timeout
cls.ssh_user = CONF.compute.ssh_user
@@ -58,7 +58,6 @@
cls.image_ssh_password = CONF.compute.image_ssh_password
cls.servers = []
cls.images = []
- cls.multi_user = cls.get_multi_user()
cls.security_groups = []
cls.server_groups = []
@@ -118,27 +117,12 @@
raise exceptions.InvalidConfiguration(message=msg)
@classmethod
- def get_multi_user(cls):
- multi_user = True
- # Determine if there are two regular users that can be
- # used in testing. If the test cases are allowed to create
- # users (config.compute.allow_tenant_isolation is true,
- # then we allow multi-user.
- if not CONF.compute.allow_tenant_isolation:
- user1 = CONF.identity.username
- user2 = CONF.identity.alt_username
- if not user2 or user1 == user2:
- multi_user = False
- else:
- user2_password = CONF.identity.alt_password
- user2_tenant_name = CONF.identity.alt_tenant_name
- if not user2_password or not user2_tenant_name:
- msg = ("Alternate user specified but not alternate "
- "tenant or password: alt_tenant_name=%s "
- "alt_password=%s"
- % (user2_tenant_name, user2_password))
- raise exceptions.InvalidConfiguration(msg)
- return multi_user
+ def check_multi_user(cls):
+ # We have a list of accounts now, so just checking if the list is gt 2
+ if not cls.isolated_creds.is_multi_user():
+ msg = "Not enough users available for multi-user testing"
+ raise exceptions.InvalidConfiguration(msg)
+ return True
@classmethod
def clear_servers(cls):
@@ -390,19 +374,14 @@
@classmethod
def resource_setup(cls):
super(BaseComputeAdminTest, cls).resource_setup()
- if (CONF.compute.allow_tenant_isolation or
- cls.force_tenant_isolation is True):
+ try:
creds = cls.isolated_creds.get_admin_creds()
- cls.os_adm = clients.Manager(credentials=creds,
- interface=cls._interface)
- else:
- try:
- cls.os_adm = clients.ComputeAdminManager(
- interface=cls._interface)
- except exceptions.InvalidCredentials:
- msg = ("Missing Compute Admin API credentials "
- "in configuration.")
- raise cls.skipException(msg)
+ cls.os_adm = clients.Manager(
+ credentials=creds, interface=cls._interface)
+ except NotImplementedError:
+ msg = ("Missing Compute Admin API credentials in configuration.")
+ raise cls.skipException(msg)
+
if cls._api_version == 2:
cls.availability_zone_admin_client = (
cls.os_adm.availability_zone_client)
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index c0b6730..459d78b 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -105,7 +105,11 @@
raise self.skipException("Not testable in XML")
# prefix character is:
# http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
- utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
+
+ # We use a string with 3 byte utf-8 character due to bug
+ # #1370954 in glance which will 500 if mysql is used as the
+ # backend and it attempts to store a 4 byte utf-8 character
+ utf8_name = data_utils.rand_name('\xe2\x82\xa1')
resp, body = self.client.create_image(self.server_id, utf8_name)
image_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.client.delete_image, image_id)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 5df8d82..25dc87d 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -42,6 +42,7 @@
personality = [{'path': '/test.txt',
'contents': base64.b64encode(file_contents)}]
cls.client = cls.servers_client
+ cls.network_client = cls.os.network_client
cli_resp = cls.create_test_server(name=cls.name,
meta=cls.meta,
accessIPv4=cls.accessIPv4,
@@ -124,6 +125,40 @@
self.assertEqual(200, resp.status)
self.assertIn(server['id'], server_group['members'])
+ @testtools.skipUnless(CONF.service_available.neutron,
+ 'Neutron service must be available.')
+ def test_verify_multiple_nics_order(self):
+ # Verify that the networks order given at the server creation is
+ # preserved within the server.
+ name_net1 = data_utils.rand_name(self.__class__.__name__)
+ _, net1 = self.network_client.create_network(name=name_net1)
+ name_net2 = data_utils.rand_name(self.__class__.__name__)
+ _, net2 = self.network_client.create_network(name=name_net2)
+
+ _, subnet1 = self.network_client.create_subnet(
+ network_id=net1['network']['id'],
+ cidr='19.80.0.0/24',
+ ip_version=4)
+ _, subnet2 = self.network_client.create_subnet(
+ network_id=net2['network']['id'],
+ cidr='19.86.0.0/24',
+ ip_version=4)
+
+ networks = [{'uuid': net1['network']['id']},
+ {'uuid': net2['network']['id']}]
+
+ _, server_multi_nics = self.create_test_server(
+ networks=networks, wait_until='ACTIVE')
+
+ _, addresses = self.client.list_addresses(server_multi_nics['id'])
+
+ expected_addr = ['19.80.0.2', '19.86.0.2']
+
+ addr = [addresses[name_net1][0]['addr'],
+ addresses[name_net2][0]['addr']]
+
+ self.assertEqual(expected_addr, addr)
+
class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
disk_config = 'AUTO'
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 98fe387..e660f00 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -69,12 +69,12 @@
resp, cls.s3 = cls.create_test_server(name=cls.s3_name,
flavor=cls.flavor_ref_alt,
wait_until='ACTIVE')
- if (CONF.service_available.neutron and
- CONF.compute.allow_tenant_isolation):
- network = cls.isolated_creds.get_primary_network()
- cls.fixed_network_name = network['name']
- else:
- cls.fixed_network_name = CONF.compute.fixed_network_name
+
+ cls.fixed_network_name = CONF.compute.fixed_network_name
+ if CONF.service_available.neutron:
+ if hasattr(cls.isolated_creds, 'get_primary_network'):
+ network = cls.isolated_creds.get_primary_network()
+ cls.fixed_network_name = network['name']
@utils.skip_unless_attr('multiple_images', 'Only one image found')
@test.attr(type='gate')
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index b86ee06..0349260 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -45,10 +45,7 @@
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())
- else:
- cls.alt_os = clients.AltManager()
+ cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
cls.alt_client = cls.alt_os.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 015d9f5..175f008 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -45,12 +45,8 @@
cls.keypairs_client = cls.os.keypairs_client
cls.security_client = cls.os.security_groups_client
- if CONF.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- cls.alt_manager = clients.Manager(credentials=creds)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
+ creds = cls.isolated_creds.get_alt_creds()
+ cls.alt_manager = clients.Manager(credentials=creds)
cls.alt_client = cls.alt_manager.servers_client
cls.alt_images_client = cls.alt_manager.images_client
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 209d293..73844cf 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -70,12 +70,11 @@
flavor=cls.flavor_ref_alt,
wait_until='ACTIVE')
- if (CONF.service_available.neutron and
- CONF.compute.allow_tenant_isolation):
- network = cls.isolated_creds.get_primary_network()
- cls.fixed_network_name = network['name']
- else:
- cls.fixed_network_name = CONF.compute.fixed_network_name
+ cls.fixed_network_name = CONF.compute.fixed_network_name
+ if CONF.service_available.neutron:
+ if hasattr(cls.isolated_creds, 'get_primary_network'):
+ network = cls.isolated_creds.get_primary_network()
+ cls.fixed_network_name = network['name']
@utils.skip_unless_attr('multiple_images', 'Only one image found')
@test.attr(type='gate')
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 30ac0ac..4b1fe04 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -45,10 +45,7 @@
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())
- else:
- cls.alt_os = clients.AltManager()
+ cls.alt_os = clients.Manager(cls.isolated_creds.get_alt_creds())
cls.alt_client = cls.alt_os.servers_v3_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index a225f12..1e4973b 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -202,7 +202,7 @@
def _try_wrapper(func, item, **kwargs):
try:
if kwargs:
- func(item['id'], kwargs)
+ func(item['id'], **kwargs)
else:
func(item['id'])
except exceptions.NotFound:
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 08767e3..74baba6 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -41,10 +41,7 @@
if not CONF.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- if CONF.compute.allow_tenant_isolation:
- cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
- else:
- cls.os = clients.Manager()
+ cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
@classmethod
def resource_cleanup(cls):
@@ -91,10 +88,7 @@
@classmethod
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:
- cls.os_alt = clients.AltManager()
+ cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
cls.alt_img_cli = cls.os_alt.image_client
cls.alt_tenant_id = cls.alt_img_cli.tenant_id
@@ -126,11 +120,8 @@
@classmethod
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)
- else:
- cls.os_alt = clients.AltManager()
+ creds = cls.isolated_creds.get_alt_creds()
+ cls.os_alt = clients.Manager(creds)
cls.os_img_client = cls.os.image_client_v2
cls.alt_img_client = cls.os_alt.image_client_v2
cls.alt_tenant_id = cls.alt_img_client.tenant_id
diff --git a/tempest/api/messaging/test_queues.py b/tempest/api/messaging/test_queues.py
index ab099ff..8f9ac20 100644
--- a/tempest/api/messaging/test_queues.py
+++ b/tempest/api/messaging/test_queues.py
@@ -32,11 +32,10 @@
def test_create_queue(self):
# Create Queue
queue_name = data_utils.rand_name('test-')
- resp, body = self.create_queue(queue_name)
+ _, body = self.create_queue(queue_name)
self.addCleanup(self.client.delete_queue, queue_name)
- self.assertEqual('201', resp['status'])
self.assertEqual('', body)
@@ -57,30 +56,27 @@
def test_delete_queue(self):
# Delete Queue
queue_name = self.queues.pop()
- resp, body = self.delete_queue(queue_name)
- self.assertEqual('204', resp['status'])
+ _, body = self.delete_queue(queue_name)
self.assertEqual('', body)
@test.attr(type='smoke')
def test_check_queue_existence(self):
# Checking Queue Existence
for queue_name in self.queues:
- resp, body = self.check_queue_exists(queue_name)
- self.assertEqual('204', resp['status'])
+ _, body = self.check_queue_exists(queue_name)
self.assertEqual('', body)
@test.attr(type='smoke')
def test_check_queue_head(self):
# Checking Queue Existence by calling HEAD
for queue_name in self.queues:
- resp, body = self.check_queue_exists_head(queue_name)
- self.assertEqual('204', resp['status'])
+ _, body = self.check_queue_exists_head(queue_name)
self.assertEqual('', body)
@test.attr(type='smoke')
def test_list_queues(self):
# Listing queues
- resp, body = self.list_queues()
+ _, body = self.list_queues()
self.assertEqual(len(body['queues']), len(self.queues))
for item in body['queues']:
self.assertIn(item['name'], self.queues)
@@ -91,7 +87,7 @@
queue_name = self.queues[data_utils.rand_int_id(0,
len(self.queues) - 1)]
# Get Queue Stats for a newly created Queue
- resp, body = self.get_queue_stats(queue_name)
+ _, body = self.get_queue_stats(queue_name)
msgs = body['messages']
for element in ('free', 'claimed', 'total'):
self.assertEqual(0, msgs[element])
@@ -104,8 +100,7 @@
queue_name = self.queues[data_utils.rand_int_id(0,
len(self.queues) - 1)]
# Check the Queue has no metadata
- resp, body = self.get_queue_metadata(queue_name)
- self.assertEqual('200', resp['status'])
+ _, body = self.get_queue_metadata(queue_name)
self.assertThat(body, matchers.HasLength(0))
# Create metadata
key3 = [0, 1, 2, 3, 4]
@@ -116,12 +111,10 @@
req_body = dict()
req_body[data_utils.rand_name('key1')] = req_body1
# Set Queue Metadata
- resp, body = self.set_queue_metadata(queue_name, req_body)
- self.assertEqual('204', resp['status'])
+ _, body = self.set_queue_metadata(queue_name, req_body)
self.assertEqual('', body)
# Get Queue Metadata
- resp, body = self.get_queue_metadata(queue_name)
- self.assertEqual('200', resp['status'])
+ _, body = self.get_queue_metadata(queue_name)
self.assertThat(body, matchers.Equals(req_body))
@classmethod
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index d9b2848..91e3e14 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -366,19 +366,15 @@
@classmethod
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
- if not (admin_username and admin_password and admin_tenant):
+
+ try:
+ creds = cls.isolated_creds.get_admin_creds()
+ cls.os_adm = clients.Manager(
+ credentials=creds, interface=cls._interface)
+ except NotImplementedError:
msg = ("Missing Administrative Network API credentials "
"in configuration.")
raise cls.skipException(msg)
- if (CONF.compute.allow_tenant_isolation or
- cls.force_tenant_isolation is True):
- cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(),
- interface=cls._interface)
- else:
- cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)
cls.admin_client = cls.os_adm.network_client
@classmethod
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 11588d6..8e2b7f5 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -36,6 +36,8 @@
List firewall policies
Create firewall policy
Update firewall policy
+ Insert firewall rule to policy
+ Remove firewall rule from policy
Delete firewall policy
Show firewall policy
List firewall
@@ -62,6 +64,14 @@
except exceptions.NotFound:
pass
+ def _try_delete_rule(self, rule_id):
+ # delete rule, if it exists
+ try:
+ self.client.delete_firewall_rule(rule_id)
+ # if rule is not found, this means it was deleted in the test
+ except exceptions.NotFound:
+ pass
+
def _try_delete_firewall(self, fw_id):
# delete firewall, if it exists
try:
@@ -211,6 +221,40 @@
# Delete firewall
self.client.delete_firewall(firewall_id)
+ @test.attr(type='smoke')
+ def test_insert_remove_firewall_rule_from_policy(self):
+ # Create firewall rule
+ resp, body = self.client.create_firewall_rule(
+ name=data_utils.rand_name("fw-rule"),
+ action="allow",
+ protocol="tcp")
+ fw_rule_id = body['firewall_rule']['id']
+ self.addCleanup(self._try_delete_rule, fw_rule_id)
+ # Create firewall policy
+ _, body = self.client.create_firewall_policy(
+ name=data_utils.rand_name("fw-policy"))
+ fw_policy_id = body['firewall_policy']['id']
+ self.addCleanup(self._try_delete_policy, fw_policy_id)
+
+ # Insert rule to firewall policy
+ self.client.insert_firewall_rule_in_policy(
+ fw_policy_id, fw_rule_id, '', '')
+
+ # Verify insertion of rule in policy
+ self.assertIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+ # Remove rule from the firewall policy
+ self.client.remove_firewall_rule_from_policy(
+ fw_policy_id, fw_rule_id)
+
+ # Verify removal of rule from firewall policy
+ self.assertNotIn(fw_rule_id, self._get_list_fw_rule_ids(fw_policy_id))
+
+ def _get_list_fw_rule_ids(self, fw_policy_id):
+ _, fw_policy = self.client.show_firewall_policy(
+ fw_policy_id)
+ return [ruleid for ruleid in fw_policy['firewall_policy']
+ ['firewall_rules']]
+
class FWaaSExtensionTestXML(FWaaSExtensionTestJSON):
_interface = 'xml'
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index 6a5fd3d..2e39cf9 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -36,18 +36,12 @@
raise cls.skipException(skip_msg)
cls.isolated_creds = isolated_creds.IsolatedCreds(
cls.__name__, network_resources=cls.network_resources)
- if CONF.compute.allow_tenant_isolation:
- # Get isolated creds for normal user
- cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
- # Get isolated creds for admin user
- cls.os_admin = clients.Manager(
- cls.isolated_creds.get_admin_creds())
- # Get isolated creds for alt user
- cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
- else:
- cls.os = clients.Manager()
- cls.os_admin = clients.AdminManager()
- cls.os_alt = clients.AltManager()
+ # Get isolated creds for normal user
+ cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
+ # Get isolated creds for admin user
+ cls.os_admin = clients.Manager(cls.isolated_creds.get_admin_creds())
+ # Get isolated creds for alt user
+ cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
cls.object_client = cls.os.object_client
cls.container_client = cls.os.container_client
diff --git a/tempest/api/telemetry/test_telemetry_notification_api.py b/tempest/api/telemetry/test_telemetry_notification_api.py
index 3782b70..42e2a2d 100644
--- a/tempest/api/telemetry/test_telemetry_notification_api.py
+++ b/tempest/api/telemetry/test_telemetry_notification_api.py
@@ -32,7 +32,6 @@
@test.attr(type="gate")
@testtools.skipIf(not CONF.service_available.nova,
"Nova is not available.")
- @test.skip_because(bug="1336755")
def test_check_nova_notification(self):
resp, body = self.create_server()
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 7e24fa4..ece4299 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -71,7 +71,8 @@
@test.attr(type='gate')
def test_show_quota_usage(self):
- _, quota_usage = self.quotas_client.get_quota_usage(self.adm_tenant)
+ _, quota_usage = self.quotas_client.get_quota_usage(
+ self.os_adm.credentials.tenant_name)
for key in QUOTA_KEYS:
self.assertIn(key, quota_usage)
for usage_key in QUOTA_USAGE_KEYS:
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 7f5361d..78fd61d 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -154,19 +154,14 @@
@classmethod
def resource_setup(cls):
super(BaseVolumeAdminTest, cls).resource_setup()
- cls.adm_user = CONF.identity.admin_username
- cls.adm_pass = CONF.identity.admin_password
- cls.adm_tenant = CONF.identity.admin_tenant_name
- if not all((cls.adm_user, cls.adm_pass, cls.adm_tenant)):
- 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)
+ try:
+ cls.adm_creds = cls.isolated_creds.get_admin_creds()
+ cls.os_adm = clients.Manager(
+ credentials=cls.adm_creds, interface=cls._interface)
+ except NotImplementedError:
+ msg = "Missing Volume Admin API credentials in configuration."
+ raise cls.skipException(msg)
cls.qos_specs = []
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index 90ac9c1..fe217c1 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -30,15 +30,16 @@
super(VolumesV2TransfersTest, cls).resource_setup()
# Add another tenant to test volume-transfer
- if CONF.compute.allow_tenant_isolation:
- cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds(),
- interface=cls._interface)
- # Add admin tenant to cleanup resources
- cls.os_adm = clients.Manager(cls.isolated_creds.get_admin_creds(),
- interface=cls._interface)
- else:
- cls.os_alt = clients.AltManager()
- cls.os_adm = clients.ComputeAdminManager(interface=cls._interface)
+ cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds(),
+ interface=cls._interface)
+ # Add admin tenant to cleanup resources
+ try:
+ creds = cls.isolated_creds.get_admin_creds()
+ cls.os_adm = clients.Manager(
+ credentials=creds, interface=cls._interface)
+ except NotImplementedError:
+ msg = "Missing Volume Admin API credentials in configuration."
+ raise cls.skipException(msg)
cls.client = cls.volumes_client
cls.alt_client = cls.os_alt.volumes_client
diff --git a/tempest/api_schema/response/messaging/v1/queues.py b/tempest/api_schema/response/messaging/v1/queues.py
index f0b2691..09e0147 100644
--- a/tempest/api_schema/response/messaging/v1/queues.py
+++ b/tempest/api_schema/response/messaging/v1/queues.py
@@ -105,7 +105,9 @@
resource_schema = {
'type': 'array',
- 'items': 'string',
+ 'items': {
+ 'type': 'string'
+ },
'minItems': 1
}
diff --git a/tempest/cmd/cleanup.py b/tempest/cmd/cleanup.py
index 9ae3dfb..a305e42 100644
--- a/tempest/cmd/cleanup.py
+++ b/tempest/cmd/cleanup.py
@@ -12,7 +12,6 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-# @author: David Paterson
"""
Utility for cleaning up environment after Tempest run
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index f5f0db3..0d3c6c6 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -13,11 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-'''
-Created on Sep 3, 2014
-@author: David_Paterson
-'''
from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 3c41dd9..0adc7e0 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -20,6 +20,7 @@
"""
import argparse
+import collections
import datetime
import os
import sys
@@ -43,7 +44,7 @@
OPTS = {}
USERS = {}
-RES = {}
+RES = collections.defaultdict(list)
LOG = None
@@ -282,6 +283,8 @@
If in check mode confirm that the oldest sample available is from
before the upgrade.
"""
+ if not self.res.get('telemetry'):
+ return
LOG.info("checking telemetry")
for server in self.res['servers']:
client = client_for_user(server['owner'])
@@ -508,6 +511,9 @@
def create_volumes(volumes):
+ if not volumes:
+ return
+ LOG.info("Creating volumes")
for volume in volumes:
client = client_for_user(volume['owner'])
@@ -630,7 +636,7 @@
global RES
get_options()
setup_logging()
- RES = load_resources(OPTS.resources)
+ RES.update(load_resources(OPTS.resources))
if OPTS.mode == 'create':
create_resources()
diff --git a/tempest/cmd/resources.yaml b/tempest/cmd/resources.yaml
index 19ee6d5..2d5e686 100644
--- a/tempest/cmd/resources.yaml
+++ b/tempest/cmd/resources.yaml
@@ -57,3 +57,4 @@
name: javelin1
owner: javelin
file: /etc/hosts
+telemetry: true
diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py
index 5046bff..f426e4d 100755
--- a/tempest/cmd/verify_tempest_config.py
+++ b/tempest/cmd/verify_tempest_config.py
@@ -122,6 +122,18 @@
not CONF.volume_feature_enabled.api_v2, update)
+def verify_api_versions(os, service, update):
+ verify = {
+ 'cinder': verify_cinder_api_versions,
+ 'glance': verify_glance_api_versions,
+ 'keystone': verify_keystone_api_versions,
+ 'nova': verify_nova_api_versions,
+ }
+ if service not in verify:
+ return
+ verify[service](os, update)
+
+
def get_extension_client(os, service):
extensions_client = {
'nova': os.extensions_client,
@@ -337,10 +349,13 @@
elif service not in services:
continue
results = verify_extensions(os, service, results)
- verify_keystone_api_versions(os, update)
- verify_glance_api_versions(os, update)
- verify_nova_api_versions(os, update)
- verify_cinder_api_versions(os, update)
+
+ # Verify API verisons of all services in the keystone catalog and keystone
+ # itself.
+ services.append('keystone')
+ for service in services:
+ verify_api_versions(os, service, update)
+
display_results(results, update, replace)
if update:
conf_file.close()
diff --git a/tempest/common/accounts.py b/tempest/common/accounts.py
index 7423c17..88e8ced 100644
--- a/tempest/common/accounts.py
+++ b/tempest/common/accounts.py
@@ -58,7 +58,12 @@
return hash_dict
def is_multi_user(self):
- return len(self.hash_dict) > 1
+ # Default credentials is not a valid option with locking Account
+ if self.use_default_creds:
+ raise exceptions.InvalidConfiguration(
+ "Account file %s doesn't exist" % CONF.auth.test_accounts_file)
+ else:
+ return len(self.hash_dict) > 1
def _create_hash_file(self, hash_string):
path = os.path.join(os.path.join(self.accounts_dir, hash_string))
@@ -144,6 +149,21 @@
to preserve the current behaviour of the serial tempest run.
"""
+ def is_multi_user(self):
+ if self.use_default_creds:
+ # Verify that the configured users are valid and distinct
+ try:
+ user = self.get_primary_creds()
+ alt_user = self.get_alt_creds()
+ return user.username != alt_user.username
+ except exceptions.InvalidCredentials as ic:
+ msg = "At least one of the configured credentials is " \
+ "not valid: %s" % ic.message
+ raise exceptions.InvalidConfiguration(msg)
+ else:
+ # TODO(andreaf) Add a uniqueness check here
+ return len(self.hash_dict) > 1
+
def get_creds(self, id):
try:
# No need to sort the dict as within the same python process
diff --git a/tempest/common/cred_provider.py b/tempest/common/cred_provider.py
index 56d34a5..b09c964 100644
--- a/tempest/common/cred_provider.py
+++ b/tempest/common/cred_provider.py
@@ -1,4 +1,5 @@
-# (c) 2014 Deutsche Telekom AG
+# Copyright (c) 2014 Deutsche Telekom AG
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -43,3 +44,7 @@
@abc.abstractmethod
def clear_isolated_creds(self):
return
+
+ @abc.abstractmethod
+ def is_multi_user(self):
+ return
diff --git a/tempest/common/credentials.py b/tempest/common/credentials.py
new file mode 100644
index 0000000..08b592f
--- /dev/null
+++ b/tempest/common/credentials.py
@@ -0,0 +1,39 @@
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from tempest.common import accounts
+from tempest.common import isolated_creds
+from tempest import config
+
+CONF = config.CONF
+
+
+# Return the right implementation of CredentialProvider based on config
+# Dropping interface and password, as they are never used anyways
+# TODO(andreaf) Drop them from the CredentialsProvider interface completely
+def get_isolated_credentials(name, network_resources=None,
+ force_tenant_isolation=False):
+ # If a test requires a new account to work, it can have it via forcing
+ # tenant isolation. A new account will be produced only for that test.
+ # In case admin credentials are not available for the account creation,
+ # the test should be skipped else it would fail.
+ if CONF.auth.allow_tenant_isolation or force_tenant_isolation:
+ return isolated_creds.IsolatedCreds(
+ name=name,
+ network_resources=network_resources)
+ else:
+ if CONF.auth.locking_credentials_provider:
+ # Most params are not relevant for pre-created accounts
+ return accounts.Accounts(name=name)
+ else:
+ return accounts.NotLockingAccounts(name=name)
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index b2edfee..2d16107 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -351,3 +351,6 @@
except exceptions.NotFound:
LOG.warn("tenant with name: %s not found for delete" %
creds.tenant_name)
+
+ def is_multi_user(self):
+ return True
diff --git a/tempest/config.py b/tempest/config.py
index 174a895..6a41f24 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -38,9 +38,28 @@
default='etc/accounts.yaml',
help="Path to the yaml file that contains the list of "
"credentials to use for running tests"),
+ cfg.BoolOpt('allow_tenant_isolation',
+ default=False,
+ help="Allows test cases to create/destroy tenants and "
+ "users. This option requires that OpenStack Identity "
+ "API admin credentials are known. If false, isolated "
+ "test cases and parallel execution, can still be "
+ "achieved configuring a list of test accounts",
+ deprecated_opts=[cfg.DeprecatedOpt('allow_tenant_isolation',
+ group='compute'),
+ cfg.DeprecatedOpt('allow_tenant_isolation',
+ group='orchestration')]),
+ cfg.BoolOpt('locking_credentials_provider',
+ default=False,
+ help="If set to True it enables the Accounts provider, "
+ "which locks credentials to allow for parallel execution "
+ "with pre-provisioned accounts. It can only be used to "
+ "run tests that ensure credentials cleanup happens. "
+ "It requires at least `2 * CONC` distinct accounts "
+ "configured in `test_accounts_file`, with CONC == the "
+ "number of concurrent test processes."),
]
-
identity_group = cfg.OptGroup(name='identity',
title="Keystone Configuration Options")
@@ -129,12 +148,6 @@
title='Compute Service Options')
ComputeGroup = [
- cfg.BoolOpt('allow_tenant_isolation',
- default=False,
- help="Allows test cases to create/destroy tenants and "
- "users. This option enables isolated test cases and "
- "better parallel execution, but also requires that "
- "OpenStack Identity API admin credentials are known."),
cfg.StrOpt('image_ref',
help="Valid primary image reference to be used in tests. "
"This is a required option"),
@@ -514,7 +527,7 @@
help='Time in seconds between volume availability checks.'),
cfg.IntOpt('build_timeout',
default=300,
- help='Timeout in seconds to wait for a volume to become'
+ help='Timeout in seconds to wait for a volume to become '
'available.'),
cfg.StrOpt('catalog_type',
default='volume',
@@ -666,12 +679,6 @@
choices=['public', 'admin', 'internal',
'publicURL', 'adminURL', 'internalURL'],
help="The endpoint type to use for the orchestration service."),
- cfg.BoolOpt('allow_tenant_isolation',
- default=False,
- help="Allows test cases to create/destroy tenants and "
- "users. This option enables isolated test cases and "
- "better parallel execution, but also requires that "
- "OpenStack Identity API admin credentials are known."),
cfg.IntOpt('build_interval',
default=1,
help="Time in seconds between build status checks."),
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 79207cd..383a28d 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -23,8 +23,8 @@
from tempest import auth
from tempest import clients
+from tempest.common import credentials
from tempest.common import debug
-from tempest.common import isolated_creds
from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client
from tempest import config
@@ -51,8 +51,9 @@
@classmethod
def resource_setup(cls):
super(ScenarioTest, cls).resource_setup()
- # Using tempest client for isolated credentials as well
- cls.isolated_creds = isolated_creds.IsolatedCreds(
+ # TODO(andreaf) Some of the code from this resource_setup could be
+ # moved into `BaseTestCase`
+ cls.isolated_creds = credentials.get_isolated_credentials(
cls.__name__, network_resources=cls.network_resources)
cls.manager = clients.Manager(
credentials=cls.credentials()
@@ -79,27 +80,19 @@
cls.orchestration_client = cls.manager.orchestration_client
@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')
+ return cls.isolated_creds.get_primary_creds()
@classmethod
def alt_credentials(cls):
- return cls._get_credentials(cls.isolated_creds.get_alt_creds,
- 'alt_user')
+ return cls.isolated_creds.get_alt_creds()
@classmethod
def admin_credentials(cls):
- return cls._get_credentials(cls.isolated_creds.get_admin_creds,
- 'identity_admin')
+ try:
+ return cls.isolated_creds.get_admin_creds()
+ except NotImplementedError:
+ raise cls.skipException('Admin Credentials are not available')
# ## Methods to handle sync and async deletes
@@ -386,6 +379,12 @@
LOG.debug(self.servers_client.get_console_output(server['id'],
length=None))
+ def _log_net_info(self, exc):
+ # network debug is called as part of ssh init
+ if not isinstance(exc, exceptions.SSHTimeout):
+ LOG.debug('Network information on a devstack host')
+ debug.log_net_debug()
+
def create_server_snapshot(self, server, name=None):
# Glance client
_image_client = self.image_client
@@ -443,7 +442,9 @@
if wait:
self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
- def ping_ip_address(self, ip_address, should_succeed=True):
+ def ping_ip_address(self, ip_address, should_succeed=True,
+ ping_timeout=None):
+ timeout = ping_timeout or CONF.compute.ping_timeout
cmd = ['ping', '-c1', '-w1', ip_address]
def ping():
@@ -453,8 +454,7 @@
proc.communicate()
return (proc.returncode == 0) == should_succeed
- return tempest.test.call_until_true(
- ping, CONF.compute.ping_timeout, 1)
+ return tempest.test.call_until_true(ping, timeout, 1)
class NetworkScenarioTest(ScenarioTest):
@@ -622,6 +622,23 @@
self.assertIsNone(floating_ip.port_id)
return floating_ip
+ def check_floating_ip_status(self, floating_ip, status):
+ """Verifies floatingip has reached given status. without waiting
+
+ :param floating_ip: net_resources.DeletableFloatingIp floating IP to
+ to check status
+ :param status: target status
+ :raises: AssertionError if status doesn't match
+ """
+ floating_ip.refresh()
+ self.assertEqual(status, floating_ip.status,
+ message="FloatingIP: {fp} is at status: {cst}. "
+ "failed to reach status: {st}"
+ .format(fp=floating_ip, cst=floating_ip.status,
+ st=status))
+ LOG.info("FloatingIP: {fp} is at status: {st}"
+ .format(fp=floating_ip, st=status))
+
def _check_vm_connectivity(self, ip_address,
username=None,
private_key=None,
@@ -666,9 +683,7 @@
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()
+ self._log_net_info(e)
raise
def _check_tenant_network_connectivity(self, server,
@@ -692,9 +707,7 @@
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()
+ self._log_net_info(e)
raise
def _check_remote_connectivity(self, source, dest, should_succeed=True):
@@ -924,8 +937,8 @@
router_id = CONF.network.public_router_id
network_id = CONF.network.public_network_id
if router_id:
- result = client.show_router(router_id)
- return net_resources.AttributeDict(**result['router'])
+ resp, body = client.show_router(router_id)
+ return net_resources.AttributeDict(**body['router'])
elif network_id:
router = self._create_router(client, tenant_id)
router.set_gateway(network_id)
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index abda1f8..791c564 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -24,7 +24,6 @@
class CfnInitScenarioTest(manager.OrchestrationScenarioTest):
- @test.skip_because(bug="1374175")
def setUp(self):
super(CfnInitScenarioTest, self).setUp()
if not CONF.orchestration.image_ref:
@@ -84,7 +83,8 @@
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, ping_timeout=CONF.orchestration.build_timeout):
self._log_console_output(servers=[server])
self.fail(
"(CfnInitScenarioTest:test_server_cfn_init) Timed out waiting "
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 58a028f..0c48334 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -87,6 +87,7 @@
self._check_public_network_connectivity(floating_ip, username,
private_key, should_connect,
servers=[self.server])
+ self.check_floating_ip_status(self.floating_ip, 'ACTIVE')
def _wait_server_status_and_check_network_connectivity(self):
self.servers_client.wait_for_server_status(self.server['id'], 'ACTIVE')
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index de60745..5d75b64 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -176,16 +176,31 @@
def _check_public_network_connectivity(self, should_connect=True,
msg=None):
+ """Verifies connectivty to a VM via public network and floating IP,
+ and verifies floating IP has resource status is correct.
+
+ Floating IP status is verified after connectivity test in order to
+ not add extra waiting and mask racing conditions.
+
+ :param should_connect: bool. determines if connectivity check is
+ negative or positive.
+ :param msg: Failure message to add to Error message. Should describe
+ the place in the test scenario where the method was called,
+ to indicate the context of the failure
+ """
ssh_login = CONF.compute.image_ssh_user
floating_ip, server = self.floating_ip_tuple
ip_address = floating_ip.floating_ip_address
private_key = None
+ floatingip_status = 'DOWN'
if should_connect:
private_key = self._get_server_key(server)
+ floatingip_status = 'ACTIVE'
# call the common method in the parent class
super(TestNetworkBasicOps, self)._check_public_network_connectivity(
ip_address, ssh_login, private_key, should_connect, msg,
self.servers)
+ self.check_floating_ip_status(floating_ip, floatingip_status)
def _disassociate_floating_ips(self):
floating_ip, server = self.floating_ip_tuple
@@ -350,6 +365,8 @@
VMs are created with unique keypair so connectivity also asserts that
floating IP is associated with the new VM instead of the old one
+ Verifies that floating IP status is updated correctly after each change
+
"""
self._setup_network_and_servers()
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 188dea8..6c36034 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -241,7 +241,11 @@
'security_groups': security_groups,
'tenant_id': tenant.creds.tenant_id
}
- return self.create_server(name=name, create_kwargs=create_kwargs)
+ server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.assertEqual(
+ sorted([s['name'] for s in security_groups]),
+ sorted([s['name'] for s in server['security_groups']]))
+ return server
def _create_tenant_servers(self, tenant, num=1):
for i in range(num):
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 156d889..06f1b83 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -349,8 +349,11 @@
networks = xml_utils.Element("networks")
server.append(networks)
for network in kwargs['networks']:
- s = xml_utils.Element("network", uuid=network['uuid'],
- fixed_ip=network['fixed_ip'])
+ if 'fixed_ip' in network:
+ s = xml_utils.Element("network", uuid=network['uuid'],
+ fixed_ip=network['fixed_ip'])
+ else:
+ s = xml_utils.Element("network", uuid=network['uuid'])
networks.append(s)
if 'meta' in kwargs:
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index df424ca..5ad416c 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -31,14 +31,11 @@
self.endpoint_url = 'adminURL'
self.api_version = "v3"
- def create_user(self, user_name, **kwargs):
+ def create_user(self, user_name, password=None, project_id=None,
+ email=None, domain_id='default', **kwargs):
"""Creates a user."""
- password = kwargs.get('password', None)
- email = kwargs.get('email', None)
en = kwargs.get('enabled', True)
- project_id = kwargs.get('project_id', None)
description = kwargs.get('description', None)
- domain_id = kwargs.get('domain_id', 'default')
post_body = {
'project_id': project_id,
'description': description,
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index 5c43692..fdc0a0a 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -95,14 +95,11 @@
_json = common.xml_to_json(body)
return _json
- def create_user(self, user_name, **kwargs):
+ def create_user(self, user_name, password=None, project_id=None,
+ email=None, domain_id='default', **kwargs):
"""Creates a user."""
- password = kwargs.get('password', None)
- email = kwargs.get('email', None)
en = kwargs.get('enabled', 'true')
- project_id = kwargs.get('project_id', None)
description = kwargs.get('description', None)
- domain_id = kwargs.get('domain_id', 'default')
post_body = common.Element("user",
xmlns=XMLNS,
name=user_name,
diff --git a/tempest/services/messaging/json/messaging_client.py b/tempest/services/messaging/json/messaging_client.py
index 3e82399..2794ea9 100644
--- a/tempest/services/messaging/json/messaging_client.py
+++ b/tempest/services/messaging/json/messaging_client.py
@@ -48,22 +48,26 @@
def create_queue(self, queue_name):
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
resp, body = self.put(uri, body=None)
+ self.expected_success(201, resp.status)
return resp, body
def get_queue(self, queue_name):
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
resp, body = self.get(uri)
+ self.expected_success(204, resp.status)
return resp, body
def head_queue(self, queue_name):
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
resp, body = self.head(uri)
+ self.expected_success(204, resp.status)
return resp, body
def delete_queue(self, queue_name):
uri = '{0}/queues/{1}'.format(self.uri_prefix, queue_name)
- resp = self.delete(uri)
- return resp
+ resp, body = self.delete(uri)
+ self.expected_success(204, resp.status)
+ return resp, body
def get_queue_stats(self, queue_name):
uri = '{0}/queues/{1}/stats'.format(self.uri_prefix, queue_name)
@@ -75,12 +79,14 @@
def get_queue_metadata(self, queue_name):
uri = '{0}/queues/{1}/metadata'.format(self.uri_prefix, queue_name)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
def set_queue_metadata(self, queue_name, rbody):
uri = '{0}/queues/{1}/metadata'.format(self.uri_prefix, queue_name)
resp, body = self.put(uri, body=json.dumps(rbody))
+ self.expected_success(204, resp.status)
return resp, body
def post_messages(self, queue_name, rbody):
@@ -90,6 +96,7 @@
headers=self.headers)
body = json.loads(body)
+ self.validate_response(queues_schema.post_messages, resp, body)
return resp, body
def list_messages(self, queue_name):
@@ -126,7 +133,7 @@
def delete_messages(self, message_uri):
resp, body = self.delete(message_uri)
- assert(resp['status'] == '204')
+ self.expected_success(204, resp.status)
return resp, body
def post_claims(self, queue_name, rbody, url_params=False):
@@ -152,10 +159,10 @@
def update_claim(self, claim_uri, rbody):
resp, body = self.patch(claim_uri, body=json.dumps(rbody))
- assert(resp['status'] == '204')
+ self.expected_success(204, resp.status)
return resp, body
def release_claim(self, claim_uri):
resp, body = self.delete(claim_uri)
- assert(resp['status'] == '204')
+ self.expected_success(204, resp.status)
return resp, body
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 16a4f5c..78ed56f 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -320,3 +320,30 @@
self.rest_client.expected_success(201, resp.status)
body = json.loads(body)
return resp, body
+
+ def insert_firewall_rule_in_policy(self, firewall_policy_id,
+ firewall_rule_id, insert_after="",
+ insert_before=""):
+ uri = '%s/fw/firewall_policies/%s/insert_rule' % (self.uri_prefix,
+ firewall_policy_id)
+ body = {
+ "firewall_rule_id": firewall_rule_id,
+ "insert_after": insert_after,
+ "insert_before": insert_before
+ }
+ body = json.dumps(body)
+ resp, body = self.put(uri, body)
+ self.rest_client.expected_success(200, resp.status)
+ body = json.loads(body)
+ return resp, body
+
+ def remove_firewall_rule_from_policy(self, firewall_policy_id,
+ firewall_rule_id):
+ uri = '%s/fw/firewall_policies/%s/remove_rule' % (self.uri_prefix,
+ firewall_policy_id)
+ update_body = {"firewall_rule_id": firewall_rule_id}
+ update_body = json.dumps(update_body)
+ resp, body = self.put(uri, update_body)
+ self.rest_client.expected_success(200, resp.status)
+ body = json.loads(body)
+ return resp, body
diff --git a/tempest/services/network/resources.py b/tempest/services/network/resources.py
index 2b182d0..a84b4d5 100644
--- a/tempest/services/network/resources.py
+++ b/tempest/services/network/resources.py
@@ -52,7 +52,7 @@
return
@abc.abstractmethod
- def show(self):
+ def refresh(self):
return
def __hash__(self):
@@ -62,7 +62,11 @@
if not hasattr(self, 'status'):
return
- return self.client.wait_for_resource_status(self.show, status)
+ def helper_get():
+ self.refresh()
+ return self
+
+ return self.client.wait_for_resource_status(helper_get, status)
class DeletableNetwork(DeletableResource):
@@ -116,6 +120,12 @@
class DeletableFloatingIp(DeletableResource):
+ def refresh(self, *args, **kwargs):
+ _, result = self.client.show_floatingip(self.id,
+ *args,
+ **kwargs)
+ super(DeletableFloatingIp, self).update(**result['floatingip'])
+
def update(self, *args, **kwargs):
_, result = self.client.update_floatingip(self.id,
*args,
@@ -172,7 +182,6 @@
def delete(self):
self.client.delete_vip(self.id)
- def show(self):
+ def refresh(self):
_, result = self.client.show_vip(self.id)
- super(DeletableVip, self).update(**result['vip'])
- return self
+ super(DeletableVip, self).update(**result['vip'])
\ No newline at end of file
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index 17b1f8e..c65390e 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -25,7 +25,8 @@
# list of plurals used for xml serialization
PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
'fixed_ips', 'extensions', 'extra_dhcp_opts', 'pools',
- 'health_monitors', 'vips', 'members', 'allowed_address_pairs']
+ 'health_monitors', 'vips', 'members', 'allowed_address_pairs',
+ 'firewall_rules']
def get_rest_client(self, auth_provider):
rc = rest_client.RestClient(auth_provider)
@@ -281,6 +282,27 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
+ def insert_firewall_rule_in_policy(self, firewall_policy_id,
+ firewall_rule_id, insert_after="",
+ insert_before=""):
+ uri = '%s/fw/firewall_policies/%s/insert_rule' % (self.uri_prefix,
+ firewall_policy_id)
+ rule = common.Element("firewall_rule_id", firewall_rule_id)
+ resp, body = self.put(uri, str(common.Document(rule)))
+ self.rest_client.expected_success(200, resp.status)
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
+
+ def remove_firewall_rule_from_policy(self, firewall_policy_id,
+ firewall_rule_id):
+ uri = '%s/fw/firewall_policies/%s/remove_rule' % (self.uri_prefix,
+ firewall_policy_id)
+ rule = common.Element("firewall_rule_id", firewall_rule_id)
+ resp, body = self.put(uri, str(common.Document(rule)))
+ self.rest_client.expected_success(200, resp.status)
+ 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)
diff --git a/tempest/test.py b/tempest/test.py
index 2ed6665..1c6265d 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -29,8 +29,8 @@
import testtools
from tempest import clients
+from tempest.common import credentials
import tempest.common.generator.valid_generator as valid
-from tempest.common import isolated_creds
from tempest import config
from tempest import exceptions
from tempest.openstack.common import importutils
@@ -270,7 +270,14 @@
try:
cls.tearDownClass()
except Exception as te:
- LOG.exception("tearDownClass failed: %s" % te)
+ tetype, _, _ = sys.exc_info()
+ # TODO(gmann): Till we split-up resource_setup &
+ # resource_cleanup in more structural way, log
+ # AttributeError as info instead of exception.
+ if tetype is AttributeError:
+ LOG.info("tearDownClass failed: %s" % te)
+ else:
+ LOG.exception("tearDownClass failed: %s" % te)
try:
raise etype(value), None, trace
finally:
@@ -333,31 +340,20 @@
"""
Returns an OpenStack client manager
"""
- cls.isolated_creds = isolated_creds.IsolatedCreds(
- cls.__name__, network_resources=cls.network_resources)
-
force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
- if CONF.compute.allow_tenant_isolation or force_tenant_isolation:
- creds = cls.isolated_creds.get_primary_creds()
- if getattr(cls, '_interface', None):
- os = clients.Manager(credentials=creds,
- interface=cls._interface,
- service=cls._service)
- elif interface:
- os = clients.Manager(credentials=creds,
- interface=interface,
- service=cls._service)
- else:
- os = clients.Manager(credentials=creds,
- service=cls._service)
- else:
- if getattr(cls, '_interface', None):
- os = clients.Manager(interface=cls._interface,
- service=cls._service)
- elif interface:
- os = clients.Manager(interface=interface, service=cls._service)
- else:
- os = clients.Manager(service=cls._service)
+
+ cls.isolated_creds = credentials.get_isolated_credentials(
+ name=cls.__name__, network_resources=cls.network_resources,
+ force_tenant_isolation=force_tenant_isolation,
+ )
+
+ creds = cls.isolated_creds.get_primary_creds()
+ params = dict(credentials=creds, service=cls._service)
+ if getattr(cls, '_interface', None):
+ interface = cls._interface
+ if interface:
+ params['interface'] = interface
+ os = clients.Manager(**params)
return os
@classmethod
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index a28684e..6679c79 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -86,6 +86,24 @@
self.assertIn('v2.0', versions)
self.assertIn('v3.0', versions)
+ def test_verify_api_versions(self):
+ api_services = ['cinder', 'glance', 'keystone', 'nova']
+ fake_os = mock.MagicMock()
+ for svc in api_services:
+ m = 'verify_%s_api_versions' % svc
+ with mock.patch.object(verify_tempest_config, m) as verify_mock:
+ verify_tempest_config.verify_api_versions(fake_os, svc, True)
+ verify_mock.assert_called_once_with(fake_os, True)
+
+ def test_verify_api_versions_not_implemented(self):
+ api_services = ['cinder', 'glance', 'keystone', 'nova']
+ fake_os = mock.MagicMock()
+ for svc in api_services:
+ m = 'verify_%s_api_versions' % svc
+ with mock.patch.object(verify_tempest_config, m) as verify_mock:
+ verify_tempest_config.verify_api_versions(fake_os, 'foo', True)
+ self.assertFalse(verify_mock.called)
+
def test_verify_keystone_api_versions_no_v3(self):
self.useFixture(mockpatch.PatchObject(
verify_tempest_config, '_get_unversioned_endpoint',
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 3496dce..62073bd 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -498,7 +498,10 @@
def _volume_state():
volume.update(validate=True)
try:
- if volume.status != "available":
+ # NOTE(gmann): Make sure volume is attached.
+ # Checking status as 'not "available"' is not enough to make
+ # sure volume is attached as it can be in "error" state
+ if volume.status == "in-use":
volume.detach(force=True)
except BaseException:
LOG.exception("Failed to detach volume %s" % volume)