Test suite: Fix the timeouts on the skip share check tests.
[vlendec/samba-autobuild/.git] / ctdb / tests / complex / 44_failover_nfs_oneway.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that a file created on a node is readable via NFS after a failover.
7
8 We write a file into an exported directory on a node, mount the NFS
9 share from a node, verify that we can read the file via NFS and that
10 we can still read it after a failover.
11
12 Prerequisites:
13
14 * An active CTDB cluster with at least 2 nodes with public addresses.
15
16 * Test must be run on a real or virtual cluster rather than against
17   local daemons.
18
19 * Test must not be run from a cluster node.
20
21 Steps:
22
23 1.  Verify that the cluster is healthy.
24 2.  Select a public address and its corresponding node.
25 3.  Select the 1st NFS share exported on the node.
26 4.  Write a file into exported directory on the node and calculate its
27     checksum.
28 5.  Mount the selected NFS share.
29 6.  Read the file via the NFS mount and calculate its checksum.
30 7.  Compare checksums.
31 8.  Disable the selected node.
32 9.  Read the file via NFS and calculate its checksum.
33 10. Compare the checksums.
34
35 Expected results:
36
37 * Checksums for the file on all 3 occasions should be the same.
38 EOF
39 }
40
41 . ctdb_test_functions.bash
42
43 set -e
44
45 ctdb_test_init "$@"
46
47 ctdb_test_check_real_cluster
48
49 cluster_is_healthy
50
51 # Reset configuration
52 ctdb_restart_when_done
53
54 select_test_node_and_ips
55
56 first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
57 local_f=$(mktemp)
58 mnt_d=$(mktemp -d)
59 nfs_f="${mnt_d}/$RANDOM"
60 remote_f="${test_ip}:${first_export}/$(basename $nfs_f)"
61
62 ctdb_test_exit_hook_add rm -f "$local_f"
63 ctdb_test_exit_hook_add rm -f "$nfs_f"
64 ctdb_test_exit_hook_add umount -f "$mnt_d"
65 ctdb_test_exit_hook_add rmdir "$mnt_d"
66
67 echo "Create file containing random data..."
68 dd if=/dev/urandom of=$local_f bs=1k count=1
69 chmod 644 "$local_f" # needed for *_squash?
70 local_sum=$(sum $local_f)
71 [ $? -eq 0 ]
72
73 scp -p "$local_f" "$remote_f"
74
75 echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
76 mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
77
78 nfs_sum=$(sum $nfs_f)
79
80 if [ "$local_sum" = "$nfs_sum" ] ; then
81     echo "GOOD: file contents read correctly via NFS"
82 else
83     echo "BAD: file contents are different over NFS"
84     echo "  original file: $local_sum"
85     echo "       NFS file: $nfs_sum"
86     exit 1
87 fi
88
89 gratarp_sniff_start
90
91 echo "Disabling node $test_node"
92 try_command_on_node 0 $CTDB disable -n $test_node
93 wait_until_node_has_status $test_node disabled
94
95 gratarp_sniff_wait_show
96
97 new_sum=$(sum $nfs_f)
98 [ $? -eq 0 ]
99
100 if [ "$nfs_sum" = "$new_sum" ] ; then
101     echo "GOOD: file contents unchanged after failover"
102 else
103     echo "BAD: file contents are different after failover"
104     echo "  original file: $nfs_sum"
105     echo "       NFS file: $new_sum"
106     exit 1
107 fi