[SCM] CTDB repository - branch master updated - 1.0.99-16-g514a60c

Ronnie Sahlberg sahlberg at samba.org
Thu Oct 22 19:21:22 MDT 2009


The branch, master has been updated
       via  514a60c57557042e463efeff53dd11b9fec40561 (commit)
       via  f3e09f2cfd33e79e69fc8c84ce4781a31a7a0437 (commit)
       via  431f79f7c9038ebd95d27c2465207ca40b8f4f23 (commit)
       via  61282d4a9be9e544aaa86f3cffc5b58e417f5ab1 (commit)
       via  8264c42969d4be7fc6c5b4d56f8b5ef7c62b3bfb (commit)
       via  25e82a8a667a54c6921ef076c63fdd738dd75d19 (commit)
       via  6ef4364b3349145b2fec23e0431cd6df6dcadd41 (commit)
       via  a4aac7312947aa3b26bc26993f04b586c64f18cb (commit)
       via  f50d64a8ac91415ca297216d2103ff940076f02b (commit)
       via  2b478b0f5f09dd06626592573f053706ac637edd (commit)
       via  11137bc2d492a62a26ec9f9f62ff362e81643f66 (commit)
       via  1f906bd3476e7cebf217e35b5477d6a7bb615a0c (commit)
       via  b3ae2b753261443dca317803752a9d61285a3270 (commit)
       via  454125ccfda04aa6b4e14f5c05164d29f41a0ead (commit)
       via  5ad283458e59ea8232e01f34be007901c10c8a2e (commit)
       via  bf5402b41282da94fee1ab3e4546ec089ff12f37 (commit)
      from  14fca8383b6b1da49278a9181a975543b956161b (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 514a60c57557042e463efeff53dd11b9fec40561
Merge: 14fca8383b6b1da49278a9181a975543b956161b f3e09f2cfd33e79e69fc8c84ce4781a31a7a0437
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Fri Oct 23 10:43:13 2009 +1100

    Merge commit 'martins/master'

commit f3e09f2cfd33e79e69fc8c84ce4781a31a7a0437
Merge: 431f79f7c9038ebd95d27c2465207ca40b8f4f23 e01ab46bafad09a5e320d420734db129d35863bc
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Oct 22 17:48:09 2009 +1100

    Merge commit 'origin/master'

commit 431f79f7c9038ebd95d27c2465207ca40b8f4f23
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Oct 22 17:47:10 2009 +1100

    Document onnode -n and -f options.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 61282d4a9be9e544aaa86f3cffc5b58e417f5ab1
Merge: 8264c42969d4be7fc6c5b4d56f8b5ef7c62b3bfb befabc917edb036ca81f5216f65a6d62b26ee83e
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Oct 21 21:48:15 2009 +1100

    Merge commit 'origin/master'

commit 8264c42969d4be7fc6c5b4d56f8b5ef7c62b3bfb
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Oct 21 21:47:06 2009 +1100

    Test suite: Remove the disable/enable monitor tests - they are useless.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 25e82a8a667a54c6921ef076c63fdd738dd75d19
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Oct 21 21:36:39 2009 +1100

    Test suite: Fix the timeouts on the skip share check tests.
    
    The timeout for waiting for state changes isn't very predictable.  It
    is "about" MonitorInterval seconds...  but can be longer given the
    duration of eventscript runs and other things.  So, we change the
    timeout to MonitorInterval + EventScriptTimeout, hoping it never takes
    that long.
    
    Move the eventscript installation/removal from the old fake-tests into
    a function in the functions file.  Implement supporting functions to
    create/remove/check-for various files that it handles.  Also add a
    function that uses all of this that waits for the next monitor event
    (but only if all other monitor events pass).
    
    The final check in the skip share check tests uses the above and waits
    for a monitor event, and then checks that the node is still healthy.
    
    Also enhance the wait_until function to handle a command starting with
    '!' (as a separate word) to make it easy to wait for a file not to
    exist.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 6ef4364b3349145b2fec23e0431cd6df6dcadd41
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 17:11:01 2009 +1100

    Test suite: A timeout of MonitorInterval seconds sometimes isn't enough.
    
    Monitor events sometimes happen a little bit more than MonitorInterval
    seconds apart.  This changes some timeouts to MonitorInterval + 1
    seconds.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit a4aac7312947aa3b26bc26993f04b586c64f18cb
Merge: f50d64a8ac91415ca297216d2103ff940076f02b 02862c086d045497f49f3c060700419815d607e7
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 16:53:04 2009 +1100

    Merge commit 'origin/master'

commit f50d64a8ac91415ca297216d2103ff940076f02b
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 16:52:22 2009 +1100

    Test suite: New tests for validating SKIP_SHARE_CHECK options.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 2b478b0f5f09dd06626592573f053706ac637edd
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 16:51:06 2009 +1100

    Test suite: Update 99_ctdb_uninstall_eventscript.sh to use ctdb_init().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 11137bc2d492a62a26ec9f9f62ff362e81643f66
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 16:45:29 2009 +1100

    Test suite: Fix bug in node_has_status().
    
    This function has been broken since it was updated to work with the
    "stopped" state (probably commit
    67c5bfb5f02c9d45a32d976021ede4fb2174dfe9).  Although ${var#:*:0}
    removes the shortest matching prefix of $var, '*' can match substrings
    that include ':' if '0' isn't where you expect.  So we were making
    unexpected matches and incorrectly returning true for some cases.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 1f906bd3476e7cebf217e35b5477d6a7bb615a0c
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 20 16:44:44 2009 +1100

    Test suite: add -x option to ctdb_init() function.
    
    This facilitates tracing of tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit b3ae2b753261443dca317803752a9d61285a3270
Merge: 454125ccfda04aa6b4e14f5c05164d29f41a0ead 27d152a918680a59c7412aec7e1772f25b72d469
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 19 16:46:45 2009 +1100

    Merge commit 'origin/master'

commit 454125ccfda04aa6b4e14f5c05164d29f41a0ead
Merge: 5ad283458e59ea8232e01f34be007901c10c8a2e e62928f56ce8927b1d8686db2c31538c86462d1a
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Oct 16 16:39:46 2009 +1100

    Merge branch 'onnode_options'

commit 5ad283458e59ea8232e01f34be007901c10c8a2e
Merge: bf5402b41282da94fee1ab3e4546ec089ff12f37 536229fd120bc3fdc2419e22d3bd6ab243dd6667
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Oct 16 16:36:48 2009 +1100

    Merge commit 'origin/master'

commit bf5402b41282da94fee1ab3e4546ec089ff12f37
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Oct 16 16:35:56 2009 +1100

    initscript: when stopping on Red Hat use the success/failure functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 config/ctdb.init                                |    2 +-
 doc/onnode.1                                    |   16 +++-
 doc/onnode.1.html                               |   25 +++--
 doc/onnode.1.xml                                |   21 ++++
 tests/complex/01_ctdb_nfs_skip_share_check.sh   |  135 ++++++++++++++++++++++
 tests/complex/02_ctdb_samba_skip_share_check.sh |  140 +++++++++++++++++++++++
 tests/scripts/ctdb_test_functions.bash          |  128 ++++++++++++++++++++-
 tests/simple/00_ctdb_install_eventscript.sh     |   58 ----------
 tests/simple/21_ctdb_disablemonitor.sh          |  100 ----------------
 tests/simple/22_ctdb_enablemonitor.sh           |  100 ----------------
 tests/simple/99_ctdb_uninstall_eventscript.sh   |   24 ----
 11 files changed, 453 insertions(+), 296 deletions(-)
 create mode 100755 tests/complex/01_ctdb_nfs_skip_share_check.sh
 create mode 100755 tests/complex/02_ctdb_samba_skip_share_check.sh
 delete mode 100755 tests/simple/00_ctdb_install_eventscript.sh
 delete mode 100755 tests/simple/21_ctdb_disablemonitor.sh
 delete mode 100755 tests/simple/22_ctdb_enablemonitor.sh
 delete mode 100755 tests/simple/99_ctdb_uninstall_eventscript.sh


Changeset truncated at 500 lines:

diff --git a/config/ctdb.init b/config/ctdb.init
index d4b9424..df333b2 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -210,7 +210,7 @@ stop() {
 	    rc_status -v
 	    ;;
 	redhat)
-	    echo
+            [ $RETVAL -eq 0 ] && success || failure
 	    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
 	    echo ""
 	    ;;
diff --git a/doc/onnode.1 b/doc/onnode.1
index fe86a57..54249f6 100644
--- a/doc/onnode.1
+++ b/doc/onnode.1
@@ -2,12 +2,12 @@
 .\"     Title: onnode
 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
-.\"      Date: 10/06/2009
+.\"      Date: 10/22/2009
 .\"    Manual: [FIXME: manual]
 .\"    Source: [FIXME: source]
 .\"  Language: English
 .\"
-.TH "ONNODE" "1" "10/06/2009" "[FIXME: source]" "[FIXME: manual]"
+.TH "ONNODE" "1" "10/22/2009" "[FIXME: source]" "[FIXME: manual]"
 .\" -----------------------------------------------------------------
 .\" * set default formatting
 .\" -----------------------------------------------------------------
@@ -90,6 +90,18 @@ Run COMMAND in parallel on the specified nodes\&. The default is to run COMMAND
 Do not print node addresses\&. Normally, onnode prints informational node addresses if more than one node is specified\&. This overrides \-v\&.
 .RE
 .PP
+\-n
+.RS 4
+Allow nodes to be specified by name rather than node numbers\&. These nodes don\'t need to be listed in the nodes file\&. You can avoid the nodes file entirely by combining this with
+\-f /dev/null\&.
+.RE
+.PP
+\-f <file>
+.RS 4
+Specify an alternative nodes file to use instead of
+/etc/ctdb/nodes\&. This overrides the CTDB_NODES_FILE environment variable\&.
+.RE
+.PP
 \-v
 .RS 4
 Print a node addresses even if only one node is specified\&. Normally, onnode prints informational node addresses when more than one node is specified\&.
diff --git a/doc/onnode.1.html b/doc/onnode.1.html
index c8e3157..3ddfa2f 100644
--- a/doc/onnode.1.html
+++ b/doc/onnode.1.html
@@ -1,4 +1,4 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>onnode</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="onnode"><a name="onnode.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>onnode &#8212; run commands on ctdb nodes</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">onnode [OPTION] ... NODES COMMAND ...</code> </p></div></div><div class="refsect1" title="DESCRIPTION"><a name="id2711756"></a><h2>DESCRIPTION</h2><p>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>onnode</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="onnode"><a name="onnode.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>onnode &#8212; run commands on ctdb nodes</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">onnode [OPTION] ... NODES COMMAND ...</code> </p></div></div><div class="refsect1" title="DESCRIPTION"><a name="id2777487"></a><h2>DESCRIPTION</h2><p>
       onnode is a utility to run commands on a specific node of a CTDB
       cluster, or on all nodes.
     </p><p>
@@ -13,7 +13,7 @@
     </p><p>
       The COMMAND can be any shell command. The onnode utility uses
       ssh or rsh to connect to the remote nodes and run the command.
-    </p></div><div class="refsect1" title="DESCRIPTIVE NODE SPECIFICATIONS"><a name="id2711784"></a><h2>DESCRIPTIVE NODE SPECIFICATIONS</h2><p>
+    </p></div><div class="refsect1" title="DESCRIPTIVE NODE SPECIFICATIONS"><a name="id2739103"></a><h2>DESCRIPTIVE NODE SPECIFICATIONS</h2><p>
       The following descriptive node specification can be used in
       place of numeric node numbers:
     </p><div class="variablelist"><dl><dt><span class="term">all</span></dt><dd><p>
@@ -32,7 +32,7 @@
             The current NAT gateway.
 	  </p></dd><dt><span class="term">rm | recmaster</span></dt><dd><p>
             The current recovery master.
-	  </p></dd></dl></div></div><div class="refsect1" title="OPTIONS"><a name="id2711252"></a><h2>OPTIONS</h2><div class="variablelist"><dl><dt><span class="term">-c</span></dt><dd><p>
+	  </p></dd></dl></div></div><div class="refsect1" title="OPTIONS"><a name="id2742732"></a><h2>OPTIONS</h2><div class="variablelist"><dl><dt><span class="term">-c</span></dt><dd><p>
             Execute COMMAND in the current working directory on the
             specified nodes.
 	  </p></dd><dt><span class="term">-o &lt;prefix&gt;</span></dt><dd><p>
@@ -45,13 +45,22 @@
             Do not print node addresses.  Normally, onnode prints
             informational node addresses if more than one node is
             specified.  This overrides -v.
+	  </p></dd><dt><span class="term">-n</span></dt><dd><p>
+            Allow nodes to be specified by name rather than node
+            numbers.  These nodes don't need to be listed in the nodes
+            file.  You can avoid the nodes file entirely by combining
+            this with <code class="code">-f /dev/null</code>.
+	  </p></dd><dt><span class="term">-f &lt;file&gt;</span></dt><dd><p>
+            Specify an alternative nodes file to use instead of
+            <code class="filename">/etc/ctdb/nodes</code>.  This overrides the
+            CTDB_NODES_FILE environment variable.
 	  </p></dd><dt><span class="term">-v</span></dt><dd><p>
             Print a node addresses even if only one node is specified.
             Normally, onnode prints informational node addresses when
             more than one node is specified.
 	  </p></dd><dt><span class="term">-h, --help</span></dt><dd><p>
             Show a short usage guide.
-	  </p></dd></dl></div></div><div class="refsect1" title="EXAMPLES"><a name="id2711346"></a><h2>EXAMPLES</h2><p>
+	  </p></dd></dl></div></div><div class="refsect1" title="EXAMPLES"><a name="id2742865"></a><h2>EXAMPLES</h2><p>
       The following command would show the process ID of ctdb on all nodes
     </p><pre class="screen">
       onnode all pidof ctdbd
@@ -69,10 +78,10 @@
       directory, in parallel, on nodes 0, 2, 3 and 4.
     </p><pre class="screen">
       onnode -c -p 0,2-4 ./foo
-    </pre></div><div class="refsect1" title="ENVIRONMENT"><a name="id2711396"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl><dt><span class="term"><code class="envar">CTDB_NODES_FILE</code></span></dt><dd><p>
+    </pre></div><div class="refsect1" title="ENVIRONMENT"><a name="id2742916"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl><dt><span class="term"><code class="envar">CTDB_NODES_FILE</code></span></dt><dd><p>
             Name of alternative nodes file to use instead of
             <code class="filename">/etc/ctdb/nodes</code>.
-	  </p></dd></dl></div></div><div class="refsect1" title="FILES"><a name="id2711425"></a><h2>FILES</h2><div class="variablelist"><dl><dt><span class="term"><code class="filename">/etc/ctdb/nodes</code></span></dt><dd><p>
+	  </p></dd></dl></div></div><div class="refsect1" title="FILES"><a name="id2742944"></a><h2>FILES</h2><div class="variablelist"><dl><dt><span class="term"><code class="filename">/etc/ctdb/nodes</code></span></dt><dd><p>
             Default file containing a list of each node's IP address
             or hostname.
 	  </p></dd><dt><span class="term"><code class="filename">/etc/ctdb/onnode.conf</code></span></dt><dd><p>
@@ -81,9 +90,9 @@
             something other than "ssh".  In this case the -t option is
             ignored.  For example, the administrator may choose to use
             use rsh instead of ssh.
-	  </p></dd></dl></div></div><div class="refsect1" title="SEE ALSO"><a name="id2711471"></a><h2>SEE ALSO</h2><p>
+	  </p></dd></dl></div></div><div class="refsect1" title="SEE ALSO"><a name="id2791501"></a><h2>SEE ALSO</h2><p>
       ctdbd(1), ctdb(1), <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a>
-    </p></div><div class="refsect1" title="COPYRIGHT/LICENSE"><a name="id2711483"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
+    </p></div><div class="refsect1" title="COPYRIGHT/LICENSE"><a name="id2791514"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
 Copyright (C) Andrew Tridgell 2007<br>
 Copyright (C) Ronnie sahlberg 2007<br>
 Copyright (C) Martin Schwenke 2008<br>
diff --git a/doc/onnode.1.xml b/doc/onnode.1.xml
index 578baf9..36a569e 100644
--- a/doc/onnode.1.xml
+++ b/doc/onnode.1.xml
@@ -142,6 +142,27 @@
         </listitem>
       </varlistentry>
 
+      <varlistentry><term>-n</term>
+        <listitem>
+          <para>
+            Allow nodes to be specified by name rather than node
+            numbers.  These nodes don't need to be listed in the nodes
+            file.  You can avoid the nodes file entirely by combining
+            this with <code>-f /dev/null</code>.
+	  </para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry><term>-f &lt;file&gt;</term>
+        <listitem>
+          <para>
+            Specify an alternative nodes file to use instead of
+            <filename>/etc/ctdb/nodes</filename>.  This overrides the
+            CTDB_NODES_FILE environment variable.
+	  </para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry><term>-v</term>
         <listitem>
           <para>
diff --git a/tests/complex/01_ctdb_nfs_skip_share_check.sh b/tests/complex/01_ctdb_nfs_skip_share_check.sh
new file mode 100755
index 0000000..cd4dec8
--- /dev/null
+++ b/tests/complex/01_ctdb_nfs_skip_share_check.sh
@@ -0,0 +1,135 @@
+#!/bin/bash
+
+test_info()
+{
+    cat <<EOF
+Verify that the CTDB_NFS_SKIP_SHARE_CHECK configuration option is respected.
+
+We create a file in /etc/ctdb/rc.local.d/ that creates a function
+called exportfs.  This effectively hooks the exportfs command,
+allowing us to provide a fake list of shares to check or not check.
+
+We create another file in the same directory to set and unset the
+CTDB_NFS_SKIP_SHARE_CHECK option, utilising the shell's "readonly"
+built-in to ensure that our value for the option is used.
+
+Prerequisites:
+
+* An active CTDB cluster with at least 2 nodes with public addresses.
+
+* Test must be run on a real or virtual cluster rather than against
+  local daemons.  There is nothing intrinsic to this test that forces
+  this - it is because tests run against local daemons don't use the
+  regular eventscripts.
+
+Steps:
+
+1.  Verify that the cluster is healthy.
+2.  Determine a timeout for state changes by adding MonitorInterval
+    and EventScriptTimeout.
+3.  Create a temporary directory on the test node using mktemp,
+    remember the name in $mydir.
+4.  On the test node create an executable file
+    /etc/ctdb/rc.local.d/fake-exportfs that contains a definiton for
+    the function exportfs, which prints a share definition for a
+    directory $mydir/foo (which does not currently exist).
+5.  On the test node create an executable file
+    /etc/ctdb/rc.local.d/nfs-skip-share-check that replaces the
+    loadconfig() function by one with equivalent functionality, but
+    which also sets CTDB_NFS_SKIP_SHARE_CHECK="no" if loading
+    "ctdb" configuration.
+6.  Wait for the test node to become unhealthy.
+7.  Create the directory $mydir/foo.
+8.  Wait for the test node to become healthy.
+9.  Modify /etc/ctdb/rc.local.d/nfs-skip-share-check so that it sets
+    CTDB_NFS_SKIP_SHARE_CHECK to "yes".
+10. Remove the directory $mydir/foo.
+11. Wait for  a monitor event and confirm that the the node is still
+    healthy.
+
+Expected results:
+
+* When an NFS share directory is missing CTDB should only mark a node
+  as unhealthy if CTDB_NFS_SKIP_SHARE_CHECK is set to "no".
+EOF
+}
+
+. ctdb_test_functions.bash
+
+set -e
+
+ctdb_test_init "$@"
+
+ctdb_test_check_real_cluster
+
+cluster_is_healthy
+
+select_test_node_and_ips
+
+# We need this for later, so we know how long to sleep.
+try_command_on_node $test_node $CTDB getvar MonitorInterval
+monitor_interval=${out#*= }
+try_command_on_node $test_node $CTDB getvar EventScriptTimeout
+event_script_timeout=${out#*= }
+
+monitor_timeout=$(($monitor_interval + $event_script_timeout))
+
+echo "Using timeout of ${monitor_timeout}s (MonitorInterval + EventScriptTimeout)..."
+
+
+mydir=$(onnode -q $test_node mktemp -d)
+rc_local_d="${CTDB_BASE:-/etc/ctdb}/rc.local.d"
+
+my_exit_hook ()
+{
+    ctdb_test_eventscript_uninstall
+    onnode -q $test_node "rm -f $mydir/*"
+    onnode -q $test_node "rmdir --ignore-fail-on-non-empty $mydir"
+    onnode -q $test_node "rm -f \"$rc_local_d/\"*"
+    onnode -q $test_node "rmdir --ignore-fail-on-non-empty \"$rc_local_d\""
+}
+
+ctdb_test_exit_hook_add my_exit_hook
+
+ctdb_test_eventscript_install
+
+foo_dir=$mydir/foo
+
+try_command_on_node -v $test_node "mkdir -p \"$rc_local_d\""
+
+f="$rc_local_d/fake-exportfs"
+echo "Installing \"$f\"..."
+try_command_on_node $test_node "echo \"function exportfs () { echo $foo_dir 127.0.0.1/32 ; }\" >\"$f\" ; chmod +x \"$f\""
+
+n="$rc_local_d/nfs-skip-share-check"
+n_contents='loadconfig() {
+    name="$1"
+    if [ -f /etc/sysconfig/$name ]; then
+	. /etc/sysconfig/$name
+    elif [ -f /etc/default/$name ]; then
+	. /etc/default/$name
+    elif [ -f $CTDB_BASE/sysconfig/$name ]; then
+	. $CTDB_BASE/sysconfig/$name
+    fi
+    if [ "$name" = "ctdb" ] ; then
+        CTDB_NFS_SKIP_SHARE_CHECK=no
+    fi
+}
+'
+echo "Installing \"$n\" with CTDB_NSF_SKIP_SHARE_CHECK=no..."
+try_command_on_node $test_node "echo '$n_contents' >\"$n\" ; chmod +x \"$n\""
+
+wait_until_node_has_status $test_node unhealthy $monitor_timeout
+
+try_command_on_node -v $test_node "mkdir $foo_dir"
+
+wait_until_node_has_status $test_node healthy $monitor_timeout
+
+echo "Re-installing \"$n\" with CTDB_NFS_SKIP_SHARE_CHECK=yes..."
+try_command_on_node $test_node "echo '${n_contents/=no/=yes}' >\"$n\" ; chmod +x \"$n\""
+
+try_command_on_node -v $test_node "rmdir $foo_dir"
+
+wait_for_monitor_event $test_node
+
+wait_until_node_has_status $test_node healthy 1
diff --git a/tests/complex/02_ctdb_samba_skip_share_check.sh b/tests/complex/02_ctdb_samba_skip_share_check.sh
new file mode 100755
index 0000000..4cb24d6
--- /dev/null
+++ b/tests/complex/02_ctdb_samba_skip_share_check.sh
@@ -0,0 +1,140 @@
+#!/bin/bash
+
+test_info()
+{
+    cat <<EOF
+Verify that the CTDB_SAMBA_SKIP_SHARE_CHECK configuration option is respected.
+
+We create a file in /etc/ctdb/rc.local.d/ that creates a function
+called testparm.  This effectively hooks the testparm command,
+allowing us to provide a fake list of shares to check or not check.
+
+We create another file in the same directory to set and unset the
+CTDB_SAMBA_SKIP_SHARE_CHECK option, utilising the shell's "readonly"
+built-in to ensure that our value for the option is used.
+
+Prerequisites:
+
+* An active CTDB cluster with at least 2 nodes with public addresses.
+
+* Test must be run on a real or virtual cluster rather than against
+  local daemons.  There is nothing intrinsic to this test that forces
+  this - it is because tests run against local daemons don't use the
+  regular eventscripts.
+
+Steps:
+
+1.  Verify that the cluster is healthy.
+2.  Determine a timeout for state changes by adding MonitorInterval
+    and EventScriptTimeout.
+3.  Create a temporary directory using mktemp, remember the name in
+    $mydir.
+4.  Create an executable file /etc/ctdb/rc.local.d/fake-testparm that
+    contains a definiton for the function testparm, which prints a
+    share definition for a directory $mydir/foo (which does not
+    currently exist).
+5.  Create an executable file
+    /etc/ctdb/rc.local.d/samba-skip-share-check that replaces the
+    loadconfig() function by one with equivalent functionality, but
+    which also sets CTDB_SAMBA_SKIP_SHARE_CHECK="no" if loading
+    "ctdb" configuration.
+6.  Wait for a maximum of MonitorInterval seconds for the node to
+    become unhealthy.
+7.  Create the directory $mydir/foo.
+8.  Wait for a maximum of MonitorInterval seconds for the node to
+    become healthy.
+9.  Modify /etc/ctdb/rc.local.d/samba-skip-share-check so that it sets
+    CTDB_SAMBA_SKIP_SHARE_CHECK="yes".
+10. Remove the directory $mydir/foo.
+11. Wait for  a monitor event and confirm that the the node is still
+    healthy.
+
+Expected results:
+
+* When an SAMBA share directory is missing CTDB should only mark a node
+  as unhealthy if CTDB_SAMBA_SKIP_SHARE_CHECK is set to "no".
+EOF
+}
+
+. ctdb_test_functions.bash
+
+set -e
+
+ctdb_test_init "$@"
+
+ctdb_test_check_real_cluster
+
+cluster_is_healthy
+
+select_test_node_and_ips
+
+# We need this for later, so we know how long to sleep.
+# We need this for later, so we know how long to sleep.
+try_command_on_node $test_node $CTDB getvar MonitorInterval
+monitor_interval=${out#*= }
+try_command_on_node $test_node $CTDB getvar EventScriptTimeout
+event_script_timeout=${out#*= }
+
+monitor_timeout=$(($monitor_interval + $event_script_timeout))
+
+echo "Using timeout of ${monitor_timeout}s (MonitorInterval + EventScriptTimeout)..."
+
+mydir=$(onnode -q $test_node mktemp -d)
+rc_local_d="${CTDB_BASE:-/etc/ctdb}/rc.local.d"
+
+my_exit_hook ()
+{
+    ctdb_test_eventscript_uninstall
+    onnode -q $test_node "rm -f $mydir/*"
+    onnode -q $test_node "rmdir --ignore-fail-on-non-empty $mydir"
+    onnode -q $test_node "rm -f \"$rc_local_d/\"*"
+    onnode -q $test_node "rmdir --ignore-fail-on-non-empty \"$rc_local_d\""
+}
+
+ctdb_test_exit_hook_add my_exit_hook
+
+ctdb_test_eventscript_install
+
+foo_dir=$mydir/foo
+
+try_command_on_node -v $test_node "mkdir -p \"$rc_local_d\""
+
+f="$rc_local_d/fake-testparm"
+echo "Installing \"$f\"..."
+# Yes, the quoting is very tricky.  We want $foo_dir and $f expanded when
+# we echo the function definition but we don't want any of the other
+# items expanded until the function is run.
+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\""
+
+n="$rc_local_d/samba-skip-share-check"
+n_contents='loadconfig() {
+    name="$1"
+    if [ -f /etc/sysconfig/$name ]; then
+	. /etc/sysconfig/$name
+    elif [ -f /etc/default/$name ]; then
+	. /etc/default/$name
+    elif [ -f $CTDB_BASE/sysconfig/$name ]; then
+	. $CTDB_BASE/sysconfig/$name
+    fi
+    if [ "$name" = "ctdb" ] ; then
+        CTDB_SAMBA_SKIP_SHARE_CHECK=no
+    fi
+}
+'
+echo "Installing \"$n\" with CTDB_SAMBA_SKIP_SHARE_CHECK=no..."
+try_command_on_node $test_node "echo '$n_contents' >\"$n\" ; chmod +x \"$n\""
+
+wait_until_node_has_status $test_node unhealthy $monitor_timeout
+
+try_command_on_node -v $test_node "mkdir $foo_dir"
+
+wait_until_node_has_status $test_node healthy $monitor_timeout
+
+echo "Re-installing \"$n\" with CTDB_SAMBA_SKIP_SHARE_CHECK=yes..."
+try_command_on_node $test_node "echo '${n_contents/=no/=yes}' >\"$n\" ; chmod +x \"$n\""
+
+try_command_on_node -v $test_node "rmdir $foo_dir"
+
+wait_for_monitor_event $test_node
+
+wait_until_node_has_status $test_node healthy 1
diff --git a/tests/scripts/ctdb_test_functions.bash b/tests/scripts/ctdb_test_functions.bash
index 3da0f0e..e554680 100644
--- a/tests/scripts/ctdb_test_functions.bash
+++ b/tests/scripts/ctdb_test_functions.bash
@@ -120,6 +120,7 @@ Options:
     --category          show the test category (ACL, CTDB, Samba ...).
     -d, --description   show test case description.
     --summary           show short test case summary.
+    -x                  trace test using set -x
 EOF
 
     exit $status
@@ -141,7 +142,7 @@ ctdb_test_cmd_options()
         -v|--version)     ctdb_test_version   ;;
         --category)       echo "CTDB"         ;; 
         -d|--description) test_info           ;;
-	--summary)        test_info | head -1 ;;
+	-x)               set -x ; return 0   ;;
 	*)
 	    echo "Error: Unknown parameter = $1"
 	    echo
@@ -287,10 +288,19 @@ wait_until ()
 {
     local timeout="$1" ; shift # "$@" is the command...
 
+    local negate=false
+    if [ "$1" = "!" ] ; then
+	negate=true
+	shift
+    fi
+
     echo -n "<${timeout}|"
     local t=$timeout
     while [ $t -gt 0 ] ; do
-	if "$@" ; then
+	("$@")
+	local rc=$?
+	if { ! $negate && [ $rc -eq 0 ] ; } || \
+	    { $negate && [ $rc -ne 0 ] ; } ; then
 	    echo "|$(($timeout - $t))|"
 	    echo "OK"
 	    return 0
@@ -395,7 +405,10 @@ node_has_status ()
 	{
             read x
             while read line ; do
-		[ "${line#:${pnn}:*:${bits}}" != "$line" ] && return 0
+		# This needs to be done in 2 steps to avoid false matches.
+		local line_bits="${line#:${pnn}:*:}"
+		[ "$line_bits" = "$line" ] && continue
+		[ "${line_bits#${bits}}" != "$line_bits" ] && return 0
             done
 	    return 1


-- 
CTDB repository


More information about the samba-cvs mailing list