Skip to content

Commit 8f9ad06

Browse files
mmatsuyaLaszloGombos
authored andcommitted
feat(test): nfs_fetch_url test into nfs test
This is to check the behavior of nfs_fetch_url() in nfs-lib.sh. nfs_fetch_url() calls nfs_already_mounted() internally. A file /nfs/client/root/fetchfile is on NFS server, which is fetched from clients for testing with nfs_fetch_url().
1 parent 966b6ce commit 8f9ad06

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/TEST-20-NFS/client-init.sh

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
: > /dev/watchdog
33
. /lib/dracut-lib.sh
4+
. /lib/url-lib.sh
45

56
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
67
command -v plymouth > /dev/null 2>&1 && plymouth --quit
@@ -23,6 +24,25 @@ while read -r dev _ fstype opts rest || [ -n "$dev" ]; do
2324
break
2425
done < /proc/mounts
2526

27+
if [ "$fstype" = "nfs" -o "$fstype" = "nfs4" ]; then
28+
29+
serverip=${dev%:*}
30+
path=${dev#*:}
31+
echo serverip="${serverip}"
32+
echo path="${path}"
33+
echo /proc/mounts status
34+
cat /proc/mounts
35+
36+
echo test:nfs_fetch_url nfs::"${serverip}":"${path}"/root/fetchfile
37+
if nfs_fetch_url nfs::"${serverip}":"${path}"/root/fetchfile /run/nfsfetch.out; then
38+
echo nfsfetch-OK
39+
echo "nfsfetch-OK" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker2
40+
fi
41+
else
42+
echo nfsfetch-BYPASS fstype="${fstype}"
43+
echo "nfsfetch-OK" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker2
44+
fi
45+
2646
: > /dev/watchdog
2747

2848
sync

test/TEST-20-NFS/test.sh

+12
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ client_test() {
5757

5858
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
5959
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
60+
dd if=/dev/zero of="$TESTDIR"/marker2.img bs=1MiB count=1
6061
declare -a disk_args=()
6162
# shellcheck disable=SC2034
6263
declare -i disk_index=0
6364
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
65+
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker2.img marker2
6466
cmdline="$cmdline rd.net.timeout.dhcp=30"
6567

6668
"$testdir"/run-qemu \
@@ -115,6 +117,11 @@ client_test() {
115117
return 1
116118
fi
117119

120+
if ! grep -U --binary-files=binary -F -m 1 -q nfsfetch-OK "$TESTDIR"/marker2.img; then
121+
echo "CLIENT TEST END: $test_name [FAILED - NFS FETCH FAILED]"
122+
return 1
123+
fi
124+
118125
echo "CLIENT TEST END: $test_name [OK]"
119126
return 0
120127
}
@@ -257,6 +264,7 @@ test_setup() {
257264
done
258265
type -P portmap > /dev/null && inst_multiple portmap
259266
type -P rpcbind > /dev/null && inst_multiple rpcbind
267+
260268
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
261269
type -P dhcpd > /dev/null && inst_multiple dhcpd
262270
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
@@ -302,6 +310,7 @@ test_setup() {
302310
(
303311
cd "$initdir" || exit
304312
mkdir -p dev sys proc etc run root usr var/lib/nfs/rpc_pipefs
313+
echo "TEST FETCH FILE" > root/fetchfile
305314
)
306315

307316
inst_multiple sh shutdown poweroff stty cat ps ln ip dd \
@@ -315,6 +324,9 @@ test_setup() {
315324

316325
inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
317326
inst_simple "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh"
327+
inst_simple "${basedir}/modules.d/45url-lib/url-lib.sh" "/lib/url-lib.sh"
328+
inst_simple "${basedir}/modules.d/40network/net-lib.sh" "/lib/net-lib.sh"
329+
inst_simple "${basedir}/modules.d/95nfs/nfs-lib.sh" "/lib/nfs-lib.sh"
318330
inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util"
319331
ln -s dracut-util "${initdir}/usr/bin/dracut-getarg"
320332
ln -s dracut-util "${initdir}/usr/bin/dracut-getargs"

0 commit comments

Comments
 (0)