Skip to content

Commit 12d3ab2

Browse files
committed
ZTS: Add LUKS sanity test
Add a LUKS sanity test to trigger: #16631 Signed-off-by: Tony Hutter <[email protected]>
1 parent aefc2da commit 12d3ab2

File tree

5 files changed

+117
-18
lines changed

5 files changed

+117
-18
lines changed

.github/workflows/scripts/qemu-3-deps.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function archlinux() {
1313
echo "##[endgroup]"
1414

1515
echo "##[group]Install Development Tools"
16-
sudo pacman -Sy --noconfirm base-devel bc cpio dhclient dkms fakeroot \
17-
fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils parted \
18-
pax perf python-packaging python-setuptools qemu-guest-agent ksh samba \
19-
sysstat rng-tools rsync wget xxhash
16+
sudo pacman -Sy --noconfirm base-devel bc cpio cryptsetup dhclient dkms \
17+
fakeroot fio gdb inetutils jq less linux linux-headers lsscsi nfs-utils \
18+
parted pax perf python-packaging python-setuptools qemu-guest-agent ksh \
19+
samba sysstat rng-tools rsync wget xxhash
2020
echo "##[endgroup]"
2121
}
2222

@@ -30,11 +30,11 @@ function debian() {
3030

3131
echo "##[group]Install Development Tools"
3232
sudo apt-get install -y \
33-
acl alien attr autoconf bc cpio curl dbench dh-python dkms fakeroot \
34-
fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev libaio-dev \
35-
libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev libelf-dev \
36-
libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev libtool \
37-
libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \
33+
acl alien attr autoconf bc cpio cryptsetup curl dbench dh-python dkms \
34+
fakeroot fio gdb gdebi git ksh lcov isc-dhcp-client jq libacl1-dev \
35+
libaio-dev libattr1-dev libblkid-dev libcurl4-openssl-dev libdevmapper-dev \
36+
libelf-dev libffi-dev libmount-dev libpam0g-dev libselinux-dev libssl-dev \
37+
libtool libtool-bin libudev-dev libunwind-dev linux-headers-$(uname -r) \
3838
lsscsi nfs-kernel-server pamtester parted python3 python3-all-dev \
3939
python3-cffi python3-dev python3-distlib python3-packaging \
4040
python3-setuptools python3-sphinx qemu-guest-agent rng-tools rpm2cpio \
@@ -68,14 +68,15 @@ function rhel() {
6868
echo "##[group]Install Development Tools"
6969
sudo dnf group install -y "Development Tools"
7070
sudo dnf install -y \
71-
acl attr bc bzip2 curl dbench dkms elfutils-libelf-devel fio gdb git \
72-
jq kernel-rpm-macros ksh libacl-devel libaio-devel libargon2-devel \
73-
libattr-devel libblkid-devel libcurl-devel libffi-devel ncompress \
74-
libselinux-devel libtirpc-devel libtool libudev-devel libuuid-devel \
75-
lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester parted perf \
76-
python3 python3-cffi python3-devel python3-packaging kernel-devel \
77-
python3-setuptools qemu-guest-agent rng-tools rpcgen rpm-build rsync \
78-
samba sysstat systemd watchdog wget xfsprogs-devel xxhash zlib-devel
71+
acl attr bc bzip2 cryptsetup curl dbench dkms elfutils-libelf-devel fio \
72+
gdb git jq kernel-rpm-macros ksh libacl-devel libaio-devel \
73+
libargon2-devel libattr-devel libblkid-devel libcurl-devel libffi-devel \
74+
ncompress libselinux-devel libtirpc-devel libtool libudev-devel \
75+
libuuid-devel lsscsi mdadm nfs-utils openssl-devel pam-devel pamtester \
76+
parted perf python3 python3-cffi python3-devel python3-packaging \
77+
kernel-devel python3-setuptools qemu-guest-agent rng-tools rpcgen \
78+
rpm-build rsync samba sysstat systemd watchdog wget xfsprogs-devel xxhash \
79+
zlib-devel
7980
echo "##[endgroup]"
8081
}
8182

tests/runfiles/linux.run

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ tags = ['functional', 'largest_pool']
147147
tests = ['longname_001_pos', 'longname_002_pos', 'longname_003_pos']
148148
tags = ['functional', 'longname']
149149

150+
[tests/functional/luks:Linux]
151+
pre =
152+
post =
153+
tests = ['luks_sanity']
154+
tags = ['functional', 'luks']
155+
150156
[tests/functional/mmap:Linux]
151157
tests = ['mmap_libaio_001_pos', 'mmap_sync_001_pos']
152158
tags = ['functional', 'mmap']

tests/zfs-tests/include/commands.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export SYSTEM_FILES_LINUX='attr
129129
blkdiscard
130130
blockdev
131131
chattr
132+
cryptsetup
132133
exportfs
133134
fallocate
134135
flock

tests/zfs-tests/tests/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ if BUILD_LINUX
8080
nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
8181
functional/simd/simd_supported.ksh \
8282
functional/tmpfile/cleanup.ksh \
83-
functional/tmpfile/setup.ksh
83+
functional/tmpfile/setup.ksh \
84+
functional/luks/luks_sanity.ksh
8485
endif
8586

8687
nobase_dist_datadir_zfs_tests_tests_DATA += \
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/ksh -p
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License (the "License").
7+
# You may not use this file except in compliance with the License.
8+
#
9+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10+
# or https://opensource.org/licenses/CDDL-1.0.
11+
# See the License for the specific language governing permissions
12+
# and limitations under the License.
13+
#
14+
# When distributing Covered Code, include this CDDL HEADER in each
15+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16+
# If applicable, add the following below this CDDL HEADER, with the
17+
# fields enclosed by brackets "[]" replaced with your own identifying
18+
# information: Portions Copyright [yyyy] [name of copyright owner]
19+
#
20+
# CDDL HEADER END
21+
#
22+
23+
#
24+
# Copyright (c) 2024 by Lawrence Livermore National Security, LLC.
25+
# Use is subject to license terms.
26+
#
27+
28+
# DESCRIPTION:
29+
# Verify ZFS works on a LUKS-backed pool
30+
#
31+
# STRATEGY:
32+
# 1. Create a LUKS device
33+
# 2. Make a pool with it
34+
# 3. Write files to the pool
35+
# 4. Verify no errors
36+
37+
. $STF_SUITE/include/libtest.shlib
38+
39+
verify_runnable "both"
40+
41+
VDEV=$(mktemp --suffix=luks_sanity)
42+
TESTPOOL=testpool
43+
44+
function cleanup
45+
{
46+
log_must zpool destroy $TESTPOOL
47+
48+
log_must cryptsetup luksClose /dev/mapper/luksdev
49+
log_must rm -f $VDEV
50+
}
51+
52+
log_assert "Verify ZFS on LUKS works"
53+
log_onexit cleanup
54+
55+
PASS="fdsjfosdijfsdkjsldfjdlk"
56+
57+
# Make a small LUKS device since LUKS formatting takes time and we want to
58+
# make this test run as quickly as possible.
59+
truncate -s 100M $VDEV
60+
61+
log_must cryptsetup luksFormat --type luks2 $VDEV <<< $PASS
62+
log_must cryptsetup luksOpen $VDEV luksdev <<< $PASS
63+
64+
log_must zpool create $TESTPOOL /dev/mapper/luksdev
65+
66+
CPUS=$(get_num_cpus)
67+
68+
# Use these specific size and offset ranges as they often cause errors with
69+
# https://github.com/openzfs/zfs/issues/16631
70+
# and we want to try to test for that.
71+
for SIZE in {70..100} ; do
72+
for OFF in {70..100} ; do
73+
for i in {1..$CPUS} ; do
74+
dd if=/dev/urandom of=/$TESTPOOL/file$i-bs$SIZE-off$OFF \
75+
seek=$OFF bs=$SIZE count=1 &>/dev/null &
76+
done
77+
wait
78+
done
79+
sync_pool $TESTPOOL
80+
rm -f /$TESTPOOL/file*
81+
done
82+
83+
# Verify no read/write/checksum errors. Don't use JSON here so that we could
84+
# could potentially backport this test case to the 2.2.x branch.
85+
if zpool status -e | grep -q "luksdev" ; then
86+
log_note "$(zpool status -v)"
87+
log_fail "Saw errors writing to LUKS device"
88+
fi
89+
90+
log_pass "Verified ZFS on LUKS works"

0 commit comments

Comments
 (0)