[Tempest] Add valuable tags to tests
To be able to run tests based on following criteria:
- Only API is required and tested.
- API and share back-end required, API is tested.
- API and share back-end required, back-end is tested
Also, add doc with detailed description of running subset of tests.
Change-Id: I9ae105eaa527621c85d5038bba15edf4b065eaa3
Closes-Bug: #1587874
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 6a75bee..ec64174 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -15,6 +15,7 @@
import copy
import inspect
+import re
import traceback
from oslo_concurrency import lockutils
@@ -35,6 +36,37 @@
CONF = config.CONF
LOG = log.getLogger(__name__)
+# Test tags related to test direction
+TAG_POSITIVE = "positive"
+TAG_NEGATIVE = "negative"
+
+# Test tags related to service involvement
+TAG_API = "api"
+TAG_BACKEND = "backend"
+TAG_API_WITH_BACKEND = "api_with_backend"
+
+TAGS_MAPPER = {
+ "p": TAG_POSITIVE,
+ "n": TAG_NEGATIVE,
+ "a": TAG_API,
+ "b": TAG_BACKEND,
+ "ab": TAG_API_WITH_BACKEND,
+}
+TAGS_PATTERN = re.compile(
+ r"(?=.*\[.*\b(%(p)s|%(n)s)\b.*\])(?=.*\[.*\b(%(a)s|%(b)s|%(ab)s)\b.*\])" %
+ TAGS_MAPPER)
+
+
+def verify_test_has_appropriate_tags(self):
+ if not TAGS_PATTERN.match(self.id()):
+ msg = (
+ "Required attributes either not set or set improperly. "
+ "Two test attributes are expected:\n"
+ " - one of '%(p)s' or '%(n)s' and \n"
+ " - one of '%(a)s', '%(b)s' or '%(ab)s'."
+ ) % TAGS_MAPPER
+ raise self.failureException(msg)
+
class handle_cleanup_exceptions(object):
"""Handle exceptions raised with cleanup operations.
@@ -219,6 +251,7 @@
super(BaseSharesTest, self).setUp()
self.addCleanup(self.clear_isolated_creds)
self.addCleanup(self.clear_resources)
+ verify_test_has_appropriate_tags(self)
@classmethod
def resource_cleanup(cls):