Use random IPs in security service tests

This patch changes the creation of security services in Manila
tempest to use randomized IP addresses instead of name-like strings
for both the 'dns_ip' and 'server' fields. The use of a name-like
string for the dns_ip field does not make sense from a positive test
perspective. The server field is more ambiguous in whether it should
take an IP or a hostname, but since nearly anything that can take a
hostname can also accept an IP, but not necessarily the reverse
(e.g. the NetApp drivers are expecting an IP), then it makes more
sense to use an IP here as well to cater to a broader audience.

The rand_ip() method is not in an ideal location. My preference
would be to push for this method to make it into the
tempest_lib.common.utils.data_utils package along with all the other
rand_whatever() methods. However, until that can be submitted,
accepted, and released, it will need to live inside the manila tests
temporarily.

Closes-bug: 1500899

Change-Id: I7dbeb9407e056266cc7a61722365f70ab668a525
This commit is contained in:
Andrew Kerr 2015-09-28 13:22:33 -04:00
parent 7049a9aac9
commit 20ffa20cb0

View File

@ -15,6 +15,7 @@
import copy
import inspect
import random
import traceback
from oslo_concurrency import lockutils
@ -33,6 +34,18 @@ 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.
@ -612,8 +625,8 @@ class BaseSharesTest(test.BaseTestCase):
data = {
"name": data_utils.rand_name("ss-name"),
"description": data_utils.rand_name("ss-desc"),
"dns_ip": data_utils.rand_name("ss-dns_ip"),
"server": data_utils.rand_name("ss-server"),
"dns_ip": rand_ip(),
"server": rand_ip(),
"domain": data_utils.rand_name("ss-domain"),
"user": data_utils.rand_name("ss-user"),
"password": data_utils.rand_name("ss-password"),