X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=debian%2Ftests%2Flocal-server-client;fp=debian%2Ftests%2Flocal-server-client;h=549ab0c42076f1f0aabbcbabc3745c682cb738a1;hp=0000000000000000000000000000000000000000;hb=afdaac552004aa553336a1775ed047896701b4e9;hpb=5f33a379be5a2695cd5d4052756a7fcb4cef2517 diff --git a/debian/tests/local-server-client b/debian/tests/local-server-client new file mode 100644 index 0000000..549ab0c --- /dev/null +++ b/debian/tests/local-server-client @@ -0,0 +1,65 @@ +#!/bin/sh +# install server and client, do some mounts, verify that it boots and works +set -e + +if ! [ -x /tmp/autopkgtest-reboot ]; then + echo "SKIP: testbed does not support rebooting" + exit 0 +fi + +pre_boot_setup() { + # set up some exports + cat <> /etc/exports +/home localhost(rw,no_root_squash,no_subtree_check) +/var/log/ localhost(ro,no_root_squash,subtree_check) +EOF + + # set up client mounts + mkdir -p /mnt/nfs_home /mnt/nfs_log + cat << EOF >> /etc/fstab +localhost:/home /mnt/nfs_home nfs defaults,nofail 0 0 +localhost:/var/log /mnt/nfs_log nfs defaults,nofail 0 0 +EOF +} + +fail() { + echo "FAIL: $1" >&2 + exit 1 +} + +post_boot_tests() { + # ensure we have our mounts + mount | grep 'localhost:.*nfs_home' || fail "nfs_home not mounted" + mount | grep 'localhost:.*nfs_log' || fail "nfs_log not mounted" + + # test that we can write to NFS export and get it in /home + [ ! -e /home/hello.txt ] || fail "/home/hello.txt already exists" + echo world > /mnt/nfs_home/hello.txt + sync + [ -e /home/hello.txt ] || fail "/home/hello.txt does not exist" + [ "$(cat /home/hello.txt)" = "world" ] || fail "/home/hello.txt has wrong contents" + + # test that we can write to /home and get it in NFS + rm /home/hello.txt + sync + [ ! -e /mnt/nfs_home/hello.txt ] || fail "/mnt/nfs_home/hello.txt exists after removal" + + # read-only, should fail + ! touch /mnt/nfs_log/pwned 2>/dev/null || fail "writing to r/o /mnt/nfs_log succeeded" + + # our systemd jobs have a rather delicate dependency structure and run + # early; ensure that we did not run into any cycles + if [ -d /run/systemd/system ]; then + if journalctl | grep 'Found ordering cycle'; then + journalctl -p warning || true + fail "found ordering cycle in units" + fi + fi +} + +if [ -z "$ADT_REBOOT_MARK" ]; then + pre_boot_setup + /tmp/autopkgtest-reboot boot1 +else + post_boot_tests +fi