The branch, 2.5 has been updated
       via  0646118393e493704915e9e112d2afb607fcc12b (commit)
       via  08dab474b2c3f9e06393deba474bcdb990811bd2 (commit)
       via  6211bc763133852873fc08e99f2e7ca977ee912c (commit)
       via  80866aac84ad93b7e3e25a45a26180f752667877 (commit)
       via  1b76ed66a187bc923d7d9e1c0b0d527189c60dc9 (commit)
       via  3ac9aa7cb3b5522f603d6460bd23e72b3491ebce (commit)
       via  d9bd5246ce37626456f0f93b97291492fa1d7db1 (commit)
       via  f584e4db6090e5bf2b03148535c43841883b1c20 (commit)
      from  3639856145063750fdda3e85daa7b4361fc72450 (commit)

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


- Log -----------------------------------------------------------------
commit 0646118393e493704915e9e112d2afb607fcc12b
Author: Martin Schwenke <mar...@meltin.net>
Date:   Thu Apr 10 11:58:57 2014 +1000

    eventscripts: CTDB_NATGW_PUBLIC_* optional on slave-only nodes
    
    Commit 4ee4925d416a86341bd76c11fa99ec9173682a1d forgot about
    CTDB_NATGW_SLAVE_ONLY so it introduces an incorrect failure when this
    is set, and CTDB_NATGW_PUBLIC_IFACE or CTDB_NATGW_PUBLIC_IP is unset.
    
    Relax the sanity check to see if CTDB_NATGW_SLAVE_ONLY is set.
    
    Update the documentation to explicitly state that
    CTDB_NATGW_PUBLIC_IFACE and CTDB_NATGW_PUBLIC_IP are optional and
    unused if CTDB_NATGW_SLAVE_ONLY is set.  It would be possible to
    insist that CTDB_NATGW_PUBLIC_IFACE and CTDB_NATGW_PUBLIC_IFACE should
    be unset in that case.  However, it is more reasonable to allow
    consistent configuration across nodes except with some nodes
    configured slave-only.
    
    Add tests, update infrastructure and fix a thinko in the stub's
    "natgwlist" implementation.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    Autobuild-User(master): Martin Schwenke <mart...@samba.org>
    Autobuild-Date(master): Mon Apr 14 06:06:49 CEST 2014 on sn-devel-104
    
    (Imported from commit 2f2421bae1a8ff46ad54f76d02e6dd1c3ffe3300)

commit 08dab474b2c3f9e06393deba474bcdb990811bd2
Author: Martin Schwenke <mar...@meltin.net>
Date:   Wed Apr 9 14:26:23 2014 +1000

    tools-ctdb: Drop disconnected nodes when filtering by capability
    
    Commit ba69742ccd822562ca2135d2466e09bf1216644b missed the point of
    filtering disconnected nodes while limiting the nodemap to those in
    the NAT gateway group.  It was really to avoid trying to fetch
    capabilities from disconnected nodes.  This should be explicitly done
    in filter_nodemap_by_capabilities(), otherwise "ctdb natgwlist" simply
    fails when there is a disconnected node.
    
    Note that the alternate solution where filter_nodemap_by_flags() is
    called before filter_nodemap_by_capabilities() would not be not
    correct.  Filtering on flags first can produce a "healthier" set of
    nodes where none of them have the NAT gateway capability.
    
    Also extend stub for ctdb_ctrl_getcapabilities() to fail when trying
    to get capabilities from a disconnected node and add a corresponding
    test to confirm that "ctdb natgwlist" is no longer broken.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    (Imported from commit ce8ac88b969bb8bb7a94e62bb6e86aec389be6ac)

commit 6211bc763133852873fc08e99f2e7ca977ee912c
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Wed Apr 9 11:38:57 2014 +1000

    tests: Add a simple test for "ctdb detach"
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit c048011cd6a9ff976a88ac05ad15e0ffc73a73ae)

commit 80866aac84ad93b7e3e25a45a26180f752667877
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Apr 7 12:00:54 2014 +1000

    doc: Remove commands that have been deleted
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit 89bf1d2e34c7f4afe8c75dd5cf48e8564104f71b)

