From b5d6f2997f325bd3b59f663bd9def88f068d8f9b Mon Sep 17 00:00:00 2001 From: lkuchlan Date: Sat, 9 Nov 2024 19:54:47 +0200 Subject: [PATCH] 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 --- manila_tempest_tests/config.py | 6 ++++++ manila_tempest_tests/tests/scenario/manager_share.py | 5 ++++- .../tests/scenario/test_share_basic_ops.py | 9 ++++++++- releasenotes/notes/nfs-versions-6886a2dd1bab094f.yaml | 8 ++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/nfs-versions-6886a2dd1bab094f.yaml diff --git a/manila_tempest_tests/config.py b/manila_tempest_tests/config.py index 03dfafbb..decf2ac4 100644 --- a/manila_tempest_tests/config.py +++ b/manila_tempest_tests/config.py @@ -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", diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py index 3e06323b..49fa20eb 100644 --- a/manila_tempest_tests/tests/scenario/manager_share.py +++ b/manila_tempest_tests/tests/scenario/manager_share.py @@ -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) ) 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 d8329744..fbcc87f9 100644 --- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py +++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py @@ -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, diff --git a/releasenotes/notes/nfs-versions-6886a2dd1bab094f.yaml b/releasenotes/notes/nfs-versions-6886a2dd1bab094f.yaml new file mode 100644 index 00000000..b18d1973 --- /dev/null +++ b/releasenotes/notes/nfs-versions-6886a2dd1bab094f.yaml @@ -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.