From ebc901ce5bc92bd791b4df92f54cfaeedc318d1e Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Fri, 6 Sep 2024 01:23:02 -0400 Subject: [PATCH 1/5] tests/fs/lustre: add boot.ktest This just boots using the kernel required for Lustre. I find myself doing this quite often with llmount.ktest. An explicit boot.ktest would be helpful. Signed-off-by: Timothy Day --- tests/fs/lustre/boot.ktest | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tests/fs/lustre/boot.ktest diff --git a/tests/fs/lustre/boot.ktest b/tests/fs/lustre/boot.ktest new file mode 100755 index 0000000..ee15940 --- /dev/null +++ b/tests/fs/lustre/boot.ktest @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# +# Copyright (c) 2024, Amazon and/or its affiliates. All rights reserved. +# Use is subject to license terms. +# + +# +# Just boot using the Lustre kernel config +# +# Author: Timothy Day +# + +. "$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/lustre-libs.sh" + +require-lustre-kernel-config +require-lustre-debug-kernel-config + +config-mem 10G +config-timeout 60 + +test_llmount() +{ + echo boot +} + +main "$@" From c7fd44c79e7a7496f7bc15b66983b0098b5b2885 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Mon, 9 Sep 2024 23:04:57 -0400 Subject: [PATCH 2/5] tests/fs/lustre: add test to setup/teardown MGT Simple setup/teardown test for MGT. This is the simpliest Lustre storage target - so this testing is useful for simple functional testing of an OSD. Signed-off-by: Timothy Day --- tests/fs/lustre/lustre-libs.sh | 19 +++++++++++++++++++ tests/fs/lustre/mgs-setup.ktest | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 tests/fs/lustre/mgs-setup.ktest diff --git a/tests/fs/lustre/lustre-libs.sh b/tests/fs/lustre/lustre-libs.sh index 5a051a0..ebf1ec4 100644 --- a/tests/fs/lustre/lustre-libs.sh +++ b/tests/fs/lustre/lustre-libs.sh @@ -64,6 +64,25 @@ function require-lustre-debug-kernel-config() require-kernel-config KASAN_VMALLOC } +function load_lustre_modules() +{ + load_zfs_modules + + "$lustre_pkg_path/lustre/tests/llmount.sh" --load-modules +} + +function setup_lustre_mgs() +{ + zpool create lustre-mgs "${ktest_scratch_dev[0]}" + "$lustre_pkg_path/lustre/utils/mkfs.lustre" --mgs --fsname=lustre lustre-mgs/mgs + mkdir -p /mnt/lustre-mgs + mount -t lustre lustre-mgs/mgs /mnt/lustre-mgs + + sleep 5 + + umount -t lustre /mnt/lustre-mgs +} + function setup_lustrefs() { load_zfs_modules diff --git a/tests/fs/lustre/mgs-setup.ktest b/tests/fs/lustre/mgs-setup.ktest new file mode 100755 index 0000000..382f381 --- /dev/null +++ b/tests/fs/lustre/mgs-setup.ktest @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# +# Copyright (c) 2024, Amazon and/or its affiliates. All rights reserved. +# Use is subject to license terms. +# + +# +# Run a simple mount test (client and server). This currently +# only works with ZFS. +# +# Author: Timothy Day +# + +. "$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/lustre-libs.sh" + +require-lustre-kernel-config +require-lustre-debug-kernel-config + +config-mem 10G +config-timeout 60 + +config-scratch-devs 512M + +test_llmount() +{ + load_lustre_modules + setup_lustre_mgs +} + +main "$@" From f552940f826c13bbfacc93c3ec61c647728d7fb4 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Tue, 10 Sep 2024 00:00:53 -0400 Subject: [PATCH 3/5] tests/fs/lustre: allow multiple OSD types Use the Lustre environment variable FSTYPE to allow for different backing OSDs to be used with the Lustre ktests. Signed-off-by: Timothy Day --- tests/fs/lustre/llmount.ktest | 4 +- tests/fs/lustre/lustre-libs.sh | 66 +++++++++++++++++++++++++----- tests/fs/lustre/mgs-setup.ktest | 8 +++- tests/fs/lustre/sanity-quick.ktest | 2 +- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/tests/fs/lustre/llmount.ktest b/tests/fs/lustre/llmount.ktest index fe583bb..dec16f6 100755 --- a/tests/fs/lustre/llmount.ktest +++ b/tests/fs/lustre/llmount.ktest @@ -7,8 +7,8 @@ # # -# Run a simple mount test (client and server). This currently -# only works with ZFS. +# Run a simple mount test (client and server). The backing OSD is +# specified with FSTYPE. # # Author: Timothy Day # diff --git a/tests/fs/lustre/lustre-libs.sh b/tests/fs/lustre/lustre-libs.sh index ebf1ec4..85bfd2d 100644 --- a/tests/fs/lustre/lustre-libs.sh +++ b/tests/fs/lustre/lustre-libs.sh @@ -23,7 +23,7 @@ export zfs_pkg_path="$workspace_path/zfs" # Set Lustre test-framework.sh environment export ZFS="$zfs_pkg_path/cmd/zfs/zfs" export ZPOOL="$zfs_pkg_path/cmd/zpool/zpool" -export FSTYPE="zfs" +export LUSTRE="$lustre_pkg_path/lustre" export RUNAS_ID="1000" # Update paths @@ -33,6 +33,31 @@ export LD_LIBRARY_PATH="$zfs_pkg_path/lib/libzfs/.libs:$zfs_pkg_path/lib/libzfs_ export LD_LIBRARY_PATH="$zfs_pkg_path/lib/libuutil/.libs:$zfs_pkg_path/lib/libnvpair/.libs:$LD_LIBRARY_PATH" set -u +# Dump out all of the special Lustre variables +function print_lustre_env() { + echo "FSTYPE=$FSTYPE" +} + +# Run a command as if it were part of test-framework.sh +function run_tf() { + cat << EOF | bash +. "$LUSTRE/tests/test-framework.sh" > /dev/null +init_test_env > /dev/null +$@ +EOF +} + +# Grab special Lustre environment variables +# TODO: There's probably a better way to do this... +set +u +if [[ -n $FSTYPE ]]; then + rm -f /tmp/ktest-lustre.env + print_lustre_env > /tmp/ktest-lustre.env +else + eval $(cat /host/tmp/ktest-lustre.env) +fi +set -u + function load_zfs_modules() { insmod "$zfs_pkg_path/module/spl/spl.ko" @@ -66,33 +91,54 @@ function require-lustre-debug-kernel-config() function load_lustre_modules() { - load_zfs_modules + if [[ "$FSTYPE" =~ "zfs" ]]; then + load_zfs_modules + fi - "$lustre_pkg_path/lustre/tests/llmount.sh" --load-modules + FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmount.sh" --load-modules } function setup_lustre_mgs() { - zpool create lustre-mgs "${ktest_scratch_dev[0]}" - "$lustre_pkg_path/lustre/utils/mkfs.lustre" --mgs --fsname=lustre lustre-mgs/mgs mkdir -p /mnt/lustre-mgs - mount -t lustre lustre-mgs/mgs /mnt/lustre-mgs - sleep 5 + # TODO: This logic probably belongs in llmount.sh or test-framework.sh? + case "$FSTYPE" in + zfs) + zpool create lustre-mgs "${ktest_scratch_dev[0]}" + "$lustre_pkg_path/lustre/utils/mkfs.lustre" --mgs --fsname=lustre lustre-mgs/mgs + mount -t lustre lustre-mgs/mgs /mnt/lustre-mgs + ;; + mem) + export OSD_MEM_TGT_TYPE="MGT" + export OSD_MEM_INDEX="0" + export OSD_MEM_MGS_NID="$(hostname -i)@tcp" + run_tf "$lustre_pkg_path/lustre/utils/mount.lustre" -v /mnt/lustre-mgs + ;; + *) + echo "Unsupported OSD!" + exit 1 + ;; + esac +} +function cleanup_lustre_mgs() +{ umount -t lustre /mnt/lustre-mgs } function setup_lustrefs() { - load_zfs_modules + print_lustre_env + load_lustre_modules - "$lustre_pkg_path/lustre/tests/llmount.sh" + FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmount.sh" + mount -t lustre } function cleanup_lustrefs() { - "$lustre_pkg_path/lustre/tests/llmountcleanup.sh" + FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmountcleanup.sh" } # Lustre/ZFS will always taint kernel diff --git a/tests/fs/lustre/mgs-setup.ktest b/tests/fs/lustre/mgs-setup.ktest index 382f381..3b5b644 100755 --- a/tests/fs/lustre/mgs-setup.ktest +++ b/tests/fs/lustre/mgs-setup.ktest @@ -7,8 +7,8 @@ # # -# Run a simple mount test (client and server). This currently -# only works with ZFS. +# Setup/cleanup a Lustre MGT. The backing OSD is specified +# with FSTYPE. # # Author: Timothy Day # @@ -27,6 +27,10 @@ test_llmount() { load_lustre_modules setup_lustre_mgs + + sleep 5 + + cleanup_lustre_mgs } main "$@" diff --git a/tests/fs/lustre/sanity-quick.ktest b/tests/fs/lustre/sanity-quick.ktest index a74e772..54d7b0f 100755 --- a/tests/fs/lustre/sanity-quick.ktest +++ b/tests/fs/lustre/sanity-quick.ktest @@ -22,7 +22,7 @@ test_sanity-quick() { setup_lustrefs - "$lustre_pkg_path/lustre/tests/auster" -v sanity --stop-at 16 + FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/auster" -v sanity --stop-at 16 cleanup_lustrefs } From 293041fe66a5d6a27335dc12cf5b44d971ab64a8 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 11 Sep 2024 22:41:54 -0400 Subject: [PATCH 4/5] tests/fs/lustre: llog unit tests with MGT Run the llog unit tests with a standalone MGT. Signed-off-by: Timothy Day --- tests/fs/lustre/llog-unit.ktest | 35 +++++++++++++++++++++++++++++++++ tests/fs/lustre/lustre-libs.sh | 25 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 tests/fs/lustre/llog-unit.ktest diff --git a/tests/fs/lustre/llog-unit.ktest b/tests/fs/lustre/llog-unit.ktest new file mode 100755 index 0000000..5f4c5de --- /dev/null +++ b/tests/fs/lustre/llog-unit.ktest @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# +# Copyright (c) 2024, Amazon and/or its affiliates. All rights reserved. +# Use is subject to license terms. +# + +# +# Run the llog unit tests with a stand-alone MGT. +# +# Author: Timothy Day +# + +. "$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")/lustre-libs.sh" + +require-lustre-kernel-config +require-lustre-debug-kernel-config + +config-mem 10G +config-timeout 60 + +config-scratch-devs 512M + +test_llmount() +{ + load_lustre_modules + setup_lustre_mgs + + run_llog + + cleanup_lustre_mgs +} + +main "$@" diff --git a/tests/fs/lustre/lustre-libs.sh b/tests/fs/lustre/lustre-libs.sh index 85bfd2d..0274dae 100644 --- a/tests/fs/lustre/lustre-libs.sh +++ b/tests/fs/lustre/lustre-libs.sh @@ -24,6 +24,7 @@ export zfs_pkg_path="$workspace_path/zfs" export ZFS="$zfs_pkg_path/cmd/zfs/zfs" export ZPOOL="$zfs_pkg_path/cmd/zpool/zpool" export LUSTRE="$lustre_pkg_path/lustre" +export LCTL="$LUSTRE/utils/lctl" export RUNAS_ID="1000" # Update paths @@ -47,6 +48,30 @@ $@ EOF } +# Run llog_test.ko unit tests +function run_llog() { + export MGS="$($LCTL dl | awk '/mgs/ { print $4 }')" + + cat << EOF | bash +. "$LUSTRE/tests/test-framework.sh" > /dev/null +init_test_env > /dev/null + +# Load module +load_module kunit/llog_test || error "load_module failed" + +# Using ignore_errors will allow lctl to cleanup even if the test fails. +$LCTL mark "Attempt llog unit tests" +eval "$LCTL <<-EOF || RC=2 + attach llog_test llt_name llt_uuid + ignore_errors + setup $MGS + --device llt_name cleanup + --device llt_name detach +EOF" +$LCTL mark "Finish llog units tests" +EOF +} + # Grab special Lustre environment variables # TODO: There's probably a better way to do this... set +u From 01ff77bead0ade9d65ab1c731e12c942070695b8 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Thu, 12 Sep 2024 00:25:49 -0400 Subject: [PATCH 5/5] tests/fs/lustre: disable identity_upcall on MDT The in-memory OSD doesn't like the identity_upcall. So disable it for now. Signed-off-by: Timothy Day --- tests/fs/lustre/lustre-libs.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/fs/lustre/lustre-libs.sh b/tests/fs/lustre/lustre-libs.sh index 0274dae..24917d3 100644 --- a/tests/fs/lustre/lustre-libs.sh +++ b/tests/fs/lustre/lustre-libs.sh @@ -158,6 +158,10 @@ function setup_lustrefs() load_lustre_modules FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmount.sh" + + # Disable identity upcall (for OSD mem) + "$LCTL" set_param mdt.*.identity_upcall=NONE + mount -t lustre }