Merge "Fix pygments style"
diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst
index 36828e0..c43e420 100644
--- a/doc/source/configuration.rst
+++ b/doc/source/configuration.rst
@@ -193,10 +193,6 @@
There are also options in the ``scenario`` section for images:
#. ``img_file``
-#. ``img_dir``
-#. ``aki_img_file``
-#. ``ari_img_file``
-#. ``ami_img_file``
#. ``img_container_format``
#. ``img_disk_format``
@@ -205,13 +201,9 @@
Tempest where an image file is located and describe its metadata for when it is
uploaded.
-The behavior of these options is a bit convoluted (which will likely be fixed in
-future versions). You first need to specify ``img_dir``, which is the directory
-in which Tempest will look for the image files. First, it will check if the
-filename set for ``img_file`` could be found in ``img_dir``. If it is found then
-the ``img_container_format`` and ``img_disk_format`` options are used to upload
-that image to glance. However, if it is not found, Tempest will look for the
-three uec image file name options as a fallback. If neither is found, the tests
+You first need to specify full path of the image using ``img_file`` option.
+If it is found then the ``img_container_format`` and ``img_disk_format``
+options are used to upload that image to glance. If it's not found, the tests
requiring an image to upload will fail.
It is worth pointing out that using `cirros`_ is a very good choice for running
diff --git a/doc/source/sampleconf.rst b/doc/source/sampleconf.rst
index c290140..45164a3 100644
--- a/doc/source/sampleconf.rst
+++ b/doc/source/sampleconf.rst
@@ -10,4 +10,6 @@
The sample configuration can also be viewed in `file form <_static/tempest.conf.sample>`_.
-.. literalinclude:: _static/tempest.conf.sample
+.. only:: html
+
+ .. literalinclude:: _static/tempest.conf.sample
diff --git a/releasenotes/notes/Remove-deprecated-image-scenario-options-b573c60e873ab451.yaml b/releasenotes/notes/Remove-deprecated-image-scenario-options-b573c60e873ab451.yaml
new file mode 100644
index 0000000..018d01d
--- /dev/null
+++ b/releasenotes/notes/Remove-deprecated-image-scenario-options-b573c60e873ab451.yaml
@@ -0,0 +1,15 @@
+---
+upgrade:
+ - |
+ The following deprecated image scenario options are removed after a ~4
+ year deprecation period.
+
+ * ``ami_img_file``
+ * ``ari_img_file``
+ * ``aki_img_file``
+
+ Starting Tempest 25.0.0 release, CONF.scenario.img_file need a full path
+ for the image. CONF.scenario.img_dir was deprecated and will be removed
+ in the next release. Till Tempest 25.0.0, old behavior is maintained and
+ keep working but starting Tempest 26.0.0, you need to specify the full path
+ in CONF.scenario.img_file config option.
diff --git a/releasenotes/notes/network-swap-to-project_id-a1d7fdf6c5e1cf44.yaml b/releasenotes/notes/network-swap-to-project_id-a1d7fdf6c5e1cf44.yaml
new file mode 100644
index 0000000..4cf0c76
--- /dev/null
+++ b/releasenotes/notes/network-swap-to-project_id-a1d7fdf6c5e1cf44.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - |
+ [`blueprint blueprint adopt-oslo-versioned-objects-for-db <https://blueprints.launchpad.net/neutron/+spec/adopt-oslo-versioned-objects-for-db>`_]
+ Any reference to "tenant_id" in Network objects is replaced with
+ "project_id".
diff --git a/requirements.txt b/requirements.txt
index bf38fae..d8738f0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
cliff!=2.9.0,>=2.8.0 # Apache-2.0
-jsonschema>=2.6.0 # MIT
+jsonschema>=3.2.0 # MIT
testtools>=2.2.0 # MIT
paramiko>=2.0.0 # LGPLv2.1+
netaddr>=0.7.18 # BSD
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index 033caa8..a4d7d3f 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -43,6 +43,9 @@
Expect all services to be returned when the request contains invalid
parameters.
"""
+ if not self.is_requested_microversion_compatible('2.74'):
+ raise self.skipException(
+ "From microversion 2.75 invalid parameters are not allowed.")
services = self.client.list_services()['services']
services_xxx = (self.client.list_services(xxx='nova-compute')
['services'])
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index adc4dda..7d41019 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -93,7 +93,7 @@
# Creates a floating IP
body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
- tenant_id=self.network['tenant_id'],
+ project_id=self.network['project_id'],
port_id=self.port['id'])
created_floating_ip = body['floatingip']
self.addCleanup(
@@ -101,7 +101,7 @@
self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
- self.assertIsNotNone(created_floating_ip['tenant_id'])
+ self.assertIsNotNone(created_floating_ip['project_id'])
self.assertIsNotNone(created_floating_ip['floating_ip_address'])
self.assertEqual(created_floating_ip['port_id'], self.port['id'])
self.assertEqual(created_floating_ip['floating_network_id'],
@@ -116,8 +116,8 @@
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id)
- self.assertEqual(shown_floating_ip['tenant_id'],
- self.network['tenant_id'])
+ self.assertEqual(shown_floating_ip['project_id'],
+ self.network['project_id'])
self.assertEqual(shown_floating_ip['floating_ip_address'],
created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.port['id'])
diff --git a/tempest/api/network/admin/test_metering_extensions.py b/tempest/api/network/admin/test_metering_extensions.py
index 5063fef..942b66c 100644
--- a/tempest/api/network/admin/test_metering_extensions.py
+++ b/tempest/api/network/admin/test_metering_extensions.py
@@ -121,7 +121,7 @@
metering_label = body['metering_label']
self.assertEqual(self.metering_label['id'], metering_label['id'])
self.assertEqual(self.metering_label['tenant_id'],
- metering_label['tenant_id'])
+ metering_label['project_id'])
self.assertEqual(self.metering_label['name'], metering_label['name'])
self.assertEqual(self.metering_label['description'],
metering_label['description'])
diff --git a/tempest/api/network/admin/test_negative_quotas.py b/tempest/api/network/admin/test_negative_quotas.py
index 0db038d..3562d6f 100644
--- a/tempest/api/network/admin/test_negative_quotas.py
+++ b/tempest/api/network/admin/test_negative_quotas.py
@@ -58,12 +58,12 @@
# Create two networks
n1 = self.admin_networks_client.create_network(
- tenant_id=self.project['id'])
+ project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network,
n1['network']['id'])
n2 = self.admin_networks_client.create_network(
- tenant_id=self.project['id'])
+ project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network,
n2['network']['id'])
@@ -73,7 +73,7 @@
lib_exc.Conflict,
r"Quota exceeded for resources: \['network'\].*"):
n3 = self.admin_networks_client.create_network(
- tenant_id=self.project['id'])
+ project_id=self.project['id'])
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_networks_client.delete_network,
n3['network']['id'])
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index ef5ebb6..8b7bfb1 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -67,7 +67,7 @@
non_default_quotas = self.admin_quotas_client.list_quotas()
found = False
for qs in non_default_quotas['quotas']:
- if qs['tenant_id'] == project_id:
+ if qs['project_id'] == project_id:
found = True
self.assertTrue(found)
@@ -81,7 +81,7 @@
self.admin_quotas_client.reset_quotas(project_id)
non_default_quotas = self.admin_quotas_client.list_quotas()
for q in non_default_quotas['quotas']:
- self.assertNotEqual(project_id, q['tenant_id'])
+ self.assertNotEqual(project_id, q['project_id'])
quota_set = self.admin_quotas_client.show_quotas(project_id)['quota']
default_quotas = self.admin_quotas_client.show_default_quotas(
project_id)['quota']
diff --git a/tempest/api/network/admin/test_routers.py b/tempest/api/network/admin/test_routers.py
index 41f97d8..417eb70 100644
--- a/tempest/api/network/admin/test_routers.py
+++ b/tempest/api/network/admin/test_routers.py
@@ -63,11 +63,11 @@
name = data_utils.rand_name('router-')
create_body = self.admin_routers_client.create_router(
- name=name, tenant_id=project_id)
+ name=name, project_id=project_id)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_routers_client.delete_router,
create_body['router']['id'])
- self.assertEqual(project_id, create_body['router']['tenant_id'])
+ self.assertEqual(project_id, create_body['router']['project_id'])
@decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8')
@utils.requires_ext(extension='ext-gw-mode', service='network')
diff --git a/tempest/api/network/admin/test_routers_dvr.py b/tempest/api/network/admin/test_routers_dvr.py
index 270f802..291581c 100644
--- a/tempest/api/network/admin/test_routers_dvr.py
+++ b/tempest/api/network/admin/test_routers_dvr.py
@@ -106,14 +106,14 @@
attribute will be set to True
"""
name = data_utils.rand_name('router')
- tenant_id = self.routers_client.tenant_id
+ project_id = self.routers_client.project_id
# router needs to be in admin state down in order to be upgraded to DVR
# l3ha routers are not upgradable to dvr, make it explicitly non ha
router = self.admin_routers_client.create_router(name=name,
distributed=False,
admin_state_up=False,
ha=False,
- tenant_id=tenant_id)
+ project_id=project_id)
router_id = router['router']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.admin_routers_client.delete_router, router_id)
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index aaa5497..abcbbf7 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -83,7 +83,7 @@
self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
- self.assertIsNotNone(created_floating_ip['tenant_id'])
+ self.assertIsNotNone(created_floating_ip['project_id'])
self.assertIsNotNone(created_floating_ip['floating_ip_address'])
self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
self.assertEqual(created_floating_ip['floating_network_id'],
@@ -97,8 +97,8 @@
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id)
- self.assertEqual(shown_floating_ip['tenant_id'],
- created_floating_ip['tenant_id'])
+ self.assertEqual(shown_floating_ip['project_id'],
+ created_floating_ip['project_id'])
self.assertEqual(shown_floating_ip['floating_ip_address'],
created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 10121de..c4ad720 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -192,9 +192,9 @@
port_list = self.ports_client.list_ports(fixed_ips=fixed_ips)
# Check that we got the desired port
ports = port_list['ports']
- tenant_ids = set([port['tenant_id'] for port in ports])
- self.assertEqual(len(tenant_ids), 1,
- 'Ports from multiple tenants are in the list resp')
+ project_ids = set([port['project_id'] for port in ports])
+ self.assertEqual(len(project_ids), 1,
+ 'Ports from multiple projects are in the list resp')
port_ids = [port['id'] for port in ports]
fixed_ips = [port['fixed_ips'] for port in ports]
port_net_ids = [port['network_id'] for port in ports]
diff --git a/tempest/api/object_storage/test_account_bulk.py b/tempest/api/object_storage/test_account_bulk.py
index 6599e43..80f790f 100644
--- a/tempest/api/object_storage/test_account_bulk.py
+++ b/tempest/api/object_storage/test_account_bulk.py
@@ -16,7 +16,6 @@
import tempfile
from tempest.api.object_storage import base
-from tempest.common import custom_matchers
from tempest.common import utils
from tempest.lib import decorators
@@ -76,17 +75,7 @@
resp = self._upload_archive(filepath)
self.containers.append(container_name)
- # When uploading an archived file with the bulk operation, the response
- # does not contain 'content-length' header. This is the special case,
- # therefore the existence of response headers is checked without
- # custom matcher.
- self.assertIn('transfer-encoding', resp.response)
- self.assertIn('content-type', resp.response)
- self.assertIn('x-trans-id', resp.response)
- self.assertIn('date', resp.response)
-
- # Check only the format of common headers with custom matcher
- self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
+ self.assertHeaders(resp.response, 'Account', 'PUT')
param = {'format': 'json'}
resp, body = self.account_client.list_account_containers(param)
@@ -113,17 +102,7 @@
data = '%s/%s\n%s' % (container_name, object_name, container_name)
resp = self.bulk_client.delete_bulk_data(data=data)
- # When deleting multiple files using the bulk operation, the response
- # does not contain 'content-length' header. This is the special case,
- # therefore the existence of response headers is checked without
- # custom matcher.
- self.assertIn('transfer-encoding', resp.response)
- self.assertIn('content-type', resp.response)
- self.assertIn('x-trans-id', resp.response)
- self.assertIn('date', resp.response)
-
- # Check only the format of common headers with custom matcher
- self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
+ self.assertHeaders(resp.response, 'Account', 'DELETE')
# Check if uploaded contents are completely deleted
self._check_contents_deleted(container_name)
@@ -139,17 +118,7 @@
resp = self.bulk_client.delete_bulk_data_with_post(data=data)
- # When deleting multiple files using the bulk operation, the response
- # does not contain 'content-length' header. This is the special case,
- # therefore the existence of response headers is checked without
- # custom matcher.
- self.assertIn('transfer-encoding', resp.response)
- self.assertIn('content-type', resp.response)
- self.assertIn('x-trans-id', resp.response)
- self.assertIn('date', resp.response)
-
- # Check only the format of common headers with custom matcher
- self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
+ self.assertHeaders(resp.response, 'Account', 'POST')
# Check if uploaded contents are completely deleted
self._check_contents_deleted(container_name)
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index 322579c..bdcb5ae 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -123,7 +123,7 @@
self.assertEqual(object_content, obj_name[::-1].encode())
@decorators.attr(type='slow')
- @decorators.skip_because(bug='1317133')
+ @decorators.unstable_test(bug='1317133')
@decorators.idempotent_id('be008325-1bba-4925-b7dd-93b58f22ce9b')
@testtools.skipIf(
not CONF.object_storage_feature_enabled.container_sync,
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index c66776e..8bb2e6e 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -17,7 +17,6 @@
from oslo_serialization import jsonutils as json
from tempest.api.object_storage import base
-from tempest.common import custom_matchers
from tempest.common import utils
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
@@ -160,17 +159,7 @@
object_name,
params=params_del)
- # When deleting SLO using multipart manifest, the response contains
- # not 'content-length' but 'transfer-encoding' header. This is the
- # special case, therefore the existence of response headers is checked
- # outside of custom matcher.
- self.assertIn('transfer-encoding', resp)
- self.assertIn('content-type', resp)
- self.assertIn('x-trans-id', resp)
- self.assertIn('date', resp)
-
- # Check only the format of common headers with custom matcher
- self.assertThat(resp, custom_matchers.AreAllWellFormatted())
+ self.assertHeaders(resp, 'Object', 'DELETE')
resp, body = self.container_client.list_container_objects(
self.container_name)
diff --git a/tempest/common/custom_matchers.py b/tempest/common/custom_matchers.py
index c702d88..f1adeab 100644
--- a/tempest/common/custom_matchers.py
+++ b/tempest/common/custom_matchers.py
@@ -62,8 +62,9 @@
# [1] https://bugs.launchpad.net/swift/+bug/1537811
# [2] http://tracker.ceph.com/issues/13582
if ('content-length' not in actual and
+ 'transfer-encoding' not in actual and
self._content_length_required(actual)):
- return NonExistentHeader('content-length')
+ return NonExistentHeaders(['content-length', 'transfer-encoding'])
if 'content-type' not in actual:
return NonExistentHeader('content-type')
if 'x-trans-id' not in actual:
@@ -192,6 +193,19 @@
return {}
+class NonExistentHeaders(object):
+ """Informs an error message in the case of missing certain headers"""
+
+ def __init__(self, headers):
+ self.headers = headers
+
+ def describe(self):
+ return "none of these headers exist: %s" % self.headers
+
+ def get_details(self):
+ return {}
+
+
class InvalidHeaderValue(object):
"""Informs an error message when a header contains a bad value"""
diff --git a/tempest/config.py b/tempest/config.py
index e4e17f1..11f9426 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1068,11 +1068,13 @@
cfg.StrOpt('img_dir',
default='/opt/stack/new/devstack/files/images/'
'cirros-0.3.1-x86_64-uec',
- help='Directory containing image files',
+ help='Directory containing image files, this has been '
+ 'deprecated - img_file option contains a full path now.',
deprecated_for_removal=True),
cfg.StrOpt('img_file', deprecated_name='qcow2_img_file',
- default='cirros-0.3.1-x86_64-disk.img',
- help='Image file name'),
+ default='/opt/stack/new/devstack/files/images'
+ '/cirros-0.3.1-x86_64-disk.img',
+ help='Image full path.'),
cfg.StrOpt('img_disk_format',
default='qcow2',
help='Image disk format'),
@@ -1081,18 +1083,6 @@
help='Image container format'),
cfg.DictOpt('img_properties', help='Glance image properties. '
'Use for custom images which require them'),
- cfg.StrOpt('ami_img_file',
- default='cirros-0.3.1-x86_64-blank.img',
- help='AMI image file name',
- deprecated_for_removal=True),
- cfg.StrOpt('ari_img_file',
- default='cirros-0.3.1-x86_64-initrd',
- help='ARI image file name',
- deprecated_for_removal=True),
- cfg.StrOpt('aki_img_file',
- default='cirros-0.3.1-x86_64-vmlinuz',
- help='AKI image file name',
- deprecated_for_removal=True),
# TODO(yfried): add support for dhcpcd
cfg.StrOpt('dhcp_client',
default='udhcpc',
diff --git a/tempest/lib/common/rest_client.py b/tempest/lib/common/rest_client.py
index 431a0a0..1d524f0 100644
--- a/tempest/lib/common/rest_client.py
+++ b/tempest/lib/common/rest_client.py
@@ -21,6 +21,7 @@
import jsonschema
from oslo_log import log as logging
+from oslo_log import versionutils
from oslo_serialization import jsonutils as json
import six
from six.moves import urllib
@@ -177,13 +178,27 @@
return self.auth_provider.credentials.tenant_name
@property
+ def project_id(self):
+ """The project id being used for requests
+
+ :rtype: string
+ :return: The project id being used for requests
+ """
+ return self.auth_provider.credentials.tenant_id
+
+ @property
def tenant_id(self):
"""The tenant/project id being used for requests
:rtype: string
:return: The tenant/project id being used for requests
"""
- return self.auth_provider.credentials.tenant_id
+ # NOTE(ralonsoh): this property should be deprecated, reference
+ # blueprint adopt-oslo-versioned-objects-for-db.
+ versionutils.report_deprecated_feature(
+ self.LOG, '"tenant_id" property is deprecated for removal, use '
+ '"project_id" instead')
+ return self.project_id
@property
def password(self):
diff --git a/tempest/lib/services/network/quotas_client.py b/tempest/lib/services/network/quotas_client.py
index 997d201..96cc65d 100644
--- a/tempest/lib/services/network/quotas_client.py
+++ b/tempest/lib/services/network/quotas_client.py
@@ -12,11 +12,33 @@
# License for the specific language governing permissions and limitations
# under the License.
+import functools
+
from tempest.lib.services.network import base
+def _warning_deprecate_tenant_id(func):
+ @functools.wraps(func)
+ def inner(*args, **kwargs):
+ _self = args[0]
+ # check length of arg to know whether 'tenant_id' is passed as
+ # positional arg or kwargs.
+ if len(args) < 2:
+ if 'tenant_id' in kwargs:
+ _self.LOG.warning(
+ 'positional arg name "tenant_id" is deprecated, for '
+ 'removal, please start using "project_id" instead')
+ elif 'project_id' in kwargs:
+ # fallback to deprecated name till deprecation phase.
+ kwargs['tenant_id'] = kwargs.pop('project_id')
+
+ return func(*args, **kwargs)
+ return inner
+
+
class QuotasClient(base.BaseNetworkClient):
+ @_warning_deprecate_tenant_id
def update_quotas(self, tenant_id, **kwargs):
"""Update quota for a project.
@@ -28,12 +50,14 @@
uri = '/quotas/%s' % tenant_id
return self.update_resource(uri, put_body)
+ @_warning_deprecate_tenant_id
def reset_quotas(self, tenant_id): # noqa
# NOTE: This noqa is for passing T111 check and we cannot rename
# to keep backwards compatibility.
uri = '/quotas/%s' % tenant_id
return self.delete_resource(uri)
+ @_warning_deprecate_tenant_id
def show_quotas(self, tenant_id, **fields):
"""Show quota for a project.
@@ -54,11 +78,13 @@
uri = '/quotas'
return self.list_resources(uri, **filters)
+ @_warning_deprecate_tenant_id
def show_default_quotas(self, tenant_id):
"""List default quotas for a project."""
uri = '/quotas/%s/default' % tenant_id
return self.show_resource(uri)
+ @_warning_deprecate_tenant_id
def show_quota_details(self, tenant_id):
"""Show quota details for a project."""
uri = '/quotas/%s/details.json' % tenant_id
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 8591771..a80b77d 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import os
import subprocess
import netaddr
@@ -531,33 +532,32 @@
return image['id']
def glance_image_create(self):
- img_path = CONF.scenario.img_dir + "/" + CONF.scenario.img_file
- aki_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.aki_img_file
- ari_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ari_img_file
- ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file
+ img_path = CONF.scenario.img_file
+ if not os.path.exists(img_path):
+ # TODO(kopecmartin): replace LOG.warning for rasing
+ # InvalidConfiguration exception after tempest 25.0.0 is
+ # released - there will be one release which accepts both
+ # behaviors in order to avoid many failures across CIs and etc.
+ LOG.warning(
+ 'Starting Tempest 25.0.0 release, CONF.scenario.img_file need '
+ 'a full path for the image. CONF.scenario.img_dir was '
+ 'deprecated and will be removed in the next release. Till '
+ 'Tempest 25.0.0, old behavior is maintained and keep working '
+ 'but starting Tempest 26.0.0, you need to specify the full '
+ 'path in CONF.scenario.img_file config option.')
+ img_path = os.path.join(CONF.scenario.img_dir, img_path)
img_container_format = CONF.scenario.img_container_format
img_disk_format = CONF.scenario.img_disk_format
img_properties = CONF.scenario.img_properties
LOG.debug("paths: img: %s, container_format: %s, disk_format: %s, "
- "properties: %s, ami: %s, ari: %s, aki: %s",
+ "properties: %s",
img_path, img_container_format, img_disk_format,
- img_properties, ami_img_path, ari_img_path, aki_img_path)
- try:
- image = self._image_create('scenario-img',
- img_container_format,
- img_path,
- disk_format=img_disk_format,
- properties=img_properties)
- except IOError:
- LOG.warning(
- "A(n) %s image was not found. Retrying with uec image.",
- img_disk_format)
- kernel = self._image_create('scenario-aki', 'aki', aki_img_path)
- ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path)
- properties = {'kernel_id': kernel, 'ramdisk_id': ramdisk}
- image = self._image_create('scenario-ami', 'ami',
- path=ami_img_path,
- properties=properties)
+ img_properties)
+ image = self._image_create('scenario-img',
+ img_container_format,
+ img_path,
+ disk_format=img_disk_format,
+ properties=img_properties)
LOG.debug("image:%s", image)
return image
@@ -868,15 +868,15 @@
raise cls.skipException('Neutron not available')
def _create_network(self, networks_client=None,
- tenant_id=None,
+ project_id=None,
namestart='network-smoke-',
port_security_enabled=True, **net_dict):
if not networks_client:
networks_client = self.networks_client
- if not tenant_id:
- tenant_id = networks_client.tenant_id
+ if not project_id:
+ project_id = networks_client.project_id
name = data_utils.rand_name(namestart)
- network_kwargs = dict(name=name, tenant_id=tenant_id)
+ network_kwargs = dict(name=name, project_id=project_id)
if net_dict:
network_kwargs.update(net_dict)
# Neutron disables port security by default so we have to check the
@@ -901,14 +901,14 @@
if not subnets_client:
subnets_client = self.subnets_client
- def cidr_in_use(cidr, tenant_id):
+ def cidr_in_use(cidr, project_id):
"""Check cidr existence
:returns: True if subnet with cidr already exist in tenant
False else
"""
cidr_in_use = self.os_admin.subnets_client.list_subnets(
- tenant_id=tenant_id, cidr=cidr)['subnets']
+ project_id=project_id, cidr=cidr)['subnets']
return len(cidr_in_use) != 0
ip_version = kwargs.pop('ip_version', 4)
@@ -927,13 +927,13 @@
# blocks until an unallocated block is found.
for subnet_cidr in tenant_cidr.subnet(num_bits):
str_cidr = str(subnet_cidr)
- if cidr_in_use(str_cidr, tenant_id=network['tenant_id']):
+ if cidr_in_use(str_cidr, project_id=network['project_id']):
continue
subnet = dict(
name=data_utils.rand_name(namestart),
network_id=network['id'],
- tenant_id=network['tenant_id'],
+ project_id=network['project_id'],
cidr=str_cidr,
ip_version=ip_version,
**kwargs
@@ -1015,7 +1015,7 @@
kwargs = {
'floating_network_id': external_network_id,
'port_id': port_id,
- 'tenant_id': thing['tenant_id'],
+ 'tenant_id': thing.get('project_id') or thing['tenant_id'],
'fixed_ip_address': ip4,
}
if CONF.network.subnet_id:
@@ -1122,18 +1122,18 @@
self.fail(msg)
def _create_security_group(self, security_group_rules_client=None,
- tenant_id=None,
+ project_id=None,
namestart='secgroup-smoke',
security_groups_client=None):
if security_group_rules_client is None:
security_group_rules_client = self.security_group_rules_client
if security_groups_client is None:
security_groups_client = self.security_groups_client
- if tenant_id is None:
- tenant_id = security_groups_client.tenant_id
+ if project_id is None:
+ project_id = security_groups_client.project_id
secgroup = self._create_empty_security_group(
namestart=namestart, client=security_groups_client,
- tenant_id=tenant_id)
+ project_id=project_id)
# Add rules to the security group
rules = self._create_loginable_secgroup_rule(
@@ -1141,11 +1141,11 @@
secgroup=secgroup,
security_groups_client=security_groups_client)
for rule in rules:
- self.assertEqual(tenant_id, rule['tenant_id'])
+ self.assertEqual(project_id, rule['project_id'])
self.assertEqual(secgroup['id'], rule['security_group_id'])
return secgroup
- def _create_empty_security_group(self, client=None, tenant_id=None,
+ def _create_empty_security_group(self, client=None, project_id=None,
namestart='secgroup-smoke'):
"""Create a security group without rules.
@@ -1153,23 +1153,23 @@
- IPv4 egress to any
- IPv6 egress to any
- :param tenant_id: secgroup will be created in this tenant
+ :param project_id: secgroup will be created in this project
:returns: the created security group
"""
if client is None:
client = self.security_groups_client
- if not tenant_id:
- tenant_id = client.tenant_id
+ if not project_id:
+ project_id = client.project_id
sg_name = data_utils.rand_name(namestart)
sg_desc = sg_name + " description"
sg_dict = dict(name=sg_name,
description=sg_desc)
- sg_dict['tenant_id'] = tenant_id
+ sg_dict['project_id'] = project_id
result = client.create_security_group(**sg_dict)
secgroup = result['security_group']
self.assertEqual(secgroup['name'], sg_name)
- self.assertEqual(tenant_id, secgroup['tenant_id'])
+ self.assertEqual(project_id, secgroup['project_id'])
self.assertEqual(secgroup['description'], sg_desc)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@@ -1178,15 +1178,15 @@
def _create_security_group_rule(self, secgroup=None,
sec_group_rules_client=None,
- tenant_id=None,
+ project_id=None,
security_groups_client=None, **kwargs):
"""Create a rule from a dictionary of rule parameters.
Create a rule in a secgroup. if secgroup not defined will search for
- default secgroup in tenant_id.
+ default secgroup in project_id.
:param secgroup: the security group.
- :param tenant_id: if secgroup not passed -- the tenant in which to
+ :param project_id: if secgroup not passed -- the tenant in which to
search for default secgroup
:param kwargs: a dictionary containing rule parameters:
for example, to allow incoming ssh:
@@ -1201,18 +1201,18 @@
sec_group_rules_client = self.security_group_rules_client
if security_groups_client is None:
security_groups_client = self.security_groups_client
- if not tenant_id:
- tenant_id = security_groups_client.tenant_id
+ if not project_id:
+ project_id = security_groups_client.project_id
if secgroup is None:
- # Get default secgroup for tenant_id
+ # Get default secgroup for project_id
default_secgroups = security_groups_client.list_security_groups(
- name='default', tenant_id=tenant_id)['security_groups']
- msg = "No default security group for tenant %s." % (tenant_id)
+ name='default', project_id=project_id)['security_groups']
+ msg = "No default security group for project %s." % (project_id)
self.assertNotEmpty(default_secgroups, msg)
secgroup = default_secgroups[0]
ruleset = dict(security_group_id=secgroup['id'],
- tenant_id=secgroup['tenant_id'])
+ project_id=secgroup['project_id'])
ruleset.update(kwargs)
sg_rule = sec_group_rules_client.create_security_group_rule(**ruleset)
@@ -1278,7 +1278,7 @@
return rules
- def _get_router(self, client=None, tenant_id=None):
+ def _get_router(self, client=None, project_id=None):
"""Retrieve a router for the given tenant id.
If a public router has been configured, it will be returned.
@@ -1289,8 +1289,8 @@
"""
if not client:
client = self.routers_client
- if not tenant_id:
- tenant_id = client.tenant_id
+ if not project_id:
+ project_id = client.project_id
router_id = CONF.network.public_router_id
network_id = CONF.network.public_network_id
if router_id:
@@ -1300,7 +1300,7 @@
router = client.create_router(
name=data_utils.rand_name(self.__class__.__name__ + '-router'),
admin_state_up=True,
- tenant_id=tenant_id,
+ project_id=project_id,
external_gateway_info=dict(network_id=network_id))['router']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
client.delete_router, router['id'])
@@ -1311,14 +1311,14 @@
def create_networks(self, networks_client=None,
routers_client=None, subnets_client=None,
- tenant_id=None, dns_nameservers=None,
+ project_id=None, dns_nameservers=None,
port_security_enabled=True, **net_dict):
"""Create a network with a subnet connected to a router.
The baremetal driver is a special case since all nodes are
on the same shared network.
- :param tenant_id: id of tenant to create resources in.
+ :param project_id: id of project to create resources in.
:param dns_nameservers: list of dns servers to send to subnet.
:param port_security_enabled: whether or not port_security is enabled
:param net_dict: a dict containing experimental network information in
@@ -1343,11 +1343,11 @@
else:
network = self._create_network(
networks_client=networks_client,
- tenant_id=tenant_id,
+ project_id=project_id,
port_security_enabled=port_security_enabled,
**net_dict)
router = self._get_router(client=routers_client,
- tenant_id=tenant_id)
+ project_id=project_id)
subnet_kwargs = dict(network=network,
subnets_client=subnets_client)
# use explicit check because empty list is a valid option
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index f466729..6c1b3fa 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -331,7 +331,7 @@
internal_ips = (
p['fixed_ips'][0]['ip_address'] for p in
self.os_admin.ports_client.list_ports(
- tenant_id=server['tenant_id'],
+ project_id=server['tenant_id'],
network_id=network['id'])['ports']
if p['device_owner'].startswith('network') or
p['device_owner'].startswith('compute')
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 9cbd831..3fc93e4 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -176,7 +176,7 @@
cls.primary_tenant = cls.TenantProperties(cls.os_primary)
cls.alt_tenant = cls.TenantProperties(cls.os_alt)
for tenant in [cls.primary_tenant, cls.alt_tenant]:
- cls.tenants[tenant.creds.tenant_id] = tenant
+ cls.tenants[tenant.creds.project_id] = tenant
cls.floating_ip_access = not CONF.network.public_router_id
@@ -199,14 +199,14 @@
def _create_tenant_security_groups(self, tenant):
access_sg = self._create_empty_security_group(
namestart='secgroup_access-',
- tenant_id=tenant.creds.tenant_id,
+ project_id=tenant.creds.project_id,
client=tenant.manager.security_groups_client
)
# don't use default secgroup since it allows in-project traffic
def_sg = self._create_empty_security_group(
namestart='secgroup_general-',
- tenant_id=tenant.creds.tenant_id,
+ project_id=tenant.creds.project_id,
client=tenant.manager.security_groups_client
)
tenant.security_groups.update(access=access_sg, default=def_sg)
@@ -536,7 +536,7 @@
# Create empty security group and add icmp rule in it
new_sg = self._create_empty_security_group(
namestart='secgroup_new-',
- tenant_id=new_tenant.creds.tenant_id,
+ project_id=new_tenant.creds.project_id,
client=new_tenant.manager.security_groups_client)
icmp_rule = dict(
protocol='icmp',
diff --git a/tempest/tests/cmd/test_verify_tempest_config.py b/tempest/tests/cmd/test_verify_tempest_config.py
index dad31b4..721fd76 100644
--- a/tempest/tests/cmd/test_verify_tempest_config.py
+++ b/tempest/tests/cmd/test_verify_tempest_config.py
@@ -629,3 +629,23 @@
def test_contains_version_negative_data(self):
self.assertFalse(
verify_tempest_config.contains_version('v5.', ['v1.0', 'v2.0']))
+
+ def test_check_service_availability(self):
+ class FakeAuthProvider:
+ def get_auth(self):
+ return ('token',
+ {'serviceCatalog': [{'type': 'compute'},
+ {'type': 'image'},
+ {'type': 'volumev3'},
+ {'type': 'network'},
+ {'type': 'object-store'}]})
+
+ class Fake_os:
+ auth_provider = FakeAuthProvider()
+ auth_version = 'v2'
+ verify_tempest_config.CONF._config = fake_config.FakePrivate()
+ services = verify_tempest_config.check_service_availability(
+ Fake_os(), True)
+ self.assertEqual(
+ sorted(['nova', 'glance', 'neutron', 'swift', 'cinder']),
+ sorted(services))
diff --git a/tempest/tests/cmd/test_workspace.py b/tempest/tests/cmd/test_workspace.py
index 7a6b576..eae6202 100644
--- a/tempest/tests/cmd/test_workspace.py
+++ b/tempest/tests/cmd/test_workspace.py
@@ -16,12 +16,12 @@
import shutil
import subprocess
import tempfile
-
-from mock import patch
+from unittest.mock import patch
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
+
from tempest.cmd import workspace
from tempest.lib.common.utils import data_utils
from tempest.tests import base
diff --git a/tempest/tests/lib/cmd/__init__.py b/tempest/tests/lib/cmd/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/tests/lib/cmd/__init__.py
diff --git a/tempest/tests/lib/cmd/test_check_uuid.py b/tempest/tests/lib/cmd/test_check_uuid.py
new file mode 100644
index 0000000..130f90a
--- /dev/null
+++ b/tempest/tests/lib/cmd/test_check_uuid.py
@@ -0,0 +1,138 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import importlib
+import tempfile
+from unittest import mock
+
+from tempest.lib.cmd import check_uuid
+from tempest.tests import base
+
+
+class TestSourcePatcher(base.TestCase):
+ def test_add_patch(self):
+ patcher = check_uuid.SourcePatcher()
+ fake_file = tempfile.NamedTemporaryFile("w+t", delete=False)
+ file_contents = 'first_line\nsecond_line'
+ fake_file.write(file_contents)
+ fake_file.close()
+ patcher.add_patch(fake_file.name, 'patch', 2)
+
+ source_file = patcher.source_files[fake_file.name]
+ self.assertEqual(1, len(patcher.patches))
+ (patch_id, patch), = patcher.patches.items()
+ self.assertEqual(patcher._quote('patch\n'), patch)
+ self.assertEqual('first_line\n{%s:s}second_line' % patch_id,
+ patcher._unquote(source_file))
+
+ def test_apply_patches(self):
+ fake_file = tempfile.NamedTemporaryFile("w+t")
+ patcher = check_uuid.SourcePatcher()
+ patcher.patches = {'fake-uuid': patcher._quote('patch\n')}
+ patcher.source_files = {
+ fake_file.name: patcher._quote('first_line\n') +
+ '{fake-uuid:s}second_line'}
+ with mock.patch('sys.stdout'):
+ patcher.apply_patches()
+
+ lines = fake_file.read().split('\n')
+ fake_file.close()
+ self.assertEqual(['first_line', 'patch', 'second_line'], lines)
+ self.assertFalse(patcher.patches)
+ self.assertFalse(patcher.source_files)
+
+
+class TestTestChecker(base.TestCase):
+ def _test_add_uuid_to_test(self, source_file):
+ class Fake_test_node():
+ lineno = 1
+ col_offset = 4
+ patcher = check_uuid.SourcePatcher()
+ checker = check_uuid.TestChecker(importlib.import_module('tempest'))
+ fake_file = tempfile.NamedTemporaryFile("w+t", delete=False)
+ fake_file.write(source_file)
+ fake_file.close()
+ checker._add_uuid_to_test(patcher, Fake_test_node(), fake_file.name)
+
+ self.assertEqual(1, len(patcher.patches))
+ self.assertEqual(1, len(patcher.source_files))
+ (patch_id, patch), = patcher.patches.items()
+ changed_source_file, = patcher.source_files.values()
+ self.assertEqual('{%s:s}%s' % (patch_id, patcher._quote(source_file)),
+ changed_source_file)
+ expected_patch_start = patcher._quote(
+ ' ' + check_uuid.DECORATOR_TEMPLATE.split('(')[0])
+ self.assertTrue(patch.startswith(expected_patch_start))
+
+ def test_add_uuid_to_test_def(self):
+ source_file = (" def test_test():\n"
+ " pass")
+ self._test_add_uuid_to_test(source_file)
+
+ def test_add_uuid_to_test_decorator(self):
+ source_file = (" @decorators.idempotent_id\n"
+ " def test_test():\n"
+ " pass")
+ self._test_add_uuid_to_test(source_file)
+
+ def test_add_import_for_test_uuid_no_tempest(self):
+ patcher = check_uuid.SourcePatcher()
+ checker = check_uuid.TestChecker(importlib.import_module('tempest'))
+ fake_file = tempfile.NamedTemporaryFile("w+t")
+
+ class Fake_src_parsed():
+ body = ['test_node']
+ checker._import_name = mock.Mock(return_value='fake_module')
+
+ checker._add_import_for_test_uuid(patcher, Fake_src_parsed(),
+ fake_file.name)
+ (patch_id, patch), = patcher.patches.items()
+ self.assertEqual(patcher._quote('\n' + check_uuid.IMPORT_LINE + '\n'),
+ patch)
+ self.assertEqual('{%s:s}' % patch_id,
+ patcher.source_files[fake_file.name])
+
+ def test_add_import_for_test_uuid_tempest(self):
+ patcher = check_uuid.SourcePatcher()
+ checker = check_uuid.TestChecker(importlib.import_module('tempest'))
+ fake_file = tempfile.NamedTemporaryFile("w+t", delete=False)
+ test1 = (" def test_test():\n"
+ " pass\n")
+ test2 = (" def test_another_test():\n"
+ " pass\n")
+ source_code = test1 + test2
+ fake_file.write(source_code)
+ fake_file.close()
+
+ def fake_import_name(node):
+ return node.name
+ checker._import_name = fake_import_name
+
+ class Fake_node():
+ def __init__(self, lineno, col_offset, name):
+ self.lineno = lineno
+ self.col_offset = col_offset
+ self.name = name
+
+ class Fake_src_parsed():
+ body = [Fake_node(1, 4, 'tempest.a_fake_module'),
+ Fake_node(3, 4, 'another_fake_module')]
+
+ checker._add_import_for_test_uuid(patcher, Fake_src_parsed(),
+ fake_file.name)
+ (patch_id, patch), = patcher.patches.items()
+ self.assertEqual(patcher._quote(check_uuid.IMPORT_LINE + '\n'),
+ patch)
+ expected_source = patcher._quote(test1) + '{' + patch_id + ':s}' +\
+ patcher._quote(test2)
+ self.assertEqual(expected_source,
+ patcher.source_files[fake_file.name])
diff --git a/tempest/tests/lib/services/network/test_quotas_client.py b/tempest/tests/lib/services/network/test_quotas_client.py
index aa6c1a1..7dce4e1 100644
--- a/tempest/tests/lib/services/network/test_quotas_client.py
+++ b/tempest/tests/lib/services/network/test_quotas_client.py
@@ -52,7 +52,7 @@
}
}
- FAKE_QUOTA_TENANT_ID = "bab7d5c60cd041a0a36f7c4b6e1dd978"
+ FAKE_QUOTA_PROJECT_ID = "bab7d5c60cd041a0a36f7c4b6e1dd978"
FAKE_QUOTA_DETAILS = {
"quota": {
@@ -115,7 +115,7 @@
self.FAKE_PROJECT_QUOTAS,
bytes_body,
200,
- tenant_id=self.FAKE_QUOTA_TENANT_ID)
+ project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_show_default_quotas(self, bytes_body=False):
self.check_service_client_function(
@@ -124,7 +124,7 @@
self.FAKE_PROJECT_QUOTAS,
bytes_body,
200,
- tenant_id=self.FAKE_QUOTA_TENANT_ID)
+ project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_update_quotas(self, bytes_body=False):
self.check_service_client_function(
@@ -133,7 +133,7 @@
self.FAKE_PROJECT_QUOTAS,
bytes_body,
200,
- tenant_id=self.FAKE_QUOTA_TENANT_ID)
+ project_id=self.FAKE_QUOTA_PROJECT_ID)
def _test_show_quota_details(self, bytes_body=False):
self.check_service_client_function(
@@ -142,7 +142,7 @@
self.FAKE_QUOTA_DETAILS,
bytes_body,
200,
- tenant_id=self.FAKE_QUOTA_TENANT_ID)
+ project_id=self.FAKE_QUOTA_PROJECT_ID)
def test_reset_quotas(self):
self.check_service_client_function(
@@ -150,7 +150,7 @@
"tempest.lib.common.rest_client.RestClient.delete",
{},
status=204,
- tenant_id=self.FAKE_QUOTA_TENANT_ID)
+ project_id=self.FAKE_QUOTA_PROJECT_ID)
def test_list_quotas_with_str_body(self):
self._test_list_quotas()