Skip to content

Commit beef73a

Browse files
committed
[Enhancement]: Introduce Custom cmake flags for Gatecheck jobs and Centralise
Signed-off-by: Manimaran-MM <manim@redhat.com>
1 parent c97c4e0 commit beef73a

File tree

7 files changed

+192
-29
lines changed

7 files changed

+192
-29
lines changed

ci_utils/config/cmake_flags.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
default:
2+
- "-DCMAKE_BUILD_TYPE=Maintainer"
3+
- "-DUSE_ADMIN_TOOLS=ON"
4+
- "-DUSE_DBUS=ON"
5+
6+
tests:
7+
test_fsal_cephfs:
8+
- "-DUSE_FSAL_GLUSTER=OFF"
9+
- "-DUSE_FSAL_CEPH=ON"
10+
- "-DUSE_FSAL_RGW=OFF"
11+
- "-DUSE_FSAL_GPFS=OFF"
12+
- "-DUSE_FSAL_VFS=OFF"
13+
14+
test_fsal_rgw:
15+
- "-DUSE_FSAL_GLUSTER=OFF"
16+
- "-DUSE_FSAL_CEPH=OFF"
17+
- "-DUSE_FSAL_RGW=ON"
18+
- "-DUSE_FSAL_GPFS=OFF"
19+
- "-DUSE_FSAL_VFS=OFF"
20+
21+
test_fsal_vfs:
22+
- "-DUSE_FSAL_VFS=ON"
23+
- "-DUSE_FSAL_GLUSTER=OFF"
24+
- "-DUSE_FSAL_CEPH=OFF"
25+
- "-DUSE_FSAL_RGW=OFF"
26+
- "-DUSE_FSAL_GPFS=OFF"
27+
- "-DUSE_MONITORING=ON"
28+
29+
test_fsal_gpfs:
30+
- "-DUSE_FSAL_GLUSTER=OFF"
31+
- "-DUSE_FSAL_CEPH=OFF"
32+
- "-DUSE_FSAL_RGW=OFF"
33+
- "-DUSE_FSAL_VFS=OFF"
34+
- "-DUSE_GUI_ADMIN_TOOLS=OFF"
35+
- "-D_MSPAC_SUPPORT=ON"
36+
- "-DRADOS_URLS=OFF"
37+
- "-DUSE_RADOS_RECOV=OFF"
38+
- "-DUSE_9P=OFF"
39+
- "-DUSE_FSAL_NULL=OFF"
40+
- "-DUSE_FSAL_XFS=OFF"
41+
- "-DUSE_FSAL_MEM=OFF"
42+
- "-DUSE_FSAL_LUSTRE=OFF"
43+
- "-DUSE_FSAL_PROXY_V4=OFF"
44+
- "-DUSE_FSAL_PROXY_V3=OFF"
45+
- "-DUSE_FSAL_KVSFS=OFF"
46+
- "-DUSE_FSAL_GPFS=ON"
47+
- "-DMONITORING=ON"
48+
- "-DUSE_MONITORING=ON"

ci_utils/nfs_ganesha/gpfs_ganesha_setup.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99

1010
class GPFSGaneshaManager:
11-
def __init__(self, session, export="/ibm/fs1", system_type="centos"):
11+
def __init__(self, session, export="/ibm/fs1", system_type="centos", cmake_flags=None):
1212
"""Handles GPFS and NFS-Ganesha installation and setup on a VM.
1313
Args:
1414
session (RemoteSession): Remote session to the VM.
1515
"""
1616
self.session = session
1717
self.export = export
1818
self.system_type = system_type
19+
self.cmake_flags = cmake_flags
1920

2021
# -------------------------------
2122
# Helpers
@@ -72,7 +73,7 @@ def _build_from_source(self, test_workspace: str):
7273
logger.info("[STEP]: Building Ganesha from source...")
7374

7475
BASE_PACKAGES="git bison flex cmake gcc-c++ libacl-devel krb5-devel dbus-devel rpm-build redhat-rpm-config gdb"
75-
BUILDREQUIRES_EXTRA="libnsl2-devel libnfsidmap-devel libwbclient-devel userspace-rcu-devel libcephfs-devel"
76+
BUILDREQUIRES_EXTRA="libnsl2-devel libnfsidmap-devel libwbclient-devel userspace-rcu-devel libcephfs-devel python3-devel"
7677

7778
if self.system_type == "centos":
7879
repo_name = "crb"
@@ -100,9 +101,7 @@ def _build_from_source(self, test_workspace: str):
100101
out, code = run_cmd(self.session, [
101102
f"bash -c 'cd {src_dir} && rm -rf {build_dir} && "
102103
f"mkdir -p {build_dir} && cd {build_dir} && "
103-
f"{cmake_binary} {src_dir}/src -DCMAKE_BUILD_TYPE=Maintainer "
104-
"-DUSE_FSAL_GPFS=ON -DUSE_DBUS=ON -D_MSPAC_SUPPORT=OFF "
105-
"-DMONITORING=ON -DUSE_MONITORING=ON && make dist'"
104+
f"{cmake_binary} {src_dir}/src {self.cmake_flags} && make dist'"
106105
])
107106

