TMP: add a ctdb snapshot of current ctdb master (git://git.samba.org/ctdb.git) to...
[obnox/samba/samba-obnox.git] / ctdb / tests / complex / 43_failover_nfs_basic.sh
1 #!/bin/bash
2
3 test_info()
4 {
5     cat <<EOF
6 Verify that a mounted NFS share is still operational after failover.
7
8 We mount an NFS share from a node, write a file via NFS and then
9 confirm that we can correctly read the file after a failover.
10
11 Prerequisites:
12
13 * An active CTDB cluster with at least 2 nodes with public addresses.
14
15 * Test must be run on a real or virtual cluster rather than against
16   local daemons.
17
18 * Test must not be run from a cluster node.
19
20 Steps:
21
22 1. Verify that the cluster is healthy.
23 2. Select a public address and its corresponding node.
24 3. Select the 1st NFS share exported on the node.
25 4. Mount the selected NFS share.
26 5. Create a file in the NFS mount and calculate its checksum.
27 6. Disable the selected node.
28 7. Read the file and calculate its checksum.
29 8. Compare the checksums.
30
31 Expected results:
32
33 * When a node is disabled the public address fails over and it is
34   possible to correctly read a file over NFS.  The checksums should be
35   the same before and after.
36 EOF
37 }
38
39 . ctdb_test_functions.bash
40
41 set -e
42
43 ctdb_test_init "$@"
44
45 ctdb_test_check_real_cluster
46
47 cluster_is_healthy
48
49 # Reset configuration
50 ctdb_restart_when_done
51
52 select_test_node_and_ips
53
54 first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
55 mnt_d=$(mktemp -d)
56 test_file="${mnt_d}/$RANDOM"
57
58 ctdb_test_exit_hook_add rm -f "$test_file"
59 ctdb_test_exit_hook_add umount -f "$mnt_d"
60 ctdb_test_exit_hook_add rmdir "$mnt_d"
61
62 echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
63 mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
64
65 echo "Create file containing random data..."
66 dd if=/dev/urandom of=$test_file bs=1k count=1
67 original_sum=$(sum $test_file)
68 [ $? -eq 0 ]
69
70 gratarp_sniff_start
71
72 echo "Disabling node $test_node"
73 try_command_on_node 0 $CTDB disable -n $test_node
74 wait_until_node_has_status $test_node disabled
75
76 gratarp_sniff_wait_show
77
78 new_sum=$(sum $test_file)
79 [ $? -eq 0 ]
80
81 if [ "$original_md5" = "$new_md5" ] ; then
82     echo "GOOD: file contents unchanged after failover"
83 else
84     echo "BAD: file contents are different after failover"
85     testfailures=1
86 fi