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
This commit is contained in:
parent
2ab1bb66e0
commit
4f0dbe042f
|
@ -21,6 +21,7 @@ from six.moves.urllib.request import urlopen
|
|||
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.api import base
|
|||
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 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
|
|||
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}\" "
|
||||
|
|
|
@ -44,13 +44,6 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
|
|||
* 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 @@ class TestShareBasicOpsNFS(ShareBasicOpsBase):
|
|||
|
||||
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 @@ class TestShareBasicOpsCIFS(ShareBasicOpsBase):
|
|||
|
||||
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"
|
||||
|
|
|
@ -159,6 +159,9 @@ class TestShareExtendNFS(ShareExtendBase):
|
|||
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 @@ class TestShareExtendCIFS(ShareExtendBase):
|
|||
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 @@ class TestShareExtendCEPHFS(ShareExtendBase, manager.BaseShareCEPHFSTest):
|
|||
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
|
||||
|
|
|
@ -178,6 +178,9 @@ class ShareManageUnmanageNFS(ShareManageUnmanageBase):
|
|||
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 @@ class ShareManageUnmanageCIFS(ShareManageUnmanageBase):
|
|||
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 ShareManageUnmanageCIFS(ShareManageUnmanageBase):
|
|||
)
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -174,6 +174,9 @@ class TestShareShrinkNFS(ShareShrinkBase):
|
|||
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 @@ class TestShareShrinkCIFS(ShareShrinkBase):
|
|||
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 @@ class TestShareShrinkCEPHFS(ShareShrinkBase, manager.BaseShareCEPHFSTest):
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue