1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

1957 Commits

Author SHA1 Message Date
Martin Schwenke
2b37d99a5f ctdb-tests: Put the summary file inside $TEST_VAR_DIR
This means less random files dropped in /tmp or similar.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
7a5a4a4494 ctdb-tests: Drop run_tests -d option
The usage message says it is dodgy and some test suites may not
support it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
2730e48360 ctdb-tests: Simplify setup_ctdb()
There is no point inventing a whole new set of options here.

Continue to locally implement the --no-event-scripts option.  This
must be first, though in practice only one option is ever passed to
setup_ctdb() from ctdb_test_init().

Simply pass all other options through to "local_daemons.sh setup".
This has the side effect of causing failure when an invalid option is
passed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
8443798846 ctdb-tests: Invert some logic so it makes sense
The test should be outside the loop.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
8038f4f64f ctdb-tests: Avoid shellcheck warnings
SC2086 Double quote to prevent globbing and word splitting

This one doesn't need the double quotes if it is contained within the
preceding variable expansion.

SC2181 Check exit code directly with e.g. 'if mycmd;', not indirectly with $?
SC2004 $/${} is unnecessary on arithmetic variables

These are straightforward.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
497ae563a0 ctdb-tests: Fix zero event scripts test so it tests something
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
429502186a ctdb-tests: Drop unused code from onnode unit test ctdb stub
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
bb040f2798 ctdb-tests: Only set TEST_SUBDIR when needed
This is only needed for setup_ctdb_base() so only set it when calling
this function.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
284bbca7c7 ctdb-tests: Move NFS test functions to complex local script
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
2c6b098c72 ctdb-tests: Don't run setup_ctdb_base() for real cluster
This has not been needed for some time.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
8aed06ce8c ctdb-tests: Use db_ctdb_cattdb_count_records()
Avoid reinventing the wheel.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Martin Schwenke
68684377c6 ctdb-tests: Use ctdb_get_all_pnns()
The nested, arbitrary use of onnode can cause messages from ssh on
stderr to appear in the node list:

  Getting list of nodes...
  Output of "onnode -pq all ctdb pnn | grep '^[0-9][0-9]*$'":
  Warning: Permanently added '10.0.0.72' (RSA) to the list of known hosts.^M
  Warning: Permanently added '10.0.0.75' (RSA) to the list of known hosts.^M
  Warning: Permanently added '10.0.0.73' (RSA) to the list of known hosts.^M
  Warning: Permanently added '10.0.0.74' (RSA) to the list of known hosts.^M
  1
  0
  3
  2
  Create/wipe test database rec_test.tdb
  Failed to execute "Permanently added '10.0.0.72' (RSA) to the list of known hosts.^M ctdb attach rec_test.tdb" on node(s) "Warning:"
  Invalid <nodespec>

