6 Verify that the CTDB_NFS_SKIP_SHARE_CHECK configuration option is respected.
8 We create a file in /etc/ctdb/rc.local.d/ that creates a function
9 called exportfs. This effectively hooks the exportfs command,
10 allowing us to provide a fake list of shares to check or not check.
12 We create another file in the same directory to set and unset the
13 CTDB_NFS_SKIP_SHARE_CHECK option, utilising the shell's "readonly"
14 built-in to ensure that our value for the option is used.
18 * An active CTDB cluster with at least 2 nodes with public addresses.
20 * Test must be run on a real or virtual cluster rather than against
21 local daemons. There is nothing intrinsic to this test that forces
22 this - it is because tests run against local daemons don't use the
27 1. Verify that the cluster is healthy.
28 2. Determine the CTDB MonitorInterval setting and remember it.
29 3. Create a temporary directory using mktemp, remember the name in
31 4. Create an executable file /etc/ctdb/rc.local.d/fake-exportfs that
32 contains a definiton for the function exportfs, which prints a
33 share definition for a directory $mydir/foo (which does not
35 5. Create an executable file
36 /etc/ctdb/rc.local.d/nfs-skip-share-check that replaces the
37 loadconfig() function by one with equivalent functionality, but
38 which also sets CTDB_NFS_SKIP_SHARE_CHECK="no" if loading
40 6. Wait for a maximum of MonitorInterval seconds for the node to
42 7. Create the directory $mydir/foo.
43 8. Wait for a maximum of MonitorInterval seconds for the node to
45 9. Modify /etc/ctdb/rc.local.d/nfs-skip-share-check so that it sets
46 CTDB_NFS_SKIP_SHARE_CHECK to "yes".
47 10. Remove the directory $mydir/foo.
48 11. Wait for MonitorInterval and confirm that the the node is still
53 * When an NFS share directory is missing CTDB should only mark a node
54 as unhealthy if CTDB_NFS_SKIP_SHARE_CHECK is set to "no".
58 . ctdb_test_functions.bash
64 ctdb_test_check_real_cluster
68 select_test_node_and_ips
70 # We need this for later, so we know how long to sleep.
71 try_command_on_node $test_node $CTDB getvar MonitorInterval
72 monitor_interval="${out#*= }"
74 mydir=$(onnode -q $test_node mktemp -d)
75 rc_local_d="${CTDB_BASE:-/etc/ctdb}/rc.local.d"
76 mkdir -p "$rc_local_d"
80 onnode -q $test_node "rm -f $mydir/*"
81 onnode -q $test_node "rmdir --ignore-fail-on-non-empty $mydir"
82 onnode -q $test_node "rm -f \"$rc_local_d/\"*"
83 onnode -q $test_node "rmdir --ignore-fail-on-non-empty \"$rc_local_d\""
86 ctdb_test_exit_hook_add my_exit_hook
90 try_command_on_node -v $test_node "mkdir -p \"$rc_local_d\""
92 f="$rc_local_d/fake-exportfs"
93 echo "Installing \"$f\"..."
94 try_command_on_node $test_node "echo \"function exportfs () { echo $foo_dir 127.0.0.1/32 ; }\" >\"$f\" ; chmod +x \"$f\""
96 n="$rc_local_d/nfs-skip-share-check"
97 n_contents='loadconfig() {
99 if [ -f /etc/sysconfig/$name ]; then
100 . /etc/sysconfig/$name
101 elif [ -f /etc/default/$name ]; then
103 elif [ -f $CTDB_BASE/sysconfig/$name ]; then
104 . $CTDB_BASE/sysconfig/$name
106 if [ "$name" = "ctdb" ] ; then
107 CTDB_NFS_SKIP_SHARE_CHECK=no
111 echo "Installing \"$n\" with CTDB_NSF_SKIP_SHARE_CHECK=no..."
112 try_command_on_node $test_node "echo '$n_contents' >\"$n\" ; chmod +x \"$n\""
114 wait_until_node_has_status $test_node unhealthy $monitor_interval
116 try_command_on_node -v $test_node "mkdir $foo_dir"
118 wait_until_node_has_status $test_node healthy $monitor_interval
120 echo "Re-installing \"$n\" with CTDB_NFS_SKIP_SHARE_CHECK=yes..."
121 try_command_on_node $test_node "echo '${n_contents/=no/=yes}' >\"$n\" ; chmod +x \"$n\""
123 try_command_on_node -v $test_node "rmdir $foo_dir"
125 echo "Waiting for MonitorInterval to ensure that node $test_node stays healthy..."
126 sleep_for $monitor_interval
128 wait_until_node_has_status $test_node healthy 1