[RFT] ltp: add support for running tests on NFS mounts

Luis Chamberlain <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
Add support for running LTP tests on NFS/pNFS mounts when
both CONFIG_LTP_TESTS_NFS and CONFIG_KDEVOPS_SETUP_NFSD are enabled.

Changes include:

1. Add CONFIG_LTP_RUN_TESTS_ON_NFS option to control NFS mount testing
   - Depends on both NFS test group and NFS server being enabled
   - Defaults to enabled when dependencies are met

2. Extend KDEVOPS_SETUP_NFSD dependencies to include LTP workflow
   - Allows NFS server setup for LTP testing scenarios

3. Enhance LTP role with NFS mount capability:
   - Mount NFS exports from kdevops NFS server before running tests
   - Run LTP tests in NFS mount directory (/mnt/nfs-ltp/ltp-test)
   - Use NFS v4.2 for comprehensive pNFS testing

4. Update nfs-ltp defconfig to enable full pNFS testing:
   - Enable NFS test group (CONFIG_LTP_TESTS_NFS=y)
   - Enable NFS server setup (CONFIG_KDEVOPS_SETUP_NFSD=y)
   - Enable NFS mount testing (CONFIG_LTP_RUN_TESTS_ON_NFS=y)

This enables real pNFS testing where LTP tests execute on actual NFS
mounts, providing comprehensive validation of NFS client functionality
including parallel NFS capabilities.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <[email protected]>
---

Chuck indicated LTP isn't exactly testing NFS, and indeed one needs
to manually arrange things to test LTP. But it'd be nice to just
leverage a defconfig and that's it. This will be useful for automation.

This requires further testing. I ran out of time.

 defconfigs/nfs-ltp                 | 18 ++++++-
 kconfigs/Kconfig.nfsd              |  7 +--
 playbooks/roles/ltp/tasks/main.yml | 77 +++++++++++++++++++++++++++++-
 workflows/ltp/Kconfig              | 12 +++++
 workflows/ltp/Makefile             |  6 +++
 5 files changed, 114 insertions(+), 6 deletions(-)

diff --git a/defconfigs/nfs-ltp b/defconfigs/nfs-ltp
index 4562874e..b7a9f4cd 100644
--- a/defconfigs/nfs-ltp
+++ b/defconfigs/nfs-ltp
@@ -1,5 +1,13 @@
 # pNFS configuration for Linux Test Project (LTP)
-# Note: LTP doesn't specifically test pNFS, but can run on pNFS mounts
+#
+# This defconfig sets up LTP to run tests over pNFS (parallel NFS) mounts.
+# It configures:
+# 1. An NFS server node with exports (via CONFIG_KDEVOPS_SETUP_NFSD)
+# 2. LTP with NFS test group enabled (CONFIG_LTP_TESTS_NFS)
+# 3. Automatic NFS mount setup to run tests on NFS (CONFIG_LTP_RUN_TESTS_ON_NFS)
+#
+# The LTP tests will execute on NFS v4.2 mounts, providing comprehensive
+# testing of NFS client functionality including pNFS capabilities.
 
 # Use libvirt/QEMU for virtualization
 CONFIG_GUESTFS=y
@@ -24,8 +32,14 @@ CONFIG_WORKFLOWS_DEDICATED_WORKFLOW=y
 CONFIG_KDEVOPS_WORKFLOW_DEDICATE_LTP=y
 CONFIG_KDEVOPS_WORKFLOW_ENABLE_LTP=y
 
-# Use kdevops-provided NFS server for pNFS mount
+# Enable NFS test group for pNFS testing
+CONFIG_LTP_TESTS_NFS=y
+
+# NFS server setup for pNFS testing
 CONFIG_KDEVOPS_SETUP_NFSD=y
 
+# Run LTP tests on NFS mounts (enables actual pNFS testing)
+CONFIG_LTP_RUN_TESTS_ON_NFS=y
+
 # Enable systemd journal remote for debugging
 CONFIG_DEVCONFIG_ENABLE_SYSTEMD_JOURNAL_REMOTE=y
\ No newline at end of file
diff --git a/kconfigs/Kconfig.nfsd b/kconfigs/Kconfig.nfsd
index 8463e531..b5f20416 100644
--- a/kconfigs/Kconfig.nfsd
+++ b/kconfigs/Kconfig.nfsd
@@ -2,9 +2,10 @@
 config KDEVOPS_SETUP_NFSD
 	bool "Set up the kernel nfs server"
 	depends on KDEVOPS_WORKFLOW_ENABLE_FSTESTS || \
-			   KDEVOPS_WORKFLOW_ENABLE_PYNFS || \
-			   KDEVOPS_WORKFLOW_ENABLE_NFSTEST || \
-			   KDEVOPS_WORKFLOW_ENABLE_GITR
+		KDEVOPS_WORKFLOW_ENABLE_PYNFS || \
+		KDEVOPS_WORKFLOW_ENABLE_NFSTEST || \
+		KDEVOPS_WORKFLOW_ENABLE_GITR || \
+		KDEVOPS_WORKFLOW_ENABLE_LTP
 	default n
 	help
 	  Configure and bring up the kernel NFS server. This will provision
