ctdb-tests: Drop passing of test arguments to ctdb_test_init()
[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 . "${TEST_SCRIPTS_DIR}/integration.bash"
42
43 set -e
44
45 ctdb_test_init
46
47 ctdb_test_check_real_cluster
48
49 cluster_is_healthy
50
51 nfs_test_setup
52
53 echo "Create file containing random data..."
54 local_f=$(mktemp)
55 ctdb_test_exit_hook_add rm -f "$local_f"
56 dd if=/dev/urandom of=$local_f bs=1k count=1
57 local_sum=$(sum $local_f)
58
59 scp -p "$local_f" "[${test_ip}]:${nfs_remote_file}"
60 try_command_on_node $test_node "chmod 644 $nfs_remote_file"
61
62 nfs_sum=$(sum $nfs_local_file)
63
64 if [ "$local_sum" = "$nfs_sum" ] ; then
65     echo "GOOD: file contents read correctly via NFS"
66 else
67     echo "BAD: file contents are different over NFS"
68     echo "  original file: $local_sum"
69     echo "       NFS file: $nfs_sum"
70     exit 1
71 fi
72
73 gratarp_sniff_start
74
75 echo "Disabling node $test_node"
76 try_command_on_node 0 $CTDB disable -n $test_node
77 wait_until_node_has_status $test_node disabled
78
79 gratarp_sniff_wait_show
80
81 new_sum=$(sum $nfs_local_file)
82 [ $? -eq 0 ]
83
84 if [ "$nfs_sum" = "$new_sum" ] ; then
85     echo "GOOD: file contents unchanged after failover"
86 else
87     echo "BAD: file contents are different after failover"
88     echo "  original file: $nfs_sum"
89     echo "       NFS file: $new_sum"
90     exit 1
91 fi