Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions ci_utils/nfs_ganesha/nfs_ganesha_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GaneshaManager:
"""
NFS-Ganesha Setup and Management for CephFS
"""
def __init__(self, session, subvol_path, cephfs_name="cephfs", export_id=101, test_type=None):
def __init__(self, session, subvol_path, ganesha_opts=None, cephfs_name="cephfs", export_id=101, test_type=None):
"""
Manage NFS-Ganesha setup on a remote session.

Expand All @@ -23,17 +23,31 @@ def __init__(self, session, subvol_path, cephfs_name="cephfs", export_id=101, te
self.cephfs_name = cephfs_name
self.export_id = export_id
self.test_type = test_type
self.ganesha_opts = ganesha_opts or {}

self.conf = self._generate_conf()

# ------------------------
# Internal helpers
# ------------------------
def _generate_conf(self):
delegations_v4 = ""
delegations_export = ""

if self.test_type == "pynfs":
delegations_v4 = " Delegations = true;"
delegations_export = " delegations = readwrite;"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are changing the export readwrite to None, the gatecheck may fail..

Can you update the "tests/test_pynfs_cthon.py" file "Test 2" with additional param of ganesha_opts, so that gatecheck will continue to be green

# ---- defaults ----
deleg_v4 = "true"
deleg_export = "none"
ceph_async = "true"

# ---- override only if ganesha_opts are passed ----
if self.ganesha_opts:
if "delegations_v4" in self.ganesha_opts:
deleg_v4 = self.ganesha_opts["delegations_v4"]

if "delegations_export" in self.ganesha_opts:
deleg_export = self.ganesha_opts["delegations_export"]

if "ceph_async" in self.ganesha_opts:
ceph_async = self.ganesha_opts["ceph_async"]

return f"""NFS_CORE_PARAM {{
Enable_NLM = false;
Enable_RQUOTA = false;
Expand All @@ -42,13 +56,17 @@ def _generate_conf(self):

NFSv4 {{
Enforce_UTF8_Validation = true;
{delegations_v4}
Delegations = {deleg_v4};
}}

EXPORT_DEFAULTS {{
Access_Type = RW;
}}

CEPH {{
async = {ceph_async};
}}

EXPORT {{
Export_ID = {self.export_id};
Path = "{self.subvol_path}";
Expand All @@ -57,19 +75,19 @@ def _generate_conf(self):
Transports = TCP;
Access_Type = RW;
Squash = None;
{delegations_export}
delegations = {deleg_export};
FSAL {{
Name = "CEPH";
}}
}}"""


# ------------------------
# Public methods
# ------------------------
def write_conf(self):
"""Write ganesha.conf to remote system."""
conf_content = self._generate_conf()
run_cmd(self.session, f"echo '{conf_content}' > /etc/ganesha/ganesha.conf")
run_cmd(self.session, f"echo '{self.conf}' > /etc/ganesha/ganesha.conf")
run_cmd(self.session, "cat /etc/ganesha/ganesha.conf")
logger.info("[OK] ganesha.conf written")

Expand Down
39 changes: 36 additions & 3 deletions tests/dev_space/test_fsal.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ def test_bringup_cephfs(remote_sessions, reserved_nodes):
ganesha_setup = GaneshaManager(
session=server,
subvol_path=subvol_path,
cephfs_name=ceph_setup.cephfs_name
cephfs_name=ceph_setup.cephfs_name,
ganesha_opts={
"delegations_v4": "true",
"delegations_export": "readwrite",
"ceph_async": "false",
}
)
ganesha_setup.setup()
assert f"CephFS setup completed"
Expand All @@ -228,6 +233,34 @@ def test_cthon(remote_sessions, reserved_nodes):

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

'''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this is commented?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes since full setup(installation of ceph) is already done, it fails to install it again.

@pytest.mark.timeout(1200)
def test_delegation(remote_sessions, reserved_nodes):
logger.info("[TEST START]: Update ganesha conf with delegation parameters")

server = remote_sessions["servers"][0]
if len(remote_sessions["servers"]) > 1:
ceph_setup = CephGaneshaSetup(session=server, extra_sessions=remote_sessions["servers"][1:])
else:
ceph_setup = CephGaneshaSetup(session=remote_sessions["servers"][0])

subvol_path = ceph_setup.full_setup()

ganesha_setup = GaneshaManager(
session=server,
subvol_path=subvol_path,
cephfs_name=ceph_setup.cephfs_name,
ganesha_opts={
"delegations_v4": "true",
"delegations_export": "readwrite",
"ceph_async": "false",
}
)
ganesha_setup.setup()

logger.info("Delegation updation completed")
'''

def test_pynfs(remote_sessions, reserved_nodes):
logger.info("[TEST START]: PyNFS with CephFS")

Expand All @@ -240,5 +273,5 @@ def test_pynfs(remote_sessions, reserved_nodes):
pynfs = PyNFSManager(session=client, server_ip=server_ip, backend_type="ceph")
_, failure_summary, code = pynfs.run_all_tests(export="/nfs/cephfs")
logger.info("PyNFS test failure summary: %s", failure_summary)
assert code == 0, f"PyNFS CephFS tests failed"

assert code == 0, f"PyNFS CephFS tests failed"
7 changes: 6 additions & 1 deletion tests/test_pynfs_cthon.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ def test_pynfs_cephfs(create_session, cmake_flags):
session=server_session,
subvol_path=subvol_path,
cephfs_name=ceph_setup.cephfs_name,
test_type="pynfs"
test_type="pynfs",
ganesha_opts={
"delegations_v4": "true",
"delegations_export": "readwrite",
"ceph_async": "false",
}
)
ganesha_setup.setup()

Expand Down