diff --git a/playbooks/roles/ltp/tasks/main.yml b/playbooks/roles/ltp/tasks/main.yml
index 1b966771..3335f018 100644
--- a/playbooks/roles/ltp/tasks/main.yml
+++ b/playbooks/roles/ltp/tasks/main.yml
@@ -248,7 +248,64 @@
     state: reloaded
     enabled: true
 
-- name: Run ltp
+# NFS mount support for running LTP tests on NFS
+- name: Set NFS server address
+  tags: ["ltp", "run_tests"]
+  ansible.builtin.set_fact:
+    nfs_server_host: "{{ kdevops_host_prefix }}-nfs"
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Create NFS mount point for LTP tests
+  tags: ["ltp", "run_tests"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.file:
+    path: "/mnt/nfs-ltp"
+    state: directory
+    mode: "0755"
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Mount NFS export for LTP testing
+  tags: ["ltp", "run_tests"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.mount:
+    path: "/mnt/nfs-ltp"
+    src: "{{ nfs_server_host }}:{{ nfsd_export_path }}/0"
+    fstype: "nfs"
+    opts: "vers=4.2"
+    state: mounted
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Create LTP test directory on NFS mount
+  tags: ["ltp", "run_tests"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.file:
+    path: "/mnt/nfs-ltp/ltp-test"
+    state: directory
+    mode: "0777"
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Change to NFS mount directory for LTP tests
+  tags: ["run_tests"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  ansible.builtin.shell: |
+    cd /mnt/nfs-ltp/ltp-test
+    pwd
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Run ltp on local filesystem
   tags: ["run_tests"]
   become: true
   become_flags: "su - -c"
@@ -259,6 +316,24 @@
     cmd: "/opt/ltp/runltp {{ ltp_runltp_arg_dict[ltp_test_group] }}"
   changed_when: true
   failed_when: false
+  when:
+    - not ltp_run_tests_on_nfs|default(false)|bool
+
+- name: Run ltp on NFS mount
+  tags: ["run_tests"]
+  become: true
+  become_flags: "su - -c"
+  become_method: ansible.builtin.sudo
+  environment:
+    CREATE_ENTRIES: 1
+    TMPDIR: "/mnt/nfs-ltp/ltp-test"
+  ansible.builtin.command:
+    cmd: "/opt/ltp/runltp -d /mnt/nfs-ltp/ltp-test {{ ltp_runltp_arg_dict[ltp_test_group] }}"
+    chdir: "/mnt/nfs-ltp/ltp-test"
+  changed_when: true
+  failed_when: false
+  when:
+    - ltp_run_tests_on_nfs|default(false)|bool
 
 - name: Look for test results in target node's /opt/ltp/results
   tags: ["copy_results"]
diff --git a/workflows/ltp/Kconfig b/workflows/ltp/Kconfig
index 8b01dfb6..f6600394 100644
--- a/workflows/ltp/Kconfig
+++ b/workflows/ltp/Kconfig
@@ -61,6 +61,18 @@ config LTP_TESTS_TIRPC
 
 endmenu
 
+config LTP_RUN_TESTS_ON_NFS
+	bool "Run LTP tests on NFS mounts"
+	depends on LTP_TESTS_NFS && KDEVOPS_SETUP_NFSD
+	default y
+	help
+	  When enabled, LTP tests will be run on NFS mounts instead of
+	  local filesystems. This requires both NFS test group to be enabled
+	  and kdevops NFS server to be configured.
+
+	  The tests will mount NFS exports from the kdevops NFS server
+	  and run the LTP test suite on those mounts.
+
 endif # WORKFLOWS_DEDICATED_WORKFLOW
 
 config HAVE_MIRROR_LTP
diff --git a/workflows/ltp/Makefile b/workflows/ltp/Makefile
index 592c4f2b..02a43bb9 100644
--- a/workflows/ltp/Makefile
+++ b/workflows/ltp/Makefile
@@ -82,6 +82,12 @@ else
 LTP_ARGS += ltp_tests_tirpc='False'
 endif # CONFIG_LTP_TESTS_TIRPC
 
+ifeq (y,$(CONFIG_LTP_RUN_TESTS_ON_NFS))
+LTP_ARGS += ltp_run_tests_on_nfs='True'
+else
+LTP_ARGS += ltp_run_tests_on_nfs='False'
+endif # CONFIG_LTP_RUN_TESTS_ON_NFS
+
 WORKFLOW_ARGS += $(LTP_ARGS)
 WORKFLOW_ARGS_SEPARATED += ltp_enabled_test_groups='$(subst $(space),+,$(LTP_ENABLED_TEST_GROUPS))'
 
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.