Avoid that by using an existing function that does not nest ssh uses.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-09-17 04:35:26 +00:00
Amitay Isaacs
3bd68261ec ctdb-eventscripts: Remove non-posix -v option to mkdir
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Sep  6 11:11:02 UTC 2019 on sn-devel-184
2019-09-06 11:11:02 +00:00
Swen Schillig
085e179dcb ctdb-tests: fix mem leak in ltdb_fetch
Direct leak of 256 byte(s) in 8 object(s) allocated from:
    #0 0x7f11b90d9c08 in __interceptor_malloc (/lib64/libasan.so.5+0xefc08)
    #1 0x7f11b8f395df in tdb_alloc_read ../../../lib/tdb/common/io.c:696
    #2 0x7f11b8f290ee in _tdb_fetch ../../../lib/tdb/common/tdb.c:274
    #3 0x7f11b8f29379 in tdb_fetch ../../../lib/tdb/common/tdb.c:283
    #4 0x473ecc in ltdb_fetch ../../tests/src/fake_ctdbd.c:904
    #5 0x478b40 in ltdb_transaction_update ../../tests/src/fake_ctdbd.c:993
    #6 0x41fef2 in ctdb_rec_buffer_traverse ../../protocol/protocol_types.c:1656
    #7 0x48108b in ltdb_transaction ../../tests/src/fake_ctdbd.c:1026
    #8 0x48108b in control_trans3_commit ../../tests/src/fake_ctdbd.c:2878
    #9 0x48108b in client_process_control ../../tests/src/fake_ctdbd.c:4147
    #10 0x48108b in client_process_packet ../../tests/src/fake_ctdbd.c:3839
    #11 0x4847f5 in client_read_handler ../../tests/src/fake_ctdbd.c:3806
    #12 0x44f620 in comm_read_done ../../common/comm.c:208
    #13 0x7f11b8f94fe8 in _tevent_req_notify_callback ../../../lib/tevent/tevent_req.c:141
    #14 0x7f11b8f951fd in tevent_req_finish ../../../lib/tevent/tevent_req.c:193
    #15 0x7f11b8f95265 in _tevent_req_done ../../../lib/tevent/tevent_req.c:199
    #16 0x44e876 in pkt_read_handler ../../common/pkt_read.c:133
    #17 0x44f315 in comm_fd_handler ../../common/comm.c:412
    #18 0x7f11b8f92896 in tevent_common_invoke_fd_handler ../../../lib/tevent/tevent_fd.c:138
    #19 0x7f11b8fa6937 in epoll_event_loop ../../../lib/tevent/tevent_epoll.c:736
    #20 0x7f11b8fa6937 in epoll_event_loop_once ../../../lib/tevent/tevent_epoll.c:937
    #21 0x7f11b8f9f53e in std_event_loop_once ../../../lib/tevent/tevent_standard.c:110
    #22 0x7f11b8f90f34 in _tevent_loop_once ../../../lib/tevent/tevent.c:772
    #23 0x7f11b8f955f1 in tevent_req_poll ../../../lib/tevent/tevent_req.c:300
    #24 0x485a04 in start_server ../../tests/src/fake_ctdbd.c:4450
    #25 0x485a04 in main ../../tests/src/fake_ctdbd.c:4544
    #26 0x7f11b8c60412 in __libc_start_main (/lib64/libc.so.6+0x24412)

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Aug 26 10:19:30 UTC 2019 on sn-devel-184
2019-08-26 10:19:30 +00:00
Martin Schwenke
71ad473ba8 ctdb-tests: Clear deleted record via recovery instead of vacuuming
This test has been flapping because sometimes the record is not
vacuumed within the expected time period, perhaps even because the
check for the record can interfere with vacuuming.  However, instead
of waiting for vacuuming the record can be cleared by doing a
recovery.  This should be much more reliable.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085
RN: Fix flapping CTDB tests

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Aug 21 13:06:57 UTC 2019 on sn-devel-184
2019-08-21 13:06:57 +00:00
Martin Schwenke
45b9e02f8f ctdb-tests: Wait for child process when killing cluster mutex helper
The following test sometimes fails:

