From a91c61e13681ecaf86d7c12c4635d330382887b5 Mon Sep 17 00:00:00 2001 From: Jamie McClymont Date: Mon, 15 Jan 2018 15:25:10 +1300 Subject: [PATCH 1/7] selftest: fix envvars for creation of default user in wait_for_start Resolves failure of ad_member to start up under ad_dc (if the user is determined to be needed). Signed-off-by: Jamie McClymont Reviewed-by: Garming Sam Reviewed-by: Andreas Schneider BUG: https://bugzilla.samba.org/show_bug.cgi?id=13225 Autobuild-User(master): Garming Sam Autobuild-Date(master): Tue Jan 16 07:12:01 CET 2018 on sn-devel-144 (cherry picked from commit 7a3f97f2662c6197913aeb50e5e3c0c09ff8307f) --- selftest/target/Samba3.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index f4ae0f3..f2dcdd1 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -2455,6 +2455,8 @@ sub wait_for_start($$$$$) } if ($create_builtin_users eq "yes") { $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' "; + $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' "; + $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' "; $cmd .= Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} "; $cmd .= "sam createbuiltingroup Users"; $ret = system($cmd); @@ -2469,6 +2471,8 @@ sub wait_for_start($$$$$) system($cmd); $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' "; + $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' "; + $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' "; $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545"; $ret = system($cmd); if ($ret != 0) { -- 1.9.1 From a83d91374be420599a41e9cb26ee692064808c62 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 22 Jan 2018 12:54:49 +1100 Subject: [PATCH 2/7] ctdb-tests: Avoid race condition in sock_daemon test 5 This test fails when it takes more than 10s to run. This can occur when the system is loaded and socket-wrapper is used. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke (cherry picked from commit 33c0f5599d93a34619c8f37945f79a6e399a1b5e) --- ctdb/tests/src/sock_daemon_test.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/ctdb/tests/src/sock_daemon_test.c b/ctdb/tests/src/sock_daemon_test.c index 5641d37..ebc0b85 100644 --- a/ctdb/tests/src/sock_daemon_test.c +++ b/ctdb/tests/src/sock_daemon_test.c @@ -668,7 +668,8 @@ static void test4(TALLOC_CTX *mem_ctx, const char *pidfile, * Start daemon, multiple client connects, requests, disconnects */ -#define TEST5_MAX_CLIENTS 10 +#define TEST5_VALID_CLIENTS 10 +#define TEST5_MAX_CLIENTS 100 struct test5_pkt { uint32_t len; @@ -710,7 +711,8 @@ static void test5_client_callback(uint8_t *buf, size_t buflen, state->done = true; } -static int test5_client(const char *sockpath, int id) +static int test5_client(const char *sockpath, int id, pid_t pid_server, + pid_t *client_pid) { pid_t pid; int fd[2]; @@ -760,7 +762,9 @@ static int test5_client(const char *sockpath, int id) close(fd[0]); state.fd = -1; - sleep(10); + while (kill(pid_server, 0) == 0 || errno != ESRCH) { + sleep(1); + } exit(0); } @@ -775,6 +779,7 @@ static int test5_client(const char *sockpath, int id) close(fd[0]); + *client_pid = pid; return ret; } @@ -788,12 +793,12 @@ static bool test5_connect(struct sock_client_context *client, struct test5_server_state *state = (struct test5_server_state *)private_data; - if (state->num_clients == TEST5_MAX_CLIENTS) { + if (state->num_clients == TEST5_VALID_CLIENTS) { return false; } state->num_clients += 1; - assert(state->num_clients <= TEST5_MAX_CLIENTS); + assert(state->num_clients <= TEST5_VALID_CLIENTS); return true; } @@ -925,6 +930,7 @@ static void test5(TALLOC_CTX *mem_ctx, const char *pidfile, pid_t pid_server, pid; int fd[2], ret, i; ssize_t n; + pid_t client_pid[TEST5_MAX_CLIENTS]; pid = getpid(); @@ -968,16 +974,18 @@ static void test5(TALLOC_CTX *mem_ctx, const char *pidfile, close(fd[0]); - for (i=0; i<100; i++) { - ret = test5_client(sockpath, i); - if (i < TEST5_MAX_CLIENTS) { + for (i=0; i=0; i--) { + kill(client_pid[i], SIGKILL); + pid = wait(&ret); assert(pid != -1); } -- 1.9.1 From bfd1c3a5800061097a6282b8251906afdad20150 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sat, 20 Jan 2018 17:05:37 +1100 Subject: [PATCH 3/7] ctdb-tests: Add timeout for individual tests, default is 10 minutes This will cause a hung test to time out and fail rather than letting a test run hang indefinitely. Some tests can take 5 minutes to run, so 10 minutes should be plenty. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit da3aaf972ab5b339b51ba1e802329b69885ccfe4) --- ctdb/tests/run_tests.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index ffc81d4..d790996 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -46,8 +46,9 @@ export TEST_LOCAL_DAEMONS [ -n "$TEST_LOCAL_DAEMONS" ] || TEST_LOCAL_DAEMONS=3 export TEST_VAR_DIR="" export TEST_CLEANUP=false +export TEST_TIMEOUT=600 -temp=$(getopt -n "$prog" -o "AcCdDehHNqSvV:xX" -l help -- "$@") +temp=$(getopt -n "$prog" -o "AcCdDehHNqST:vV:xX" -l help -- "$@") [ $? != 0 ] && usage @@ -65,6 +66,7 @@ while true ; do -N) with_summary=false ; shift ;; -q) quiet=true ; shift ;; -S) socket_wrapper=true ; shift ;; + -T) TEST_TIMEOUT="$2" ; shift 2 ;; -v) TEST_VERBOSE=true ; shift ;; -V) TEST_VAR_DIR="$2" ; shift 2 ;; -x) set -x; shift ;; @@ -114,6 +116,9 @@ ctdb_test_end () interp="PASSED" statstr="" echo "ALL OK: $*" + elif [ $status -eq 124 ] ; then + interp="TIMEOUT" + statstr=" (status $status)" else interp="FAILED" statstr=" (status $status)" @@ -137,7 +142,7 @@ ctdb_test_run () $no_header || ctdb_test_begin "$name" local status=0 - "$@" || status=$? + timeout $TEST_TIMEOUT "$@" || status=$? $no_header || ctdb_test_end "$name" "$status" "$*" -- 1.9.1 From da41b1b4c6b22f23da11d872ae37d8006bff3809 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Jan 2018 19:14:48 +1100 Subject: [PATCH 4/7] ctdb-tests: Only use socket-wrapper for simple, local daemon tests The run_tests.sh -S option now takes the path to the socker-wrapper shared library. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit e17d02d4039001563d189b33200c30e3906ce845) --- ctdb/tests/run_tests.sh | 13 ++++--------- ctdb/tests/simple/scripts/local_daemons.bash | 6 ++++++ ctdb/wscript | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index d790996..a133445 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -14,7 +14,7 @@ Options: -H No headers - for running single test with other wrapper -N Don't print summary of tests results after running all tests -q Quiet - don't show tests being run (hint: use with -s) - -S Enable socket wrapper + -S Use socket wrapper library for local integration tests -v Verbose - print test output for non-failures (only some tests) -V Use as TEST_VAR_DIR -x Trace this script with the -x option @@ -36,7 +36,6 @@ with_desc=false quiet=false exit_on_fail=false no_header=false -socket_wrapper=false export TEST_VERBOSE=false export TEST_COMMAND_TRACE=false @@ -47,8 +46,9 @@ export TEST_LOCAL_DAEMONS export TEST_VAR_DIR="" export TEST_CLEANUP=false export TEST_TIMEOUT=600 +export TEST_SOCKET_WRAPPER_SO_PATH="" -temp=$(getopt -n "$prog" -o "AcCdDehHNqST:vV:xX" -l help -- "$@") +temp=$(getopt -n "$prog" -o "AcCdDehHNqS:T:vV:xX" -l help -- "$@") [ $? != 0 ] && usage @@ -65,7 +65,7 @@ while true ; do -H) no_header=true ; shift ;; -N) with_summary=false ; shift ;; -q) quiet=true ; shift ;; - -S) socket_wrapper=true ; shift ;; + -S) TEST_SOCKET_WRAPPER_SO_PATH="$2" ; shift 2 ;; -T) TEST_TIMEOUT="$2" ; shift 2 ;; -v) TEST_VERBOSE=true ; shift ;; -V) TEST_VAR_DIR="$2" ; shift 2 ;; @@ -252,11 +252,6 @@ mkdir -p "$TEST_VAR_DIR" TEST_VAR_DIR=$(cd "$TEST_VAR_DIR"; echo "$PWD") echo "TEST_VAR_DIR=$TEST_VAR_DIR" -if $socket_wrapper ; then - export SOCKET_WRAPPER_DIR="${TEST_VAR_DIR}/sw" - mkdir -p "$SOCKET_WRAPPER_DIR" -fi - export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts" # If no tests specified then run some defaults diff --git a/ctdb/tests/simple/scripts/local_daemons.bash b/ctdb/tests/simple/scripts/local_daemons.bash index a0c8077..512d11f 100644 --- a/ctdb/tests/simple/scripts/local_daemons.bash +++ b/ctdb/tests/simple/scripts/local_daemons.bash @@ -17,6 +17,12 @@ fi export CTDB_NODES="${TEST_VAR_DIR}/nodes.txt" +if [ -n "$TEST_SOCKET_WRAPPER_SO_PATH" ] ; then + export LD_PRELOAD="$TEST_SOCKET_WRAPPER_SO_PATH" + export SOCKET_WRAPPER_DIR="${TEST_VAR_DIR}/sw" + mkdir -p "$SOCKET_WRAPPER_DIR" +fi + ####################################### config_from_environment () diff --git a/ctdb/wscript b/ctdb/wscript index 715ecb1..059ce3d 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -986,8 +986,7 @@ def test(ctx): def autotest(ctx): env = samba_utils.LOAD_ENVIRONMENT() - ld = 'LD_PRELOAD=%s' % env.SOCKET_WRAPPER_SO_PATH - cmd = '%s tests/run_tests.sh -e -S -C' % ld + cmd = 'tests/run_tests.sh -e -S %s -C' % env.SOCKET_WRAPPER_SO_PATH ret = samba_utils.RUN_COMMAND(cmd) if ret != 0: print('autotest exited with exit status %d' % ret) -- 1.9.1 From 5c308e0ac2e12f3debb33906e9b812adec54a7e1 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 22 Jan 2018 19:48:02 +1100 Subject: [PATCH 5/7] ctdb-tests: Add a UNIT pseudo-test-suite This runs all of the unit tests. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 50150d75814de6a1e2cb28fb7af72caa31d73e3c) --- ctdb/tests/run_tests.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index a133445..a2a44a1 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -254,13 +254,23 @@ echo "TEST_VAR_DIR=$TEST_VAR_DIR" export TEST_SCRIPTS_DIR="${CTDB_TEST_DIR}/scripts" +unit_tests=" + cunit + eventd + eventscripts + onnode + shellcheck + takeover + takeover_helper + tool +" + # If no tests specified then run some defaults if [ -z "$1" ] ; then - if [ -n "$TEST_LOCAL_DAEMONS" ] ; then - set -- onnode takeover takeover_helper tool eventscripts \ - cunit eventd shellcheck simple - else - set -- simple complex + if [ -n "$TEST_LOCAL_DAEMONS" ] ; then + set -- UNIT simple + else + set -- simple complex fi fi @@ -287,7 +297,19 @@ cleanup_handler () trap cleanup_handler SIGINT SIGTERM +declare -a tests +i=0 for f ; do + if [ "$f" = "UNIT" ] ; then + for t in $unit_tests ; do + tests[i++]="$t" + done + else + tests[i++]="$f" + fi +done + +for f in "${tests[@]}" ; do find_and_run_one_test "$f" if [ $status -eq 127 ] ; then -- 1.9.1 From 74ecd41a751533959a5fae5ca8085421b0244d76 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 23 Jan 2018 20:18:54 +1100 Subject: [PATCH 6/7] ctdb-tests: Fix a typo This typo causes the script to be run with the default shell. If this is not bash then the shell will fail to parse integration.bash. This is a regression caused by commit c607989d91b64d837253aae794b1a3d6013eb3e0. Clearly nobody has run this test on Debian for a long time. :-( Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Wed Jan 24 10:28:52 CET 2018 on sn-devel-144 (cherry picked from commit 8b82d10856160d3b3f172bf7d45ac561002dbcac) --- ctdb/tests/simple/14_ctdb_statistics.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ctdb/tests/simple/14_ctdb_statistics.sh b/ctdb/tests/simple/14_ctdb_statistics.sh index 3dd55e0..5ff22d7 100755 --- a/ctdb/tests/simple/14_ctdb_statistics.sh +++ b/ctdb/tests/simple/14_ctdb_statistics.sh @@ -1,4 +1,3 @@ - #!/bin/bash test_info() -- 1.9.1 From ac71cc23bb723b2d7f7e3ff475ec01b5fd8e2686 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 5 Feb 2018 15:45:09 +1100 Subject: [PATCH 7/7] ctdb-tests: Set test timeout to an hour The current 10 minute timeout is causing autobuild failures in some environments. This timeout is simply meant to stop a test run from hanging indefinitely due to a broken test. A 1 hour timeout is better than no timeout. Signed-off-by: Martin Schwenke Reviewed-by: Gary Lockyer Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Thu Feb 8 04:42:56 CET 2018 on sn-devel-144 (cherry picked from commit a3485c41b826e307b31a1113abcea9843ca78540) --- ctdb/tests/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index a2a44a1..a7ca44e 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -45,7 +45,7 @@ export TEST_LOCAL_DAEMONS [ -n "$TEST_LOCAL_DAEMONS" ] || TEST_LOCAL_DAEMONS=3 export TEST_VAR_DIR="" export TEST_CLEANUP=false -export TEST_TIMEOUT=600 +export TEST_TIMEOUT=3600 export TEST_SOCKET_WRAPPER_SO_PATH="" temp=$(getopt -n "$prog" -o "AcCdDehHNqS:T:vV:xX" -l help -- "$@") -- 1.9.1