Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic OSD tests #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions tests/fs/lustre/boot.ktest
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
#

. "$(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 "$@"
4 changes: 2 additions & 2 deletions tests/fs/lustre/llmount.ktest
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
#
Expand Down
35 changes: 35 additions & 0 deletions tests/fs/lustre/llog-unit.ktest
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
#

. "$(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 "$@"
102 changes: 98 additions & 4 deletions tests/fs/lustre/lustre-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ 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 LCTL="$LUSTRE/utils/lctl"
export RUNAS_ID="1000"

# Update paths
Expand All @@ -33,6 +34,55 @@ 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
}

# 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
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"
Expand Down Expand Up @@ -64,16 +114,60 @@ function require-lustre-debug-kernel-config()
require-kernel-config KASAN_VMALLOC
}

function load_lustre_modules()
{
if [[ "$FSTYPE" =~ "zfs" ]]; then
load_zfs_modules
fi

FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmount.sh" --load-modules
}

function setup_lustre_mgs()
{
mkdir -p /mnt/lustre-mgs

# 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

FSTYPE="$FSTYPE" "$lustre_pkg_path/lustre/tests/llmount.sh"

# Disable identity upcall (for OSD mem)
"$LCTL" set_param mdt.*.identity_upcall=NONE

"$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
Expand Down
36 changes: 36 additions & 0 deletions tests/fs/lustre/mgs-setup.ktest
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/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.
#

#
# Setup/cleanup a Lustre MGT. The backing OSD is specified
# with FSTYPE.
#
# Author: Timothy Day <[email protected]>
#

. "$(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

sleep 5

cleanup_lustre_mgs
}

main "$@"
2 changes: 1 addition & 1 deletion tests/fs/lustre/sanity-quick.ktest
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down