commit 1b76ed66a187bc923d7d9e1c0b0d527189c60dc9
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Apr 7 12:06:49 2014 +1000

    doc: Add "ctdb detach" and update "ctdb attach"
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit b681e89a973d738b2f8590c078c7bcb79391469f)

commit 3ac9aa7cb3b5522f603d6460bd23e72b3491ebce
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Mar 31 15:45:23 2014 +1100

    tools/ctdb: Add ctdb detach command to detach databases
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit a3fdb5637688bfed89be7489bacd66d7cefc2923)

commit d9bd5246ce37626456f0f93b97291492fa1d7db1
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Mar 31 15:44:53 2014 +1100

    client: Add client code to detach a database
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit ce18b3b00ba2db83daa71bf73e843732f05b8f6e)

commit f584e4db6090e5bf2b03148535c43841883b1c20
Author: Amitay Isaacs <ami...@gmail.com>
Date:   Mon Mar 31 15:44:21 2014 +1100

    daemon: Add control CTDB_CONTROL_DB_DETACH
    
    This detaches specified database from all the nodes.
    
    Signed-off-by: Amitay Isaacs <ami...@gmail.com>
    Reviewed-by: Martin Schwenke <mar...@meltin.net>
    
    (Imported from commit 1c72842217245fe99ddb6d26c29ae3f522db09c6)

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

Summary of changes:
 client/ctdb_client.c                               |   19 ++++
 config/events.d/11.natgw                           |   10 +-
 doc/ctdb.1.xml                                     |  103 +++++++-------------
 doc/ctdbd.conf.5.xml                               |    6 +-
 include/ctdb_client.h                              |    1 +
 include/ctdb_private.h                             |    2 +
 include/ctdb_protocol.h                            |    1 +
 server/ctdb_control.c                              |    3 +
 server/ctdb_ltdb_server.c                          |   85 ++++++++++++++++
 .../{11.natgw.002.sh => 11.natgw.003.sh}           |    9 +-
 .../{11.natgw.002.sh => 11.natgw.004.sh}           |    9 +-
 tests/eventscripts/11.natgw.005.sh                 |   24 +++++
 .../{11.natgw.012.sh => 11.natgw.041.sh}           |    9 +-
 .../{11.natgw.012.sh => 11.natgw.042.sh}           |   10 +-
 tests/eventscripts/scripts/local.sh                |    1 +
 tests/eventscripts/stubs/ctdb                      |   31 ++++---
 tests/simple/27_ctdb_detach.sh                     |   85 ++++++++++++++++
 tests/src/ctdb_test_stubs.c                        |    9 ++
 ...by.natgwlist.002.sh => stubby.natgwlist.008.sh} |    6 +-
 tools/ctdb.c                                       |   53 ++++++++++-
 20 files changed, 362 insertions(+), 114 deletions(-)
 copy tests/eventscripts/{11.natgw.002.sh => 11.natgw.003.sh} (58%)
 copy tests/eventscripts/{11.natgw.002.sh => 11.natgw.004.sh} (59%)
 create mode 100755 tests/eventscripts/11.natgw.005.sh
 copy tests/eventscripts/{11.natgw.012.sh => 11.natgw.041.sh} (68%)
 copy tests/eventscripts/{11.natgw.012.sh => 11.natgw.042.sh} (66%)
 create mode 100755 tests/simple/27_ctdb_detach.sh
 copy tests/tool/{stubby.natgwlist.002.sh => stubby.natgwlist.008.sh} (76%)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 7560115..51eec0e 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -2120,6 +2120,25 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context 
*ctdb,
        return ctdb_db;
 }
 
