Merge "Add nfs_versions option for NFS protocol version selection"

This commit is contained in:
Zuul 2024-12-04 19:35:50 +00:00 committed by Gerrit Code Review
commit ee3079db74
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.