Skip to content

Commit fe1d4c4

Browse files
Add dictionary to configure delegations and async
By default, GaneshaManager generates a standard configuration with default values: Delegations = true, delegations = readwrite When ganesha_opts is provided, any of the following keys can override the defaults: delegations_v4: overrides the NFSv4 Delegations setting delegations_export: overrides the delegations setting in the EXPORT block ceph_async: overrides the async value in the CEPH block If ganesha_opts is empty or not provided, the existing configuration generation remains unchanged. This allows tests and setups to programmatically customize NFS-Ganesha configuration without manually editing the config file or creating separate templates. It keeps backward compatibility while supporting flexible overrides. Signed-off-by: Animesh Javali <Animesh.Javali@ibm.com>
1 parent d6a790c commit fe1d4c4

File tree

3 files changed

+64
-15
lines changed

3 files changed

+64
-15
lines changed

ci_utils/nfs_ganesha/nfs_ganesha_setup.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class GaneshaManager:
99
"""
1010
NFS-Ganesha Setup and Management for CephFS
1111
"""
12-
def __init__(self, session, subvol_path, cephfs_name="cephfs", export_id=101, test_type=None):
12+
def __init__(self, session, subvol_path, ganesha_opts=None, cephfs_name="cephfs", export_id=101, test_type=None):
1313
"""
1414
Manage NFS-Ganesha setup on a remote session.
1515
@@ -23,17 +23,31 @@ def __init__(self, session, subvol_path, cephfs_name="cephfs", export_id=101, te
2323
self.cephfs_name = cephfs_name
2424
self.export_id = export_id
2525
self.test_type = test_type
26+
self.ganesha_opts = ganesha_opts or {}
27+
28+
self.conf = self._generate_conf()
2629

2730
# ------------------------
2831
# Internal helpers
2932
# ------------------------
3033
def _generate_conf(self):
31-
delegations_v4 = ""
32-
delegations_export = ""
3334

34-
if self.test_type == "pynfs":
35-
delegations_v4 = " Delegations = true;"
36-
delegations_export = " delegations = readwrite;"
35+
# ---- defaults ----
36+
deleg_v4 = "true"
37+
deleg_export = "none"
38+
ceph_async = "true"
39+
40+
# ---- override only if ganesha_opts are passed ----
41+
if self.ganesha_opts:
42+
if "delegations_v4" in self.ganesha_opts:
43+
deleg_v4 = self.ganesha_opts["delegations_v4"]
44+
45+
if "delegations_export" in self.ganesha_opts:
46+
deleg_export = self.ganesha_opts["delegations_export"]
47+
48+
if "ceph_async" in self.ganesha_opts:
49+
ceph_async = self.ganesha_opts["ceph_async"]
50+
3751
return f"""NFS_CORE_PARAM {{
3852
Enable_NLM = false;
3953
Enable_RQUOTA = false;
@@ -42,13 +56,17 @@ def _generate_conf(self):
4256
4357
NFSv4 {{
4458
Enforce_UTF8_Validation = true;
45-
{delegations_v4}
59+
Delegations = {deleg_v4};
4660
}}
4761
4862
EXPORT_DEFAULTS {{
4963
Access_Type = RW;
5064
}}
5165
66+
CEPH {{
67+
async = {ceph_async};
68+
}}
69+
5270
EXPORT {{
5371
Export_ID = {self.export_id};
5472
Path = "{self.subvol_path}";
@@ -57,19 +75,19 @@ def _generate_conf(self):
5775
Transports = TCP;
5876
Access_Type = RW;
5977
Squash = None;
60-
{delegations_export}
78+
delegations = {deleg_export};
6179
FSAL {{
6280
Name = "CEPH";
6381
}}
6482
}}"""
6583

84+
6685
# ------------------------
6786
# Public methods
6887
# ------------------------
6988
def write_conf(self):
7089
"""Write ganesha.conf to remote system."""
71-
conf_content = self._generate_conf()
72-
run_cmd(self.session, f"echo '{conf_content}' > /etc/ganesha/ganesha.conf")
90+
run_cmd(self.session, f"echo '{self.conf}' > /etc/ganesha/ganesha.conf")
7391
run_cmd(self.session, "cat /etc/ganesha/ganesha.conf")
7492
logger.info("[OK] ganesha.conf written")
7593

tests/dev_space/test_fsal.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"CENTOS_VERSION",
2525
"CENTOS_ARCH",
2626
]
27-
NFS_GANESHA_REPO = "/tmp/workspace/sanity_dev/nfs-ganesha"
27+
NFS_GANESHA_REPO = "/tmp/workspace/test-delegation/nfs-ganesha"
2828

2929
@pytest.fixture(scope="session", autouse=True)
3030
def ci_params():
@@ -226,6 +226,32 @@ def test_cthon(remote_sessions, reserved_nodes):
226226

227227
assert rc == 0, f"Cthon CephFS tests failed"
228228

229+
@pytest.mark.timeout(1200)
230+
def test_delegation(remote_sessions, reserved_nodes):
231+
logger.info("[TEST START]: Update ganesha conf with delegation parameters")
232+
233+
server = remote_sessions["servers"][0]
234+
if len(remote_sessions["servers"]) > 1:
235+
ceph_setup = CephGaneshaSetup(session=server, extra_sessions=remote_sessions["servers"][1:])
236+
else:
237+
ceph_setup = CephGaneshaSetup(session=remote_sessions["servers"][0])
238+
239+
subvol_path = ceph_setup.full_setup()
240+
241+
ganesha_setup = GaneshaManager(
242+
session=server,
243+
subvol_path=subvol_path,
244+
cephfs_name=ceph_setup.cephfs_name,
245+
ganesha_opts={
246+
"delegations_v4": "true",
247+
"delegations_export": "readwrite",
248+
"ceph_async": "false",
249+
}
250+
)
251+
ganesha_setup.setup()
252+
253+
logger.info("Delegation updation completed")
254+
229255
def test_pynfs(remote_sessions, reserved_nodes):
230256
logger.info("[TEST START]: PyNFS with CephFS")
231257

@@ -238,5 +264,5 @@ def test_pynfs(remote_sessions, reserved_nodes):
238264
pynfs = PyNFSManager(session=client, server_ip=server_ip, backend_type="ceph")
239265
_, failure_summary, code = pynfs.run_all_tests(export="/nfs/cephfs")
240266
logger.info("PyNFS test failure summary: %s", failure_summary)
241-
242-
assert code == 0, f"PyNFS CephFS tests failed"
267+
268+
assert code == 0, f"PyNFS CephFS tests failed"

tests/test_pynfs_cthon.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,12 @@ def test_pynfs_cephfs(create_session, cmake_flags):
251251
session=server_session,
252252
subvol_path=subvol_path,
253253
cephfs_name=ceph_setup.cephfs_name,
254-
test_type="pynfs"
254+
test_type="pynfs",
255+
ganesha_opts={
256+
"delegations_v4": "true",
257+
"delegations_export": "readwrite",
258+
"ceph_async": "false",
259+
}
255260
)
256261
ganesha_setup.setup()
257262

@@ -557,4 +562,4 @@ def test_pynfs_gpfs(create_session, cmake_flags):
557562
with open(SUMMARY_FILE, "a", encoding="utf-8") as f:
558563
f.write(failure_msg)
559564
with open(SUMMARY_STATUS, "a", encoding="utf-8") as f:
560-
f.write("\nFailed")
565+
f.write("\nFailed")

0 commit comments

Comments
 (0)