Fix Tempest microversion comparison approach
Manila microversions have following template:
x.y
where 'x' and 'y' both digits.
And now tempest transforms string 'x.y' to float but it is incorrect
thing to do because float assumes that each left value is bigger than
right one. And it is not suitable for microversion comparisons.
Examples:
Microversions true conditions:
2.9 < 2.10
2.9 < 2.81
Float true conditions:
2.9 > 2.10
2.9 > 2.81
So, create new file 'manila_tempest_tests/utils.py' and place there
old and new functions that serve all microversion actions. In addition,
port another existing utility function called 'rand_ip'.
Change-Id: I88bf2cb51fd8de1bc89bf169bda7a05ca5a0b8ab
Closes-Bug: #1518996
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index be56719..d57b493 100644
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -15,7 +15,6 @@
import copy
import inspect
-import random
import traceback
from oslo_concurrency import lockutils
@@ -27,27 +26,15 @@
from tempest import test
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions
-import testtools
from manila_tempest_tests import clients_share as clients
from manila_tempest_tests import share_exceptions
+from manila_tempest_tests import utils
CONF = config.CONF
LOG = log.getLogger(__name__)
-def rand_ip():
- """This uses the TEST-NET-3 range of reserved IP addresses.
-
- Using this range, which are reserved solely for use in
- documentation and example source code, should avoid any potential
- conflicts in real-world testing.
- """
- TEST_NET_3 = '203.0.113.'
- final_octet = six.text_type(random.randint(0, 255))
- return TEST_NET_3 + final_octet
-
-
class handle_cleanup_exceptions(object):
"""Handle exceptions raised with cleanup operations.
@@ -91,19 +78,7 @@
return wrapped_func
-def is_microversion_supported(microversion):
- if (float(microversion) > float(CONF.share.max_api_microversion) or
- float(microversion) < float(CONF.share.min_api_microversion)):
- return False
- return True
-
-
-def skip_if_microversion_not_supported(microversion):
- """Decorator for tests that are microversion-specific."""
- if not is_microversion_supported(microversion):
- reason = ("Skipped. Test requires microversion '%s'." % microversion)
- return testtools.skip(reason)
- return lambda f: f
+skip_if_microversion_not_supported = utils.skip_if_microversion_not_supported
class BaseSharesTest(test.BaseTestCase):
@@ -125,7 +100,7 @@
method_isolated_creds = []
def skip_if_microversion_not_supported(self, microversion):
- if not is_microversion_supported(microversion):
+ if not utils.is_microversion_supported(microversion):
raise self.skipException(
"Microversion '%s' is not supported." % microversion)
@@ -657,8 +632,8 @@
data = {
"name": data_utils.rand_name("ss-name"),
"description": data_utils.rand_name("ss-desc"),
- "dns_ip": rand_ip(),
- "server": rand_ip(),
+ "dns_ip": utils.rand_ip(),
+ "server": utils.rand_ip(),
"domain": data_utils.rand_name("ss-domain"),
"user": data_utils.rand_name("ss-user"),
"password": data_utils.rand_name("ss-password"),