Add nfs_versions option for NFS protocol version selection

This commit introduces a new configuration option, `nfs_versions`,
to allow specifying the NFS protocol version used when mounting NFS
shares in Tempest tests. The option supports selecting specific
versions, such as NFSv3 or NFSv4, enabling compatibility with
environments where certain NFS versions are required.

- Option Name: `nfs_versions`
- Default: ["4", ] (NFSv4 is used by default)

This enhancement increases flexibility in testing scenarios with
NFS version dependencies.

Change-Id: I048d4e954329d2d4f28604a8bf02c615703ac43c
This commit is contained in:
lkuchlan 2024-11-09 19:54:47 +02:00
parent 31df75e18b
commit b5d6f2997f
4 changed files with 26 additions and 2 deletions

View File

@ -108,6 +108,12 @@ ShareGroup = [
cfg.ListOpt("enable_ro_access_level_for_protocols",
default=["nfs", ],
help="List of protocols to run tests with ro access level."),
cfg.ListOpt("nfs_versions",
default=["4", ],
help="Specifies the NFS protocol version to use when mounting "
"an NFS share. Set to '3' for NFSv3, and '4' or '4.1' "
"for NFSv4. Leave it blank to use the default version."),
# Capabilities
cfg.StrOpt("capability_storage_protocol",

View File

@ -752,8 +752,11 @@ class BaseShareScenarioNFSTest(ShareScenarioTest):
self.validate_ping_to_export_location(location, ssh_client)
target_dir = target_dir or "/mnt"
nfs_version = getattr(self, 'nfs_version', None)
version_option = f"-o vers={nfs_version}" if nfs_version else ""
ssh_client.exec_command(
"sudo mount -vt nfs \"%s\" %s" % (location, target_dir)
"sudo mount -vt nfs %s \"%s\" %s" % (
version_option, location, target_dir)
)

View File

@ -417,9 +417,16 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
"sudo touch %s/file3" % snapshot_dir)
@ddt.ddt
class TestShareBasicOpsNFS(manager.BaseShareScenarioNFSTest,
ShareBasicOpsBase):
pass
@decorators.idempotent_id('4bad2073-a19b-4851-8cbe-75b20ade5cdb')
@tc.attr(base.TAG_POSITIVE, base.TAG_BACKEND)
@ddt.data(*utils.deduplicate(CONF.share.nfs_versions))
def test_mount_share_one_vm(self, nfs_version):
self.nfs_version = nfs_version
super(TestShareBasicOpsNFS, self).test_mount_share_one_vm()
class TestShareBasicOpsCIFS(manager.BaseShareScenarioCIFSTest,

View File

@ -0,0 +1,8 @@
---
upgrade:
- |
A new configuration option, nfs_version, has been added to control
the NFS protocol version used for mounting NFS shares during testing.
This option allows users to specify which version of NFS should be used,
supporting environments where compatibility with specific versions is
required.