+/*
+ * detach from a specific database - client call
+ */
+int ctdb_detach(struct ctdb_context *ctdb, uint32_t db_id)
+{
+       int ret;
+       int32_t status;
+       TDB_DATA data;
+
+       data.dsize = sizeof(db_id);
+       data.dptr = (uint8_t *)&db_id;
+
+       ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_DB_DETACH,
+                          0, data, NULL, NULL, &status, NULL, NULL);
+       if (ret != 0 || status != 0) {
+               return -1;
+       }
+       return 0;
+}
 
 /*
   setup a call for a database
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index b2a219c..f925d4b 100755
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -18,10 +18,12 @@ natgw_check_config ()
 {
     [ -r "$CTDB_NATGW_NODES" ] || \
        die "error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable"
-    [ -n "$CTDB_NATGW_PUBLIC_IP" ] || \
-       die "Invalid configuration: CTDB_NATGW_PUBLIC_IP not set"
-    [ -n "$CTDB_NATGW_PUBLIC_IFACE" ] || \
-       die "Invalid configuration: CTDB_NATGW_PUBLIC_IFACE not set"
+    if [ "$CTDB_NATGW_SLAVE_ONLY" != "yes" ] ; then
+       [ -n "$CTDB_NATGW_PUBLIC_IP" ] || \
+           die "Invalid configuration: CTDB_NATGW_PUBLIC_IP not set"
+       [ -n "$CTDB_NATGW_PUBLIC_IFACE" ] || \
+           die "Invalid configuration: CTDB_NATGW_PUBLIC_IFACE not set"
+    fi
     [ -n "$CTDB_NATGW_PRIVATE_NETWORK" ] || \
        die "Invalid configuration: CTDB_NATGW_PRIVATE_NETWORK not set"
 
diff --git a/doc/ctdb.1.xml b/doc/ctdb.1.xml
index ec8421f..bff1188 100644
--- a/doc/ctdb.1.xml
+++ b/doc/ctdb.1.xml
@@ -94,10 +94,28 @@
     </para>
 
     <para>
-      Commands that reference a database have a
-      <parameter>DB</parameter> argument.  This is either a database
-      name, such as <filename>locking.tdb</filename> or a database ID
-      such as "0x42fe72c5".
+      Commands that reference a database use the following terms:
+      <variablelist>
+       <varlistentry>
+         <term>DB</term>
+         <listitem>
+           <para>
+             This is either a database name, such as
+             <filename>locking.tdb</filename> or a database ID such
+             as "0x42fe72c5".
+           </para>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>DB-LIST</term>
+         <listitem>
+           <para>
+             A space separated list of at least one
+             <parameter>DB</parameter>.
+           </para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
     </para>
   </refsect1>
 
@@ -1545,7 +1563,18 @@ HEALTH: NO-HEALTHY-NODES - ERROR - Backup of corrupted 
TDB in '/var/ctdb/persist
     <refsect2>
       <title>attach <parameter>DBNAME</parameter> [persistent]</title>
       <para>
-       This is a debugging command. This command will make the CTDB daemon 
create a new CTDB database and attach to it.
+       Create a new CTDB database called DBNAME and attach to it on
+       all nodes.
+      </para>
+    </refsect2>
+
+    <refsect2>
+      <title>detach <parameter>DB-LIST</parameter></title>
+      <para>
+       Detach specified non-persistent database(s) from the cluster. This
+       command will disconnect specified database(s) on all nodes in
+       the cluster.  This command should only be used when none of the
+       specified database(s) are in use.
       </para>
     </refsect2>
 
@@ -1644,70 +1673,6 @@ Server id 0:14765 exists
       </refsect3>
     </refsect2>
 
-    <refsect2>
-      <title>vacuum [<parameter>max-records</parameter>]</title>
-      <para>
-       Over time CTDB databases will fill up with empty deleted
-       records which will lead to a progressive slow down of CTDB
-       database access.  This command is used to prune all databases
-       and delete all empty records from the cluster.
-      </para>
-
-      <para>
-       By default, vacuum will delete all empty records from all databases.
-       If [max_records] is specified, the command will only delete the first
-       [max_records] empty records for each database.
-      </para>
-
-      <para>
-       Vacuum only deletes records where the local node is the
-       lmaster.  To delete all records from the entire cluster you
-       need to run a vacuum from each node.
-
-       This command is not disruptive. Samba is unaffected and will still be 
able to read/write records normally while the database is being vacuumed.
-      </para>
-
-      <para>
-       Example: ctdb vacuum
-      </para>
-
-      <para>
-       By default, this operation is issued from the 00.ctdb event script 
every 5 minutes.
-      </para>
-    </refsect2>
-
-    <refsect2>
-      <title>repack [max_freelist]</title>
-      <para>
-       Over time, when records are created and deleted in a TDB, the TDB list 
of free space will become fragmented. This can lead to a slowdown in accessing 
TDB records.
-       This command is used to defragment a TDB database and pruning the 
freelist.
-      </para>
-
-      <para>
-       If [max_freelist] is specified, then a database will only be repacked 
if it has more than this number of entries in the freelist.
-      </para>
-      <para>
-       During repacking of the database, the entire TDB database will be 
locked to prevent writes. If samba tries to write to a record in the database 
during a repack operation, samba will block until the repacking has completed.
-      </para>
-
-      <para>
-       This command can be disruptive and can cause samba to block for the 
duration of the repack operation. In general, a repack operation will take less 
than one second to complete.
-      </para>
-
-      <para>
-       A repack operation will only defragment the local TDB copy of the CTDB 
database. You need to run this command on all of the nodes to repack a CTDB 
database completely.
-      </para>
-
-      <para>
-       Example: ctdb repack 1000
-      </para>
-
-      <para>
-       By default, this operation is issued from the 00.ctdb event script 
every 5 minutes.
-      </para>
-
-    </refsect2>
-
   </refsect1>
 
   <!-- UNDOCUMENTED: showban stats disablemonitor enablemonitor
diff --git a/doc/ctdbd.conf.5.xml b/doc/ctdbd.conf.5.xml
index 188a4df..98d0924 100644
--- a/doc/ctdbd.conf.5.xml
+++ b/doc/ctdbd.conf.5.xml
@@ -537,7 +537,11 @@
          <term>CTDB_NATGW_SLAVE_ONLY=yes|no</term>
          <listitem>
            <para>
-             When set to "yes" a node can not be a NAT gateway master node.
+             When set to "yes" a node can not be a NAT gateway master
+             node.  In this case
+             <varname>CTDB_NATGW_PUBLIC_IFACE</varname> and
+             <varname>CTDB_NATGW_PUBLIC_IP</varname> are optional
+             and unused.
            </para>
            <para>
              Default is no.
diff --git a/include/ctdb_client.h b/include/ctdb_client.h
index d308427..1370ce9 100644
--- a/include/ctdb_client.h
+++ b/include/ctdb_client.h
@@ -97,6 +97,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
                                    bool persistent,
                                    uint32_t tdb_flags);
 
+int ctdb_detach(struct ctdb_context *ctdb, uint32_t db_id);
 
 /*
   find an attached ctdb_db handle given a name
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 2206f4e..8175978 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -900,6 +900,8 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, 
TDB_DATA indata,
                               bool persistent, uint32_t client_id,
                               struct ctdb_req_control *c,
                               bool *async_reply);
+int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
+                              uint32_t client_id);
 
 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
                         ctdb_fn_t fn, int id);
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index fa03a4b..f2d68f4 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -404,6 +404,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 
0,
                    CTDB_CONTROL_RECEIVE_RECORDS         = 136,
                    CTDB_CONTROL_IPREALLOCATED           = 137,
                    CTDB_CONTROL_GET_RUNSTATE            = 138,
+                   CTDB_CONTROL_DB_DETACH               = 139,
 };
 
 /*
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index b56b624..b0220de 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -682,6 +682,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context 
*ctdb,
        case CTDB_CONTROL_RECEIVE_RECORDS:
                return ctdb_control_receive_records(ctdb, indata, outdata);
 
+       case CTDB_CONTROL_DB_DETACH:
+               return ctdb_control_db_detach(ctdb, indata, client_id);
+
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode 
%u\n", opcode));
                return -1;
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index aafba42..3d8772f 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -1164,6 +1164,91 @@ int32_t ctdb_control_db_attach(struct ctdb_context 
*ctdb, TDB_DATA indata,
        return 0;
 }
 
+/*
+ * a client has asked to detach from a database
+ */
+int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
+                              uint32_t client_id)
+{
+       uint32_t db_id;
+       struct ctdb_db_context *ctdb_db;
+       struct ctdb_client *client = NULL;
+
+       db_id = *(uint32_t *)indata.dptr;
+       ctdb_db = find_ctdb_db(ctdb, db_id);
+       if (ctdb_db == NULL) {
+               DEBUG(DEBUG_ERR, ("Invalid dbid 0x%08x in DB detach\n",
+                                 db_id));
+               return -1;
+       }
+
+       if (ctdb->tunable.allow_client_db_attach == 0) {
+               DEBUG(DEBUG_ERR, ("DB detach from database %s denied by "
+                                 "tunable AllowClientDBAccess == 0\n",
+                                 ctdb_db->db_name));
+               return -1;
+       }
+
+       if (ctdb_db->persistent) {
+               DEBUG(DEBUG_ERR, ("DB detach from persistent database %s "
+                                 "denied\n", ctdb_db->db_name));
+               return -1;
+       }
+
+       /* Cannot detach from database when in recovery */
+       if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE) {
+               DEBUG(DEBUG_ERR, ("DB detach denied while in recovery\n"));
+               return -1;
+       }
+
+       /* If a control comes from a client, then broadcast it to all nodes.
+        * Do the actual detach only if the control comes from other daemons.
+        */
+       if (client_id != 0) {
+               client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
+               if (client != NULL) {
+                       /* forward the control to all the nodes */
+                       ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
+                                                CTDB_CONTROL_DB_DETACH, 0,
+                                                CTDB_CTRL_FLAG_NOREPLY,
+                                                indata, NULL, NULL);
+                       return 0;
+               }
+               DEBUG(DEBUG_ERR, ("Client has gone away. Failing DB detach "
+                                 "for database '%s'\n", ctdb_db->db_name));
+               return -1;
+       }
+
+       /* Disable vacuuming and drop all vacuuming data */
+       talloc_free(ctdb_db->vacuum_handle);
+       talloc_free(ctdb_db->delete_queue);
+
+       /* Terminate any deferred fetch */
+       talloc_free(ctdb_db->deferred_fetch);
+
+       /* Terminate any traverses */
+       while (ctdb_db->traverse) {
+               talloc_free(ctdb_db->traverse);
+       }
+
+       /* Terminate any revokes */
+       while (ctdb_db->revokechild_active) {
+               talloc_free(ctdb_db->revokechild_active);
+       }
+
+       /* Free readonly tracking database */
+       if (ctdb_db->readonly) {
+               talloc_free(ctdb_db->rottdb);
+       }
+
+       DLIST_REMOVE(ctdb->db_list, ctdb_db);
+
+       DEBUG(DEBUG_NOTICE, ("Detached from database '%s'\n",
+                            ctdb_db->db_name));
+       talloc_free(ctdb_db);
+
+       return 0;
+}
 
 /*
   attach to all existing persistent databases
diff --git a/tests/eventscripts/11.natgw.002.sh 
b/tests/eventscripts/11.natgw.003.sh
similarity index 58%
copy from tests/eventscripts/11.natgw.002.sh
copy to tests/eventscripts/11.natgw.003.sh
index e496e4a..cb2358f 100755
--- a/tests/eventscripts/11.natgw.002.sh
+++ b/tests/eventscripts/11.natgw.003.sh
@@ -2,7 +2,7 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "missing config file"
+define_test "CTDB_NATGW_PUBLIC_IFACE unset, not slave-only"
 
 setup_ctdb
 setup_ctdb_natgw <<EOF
@@ -12,13 +12,10 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-rm -f "$CTDB_NATGW_NODES"
+CTDB_NATGW_PUBLIC_IFACE=""
 
-required_result 1 <<EOF
-error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable
-EOF
+required_result 1 "Invalid configuration: CTDB_NATGW_PUBLIC_IFACE not set"
 
 for i in "startup" "ipreallocated" "monitor" ; do
     simple_test_event "$i"
 done
-
diff --git a/tests/eventscripts/11.natgw.002.sh 
b/tests/eventscripts/11.natgw.004.sh
similarity index 59%
copy from tests/eventscripts/11.natgw.002.sh
copy to tests/eventscripts/11.natgw.004.sh
index e496e4a..76f1a54 100755
--- a/tests/eventscripts/11.natgw.002.sh
+++ b/tests/eventscripts/11.natgw.004.sh
@@ -2,7 +2,7 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "missing config file"
+define_test "CTDB_NATGW_PUBLIC_IP unset, not slave-only"
 
 setup_ctdb
 setup_ctdb_natgw <<EOF
@@ -12,13 +12,10 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
-rm -f "$CTDB_NATGW_NODES"
+CTDB_NATGW_PUBLIC_IP=""
 
-required_result 1 <<EOF
-error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable
-EOF
+required_result 1 "Invalid configuration: CTDB_NATGW_PUBLIC_IP not set"
 
 for i in "startup" "ipreallocated" "monitor" ; do
     simple_test_event "$i"
 done
-
diff --git a/tests/eventscripts/11.natgw.005.sh 
b/tests/eventscripts/11.natgw.005.sh
new file mode 100755
index 0000000..94a80c8
--- /dev/null
+++ b/tests/eventscripts/11.natgw.005.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "Inconsistent test setup: slave-only but current node is master"
+
+setup_ctdb
+setup_ctdb_natgw <<EOF
+192.168.1.21 master
+192.168.1.22
+192.168.1.23
+192.168.1.24
+EOF
+
+CTDB_NATGW_SLAVE_ONLY="yes"
+
+required_result 1 <<EOF
+Inconsistent test configuration - master node is slave-only
+There is no NATGW master node
+EOF
+
+for i in "ipreallocated" "monitor" ; do
+    simple_test_event "$i"
+done
diff --git a/tests/eventscripts/11.natgw.012.sh 
b/tests/eventscripts/11.natgw.041.sh
similarity index 68%
copy from tests/eventscripts/11.natgw.012.sh
copy to tests/eventscripts/11.natgw.041.sh
index 6ec98a0..22dd392 100755
--- a/tests/eventscripts/11.natgw.012.sh
+++ b/tests/eventscripts/11.natgw.041.sh
@@ -2,10 +2,9 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "slave node, basic configuration"
+define_test "CTDB_NATGW_SLAVE_ONLY=yes, CTDB_NATGW_PUBLIC_IFACE unset"
 
 setup_ctdb
-
 setup_ctdb_natgw <<EOF
 192.168.1.21
 192.168.1.22 master
@@ -13,11 +12,11 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
+CTDB_NATGW_PUBLIC_IFACE=""
+CTDB_NATGW_SLAVE_ONLY="yes"
+
 ok_null
 simple_test_event "ipreallocated"
 
 ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX  metric 10 "
 simple_test_command ip route show
-
-ok_natgw_slave_ip_addr_show
-simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
diff --git a/tests/eventscripts/11.natgw.012.sh 
b/tests/eventscripts/11.natgw.042.sh
similarity index 66%
copy from tests/eventscripts/11.natgw.012.sh
copy to tests/eventscripts/11.natgw.042.sh
index 6ec98a0..9019d4a 100755
--- a/tests/eventscripts/11.natgw.012.sh
+++ b/tests/eventscripts/11.natgw.042.sh
@@ -2,10 +2,9 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "slave node, basic configuration"
+define_test "CTDB_NATGW_SLAVE_ONLY=yes, CTDB_NATGW_PUBLIC_IP unset"
 
 setup_ctdb
-
 setup_ctdb_natgw <<EOF
 192.168.1.21
 192.168.1.22 master
@@ -13,11 +12,12 @@ setup_ctdb_natgw <<EOF
 192.168.1.24
 EOF
 
+CTDB_NATGW_PUBLIC_IFACE=""
+CTDB_NATGW_PUBLIC_IP=""
+CTDB_NATGW_SLAVE_ONLY="yes"
+
 ok_null
 simple_test_event "ipreallocated"


-- 
CTDB repository

Reply via email to