[SCM] Samba Shared Repository - branch master updated
Amitay Isaacs
amitay at samba.org
Mon Mar 16 02:19:02 MDT 2015
The branch, master has been updated
via 8f312ae ctdb-tests: Add tests for "ctdb reloadips" and "ctdb recover"
via a3f39ae ctdb-tools: Drop a debug message to DEBUG level
via 3fc205e ctdb-tests: Add stub for ctdb_client_async_control()
via d9b46d3 ctdb-tests: Add stub for ctdb_ctrl_reload_nodes_file()
via 5fdd580 ctdb-tests: Add stubs for some CTDB client messaging functions
via e1b4cd1 ctdb-tests: Test stub fixes
via 65c3c57 ctdb-tests: Handle deleted nodes when loading fake nodemap
via a68df0a ctdb-tests: Support CTDB_DEBUGLEVEL in tool tests
via dae6a7c ctdb-tests: Add ctdb_ctrl_setrecmode() stub
via 38279d7 ctdb-eventscripts: Make 11.natgw stateful
via 57a80eb Do not use popt_common.h in dlz_bind9
from 65379ef param: Use IDL-based constants for NBT and NBT dgram ports
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 8f312aef8434dad317eab3491ff37383368ab763
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Mar 13 15:00:03 2015 +1100
ctdb-tests: Add tests for "ctdb reloadips" and "ctdb recover"
Although much of the test infrastructure in recent commits is actually
targeted for "reloadnodes", it is worthwhile adding some tests for
"reloadips" and "recover". This allows most of the test
infrastructure to be tried out against known good code.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
Autobuild-Date(master): Mon Mar 16 09:18:55 CET 2015 on sn-devel-104
commit a3f39ae7d7439c44da21e3cb506aa655ec3264de
Author: Martin Schwenke <martin at meltin.net>
Date: Sun Feb 8 08:16:47 2015 +1100
ctdb-tools: Drop a debug message to DEBUG level
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 3fc205e6d7e74fb9119aa806c255c61fd6ea8cf3
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 25 11:41:48 2015 +1100
ctdb-tests: Add stub for ctdb_client_async_control()
With support for CTDB_CONTROL_RELOAD_PUBLIC_IPS and
CTDB_CONTROL_RELOAD_NODES_FILE for now.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit d9b46d33f0ea70f12da784c2ea81a96eb2eb213c
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 4 14:57:03 2015 +1100
ctdb-tests: Add stub for ctdb_ctrl_reload_nodes_file()
ctdb_ctrl_reload_nodes_file_stub() does nothing except print a helpful
message. That's enough to help test the tool. It could update the
nodemap but that would not be incredibly useful.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 5fdd580bb3e49f00d0412379258358e5488b413d
Author: Martin Schwenke <martin at meltin.net>
Date: Sun Feb 8 08:07:56 2015 +1100
ctdb-tests: Add stubs for some CTDB client messaging functions
Stub for ctdb_client_send_message() only implements
CTDB_SRVID_TAKEOVER_RUN and CTDB_SRVID_DISABLE_TAKEOVER_RUNS. It
assumes srvid_broadcast() is in use and just calls handler to fake
appropriate replies.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit e1b4cd19a53213302bb617af2e7c68e06051a4bc
Author: Martin Schwenke <martin at meltin.net>
Date: Sun Feb 8 08:14:41 2015 +1100
ctdb-tests: Test stub fixes
Initialise ctdb->ev in ctdb_cmdline_client_stub().
Add a comment to tevent_context_init_stub() explaining why the ctdb
context is initialised there instead of ctdb_cmdline_client_stub().
This information is in the git log but that doesn't help someone who
is reading the code.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 65c3c5730cc17d84bb731b0a383fa99e66187d51
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Feb 9 17:04:30 2015 +1100
ctdb-tests: Handle deleted nodes when loading fake nodemap
The daemon uses an IP address of "0.0.0.0" when handling deleted
nodes. Do the same in the tests when loading a fake nodemap.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit a68df0a06d3a7fecb2ac295a29cab010026ecd9c
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 4 14:56:17 2015 +1100
ctdb-tests: Support CTDB_DEBUGLEVEL in tool tests
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit dae6a7c4bad3c676c7837f7b8504c2cb16a8a811
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Feb 9 21:55:59 2015 +1100
ctdb-tests: Add ctdb_ctrl_setrecmode() stub
If recovery mode is set to active then it updates the generation and
immediately sets recovery mode back to normal.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 38279d7ec1d877e5c3752fce5c0f74e19f148674
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Mar 26 16:50:59 2014 +1100
ctdb-eventscripts: Make 11.natgw stateful
IP addresses and routes are only changed if either the NAT gateway
configuration or the NAT gateway master node has changed. If running
"ip monitor" this will minimise the amount of noise seen. It should
also be more lightweight at the expense of managing a couple of state
files.
Add a test to check that configuration changes behave correctly.
Tweak the static route result generation code so that the required
output is sorted.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 57a80ebee36aceee307318638c49826df2ca54f4
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Mar 16 11:26:16 2015 +1300
Do not use popt_common.h in dlz_bind9
We do not use popt_common structures here
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
-----------------------------------------------------------------------
Summary of changes:
ctdb/config/events.d/11.natgw | 76 +++++++-
ctdb/tests/eventscripts/11.natgw.015.sh | 4 +-
ctdb/tests/eventscripts/11.natgw.025.sh | 4 +-
.../{11.natgw.025.sh => 11.natgw.031.sh} | 34 ++--
ctdb/tests/eventscripts/scripts/local.sh | 2 +
ctdb/tests/eventscripts/stubs/ip | 2 +-
ctdb/tests/src/ctdb_test.c | 44 +++++
ctdb/tests/src/ctdb_test_stubs.c | 206 ++++++++++++++++++++-
ctdb/tests/tool/scripts/local.sh | 3 +
ctdb/tests/tool/stubby.recover.001.sh | 20 ++
ctdb/tests/tool/stubby.reloadips.001.sh | 17 ++
ctdb/tests/tool/stubby.reloadips.002.sh | 25 +++
ctdb/tests/tool/stubby.reloadips.003.sh | 19 ++
ctdb/tools/ctdb.c | 2 +-
source4/dns_server/dlz_bind9.c | 2 +-
15 files changed, 430 insertions(+), 30 deletions(-)
copy ctdb/tests/eventscripts/{11.natgw.025.sh => 11.natgw.031.sh} (54%)
create mode 100755 ctdb/tests/tool/stubby.recover.001.sh
create mode 100755 ctdb/tests/tool/stubby.reloadips.001.sh
create mode 100755 ctdb/tests/tool/stubby.reloadips.002.sh
create mode 100755 ctdb/tests/tool/stubby.reloadips.003.sh
Changeset truncated at 500 lines:
diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw
index aef302c..e107f47 100755
--- a/ctdb/config/events.d/11.natgw
+++ b/ctdb/config/events.d/11.natgw
@@ -9,11 +9,20 @@
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
. $CTDB_BASE/functions
+
+service_name=natgw
+
loadconfig
[ -n "$CTDB_NATGW_NODES" ] || exit 0
export CTDB_NATGW_NODES
+ctdb_setup_service_state_dir
+
+natgw_cfg_new="${service_state_dir}/cfg_new"
+natgw_cfg_old="${service_state_dir}/cfg_old"
+natgw_master_old="${service_state_dir}/master_old"
+
natgw_check_config ()
{
[ -r "$CTDB_NATGW_NODES" ] || \
@@ -31,6 +40,39 @@ natgw_check_config ()
[ -n "$CTDB_NATGW_STATIC_ROUTES" ] || CTDB_NATGW_STATIC_ROUTES="0.0.0.0/0"
}
+natgw_write_config ()
+{
+ _f="$1"
+
+ cat >"$_f" <<EOF
+CTDB_NATGW_NODES="$CTDB_NATGW_NODES"
+CTDB_NATGW_PUBLIC_IP="$CTDB_NATGW_PUBLIC_IP"
+CTDB_NATGW_PUBLIC_IFACE="$CTDB_NATGW_PUBLIC_IFACE"
+CTDB_NATGW_DEFAULT_GATEWAY="$CTDB_NATGW_DEFAULT_GATEWAY"
+CTDB_NATGW_PRIVATE_NETWORK="$CTDB_NATGW_PRIVATE_NETWORK"
+CTDB_NATGW_STATIC_ROUTES="$CTDB_NATGW_STATIC_ROUTES"
+CTDB_NATGW_SLAVE_ONLY="$CTDB_NATGW_SLAVE_ONLY"
+EOF
+}
+
+natgw_config_has_changed ()
+{
+ natgw_write_config "$natgw_cfg_new"
+
+ # Non-existent old returns true, no log message
+ if [ ! -f "$natgw_cfg_old" ] ; then
+ return 0
+ fi
+
+ # Handle no change
+ if cmp "$natgw_cfg_old" "$natgw_cfg_new" >/dev/null 2>&1 ; then
+ return 1
+ fi
+
+ echo "NAT gateway configuration has changed"
+ return 0
+}
+
natgw_set_capability ()
{
# Set NATGW capability depending on configuration
@@ -41,7 +83,7 @@ natgw_set_capability ()
fi
}
-natgw_clear ()
+_natgw_clear ()
{
_ip="${CTDB_NATGW_PUBLIC_IP%/*}"
_maskbits="${CTDB_NATGW_PUBLIC_IP#*/}"
@@ -62,6 +104,15 @@ natgw_clear ()
iptables -D INPUT -p tcp --syn -d $_ip/32 -j REJECT 2>/dev/null
}
+natgw_clear ()
+{
+ if [ -r "$natgw_cfg_old" ] ; then
+ (. $natgw_cfg_old ; _natgw_clear)
+ else
+ _natgw_clear
+ fi
+}
+
natgw_set_master ()
{
set_proc sys/net/ipv4/ip_forward 1
@@ -116,6 +167,24 @@ natgw_ensure_master ()
fi
}
+natgw_master_has_changed ()
+{
+ if [ -r "$natgw_master_old" ] ; then
+ read _old_natgwmaster <"$natgw_master_old"
+ else
+ _old_natgwmaster=""
+ fi
+ [ "$_old_natgwmaster" != "$natgwmaster" ]
+}
+
+natgw_save_state ()
+{
+ echo "$natgwmaster" >"$natgw_master_old"
+ # Created by natgw_config_has_changed()
+ mv "$natgw_cfg_new" "$natgw_cfg_old"
+}
+
+
case "$1" in
setup)
natgw_check_config
@@ -144,6 +213,8 @@ case "$1" in
natgw_set_capability
natgw_ensure_master
+ natgw_config_has_changed || natgw_master_has_changed || exit 0
+
natgw_clear
if [ "$mypnn" = "$natgwmaster" ]; then
@@ -154,6 +225,9 @@ case "$1" in
# flush our route cache
set_proc sys/net/ipv4/route/flush 1
+
+ # Only update saved state when NATGW successfully updated
+ natgw_save_state
;;
shutdown|removenatgw)
diff --git a/ctdb/tests/eventscripts/11.natgw.015.sh b/ctdb/tests/eventscripts/11.natgw.015.sh
index d202ae6..c7e0c15 100755
--- a/ctdb/tests/eventscripts/11.natgw.015.sh
+++ b/ctdb/tests/eventscripts/11.natgw.015.sh
@@ -33,7 +33,7 @@ setup_ctdb_natgw <<EOF
192.168.1.24
EOF
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
@@ -51,7 +51,7 @@ setup_ctdb_natgw <<EOF
192.168.1.24
EOF
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
diff --git a/ctdb/tests/eventscripts/11.natgw.025.sh b/ctdb/tests/eventscripts/11.natgw.025.sh
index 60602d3..456fc3c 100755
--- a/ctdb/tests/eventscripts/11.natgw.025.sh
+++ b/ctdb/tests/eventscripts/11.natgw.025.sh
@@ -35,7 +35,7 @@ setup_ctdb_natgw <<EOF
192.168.1.24
EOF
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok_natgw_slave_static_routes
@@ -53,7 +53,7 @@ setup_ctdb_natgw <<EOF
192.168.1.24
EOF
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
diff --git a/ctdb/tests/eventscripts/11.natgw.025.sh b/ctdb/tests/eventscripts/11.natgw.031.sh
similarity index 54%
copy from ctdb/tests/eventscripts/11.natgw.025.sh
copy to ctdb/tests/eventscripts/11.natgw.031.sh
index 60602d3..a8575a5 100755
--- a/ctdb/tests/eventscripts/11.natgw.025.sh
+++ b/ctdb/tests/eventscripts/11.natgw.031.sh
@@ -2,13 +2,14 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
-define_test "static routes, custom gateway, multiple transitions"
+define_test "master node, static routes, custom gateway, config change"
setup_ctdb
export CTDB_NATGW_STATIC_ROUTES="10.1.1.0/24 10.1.2.0/24 at 10.1.1.253"
-echo "*** Master node..."
+echo "##################################################"
+echo "Static routes..."
setup_ctdb_natgw <<EOF
192.168.1.21 master
@@ -26,34 +27,26 @@ simple_test_command ip route show
ok_natgw_master_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
-echo "*** Slave node..."
+echo "##################################################"
+echo "Default routes..."
-setup_ctdb_natgw <<EOF
-192.168.1.21
-192.168.1.22 master
-192.168.1.23
-192.168.1.24
-EOF
+unset CTDB_NATGW_STATIC_ROUTES
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
-ok_natgw_slave_static_routes
+ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX metric 10 "
simple_test_command ip route show
-ok_natgw_slave_ip_addr_show
+ok_natgw_master_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
-echo "*** Master node again..."
+echo "##################################################"
+echo "Static routes again..."
-setup_ctdb_natgw <<EOF
-192.168.1.21 master
-192.168.1.22
-192.168.1.23
-192.168.1.24
-EOF
+export CTDB_NATGW_STATIC_ROUTES="10.1.3.0/24 10.1.4.4/32 10.1.2.0/24 at 10.1.1.252"
-ok_null
+ok "NAT gateway configuration has changed"
simple_test_event "ipreallocated"
ok_natgw_master_static_routes
@@ -61,4 +54,3 @@ simple_test_command ip route show
ok_natgw_master_ip_addr_show
simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
-
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index 219bbee..aba53e8 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -675,6 +675,7 @@ ok_natgw_master_static_routes ()
_t="${_t}${_t:+${_nl}}"
_t="${_t}${_net} via ${_gw} dev ethXXX metric 10 "
done
+ _t=$(echo "$_t" | sort)
ok "$_t"
}
@@ -694,6 +695,7 @@ ok_natgw_slave_static_routes ()
_t="${_t}${_t:+${_nl}}"
_t="${_t}${_net} via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX metric 10 "
done
+ _t=$(echo "$_t" | sort)
ok "$_t"
}
diff --git a/ctdb/tests/eventscripts/stubs/ip b/ctdb/tests/eventscripts/stubs/ip
index e8f17d8..696758b 100755
--- a/ctdb/tests/eventscripts/stubs/ip
+++ b/ctdb/tests/eventscripts/stubs/ip
@@ -479,7 +479,7 @@ ip_route_show ()
ip_route_common "$@"
# Missing file is just an empty table
- cat "$FAKE_IP_STATE/routes/${_table}" 2>/dev/null || true
+ sort "$FAKE_IP_STATE/routes/${_table}" 2>/dev/null || true
}
ip_route_flush ()
diff --git a/ctdb/tests/src/ctdb_test.c b/ctdb/tests/src/ctdb_test.c
index 5a067ab..0ff1803 100644
--- a/ctdb/tests/src/ctdb_test.c
+++ b/ctdb/tests/src/ctdb_test.c
@@ -41,18 +41,30 @@ int main_foobar(int argc, const char **argv);
ctdb_ctrl_getpnn_stub(ctdb, timelimit, pnn)
#define ctdb_ctrl_getrecmode(ctdb, tmp_ctx, timelimit, pnn, recmode) \
ctdb_ctrl_getrecmode_stub(ctdb, tmp_ctx, timelimit, pnn, recmode)
+#define ctdb_ctrl_setrecmode(ctdb, timeout, destnode, recmode) \
+ ctdb_ctrl_setrecmode_stub(ctdb, timeout, destnode, recmode)
#define ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timelimit, pnn, recmaster) \
ctdb_ctrl_getrecmaster_stub(ctdb, tmp_ctx, timelimit, pnn, recmaster)
#define ctdb_ctrl_getvnnmap(ctdb, timelimit, pnn, tmp_ctx, vnnmap) \
ctdb_ctrl_getvnnmap_stub(ctdb, timelimit, pnn, tmp_ctx, vnnmap)
#define ctdb_ctrl_getdebseqnum(ctdb, timelimit, pnn, db_id, seqnum) \
ctdb_ctrl_getvnnmap_stub(ctdb, timelimit, pnn, db_id, seqnum)
+#define ctdb_client_set_message_handler(ctdb, srvid, handler, private_data) \
+ ctdb_client_set_message_handler_stub(ctdb, srvid, handler, private_data)
+#define ctdb_client_remove_message_handler(ctdb, srvid, private_data) \
+ ctdb_client_remove_message_handler_stub(ctdb, srvid, private_data)
+#define ctdb_client_send_message(ctdb, pnn, srvid, data) \
+ ctdb_client_send_message_stub(ctdb, pnn, srvid, data)
#define ctdb_client_check_message_handlers(ctdb, ids, argc, result) \
ctdb_client_check_message_handlers_stub(ctdb, ids, argc, result)
#define ctdb_ctrl_getcapabilities(ctdb, timeout, destnode, capabilities) \
ctdb_ctrl_getcapabilities_stub(ctdb, timeout, destnode, capabilities)
+#define ctdb_ctrl_reload_nodes_file(ctdb, timeout, destnode) \
+ ctdb_ctrl_reload_nodes_file_stub(ctdb, timeout, destnode)
#define ctdb_sys_have_ip(addr) \
ctdb_sys_have_ip_stub(addr)
+#define ctdb_client_async_control(ctdb, opcode, nodes, srvid, timeout, dont_log_errors, data, client_callback, fail_callback, callback_data) \
+ ctdb_client_async_control_stub(ctdb, opcode, nodes, srvid, timeout, dont_log_errors, data, client_callback, fail_callback, callback_data)
#include "tools/ctdb.c"
@@ -73,12 +85,19 @@ struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
#undef ctdb_ctrl_get_ifaces
#undef ctdb_ctrl_getpnn
#undef ctdb_ctrl_getrecmode
+#undef ctdb_ctrl_setrecmode
#undef ctdb_ctrl_getrecmaster
#undef ctdb_ctrl_getvnnmap
#undef ctdb_ctrl_getdebseqnum
+#undef ctdb_client_set_message_handler
+#undef ctdb_client_remove_message_handler
+#undef ctdb_client_send_message
#undef ctdb_client_check_message_handlers
#undef ctdb_ctrl_getcapabilities
+#undef ctdb_ctrl_reload_nodes_file
#undef ctdb_sys_have_ip
+#undef ctdb_client_async_control
+
int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
@@ -91,6 +110,8 @@ int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout,
int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx, struct timeval timeout,
uint32_t destnode, uint32_t *recmode);
+int ctdb_ctrl_setrecmode(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, uint32_t recmode);
int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx, struct timeval timeout,
uint32_t destnode, uint32_t *recmaster);
@@ -99,13 +120,36 @@ int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx, struct ctdb_vnn_map **vnnmap);
int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, uint32_t dbid, uint64_t *seqnum);
+int ctdb_client_set_message_handler(struct ctdb_context *ctdb,
+ uint64_t srvid,
+ ctdb_msg_fn_t handler,
+ void *private_data);
+int ctdb_client_remove_message_handler(struct ctdb_context *ctdb,
+ uint64_t srvid,
+ void *private_data);
+int ctdb_client_send_message(struct ctdb_context *ctdb,
+ uint32_t pnn,
+ uint64_t srvid, TDB_DATA data);
int ctdb_client_check_message_handlers(struct ctdb_context *ctdb,
uint64_t *ids, uint32_t num,
uint8_t *result);
int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
uint32_t *capabilities);
+int ctdb_ctrl_reload_nodes_file(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode);
bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
+int
+ctdb_client_async_control(struct ctdb_context *ctdb,
+ enum ctdb_controls opcode,
+ uint32_t *nodes,
+ uint64_t srvid,
+ struct timeval timeout,
+ bool dont_log_errors,
+ TDB_DATA data,
+ client_async_callback client_callback,
+ client_async_callback fail_callback,
+ void *callback_data);
#undef TIMELIMIT
#include "tools/ctdb_vacuum.c"
diff --git a/ctdb/tests/src/ctdb_test_stubs.c b/ctdb/tests/src/ctdb_test_stubs.c
index 82e82f3..f6d43b1 100644
--- a/ctdb/tests/src/ctdb_test_stubs.c
+++ b/ctdb/tests/src/ctdb_test_stubs.c
@@ -48,7 +48,7 @@ static void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb)
(line[0] != '\n')) {
uint32_t pnn, flags, capabilities;
char *tok, *t;
- const char *ip;
+ char *ip;
ctdb_sock_addr saddr;
/* Get rid of pesky newline */
@@ -83,6 +83,11 @@ static void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb)
continue;
}
flags = (uint32_t)strtoul(tok, NULL, 0);
+ /* Handle deleted nodes */
+ if (flags & NODE_FLAGS_DELETED) {
+ talloc_free(ip);
+ ip = talloc_strdup(ctdb, "0.0.0.0");
+ }
capabilities = CTDB_CAP_RECMASTER|CTDB_CAP_LMASTER|CTDB_CAP_NATGW;
tok = strtok(NULL, " \t");
@@ -355,6 +360,15 @@ static bool current_node_is_connected (struct ctdb_context *ctdb)
struct ctdb_context *ctdb_cmdline_client_stub(struct tevent_context *ev,
struct timeval req_timeout)
{
+ const char *t = getenv("CTDB_DEBUGLEVEL");
+ if (t != NULL) {
+ DEBUGLEVEL= atoi(t);
+ } else {
+ DEBUGLEVEL = 0;
+ }
+
+ ctdb_global->ev = ev;
+
return ctdb_global;
}
@@ -362,6 +376,8 @@ struct tevent_context *tevent_context_init_stub(TALLOC_CTX *mem_ctx)
{
struct ctdb_context *ctdb;
+ /* This needs to be initialised prior to the client setup, for
+ the xpnn stub */
ctdb = talloc_zero(NULL, struct ctdb_context);
ctdb_set_socketname(ctdb, "fake");
@@ -468,6 +484,20 @@ ctdb_ctrl_getrecmode_stub(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
return 0;
}
+int ctdb_ctrl_setrecmode_stub(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, uint32_t recmode)
+{
+ ctdb->recovery_mode = recmode;
+
+ if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE) {
+ /* Recovery is complete! That was quick.... */
+ ctdb->recovery_mode = CTDB_RECOVERY_NORMAL;
+ ctdb->vnn_map->generation++;
+ }
+
+ return 0;
+}
+
int
ctdb_ctrl_getrecmaster_stub(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
struct timeval timeout, uint32_t destnode,
@@ -554,6 +584,120 @@ ctdb_ctrl_get_ifaces_stub(struct ctdb_context *ctdb,
return ret;
}
+/* In reality handlers can be registered for many srvids. However,
+ * the ctdb tool only registers one at a time so keep this simple. */
+static struct {
+ uint64_t srvid;
+ ctdb_msg_fn_t message_handler;
+ void *message_private;
+} ctdb_message_list_fake = {
+ .srvid = 0,
+ .message_handler = NULL,
+ .message_private = NULL,
+};
+
+int ctdb_client_set_message_handler_stub(struct ctdb_context *ctdb,
+ uint64_t srvid,
+ ctdb_msg_fn_t handler,
+ void *private_data)
+{
+ ctdb_message_list_fake.srvid = srvid;
+ ctdb_message_list_fake.message_handler = handler;
+ ctdb_message_list_fake.message_private = private_data;
+
+ return 0;
+}
+
+int ctdb_client_remove_message_handler_stub(struct ctdb_context *ctdb,
+ uint64_t srvid,
+ void *private_data)
+{
+ ctdb_message_list_fake.srvid = 0;
+ ctdb_message_list_fake.message_handler = NULL;
+ ctdb_message_list_fake.message_private = NULL;
+
+ return 0;
+}
+
+static void ctdb_fake_handler_pnn_reply(struct ctdb_context *ctdb,
+ uint32_t pnn)
+{
+ TDB_DATA reply_data;
--
Samba Shared Repository
More information about the samba-cvs
mailing list