108107
logger.info("GPFS Make CephFS output: %s", out)
@@ -146,7 +145,13 @@ def _build_from_source(self, test_workspace: str):
146145
logger.info("NTIRPC Version: %s", ntirpc_version)
147146
logger.info("NTIRPC RPM: %s", ntirpc_rpm)
148147

149-
run_cmd(self.session, f"bash -c 'cd {build_dir} && rpm -e gpfs.nfs-ganesha gpfs.nfs-ganesha-gpfs --nodeps'", check=False)
148+
run_cmd(
149+
self.session,
150+
'\"bash -c \'rpm -e --nodeps \$(rpm -qa | grep \"^gpfs\\.nfs-ganesha\")\'\"',
151+
check=False
152+
)
153+
154+
run_cmd(self.session, f"\"bash -c 'rpm -qa | grep gpfs.nfs-ganesha'\"", check=False)
150155
out, _ = run_cmd(self.session, f"ls {build_dir}/x86_64/*.rpm")
151156
rpm_files_x86 = out.strip().splitlines()
152157

ci_utils/nfs_ganesha/vfs_nfs_ganesha_setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77

88
class VFSGaneshaManager:
9-
def __init__(self, session):
9+
def __init__(self, session, cmake_flags=None):
1010
"""Handles VFS and NFS-Ganesha installation and setup on a VM.
1111
Args:
1212
session (RemoteSession): Remote session to the VM.
1313
"""
1414
self.session = session
15+
self.cmake_flags = cmake_flags
1516

1617
# -------------------------------
1718
# Install Ganesha with VFS support
@@ -43,10 +44,7 @@ def _build_from_source(self, test_workspace: str):
4344
"rm -rf build && "
4445
"mkdir -p build && "
4546
"cd build && "
46-
"cmake ../src -DCMAKE_BUILD_TYPE=Maintainer "
47-
"-DUSE_FSAL_VFS=ON -DUSE_FSAL_GLUSTER=OFF "
48-
"-DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=OFF "
49-
"-DUSE_FSAL_GPFS=OFF -DUSE_MONITORING=ON && "
47+
f"cmake ../src {self.cmake_flags} && "
5048
"make dist"
5149
)
5250

ci_utils/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pytest==7.0.1
22
pytest-xdist==3.0.2
33
GitPython==3.1.18
4-
pytest-timeout==2.1.0
4+
pytest-timeout==2.1.0
5+
pyyaml==6.0.1

tests/test_checkpatch_fsal.py

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import os
2+
import pathlib
3+
4+
import yaml
25
from ci_utils.common.remote_session import RemoteSession
36
import pytest
47
from ci_utils.common.logger import get_logger
@@ -26,6 +29,20 @@ def server_node():
2629
session_data = read_json_file(SESSION_FILE)
2730
return session_data.get("nodes")[0]
2831

32+
@pytest.fixture(scope="session")
33+
def cmake_config():
34+
# Find repo root based on THIS file's location
35+
this_file = pathlib.Path(__file__).resolve()
36+
37+
# Navigate to ci_utils/config/cmake_flags.yml relative to this conftest
38+
config_path = this_file.parent.parent / "ci_utils" / "config" / "cmake_flags.yml"
39+
40+
if not config_path.exists():
41+
raise FileNotFoundError(f"CMake flag config not found: {config_path}")
42+
43+
with config_path.open() as f:
44+
return yaml.safe_load(f)
45+
2946
# -----------------------
3047
# Fixtures - Test level
3148
# -----------------------
@@ -50,6 +67,26 @@ def create_session(server_node, request):
5067
yield session, default_dir # Yield both session and default dir
5168
session.close()
5269

70+
@pytest.fixture
71+
def cmake_flags(request, cmake_config):
72+
test_name = request.node.name
73+
yaml_default = cmake_config.get("default", [])
74+
yaml_test_specific = cmake_config.get("tests", {}).get(test_name, [])
75+
logger.info(f"Getting default values: {os.environ}")
76+
77+
# ENV variable: general flags
78+
env_flags = os.getenv("CMAKE_FLAGS", "")
79+
env_flags_list = env_flags.split(",") if env_flags else []
80+
81+
# ENV override?
82+
override = os.getenv("CMAKE_OVERRIDE", "").lower() in ("1", "true", "yes")
83+
84+
if override:
85+
# Jenkins wants to ignore YAML entirely
86+
return env_flags_list
87+
88+
# Merge YAML and CLI (YAML first, then CLI append / override)
89+
return yaml_default + yaml_test_specific + env_flags_list
5390
# ---------------------------------------------------------
5491
# Helper function to log results to summary file
5592
# ---------------------------------------------------------
@@ -219,18 +256,21 @@ def test_clang_format(create_session, server_node):
219256
# TEST 3: FSAL build tests - CephFS
220257
# Required Node: 1
221258
# -----------------------
222-
def test_fsal_cephfs(create_session):
259+
def test_fsal_cephfs(create_session, cmake_flags):
223260
logger.info("[TEST] Running FSAL CephFS test")
224261
remote_session, test_workspace = create_session
225262
logger.info("TEST WORKSPACE: %s", test_workspace)
226263

