[SCM] Samba Shared Repository - branch master updated
Amitay Isaacs
amitay at samba.org
Mon Feb 10 05:35:03 UTC 2020
The branch, master has been updated
via 0b3db29bd5f ctdb-tests: Add some tool unit tests to ensure that timeouts work
via 0e59cd25e1a ctdb-tools: Allow shorter runtime limit to be specified
via 39206fd327f ctdb-tools: When in test mode set process group in top-level ctdb tool
via 3b0b830e403 ctdb-tests: Use $PWD/bin/ if it exists when running in-tree
via b0b14e4edda ctdb-tests: Make $ctdb_dir absolute
via 1a0e1f89246 ctdb-daemon: Fork when not interactive and test mode is enabled
via a220e9454a6 ctdb-daemon: Make some conditions more explicit
via cefb3327c67 ctdb-daemon: Pass more information to ctdb_start_daemon()
via 3509aa28d4b ctdb-tests: Don't actually close stdin in fake ssh
via 8de1bb75e56 ctdb-tests: Redirect stdin from /dev/null when running a test
via 0737849b905 Revert "ctdb-tests: Enable job control when keeping stdin open"
from 2d9841c9788 smbd: Remove overriding file_attributes with unix_mode in the VFS
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0b3db29bd5f44daa0abb64ba4a7bb5e5cad2a6ac
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Jan 7 16:30:23 2020 +1100
ctdb-tests: Add some tool unit tests to ensure that timeouts work
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 Feb 10 05:34:08 UTC 2020 on sn-devel-184
commit 0e59cd25e1a254fc20bf6d0227695bf67cec3d9d
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Jan 7 16:26:42 2020 +1100
ctdb-tools: Allow shorter runtime limit to be specified
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 39206fd327f1ea154a8936b99cba0bf9bf221484
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 7 16:11:23 2020 +1100
ctdb-tools: When in test mode set process group in top-level ctdb tool
If ctdbd hangs when shutting down in post-test clean-up then killing
the process group can kill the test. When in test mode, create a
process group but only in the top-level ctdb tool - the natgw and lvs
helpers also run the ctdb tool.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 3b0b830e40330b7fa679cf3c6e25dfb29d19e969
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 5 12:09:51 2020 +1100
ctdb-tests: Use $PWD/bin/ if it exists when running in-tree
When running tests from a top-level build, a stale build in ctdb/bin/
will be preferred and may cause confusing results.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit b0b14e4eddab78ef71bc6d39f016e4a18929fd64
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 5 12:07:55 2020 +1100
ctdb-tests: Make $ctdb_dir absolute
This is used to set several variables so it might as well be cd-proof.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 1a0e1f89246685730612819d23a8398b340cb673
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jan 29 16:28:46 2020 +1100
ctdb-daemon: Fork when not interactive and test mode is enabled
There is no sane way of keeping stdin open when using the shell to
background ctdbd in local_daemons.sh. Instead, have ctdbd fork when
not interactive and when test mode is enabled. become_daemon() can't
be used for this: if it forks then it also closes stdin.
For the interactive case, become_daemon() wasn't doing anything
special, so do nothing instead.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit a220e9454a6dd56f3b0f317d9b4361d0328ff79a
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jan 29 16:26:03 2020 +1100
ctdb-daemon: Make some conditions more explicit
These don't need to depend on do_fork. Child logging should be set up
whenever the daemon is not interactive. The stdin handler should be
setup whenever test mode is enabled.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit cefb3327c67d7632fae9a931844671b43b0c2d90
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jan 29 16:08:56 2020 +1100
ctdb-daemon: Pass more information to ctdb_start_daemon()
No functional changes.
This is staging for a change that makes ctdbd fork when test mode is
enabled but interactive is not set.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 3509aa28d4b76799cbcbe60ae6c5455c93d74b0c
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Jan 30 13:38:52 2020 +1100
ctdb-tests: Don't actually close stdin in fake ssh
A subsequent file descriptor allocation may return 0 and unexpected
things may then happen.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 8de1bb75e56525d43665f0a48abbf47dd91aa9c3
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Jan 30 13:37:00 2020 +1100
ctdb-tests: Redirect stdin from /dev/null when running a test
Otherwise, if the test is run via ssh it will "unexpectedly" find
itself at the other end of a pipe.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 0737849b90523deb073d0d4987e62d52c57c3e94
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Jan 29 14:30:25 2020 +1100
Revert "ctdb-tests: Enable job control when keeping stdin open"
This doesn't work when stdin is not a tty.
This reverts commit ea754bfdec9d537c500036d4d521bd41d34c0835.
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
-----------------------------------------------------------------------
Summary of changes:
ctdb/include/ctdb_private.h | 4 ++-
ctdb/server/ctdb_daemon.c | 35 +++++++++++++++++++---
ctdb/server/ctdbd.c | 5 +---
.../tool/{ctdb.lvs.001.sh => ctdb.getpid.010.sh} | 23 ++++----------
ctdb/tests/UNIT/tool/ctdb.lvs.010.sh | 25 ++++++++++++++++
ctdb/tests/UNIT/tool/ctdb.natgw.010.sh | 25 ++++++++++++++++
ctdb/tests/local_daemons.sh | 6 ++--
ctdb/tests/run_tests.sh | 2 +-
ctdb/tests/scripts/script_install_paths.sh | 35 +++++++++++++++++-----
ctdb/tools/ctdb.c | 15 +++++++---
10 files changed, 134 insertions(+), 41 deletions(-)
copy ctdb/tests/UNIT/tool/{ctdb.lvs.001.sh => ctdb.getpid.010.sh} (52%)
create mode 100755 ctdb/tests/UNIT/tool/ctdb.lvs.010.sh
create mode 100755 ctdb/tests/UNIT/tool/ctdb.natgw.010.sh
Changeset truncated at 500 lines:
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 6aba3c1d48e..de7caef52af 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -556,7 +556,9 @@ int daemon_deregister_message_handler(struct ctdb_context *ctdb,
void daemon_tunnel_handler(uint64_t tunnel_id, TDB_DATA data,
void *private_data);
-int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
+int ctdb_start_daemon(struct ctdb_context *ctdb,
+ bool interactive,
+ bool test_mode_enabled);
struct ctdb_req_header *_ctdb_transport_allocate(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx,
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index c4ab2dbc3d3..7ebb419bc1f 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -1439,15 +1439,42 @@ static int setup_stdin_handler(struct ctdb_context *ctdb)
return 0;
}
+static void fork_only(void)
+{
+ pid_t pid;
+
+ pid = fork();
+ if (pid == -1) {
+ D_ERR("Fork failed (errno=%d)\n", errno);
+ exit(1);
+ }
+
+ if (pid != 0) {
+ /* Parent simply exits... */
+ exit(0);
+ }
+}
+
/*
start the protocol going as a daemon
*/
-int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
+int ctdb_start_daemon(struct ctdb_context *ctdb,
+ bool interactive,
+ bool test_mode_enabled)
{
int res, ret = -1;
struct tevent_fd *fde;
- become_daemon(do_fork, !do_fork, false);
+ /* Fork if not interactive */
+ if (!interactive) {
+ if (test_mode_enabled) {
+ /* Keep stdin open */
+ fork_only();
+ } else {
+ /* Fork, close stdin, start a session */
+ become_daemon(true, false, false);
+ }
+ }
ignore_signal(SIGPIPE);
ignore_signal(SIGUSR1);
@@ -1494,12 +1521,12 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
exit(1);
}
- if (do_fork) {
+ if (!interactive) {
ctdb_set_child_logging(ctdb);
}
/* Exit if stdin is closed */
- if (!do_fork) {
+ if (test_mode_enabled) {
ret = setup_stdin_handler(ctdb);
if (ret != 0) {
DBG_ERR("Failed to setup stdin handler\n");
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index 7e71d6e8272..c2dcf7d0606 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -394,11 +394,8 @@ int main(int argc, const char *argv[])
fast_start = true;
}
- /* Don't fork when running in test mode */
- interactive = interactive || test_mode != NULL;
-
/* start the protocol running (as a child) */
- return ctdb_start_daemon(ctdb, !interactive);
+ return ctdb_start_daemon(ctdb, interactive, test_mode != NULL);
fail:
talloc_free(ctdb);
diff --git a/ctdb/tests/UNIT/tool/ctdb.lvs.001.sh b/ctdb/tests/UNIT/tool/ctdb.getpid.010.sh
similarity index 52%
copy from ctdb/tests/UNIT/tool/ctdb.lvs.001.sh
copy to ctdb/tests/UNIT/tool/ctdb.getpid.010.sh
index 411072c5da4..6e220a2f8d7 100755
--- a/ctdb/tests/UNIT/tool/ctdb.lvs.001.sh
+++ b/ctdb/tests/UNIT/tool/ctdb.getpid.010.sh
@@ -2,7 +2,7 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
-define_test "3 nodes, no LVS, all ok"
+define_test "3 nodes, all ok, GET_PID control times out"
setup_lvs <<EOF
EOF
@@ -12,25 +12,14 @@ NODEMAP
0 192.168.20.41 0x0 CURRENT RECMASTER
1 192.168.20.42 0x0
2 192.168.20.43 0x0
-EOF
-
-#####
-
-required_result 255 <<EOF
-EOF
-simple_test master
-
-#####
-
-required_result 0 <<EOF
+CONTROLFAILS
+30 0 TIMEOUT # Make "ctdb getpid" time out
EOF
-simple_test list
-
#####
-required_result 0 <<EOF
+required_result 1 <<EOF
+Maximum runtime exceeded - exiting
EOF
-
-simple_test status
+simple_test -T 3
diff --git a/ctdb/tests/UNIT/tool/ctdb.lvs.010.sh b/ctdb/tests/UNIT/tool/ctdb.lvs.010.sh
new file mode 100755
index 00000000000..d4339391ba1
--- /dev/null
+++ b/ctdb/tests/UNIT/tool/ctdb.lvs.010.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, all ok, GET_NODEMAP control times out"
+
+setup_lvs <<EOF
+EOF
+
+setup_ctdbd <<EOF
+NODEMAP
+0 192.168.20.41 0x0 CURRENT RECMASTER
+1 192.168.20.42 0x0
+2 192.168.20.43 0x0
+
+CONTROLFAILS
+91 0 TIMEOUT # Make "ctdb nodestatus" time out in ctdb_lvs helper
+EOF
+
+#####
+
+required_result 1 <<EOF
+Maximum runtime exceeded - exiting
+EOF
+simple_test status -T 3
diff --git a/ctdb/tests/UNIT/tool/ctdb.natgw.010.sh b/ctdb/tests/UNIT/tool/ctdb.natgw.010.sh
new file mode 100755
index 00000000000..a3a0e9d121f
--- /dev/null
+++ b/ctdb/tests/UNIT/tool/ctdb.natgw.010.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, all OK, GET_NODEMAP control times out"
+
+setup_natgw <<EOF
+EOF
+
+setup_ctdbd <<EOF
+NODEMAP
+0 192.168.20.41 0x0 CURRENT RECMASTER
+1 192.168.20.42 0x0
+2 192.168.20.43 0x0
+
+CONTROLFAILS
+91 0 TIMEOUT # Make "ctdb nodestatus" time out in ctdb_natgw helper
+EOF
+
+#####
+
+required_result 1 <<EOF
+Maximum runtime exceeded - exiting
+EOF
+simple_test status -T 3
diff --git a/ctdb/tests/local_daemons.sh b/ctdb/tests/local_daemons.sh
index 5aa9adc387b..e9f9423cb0c 100755
--- a/ctdb/tests/local_daemons.sh
+++ b/ctdb/tests/local_daemons.sh
@@ -305,9 +305,9 @@ local_daemons_ssh ()
fi
if $_close_stdin ; then
- exec sh -c "$*" <&-
+ exec sh -c "$*" </dev/null
else
- exec sh -m -c "$*"
+ exec sh -c "$*"
fi
}
@@ -354,7 +354,7 @@ local_daemons_start ()
onnode_common
- onnode -i "$_nodes" "${VALGRIND:-} ctdbd &"
+ onnode -i "$_nodes" "${VALGRIND:-} ctdbd"
}
local_daemons_stop ()
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh
index d7c33f1865a..2a5e4bbf996 100755
--- a/ctdb/tests/run_tests.sh
+++ b/ctdb/tests/run_tests.sh
@@ -129,7 +129,7 @@ ctdb_test_run ()
start_time=$(date '+%s')
if [ -x "$f" ] ; then
- timeout "$test_time_limit" "$f" | show_progress
+ timeout "$test_time_limit" "$f" </dev/null | show_progress
status=$?
else
echo "TEST IS NOT EXECUTABLE"
diff --git a/ctdb/tests/scripts/script_install_paths.sh b/ctdb/tests/scripts/script_install_paths.sh
index 2bd8542e4b7..6890cf87aa6 100644
--- a/ctdb/tests/scripts/script_install_paths.sh
+++ b/ctdb/tests/scripts/script_install_paths.sh
@@ -1,25 +1,46 @@
# Hey Emacs, this is a -*- shell-script -*- !!! :-)
+# Sets $bin_dir
+find_bin_dir ()
+{
+ _ctdb_dir="$1"
+
+ bin_dir="$(pwd -P)/bin"
+ if [ -d "$(pwd -P)/bin" ] ; then
+ return
+ fi
+
+ bin_dir="${_ctdb_dir}/bin"
+ if [ -d "$bin_dir" ] ; then
+ return
+ fi
+
+ bin_dir="$(dirname "${_ctdb_dir}")/bin"
+ if [ -d "$bin_dir" ] ; then
+ return
+ fi
+
+ die "Unable to locate bin/ subdirectory"
+}
+
+
if ! $CTDB_TESTS_ARE_INSTALLED ; then
if [ ! -f "${CTDB_TEST_DIR}/run_tests.sh" ] ; then
die "Tests not installed but can't find run_tests.sh"
fi
- ctdb_dir=$(dirname "$CTDB_TEST_DIR")
+ ctdb_dir=$(cd -P "$(dirname "$CTDB_TEST_DIR")" && pwd) # real path
- top_dir=$(cd -P "$ctdb_dir" && echo "$PWD") # real path
- if [ ! -d "${top_dir}/bin" ] ; then
- top_dir=$(dirname "$top_dir")
- fi
+ find_bin_dir "$ctdb_dir"
CTDB_SCRIPTS_BASE="${ctdb_dir}/config"
CTDB_SCRIPTS_INIT_SCRIPT="${ctdb_dir}/config/ctdb.init"
CTDB_SCRIPTS_SBIN_DIR="${ctdb_dir}/config"
CTDB_SCRIPTS_TOOLS_BIN_DIR="${ctdb_dir}/tools"
CTDB_SCRIPTS_TOOLS_HELPER_DIR="${ctdb_dir}/tools"
- CTDB_SCRIPTS_HELPER_BINDIR="${top_dir}/bin"
+ CTDB_SCRIPTS_HELPER_BINDIR="$bin_dir"
CTDB_SCRIPTS_DATA_DIR="${ctdb_dir}/config"
- CTDB_SCRIPTS_TESTS_LIBEXEC_DIR="${top_dir}/bin"
+ CTDB_SCRIPTS_TESTS_LIBEXEC_DIR="$bin_dir"
CTDB_SCRIPTS_TESTS_BIN_DIR="$CTDB_TEST_DIR"
else
# Installed
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index c157838018e..ba994caff2d 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -6301,6 +6301,7 @@ int main(int argc, const char *argv[])
const char **extra_argv;
int extra_argc;
const struct ctdb_cmd *cmd;
+ const char *test_mode;
int loglevel;
bool ok;
int ret = 0;
@@ -6340,10 +6341,6 @@ int main(int argc, const char *argv[])
options.maxruntime = 120;
}
}
- if (options.maxruntime <= 120) {
- /* default timeout is 120 seconds */
- options.maxruntime = 120;
- }
if (options.machineparsable) {
options.machinereadable = 1;
@@ -6375,6 +6372,16 @@ int main(int argc, const char *argv[])
}
debuglevel_set(loglevel);
+ /* Stop process group kill in alarm_handler() from killing tests */
+ test_mode = getenv("CTDB_TEST_MODE");
+ if (test_mode != NULL) {
+ const char *have_setpgid = getenv("CTDB_TOOL_SETPGID");
+ if (have_setpgid == NULL) {
+ setpgid(0, 0);
+ setenv("CTDB_TOOL_SETPGID", "1", 1);
+ }
+ }
+
signal(SIGALRM, alarm_handler);
alarm(options.maxruntime);
--
Samba Shared Repository
More information about the samba-cvs
mailing list