Add UUIDs to all tempest tests and gate check
Adds uuid4 as a decorator of the form:
@test.idempotent_id('12345678-1234-1234-1234-123456789abc')
to every test in the Tempest tree. Includes a gate check to
ensure the existence and uniqueness of the ids.
Modify check tool to ignore Tempest unit tests.
Change-Id: I19e3c7dd555a3ea09d585fb9091c357a300e6559
Co-Authored-By: Sergey Slipushenko <sslypushenko@mirantis.com>
Implements: bp test-uuid
diff --git a/tools/check_uuid.py b/tools/check_uuid.py
index 837da48..541e6c3 100644
--- a/tools/check_uuid.py
+++ b/tools/check_uuid.py
@@ -28,6 +28,7 @@
IMPORT_LINE = 'from tempest import %s' % DECORATOR_MODULE
DECORATOR_TEMPLATE = "@%s.%s('%%s')" % (DECORATOR_MODULE,
DECORATOR_NAME)
+UNIT_TESTS_EXCLUDE = 'tempest.tests'
class SourcePatcher(object):
@@ -103,8 +104,10 @@
root_package = self._path_to_package(root)
for item in files:
if item.endswith('.py'):
- modules.append('.'.join((root_package,
- os.path.splitext(item)[0])))
+ module_name = '.'.join((root_package,
+ os.path.splitext(item)[0]))
+ if not module_name.startswith(UNIT_TESTS_EXCLUDE):
+ modules.append(module_name)
return modules
@staticmethod
@@ -343,7 +346,9 @@
else:
errors = checker.report_untagged(untagged) or errors
if errors:
- sys.exit('@test.idempotent_id existence and uniqueness checks failed')
+ sys.exit("@test.idempotent_id existence and uniqueness checks failed\n"
+ "Run 'tox -v -euuidgen' to automatically fix tests with\n"
+ "missing @test.idempotent_id decorators.")
if __name__ == '__main__':
run()