264+
flag_str = " ".join(cmake_flags)
265+
logger.info("Using CMake flags: %s", flag_str)
266+
227267
out, code = run_cmd(
228268
remote_session,
229269
f"cd {test_workspace}/nfs-ganesha && "
230270
"rm -rf build && "
231271
"mkdir -p build && "
232272
"cd build && "
233-
"cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=ON -DUSE_FSAL_RGW=OFF -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
273+
f"cmake ../src {flag_str} && "
234274
"make", check=False
235275
)
236276

@@ -248,18 +288,21 @@ def test_fsal_cephfs(create_session):
248288
# TEST 4: FSAL build tests - GPFS
249289
# Required Node: 1
250290
# -----------------------
251-
def test_fsal_gpfs(create_session):
291+
def test_fsal_gpfs(create_session, cmake_flags):
252292
logger.info("[TEST] Running FSAL GPFS test")
253293
remote_session, test_workspace = create_session
254294
logger.info("TEST WORKSPACE: %s", test_workspace)
255295

296+
flag_str = " ".join(cmake_flags)
297+
logger.info("Using CMake flags: %s", flag_str)
298+
256299
out, code = run_cmd(
257300
remote_session,
258301
f"cd {test_workspace}/nfs-ganesha && "
259302
"rm -rf build && "
260303
"mkdir -p build && "
261304
"cd build && "
262-
"cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=OFF -DUSE_FSAL_GPFS=ON -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
305+
f"cmake ../src {flag_str} && "
263306
"make", check=False
264307
)
265308

@@ -277,18 +320,21 @@ def test_fsal_gpfs(create_session):
277320
# TEST 5: FSAL build tests - RGW
278321
# Required Node: 1
279322
# -----------------------
280-
def test_fsal_rgw(create_session):
323+
def test_fsal_rgw(create_session, cmake_flags):
281324
logger.info("[TEST] Running FSAL RGW test")
282325
remote_session, test_workspace = create_session # Unpack the tuple
283326
logger.info("TEST WORKSPACE: %s", test_workspace)
284327

328+
flag_str = " ".join(cmake_flags)
329+
logger.info("Using CMake flags: %s", flag_str)
330+
285331
out, code = run_cmd(
286332
remote_session,
287333
f"cd {test_workspace}/nfs-ganesha && "
288334
"rm -rf build && "
289335
"mkdir -p build && "
290336
"cd build && "
291-
"cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=ON -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
337+
f"cmake ../src {flag_str} && "
292338
"make", check=False
293339
)
294340

@@ -306,18 +352,21 @@ def test_fsal_rgw(create_session):
306352
# TEST 6: FSAL build tests - VFS
307353
# Required Node: 1
308354
# -----------------------
309-
def test_fsal_vfs(create_session):
355+
def test_fsal_vfs(create_session, cmake_flags):
310356
logger.info("[TEST] Running FSAL VFS test")
311357
remote_session, test_workspace = create_session
312358
logger.info("TEST WORKSPACE: %s", test_workspace)
313359

360+
flag_str = " ".join(cmake_flags)
361+
logger.info("Using CMake flags: %s", flag_str)
362+
314363
out, code = run_cmd(
315364
remote_session,
316365
f"cd {test_workspace}/nfs-ganesha && "
317366
"rm -rf build && "
318367
"mkdir -p build && "
319368
"cd build && "
320-
"cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_VFS=ON -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=OFF -DUSE_FSAL_GPFS=OFF -DUSE_MONITORING=ON && "
369+
f"cmake ../src {flag_str} && "
321370
"make", check=False
322371
)
323372

tests/test_ci_pre_req.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def setup_node_vfs(server_node):
167167
version = duffy_session.centos_version
168168

169169
build_requires_vfs = "git bison flex cmake gcc-c++ libacl-devel krb5-devel dbus-devel rpm-build redhat-rpm-config gdb libblkid-devel libcap-devel libgfapi-devel xfsprogs-devel"
170-
build_requires_extra_vfs= "libnsl2-devel libnfsidmap-devel libwbclient-devel userspace-rcu-devel libcephfs-devel"
170+
build_requires_extra_vfs= "libnsl2-devel libnfsidmap-devel libwbclient-devel userspace-rcu-devel libcephfs-devel python3-devel"
171171
build_requires_add_on_vfs = "selinux-policy-devel sqlite"
172172

173173
if version.startswith("9"):

0 commit comments

Comments
 (0)