Finish switching to decorators.idempotent_id

Most modules are switched to using decorators.idempotent_id and
this patch covers the remaining and removes the old decorator check.

NOTE: The old decorator test.idempotent_id is still necessary to be
      used on the other projects.

Change-Id: Ice7f593fbc109863eba11402c2f3af75fc6ab9a1
Closes-Bug: #1616913
This commit is contained in:
Ken'ichi Ohmichi 2017-01-27 18:44:14 -08:00 committed by Ken'ichi Ohmichi
parent 4ce377983e
commit 44f01273cf
8 changed files with 34 additions and 26 deletions

View File

@ -22,7 +22,7 @@ import urllib3
from tempest.api.compute import base
from tempest import config
from tempest import test
from tempest.lib import decorators
CONF = config.CONF
@ -137,7 +137,7 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
# Turn the Socket into a WebSocket to do the communication
return _WebSocket(client_socket, url)
@test.idempotent_id('c640fdff-8ab4-45a4-a5d8-7e6146cbd0dc')
@decorators.idempotent_id('c640fdff-8ab4-45a4-a5d8-7e6146cbd0dc')
def test_novnc(self):
body = self.client.get_vnc_console(self.server['id'],
type='novnc')['console']
@ -151,7 +151,7 @@ class NoVNCConsoleTestJSON(base.BaseV2ComputeTest):
# Validate the RFB Negotiation to determine if a valid VNC session
self._validate_rfb_negotiation()
@test.idempotent_id('f9c79937-addc-4aaa-9e0e-841eef02aeb7')
@decorators.idempotent_id('f9c79937-addc-4aaa-9e0e-841eef02aeb7')
def test_novnc_bad_token(self):
body = self.client.get_vnc_console(self.server['id'],
type='novnc')['console']

View File

