Ping to export location until it is reachable
In some cases it takes time for the interface to acquire the
IP address. This causes a failure in the ping operation.
Therefore, we should ping until the network is reachable.
This is can be done by "call_until_true" method that allows
reusing the ping method until the defined timeout.
This patch also adds the other scenario tests for ipv6
environmet.
Change-Id: I60bf3bd1bd2cc22b5bb6be11c8174b7529d0a066
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index 43eeac3..7067e6b 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -21,6 +21,7 @@
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
from manila_tempest_tests.common import constants
@@ -29,7 +30,6 @@
from manila_tempest_tests.tests.scenario import manager
from manila_tempest_tests import utils
-
CONF = config.CONF
LOG = log.getLogger(__name__)
@@ -200,6 +200,24 @@
self.share = self.shares_client.get_share(self.share['id'])
return remote_client
+ def validate_ping_to_export_location(self, export, remote_client,
+ ping_timeout=None):
+ timeout = ping_timeout or CONF.validation.ping_timeout
+
+ def ping_to_export_location(export, remote_client):
+ ip, version = self.get_ip_and_version_from_export_location(export)
+ try:
+ remote_client.exec_command(
+ "ping{} -c5 -w1 {}".format(
+ '6' if version == 6 else '', ip))
+ return True
+ except exceptions.SSHExecCommandFailed:
+ return False
+
+ test_utils.call_until_true(ping_to_export_location,
+ timeout, 1, export=export,
+ remote_client=remote_client)
+
def write_data_to_mounted_share(self, escaped_string, remote_client,
mount_point='/mnt/t1'):
remote_client.exec_command("echo \"{escaped_string}\" "
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index 3cdc3ae..5ed3633 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -44,13 +44,6 @@
* Terminate the instance
"""
- def _ping_host_from_export_location(self, export, remote_client):
- ip, version = self.get_ip_and_version_from_export_location(export)
- if version == 6:
- remote_client.exec_command("ping6 -c 5 %s" % ip)
- else:
- remote_client.exec_command("ping -c 5 %s" % ip)
-
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
def test_mount_share_one_vm(self):
instance = self.boot_instance(wait_until="BUILD")
@@ -404,7 +397,7 @@
def mount_share(self, location, remote_client, target_dir=None):
- self._ping_host_from_export_location(location, remote_client)
+ self.validate_ping_to_export_location(location, remote_client)
target_dir = target_dir or "/mnt"
remote_client.exec_command(
@@ -428,7 +421,7 @@
def mount_share(self, location, remote_client, target_dir=None):
- self._ping_host_from_export_location(location, remote_client)
+ self.validate_ping_to_export_location(location, remote_client)
location = location.replace("\\", "/")
target_dir = target_dir or "/mnt"
diff --git a/manila_tempest_tests/tests/scenario/test_share_extend.py b/manila_tempest_tests/tests/scenario/test_share_extend.py
index 823e3c9..3bc4dd4 100644
--- a/manila_tempest_tests/tests/scenario/test_share_extend.py
+++ b/manila_tempest_tests/tests/scenario/test_share_extend.py
@@ -159,6 +159,9 @@
instance=kwargs['instance'], access_level=access_level)
def mount_share(self, location, remote_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, remote_client)
+
target_dir = target_dir or "/mnt"
remote_client.exec_command(
"sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
@@ -181,6 +184,9 @@
instance=kwargs['instance'], access_level=access_level)
def mount_share(self, location, remote_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, remote_client)
+
location = location.replace("\\", "/")
target_dir = target_dir or "/mnt"
remote_client.exec_command(
@@ -197,6 +203,10 @@
super(TestShareExtendCEPHFS, self).test_create_extend_and_write()
+class TestShareExtendNFSIPv6(TestShareExtendNFS):
+ ip_version = 6
+
+
# NOTE(u_glide): this function is required to exclude ShareExtendBase
# from executed test cases.
# See: https://docs.python.org/3/library/unittest.html#load-tests-protocol
diff --git a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
index 1005740..c707874 100644
--- a/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
+++ b/manila_tempest_tests/tests/scenario/test_share_manage_unmanage.py
@@ -178,6 +178,9 @@
protocol = "nfs"
def mount_share(self, location, remote_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, remote_client)
+
target_dir = target_dir or "/mnt"
remote_client.exec_command(
"sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
@@ -188,6 +191,9 @@
protocol = "cifs"
def mount_share(self, location, remote_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, remote_client)
+
location = location.replace("\\", "/")
target_dir = target_dir or "/mnt"
remote_client.exec_command(
@@ -195,6 +201,10 @@
)
+class ShareManageUnmanageNFSIPv6(ShareManageUnmanageNFS):
+ ip_version = 6
+
+
# NOTE(u_glide): this function is required to exclude ShareManageUnmanageBase
# from executed test cases.
# See: https://docs.python.org/3/library/unittest.html#load-tests-protocol
diff --git a/manila_tempest_tests/tests/scenario/test_share_shrink.py b/manila_tempest_tests/tests/scenario/test_share_shrink.py
index 1d0e028..5a6ab71 100644
--- a/manila_tempest_tests/tests/scenario/test_share_shrink.py
+++ b/manila_tempest_tests/tests/scenario/test_share_shrink.py
@@ -174,6 +174,9 @@
instance=kwargs['instance'], access_level=access_level)
def mount_share(self, location, ssh_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, ssh_client)
+
target_dir = target_dir or "/mnt"
ssh_client.exec_command(
"sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
@@ -196,6 +199,9 @@
instance=kwargs['instance'], access_level=access_level)
def mount_share(self, location, ssh_client, target_dir=None):
+
+ self.validate_ping_to_export_location(location, ssh_client)
+
location = location.replace("\\", "/")
target_dir = target_dir or "/mnt"
ssh_client.exec_command(
@@ -212,6 +218,10 @@
super(TestShareShrinkCEPHFS, self).test_create_shrink_and_write()
+class TestShareShrinkNFSIPv6(TestShareShrinkNFS):
+ ip_version = 6
+
+
# NOTE(u_glide): this function is required to exclude ShareShrinkBase from
# executed test cases.
# See: https://docs.python.org/3/library/unittest.html#load-tests-protocol