6 Verify that the CTDB_SAMBA_SKIP_SHARE_CHECK configuration option is respected.
8 We create a file in /etc/ctdb/rc.local.d/ that creates a function
9 called testparm. This effectively hooks the testparm 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_SAMBA_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 a timeout for state changes by adding MonitorInterval
29 and EventScriptTimeout.
30 3. Create a temporary directory using mktemp, remember the name in
32 4. Create an executable file /etc/ctdb/rc.local.d/fake-testparm that
33 contains a definiton for the function testparm, which prints a
34 share definition for a directory $mydir/foo (which does not
36 5. Create an executable file
37 /etc/ctdb/rc.local.d/samba-skip-share-check that replaces the
38 loadconfig() function by one with equivalent functionality, but
39 which also sets CTDB_SAMBA_SKIP_SHARE_CHECK="no" if loading
41 6. Wait for a maximum of MonitorInterval seconds for the node to
43 7. Create the directory $mydir/foo.
44 8. Wait for a maximum of MonitorInterval seconds for the node to
46 9. Modify /etc/ctdb/rc.local.d/samba-skip-share-check so that it sets
47 CTDB_SAMBA_SKIP_SHARE_CHECK="yes".
48 10. Remove the directory $mydir/foo.
49 11. Wait for a monitor event and confirm that the the node is still
54 * When an SAMBA share directory is missing CTDB should only mark a node
55 as unhealthy if CTDB_SAMBA_SKIP_SHARE_CHECK is set to "no".
59 . "${TEST_SCRIPTS_DIR}/integration.bash"
65 ctdb_test_check_real_cluster
69 select_test_node_and_ips
71 # We need this for later, so we know how long to sleep.
72 # We need this for later, so we know how long to sleep.
73 try_command_on_node $test_node $CTDB getvar MonitorInterval
74 monitor_interval=${out#*= }
75 try_command_on_node $test_node $CTDB getvar EventScriptTimeout
76 event_script_timeout=${out#*= }
78 monitor_timeout=$(($monitor_interval + $event_script_timeout))
80 echo "Using timeout of ${monitor_timeout}s (MonitorInterval + EventScriptTimeout)..."
82 mydir=$(onnode -q $test_node mktemp -d)
83 rc_local_d="${CTDB_BASE:-/etc/ctdb}/rc.local.d"
87 ctdb_test_eventscript_uninstall
88 onnode -q $test_node "rm -f $mydir/*"
89 onnode -q $test_node "rmdir --ignore-fail-on-non-empty $mydir"
90 onnode -q $test_node "rm -f \"$rc_local_d/\"*"
91 onnode -q $test_node "rmdir --ignore-fail-on-non-empty \"$rc_local_d\""
94 ctdb_test_exit_hook_add my_exit_hook
96 ctdb_test_eventscript_install
100 try_command_on_node -v $test_node "mkdir -p \"$rc_local_d\""
102 f="$rc_local_d/fake-testparm"
103 echo "Installing \"$f\"..."
104 # Yes, the quoting is very tricky. We want $foo_dir and $f expanded when
105 # we echo the function definition but we don't want any of the other
106 # items expanded until the function is run.
107 try_command_on_node $test_node "echo 'function testparm () { tp=\$(which testparm 2>/dev/null) ; if [ -n \"\$2\" ] ; then echo path = '\"$foo_dir\"' ; else \$tp \"\$@\" ; fi ; }' >\"$f\" ; chmod +x \"$f\""
109 n="$rc_local_d/samba-skip-share-check"
110 n_contents='loadconfig() {
113 if [ "$1" = "ctdb" ] ; then
114 CTDB_SAMBA_SKIP_SHARE_CHECK=no
118 echo "Installing \"$n\" with CTDB_SAMBA_SKIP_SHARE_CHECK=no..."
119 try_command_on_node $test_node "echo '$n_contents' >\"$n\" ; chmod +x \"$n\""
121 wait_until_node_has_status $test_node unhealthy $monitor_timeout
123 try_command_on_node -v $test_node "mkdir $foo_dir"
125 wait_until_node_has_status $test_node healthy $monitor_timeout
127 echo "Re-installing \"$n\" with CTDB_SAMBA_SKIP_SHARE_CHECK=yes..."
128 try_command_on_node $test_node "echo '${n_contents/=no/=yes}' >\"$n\" ; chmod +x \"$n\""
130 try_command_on_node -v $test_node "rmdir $foo_dir"
132 wait_for_monitor_event $test_node
134 wait_until_node_has_status $test_node healthy 1