==================================================
Running "cluster_mutex_test lock-unlock-lock-unlock ./tests/var/cluster_mutex.lockfile"
--------------------------------------------------
Output (Exit status: 134):
--------------------------------------------------
LOCK
UNLOCK
CONTENTION
NOLOCK
cluster_mutex_test: ../../tests/src/cluster_mutex_test.c:307: test_lock_unlock_lock_unlock: Assertion `dl2->mh != NULL' failed.
--------------------------------------------------
Required output (Exit status: 0):
--------------------------------------------------
LOCK
UNLOCK
LOCK
UNLOCK

FAILED
==========================================================================
TEST FAILED: tests/cunit/cluster_mutex_001.sh (status 1) (duration: 0s)
==========================================================================

This is due to a race in the test.  For the first UNLOCK a signal is
sent to the cluster mutex handler but the test tries to retake the
lock before that process is scheduled and the signal is processed.
Therefore, the fcntl() lock is still held and contention is seen.

After unlocking, tests need to wait until the child has gone, so build
this into ctdb_kill().  This is one of the only places where the PID
is accessible.

Outside of testing, on a real system, nothing will never try
to (re)take the lock so quickly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
ca4df06080 ctdb-tests: Strengthen volatile DB traverse test
Check the record count more often, from multiple nodes.  Add a case
with multiple records.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
53daeb2f87 ctdb-tests: Don't retrieve the VNN map from target node for notlmaster
Use the VNN map from the node running node_has_status().

This means that

  wait_until_node_has_status 1 notlmaster 10 0

will run "ctdb status" on node 0 and check (for up to 10 seconds) if
node 1 is in the VNN map.

If the LMASTER capability has been dropped on node 1 then the above
will wait for the VNN map to be updated on node 0.  This will happen
as part of the recovery that is triggered by the change of LMASTER
capability.  The next command will then only be able to attach to
$TESTDB after the recovery is complete thus guaranteeing a sane state
for the test to continue.

This stops simple/79_volatile_db_traverse.sh from going into recovery
during the traverse or at some other inconvenient time.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
bff1a3a548 ctdb-tests: Handle special cases first and return
All the other cases involve matching bits.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
bb59073515 ctdb-tests: Inline handling of recovered and notlmaster statuses
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
9b09a87326 ctdb-tests: Drop unused node statuses frozen/unfrozen
Silently drop unused local variable mpat.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
52227d1973 ctdb-tests: Reformat node_has_status()
Re-indent and drop non-POSIX left-parenthesis from case labels.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14085

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-21 11:50:30 +00:00
Martin Schwenke
f7f9f57d2e ctdb-tests: Use select_test_node() in ctdb setdebug simple test
There is no requirement for IP addresses here.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:36 +00:00
Martin Schwenke
3ea95ab4cb ctdb-tests: Add function select_test_node()
Should be used when public IP addresses are not assigned.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:36 +00:00
Martin Schwenke
695b3a965b ctdb-tests: Don't print summary on failure if -e option is specified
If there is a failure it will always be the last test run.  Don't
obscure this by following it with a summary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:36 +00:00
Martin Schwenke
7c01bf3d37 ctdb-tests: Drop mention of non-existent -s option
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
b3b44ae532 ctdb-tests: Add -I <count> option for iterating tests
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
91e6fc209b ctdb-tests: Factor out main test loop into run_tests()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
da33fb27ab ctdb-tests: Add shellcheck test for some test scripts and includes
These files now pass, so we might as well keep them in good shape.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
027b7ca003 ctdb-tests: New variable CTDB_SCRIPTS_TESTS_BIN_DIR
This can be used to find ctdb_run_tests and ctdb_local_daemons.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
ba55306fce ctdb-tests: Rename CTDB_SCRIPTS_TESTS_BINDIR to CTDB_SCRIPTS_TESTS_LIBEXEC_DIR
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
061656d383 ctdb-tests: Simplify test_wrap script
Given other improvements, this is now needlessly complex.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
b1d36e94d2 ctdb-tests: Avoid shellcheck warning SC2045
SC2045 Iterating over ls output is fragile. Use globs.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
7d95cb22a4 ctdb-tests: Avoid shellcheck warning SC2034
SC2034 summary appears unused. Verify use (or export if used externally)

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
b198de03dc ctdb-tests: Avoid shellcheck warning SC2230
SC2230 which is non-standard...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
93b3b01032 ctdb-tests: Avoid shellcheck warning SC2188
SC2188 This redirection doesn't have a command...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
45c9fe3abb ctdb-tests: Avoid shellcheck warning SC2155
SC2155 Declare and assign separately to avoid masking return values

The wscript changes require an identical change in local_daemons.sh.

While touching the lines in wscript, escape the backslashes to make
them literal backslashes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:35 +00:00
Martin Schwenke
664968e523 ctdb-tests: Avoid shellcheck warning SC2004
SC2004 $/${} is unnecessary on arithmetic variables

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:34 +00:00
Martin Schwenke
034f4cfab8 ctdb-tests: Avoid shellcheck warning SC2164
SC2164 Use 'cd ... || exit' or 'cd ... || return' in case cd fails

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:34 +00:00
Martin Schwenke
83f73b5abc ctdb-tests: Avoid shellcheck warning SC2086
SC2086 Double quote to prevent globbing and word splitting

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-08-14 09:11:34 +00:00
Martin Schwenke
38898775e6 ctdb-scripts: Drop monitoring of recovery lock
The fcntl helper now does a more meaningful check.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
5701f4aeca ctdb-tests: Add some 01.reclock.script init event tests
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
ecef441130 ctdb-tests: Fix 01.reclock.script tests for non-default lock
These tests currently do not do what is expected.  They test the
default case.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
2bd316d01d ctdb-tests: Add tests for cluster mutex lost handling
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
41cd44724e ctdb-mutex: Add support for exiting if the lock file disappears
If the lock file is inaccessible or the inode number changes then the
lock is lost, so exit.  This allows the recovery daemon to trigger an
election.  The ensuing recovery will re-take the lock.

By default the lock file is checked every 60 seconds.  A lot can
happen in 60 seconds but being more aggressive and accessing the lock
too often could result in a performance issue for the cluster
filesystem.

An new optional 2nd argument is added, which is the lock file re-check
time in seconds.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
fae8e438f0 ctdb-mutex: Change parent checking to use an asynchronous computation
Put the checking for the process being immediately re-parented into
the computation too.  This will be very rare and doing it
consistently makes testing saner.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
d716be19ea ctdb-tests: Add test to confirm need for cluster mutex lock file rechecking
Remove the lock and a second locker can take the it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
adcf313c49 ctdb-tests: Add cluster mutex tests
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:17 +00:00
Martin Schwenke
c276723dd8 ctdb-tests: Set LANG=C for consistency of command output
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-07-26 03:34:16 +00:00
Amitay Isaacs
6b7b1e8080 ctdb-tests: Add tests for empty values in config file
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-07-26 03:34:16 +00:00