]> git.decadent.org.uk Git - nfs-utils.git/blob - debian/tests/local-server-client
Import Debian patch 1:1.2.8-9.1
[nfs-utils.git] / debian / tests / local-server-client
1 #!/bin/sh
2 # install server and client, do some mounts, verify that it boots and works
3 set -e
4
5 if ! [ -x /tmp/autopkgtest-reboot ]; then
6     echo "SKIP: testbed does not support rebooting"
7     exit 0
8 fi
9
10 pre_boot_setup() {
11     # set up some exports
12     cat <<EOF >> /etc/exports
13 /home localhost(rw,no_root_squash,no_subtree_check)
14 /var/log/ localhost(ro,no_root_squash,subtree_check)
15 EOF
16
17     # set up client mounts
18     mkdir -p /mnt/nfs_home /mnt/nfs_log
19     cat << EOF >> /etc/fstab
20 localhost:/home /mnt/nfs_home nfs defaults,nofail 0 0
21 localhost:/var/log /mnt/nfs_log nfs defaults,nofail 0 0
22 EOF
23 }
24
25 fail() {
26     echo "FAIL: $1" >&2
27     exit 1
28 }
29
30 post_boot_tests() {
31     # ensure we have our mounts
32     mount | grep 'localhost:.*nfs_home' || fail "nfs_home not mounted"
33     mount | grep 'localhost:.*nfs_log' || fail "nfs_log not mounted"
34
35     # test that we can write to NFS export and get it in /home
36     [ ! -e /home/hello.txt ] || fail "/home/hello.txt already exists"
37     echo world > /mnt/nfs_home/hello.txt
38     sync
39     [ -e /home/hello.txt ] || fail "/home/hello.txt does not exist"
40     [ "$(cat /home/hello.txt)" = "world" ] || fail "/home/hello.txt has wrong contents"
41
42     # test that we can write to /home and get it in NFS
43     rm /home/hello.txt
44     sync
45     [ ! -e /mnt/nfs_home/hello.txt ] || fail "/mnt/nfs_home/hello.txt exists after removal"
46
47     # read-only, should fail
48     ! touch /mnt/nfs_log/pwned 2>/dev/null || fail "writing to r/o /mnt/nfs_log succeeded"
49
50     # our systemd jobs have a rather delicate dependency structure and run
51     # early; ensure that we did not run into any cycles
52     if [ -d /run/systemd/system ]; then
53         if journalctl | grep 'Found ordering cycle'; then
54             journalctl -p warning || true
55             fail "found ordering cycle in units"
56         fi
57     fi
58 }
59
60 if [ -z "$ADT_REBOOT_MARK" ]; then
61     pre_boot_setup
62     /tmp/autopkgtest-reboot boot1
63 else
64     post_boot_tests
65 fi