@ -14,6 +14,7 @@
# under the License.
from tempest.api.identity import base
from tempest.lib import decorators
from tempest import test
@ -21,7 +22,7 @@ class TestApiDiscovery(base.BaseIdentityV3Test):
"""Tests for API discovery features."""
@test.attr(type='smoke')
@test.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd')
@decorators.idempotent_id('b9232f5e-d9e5-4d97-b96c-28d3db4de1bd')
def test_api_version_resources(self):
descr = self.non_admin_client.show_api_description()['version']
expected_resources = ('id', 'links', 'media-types', 'status',
@ -32,7 +33,7 @@ class TestApiDiscovery(base.BaseIdentityV3Test):
self.assertIn(res, keys)
@test.attr(type='smoke')
@test.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265')
@decorators.idempotent_id('657c1970-4722-4189-8831-7325f3bc4265')
def test_api_media_types(self):
descr = self.non_admin_client.show_api_description()['version']
# Get MIME type bases and descriptions
@ -47,7 +48,7 @@ class TestApiDiscovery(base.BaseIdentityV3Test):
self.assertIn(s_type, media_types)
@test.attr(type='smoke')
@test.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e')
@decorators.idempotent_id('8879a470-abfb-47bb-bb8d-5a7fd279ad1e')
def test_api_version_statuses(self):
descr = self.non_admin_client.show_api_description()['version']
status = descr['status'].lower()

View File

@ -14,15 +14,15 @@
# under the License.
from tempest.api.identity import base
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from tempest import test
class IdentityV3ProjectsTest(base.BaseIdentityV3Test):
credentials = ['primary', 'alt']
@test.idempotent_id('86128d46-e170-4644-866a-cc487f699e1d')
@decorators.idempotent_id('86128d46-e170-4644-866a-cc487f699e1d')
def test_list_projects_returns_only_authorized_projects(self):
alt_project_name =\
self.alt_manager.credentials.project_name

View File

@ -16,12 +16,12 @@
from oslo_utils import timeutils
import six
from tempest.api.identity import base
from tempest import test
from tempest.lib import decorators
class TokensV3Test(base.BaseIdentityV3Test):
@test.idempotent_id('6f8e4436-fc96-4282-8122-e41df57197a9')
@decorators.idempotent_id('6f8e4436-fc96-4282-8122-e41df57197a9')
def test_create_token(self):
creds = self.os.credentials

View File

@ -20,8 +20,8 @@ import testtools
from tempest.api.identity import base
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions
from tempest import test
CONF = config.CONF
@ -78,7 +78,7 @@ class IdentityV3UsersTest(base.BaseIdentityV3Test):
time.sleep(1)
self.non_admin_users_client.auth_provider.set_auth()
@test.idempotent_id('ad71bd23-12ad-426b-bb8b-195d2b635f27')
@decorators.idempotent_id('ad71bd23-12ad-426b-bb8b-195d2b635f27')
def test_user_update_own_password(self):
old_pass = self.creds.password
old_token = self.non_admin_client.token
@ -103,7 +103,7 @@ class IdentityV3UsersTest(base.BaseIdentityV3Test):
@testtools.skipUnless(CONF.identity_feature_enabled.security_compliance,
'Security compliance not available.')
@test.idempotent_id('941784ee-5342-4571-959b-b80dd2cea516')
@decorators.idempotent_id('941784ee-5342-4571-959b-b80dd2cea516')
def test_password_history_check_self_service_api(self):
old_pass = self.creds.password
new_pass1 = data_utils.rand_password()
@ -133,7 +133,7 @@ class IdentityV3UsersTest(base.BaseIdentityV3Test):
@testtools.skipUnless(CONF.identity_feature_enabled.security_compliance,
'Security compliance not available.')
@test.idempotent_id('a7ad8bbf-2cff-4520-8c1d-96332e151658')
@decorators.idempotent_id('a7ad8bbf-2cff-4520-8c1d-96332e151658')
def test_user_account_lockout(self):
password = self.creds.password

View File

@ -15,7 +15,7 @@
from tempest.api.volume import base
from tempest import config
from tempest import test
from tempest.lib import decorators
CONF = config.CONF
@ -56,33 +56,33 @@ class VolumesV2SnapshotListTestJSON(base.BaseVolumeTest):
self.assertEqual(sorted(sorted_list, reverse=(sort_dir == 'desc')),
sorted_list, msg)
@test.idempotent_id('c5513ada-64c1-4d28-83b9-af3307ec1388')
@decorators.idempotent_id('c5513ada-64c1-4d28-83b9-af3307ec1388')
def test_snapshot_list_param_sort_id_asc(self):
self._list_snapshots_param_sort(sort_key='id', sort_dir='asc')
@test.idempotent_id('8a7fe058-0b41-402a-8afd-2dbc5a4a718b')
@decorators.idempotent_id('8a7fe058-0b41-402a-8afd-2dbc5a4a718b')
def test_snapshot_list_param_sort_id_desc(self):
self._list_snapshots_param_sort(sort_key='id', sort_dir='desc')
@test.idempotent_id('4052c3a0-2415-440a-a8cc-305a875331b0')
@decorators.idempotent_id('4052c3a0-2415-440a-a8cc-305a875331b0')
def test_snapshot_list_param_sort_created_at_asc(self):
self._list_snapshots_param_sort(sort_key='created_at', sort_dir='asc')
@test.idempotent_id('dcbbe24a-f3c0-4ec8-9274-55d48db8d1cf')
@decorators.idempotent_id('dcbbe24a-f3c0-4ec8-9274-55d48db8d1cf')
def test_snapshot_list_param_sort_created_at_desc(self):
self._list_snapshots_param_sort(sort_key='created_at', sort_dir='desc')
@test.idempotent_id('d58b5fed-0c37-42d3-8c5d-39014ac13c00')
@decorators.idempotent_id('d58b5fed-0c37-42d3-8c5d-39014ac13c00')
def test_snapshot_list_param_sort_name_asc(self):
self._list_snapshots_param_sort(sort_key='display_name',
sort_dir='asc')
@test.idempotent_id('96ba6f4d-1f18-47e1-b4bc-76edc6c21250')
@decorators.idempotent_id('96ba6f4d-1f18-47e1-b4bc-76edc6c21250')
def test_snapshot_list_param_sort_name_desc(self):
self._list_snapshots_param_sort(sort_key='display_name',
sort_dir='desc')
@test.idempotent_id('05489dde-44bc-4961-a1f5-3ce7ee7824f7')
@decorators.idempotent_id('05489dde-44bc-4961-a1f5-3ce7ee7824f7')
def test_snapshot_list_param_marker(self):
# The list of snapshots should end before the provided marker
params = {'marker': self.snapshot_id_list[1]}

View File

@ -27,6 +27,7 @@ from oslo_utils import uuidutils
import six.moves.urllib.parse as urlparse
# TODO(oomichi): Need to remove this after switching all modules to decorators
# on all OpenStack projects because they runs check-uuid on their own gates.
OLD_DECORATOR_MODULE = 'test'
DECORATOR_MODULE = 'decorators'
@ -120,7 +121,7 @@ class TestChecker(object):
@staticmethod
def _get_idempotent_id(test_node):
"""Return key-value dict with all metadata from @test.idempotent_id"""
"Return key-value dict with metadata from @decorators.idempotent_id"
idempotent_id = None
for decorator in test_node.decorator_list:
if (hasattr(decorator, 'func') and
@ -308,7 +309,8 @@ class TestChecker(object):
Returns true if untagged tests exist.
"""
def report(module_name, test_name, tests):
error_str = "%s:%s\nmissing @test.idempotent_id('...')\n%s\n" % (
error_str = ("%s:%s\nmissing @decorators.idempotent_id"
"('...')\n%s\n") % (
tests[module_name]['source_path'],
tests[module_name]['tests'][test_name].lineno,
test_name
@ -356,7 +358,8 @@ def run():
else:
errors = checker.report_untagged(untagged) or errors
if errors:
sys.exit("@test.idempotent_id existence and uniqueness checks failed\n"
sys.exit("@decorators.idempotent_id existence and uniqueness checks "
"failed\n"
"Run 'tox -v -euuidgen' to automatically fix tests with\n"
"missing @test.idempotent_id decorators.")

View File

@ -39,7 +39,11 @@ LOG = logging.getLogger(__name__)
CONF = config.CONF
idempotent_id = decorators.idempotent_id
# TODO(oomichi): This test.idempotent_id should be removed after all projects
# switch to use decorators.idempotent_id.
idempotent_id = debtcollector.moves.moved_function(
decorators.idempotent_id, 'idempotent_id', __name__,
version='Mitaka', removal_version='?')
def attr(**kwargs):