summaryrefslogtreecommitdiff
path: root/ctdb/tests/src
AgeCommit message (Collapse)AuthorFilesLines
2022-08-01ctdb-common: CID 1507498: Control flow issues (DEADCODE)Martin Schwenke1-0/+11
Fix typo in error checking. While here adjust the bottom of the range, making errno 0 invalid. Add corresponding test cases using an alternative syntax for errno packets (#nnn[;] - trailing ';' is optional). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Aug 1 09:19:55 UTC 2022 on sn-devel-184
2022-07-28ctdb-tests: Add tests for cluster mutex I/O timeoutMartin Schwenke1-0/+98
Block the locker helper child by taking a lock on the 2nd byte of the lock file. This will cause a ping timeout if the process is blocked for long enough. 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): Thu Jul 28 11:10:54 UTC 2022 on sn-devel-184
2022-07-28ctdb-tests: Terminate event loop if lock is no longer heldMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-07-28ctdb-tests: Add tests for trivial FD monitoringMartin Schwenke2-0/+776
tmon_ping_test covers complex 2-way interaction between processes using tmon_ping_send(), including via a socketpair(). tmon_test covers the more general functionality of tmon_send() but uses a simpler 1-way harness with wide coverage. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-07-22ctdb-build: Add missing dependency on tallocMartin Schwenke1-0/+1
The include isn't strictly necessary, since it is included via common/reqid.c anyway. However, it is a useful hint. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Jul 22 17:01:00 UTC 2022 on sn-devel-184
2022-07-22ctdb-common: Use POSIX if_nameindex() to check interface existenceMartin Schwenke1-8/+10
This works as an unprivileged user, so avoids unnecessary errors when running in test mode (and not as root): 2022-02-18T12:21:12.436491+11:00 node.0 ctdbd[6958]: ctdb_sys_check_iface_exists: Failed to open raw socket 2022-02-18T12:21:12.436534+11:00 node.0 ctdbd[6958]: ctdb_sys_check_iface_exists: Failed to open raw socket 2022-02-18T12:21:12.436557+11:00 node.0 ctdbd[6958]: ctdb_sys_check_iface_exists: Failed to open raw socket 2022-02-18T12:21:12.436577+11:00 node.0 ctdbd[6958]: ctdb_sys_check_iface_exists: Failed to open raw socket The corresponding porting test would now become pointless because it would just confirm that "fake" does not exist. Attempt to make it useful by using a less likely name than "fake" and attempting to detect the loopback interface. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-06-28ctdb-tests: Add runstate handling to fake ctdbdVinit Agnihotri1-1/+42
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-06-28ctdb-tests: Return error on empty fake ctdbd configuration blocksMartin Schwenke1-4/+23
These would be unintended errors. The block should be omitted to keep the default value. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-05-03ctdb-tests: Add backtrace on abort to some testsMartin Schwenke2-0/+8
These are easier to debug with a backtrace. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue May 3 10:13:23 UTC 2022 on sn-devel-184
2022-05-03ctdb-tests: Provide a method to dump the stack on abortMartin Schwenke2-0/+62
Some tests make generous use of assert() and it can be difficult to guess the cause of failures without resorting to GDB. This provides some help. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-04-06ctdb-tests: Add unit tests for tunables codeMartin Schwenke1-0/+71
This aims to test ctdb_tunable_load_file() but also exercises ctdb_tunable_names() and ctdb_tunable_get_value(). ctdb_tunable_set_value() is indirectly exercised via ctdb_tunable_load_file(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-02-23ctdb-tests: Fix missing #include for sigaction(2)Martin Schwenke1-0/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-02-23ctdb-tests: Dump a stack trace on abortMartin Schwenke1-0/+3
Debugging a test failure here without GDB is not possible. Dumping a stack trace gives a good hint. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-02-14ctdb-tests: Iterate protocol tests internallyMartin Schwenke5-44/+32
Instead of repeatedly running a test binary. Run time for these tests reduces from ~90s to ~75s. When run under valgrind, the run time for protocol_test_001.sh reduces from ~390s to <1s. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Mon Feb 14 04:32:29 UTC 2022 on sn-devel-184
2022-02-14ctdb-tests: Add iteration support for protocol testsMartin Schwenke2-0/+75
The current method of repeatedly running a binary has huge overhead, especially with valgrind. protocol_test_iterate_tag() allows output that is usually used for hinting where a test failure occurred to be replaced with a tag stored in a buffer, which is printed on test failure. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-protocol: Drop marshalling for {GET,SET}_RECMASTER controlsMartin Schwenke1-26/+0
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-daemon: Drop implementation of {GET,SET}_RECMASTER controlsMartin Schwenke1-21/+0
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-tests: Add leader broadcasts to fake_ctdbdMartin Schwenke1-0/+49
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-tests: Implement srvid_handler for dispatching messagesAmitay Isaacs1-1/+67
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2022-01-17ctdb-protocol: Add CTDB_SRVID_LEADERMartin Schwenke3-0/+4
CTDB_SRVID_LEADER will be regularly broadcast to all connected nodes by the leader. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-17ctdb-common: Separate sock_daemon's SIGHUP and SIGUSR1 handlingMartin Schwenke1-2/+98
SIGHUP is for reopening logs, SIGUSR1 is for reconfigure. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2022-01-13ctdb-protocol: Print IPv6 sockets with RFC5952 "[2001:db8::1]:80" notationMartin Schwenke1-15/+15
RFC5952 says the existing style is not recommended and the [] style should be employed. There are more optimised ways of adding the square brackets but they tend to be uglier. Parsing IPv6 sockets without [] is now tested indirectly by parsing examples in both styles and comparing the results. Signed-off-by: Martin Schwenke <martin@meltin.net> Signed-off-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jan 13 17:02:21 UTC 2022 on sn-devel-184
2022-01-13ctdb-tests: Add extra IPv6 socket parsing testsMartin Schwenke1-0/+19
Add tests to confirm that square brackets are handled and that IPv4-mapped IPv6 addresses are parsed as expected. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org>
2021-09-09ctdb_daemon: Implement controls DISABLE_NODE/ENABLE_NODEMartin Schwenke1-0/+54
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14784 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2021-09-09ctdb-protocol: Add marshalling for controls DISABLE_NODE/ENABLE_NODEMartin Schwenke2-1/+25
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14784 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2021-05-18ctdb: Fix a crash in run_proc_signal_handler()Volker Lendecke1-1/+1
If a script times out the caller can talloc_free() the script_list output of run_event_recv, which talloc_free's proc->output from run_proc.c as well. If the script generates further output after the timeout and then exits after a while, the SIGCHLD handler in the eventd tries to read into proc->output, which was already free'ed. Fix this by not doing just a talloc_steal but a talloc_move. This way proc_read_handler() called from run_proc_signal_handler() does not try to realloc the stale reference to proc->output but gets a NULL reference. I don't really know how to do a knownfail in ctdb, so this commit actually activates catching the signal by waiting long enough for 22.bar to exit and generate the SIGCHLD. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2021-05-18ctdb: Wait for SIGCHLD if script timed outVolker Lendecke1-0/+22
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2021-05-18ctdb: Introduce a helper variable in run_event_test.cVolker Lendecke1-2/+2
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2021-05-18ctdb: Call run_event_recv() in a callback functionVolker Lendecke1-8/+16
Triggers a different code path in run_event_* and aligns it more what the ctdb eventd really does. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2021-05-18ctdb: fix typosVolker Lendecke1-2/+2
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14475 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2021-01-22lib: Make accept_recv() return the listening socketVolker Lendecke2-2/+2
This is helpful if you are in a listening loop with the same receiver for many sockets doing the same thing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-22lib: Make accept_recv() return struct samba_sockaddrVolker Lendecke2-2/+2
Avoid casting problems by using the samba_sockaddr union Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-11ctdb-protocol: Drop marshalling functions for old-style database pull/pushMartin Schwenke1-36/+0
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-08-03lib: relicense smb_strtoul(l) under LGPLv3Ralph Boehme2-0/+2
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Aug 3 22:21:04 UTC 2020 on sn-devel-184
2020-05-22ctdb-tests: Update fetch_ring to take database and key on command lineMartin Schwenke1-11/+19
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2020-04-28ctdb-protocol: Add marshalling for control ECHO_DATAVolker Lendecke2-1/+21
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2020-04-28ctdb-protocol: Add marshalling for struct ctdb_echo_dataVolker Lendecke3-0/+19
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2020-03-10ctdb-tests: Use built-in hexdump() in system socket testsMartin Schwenke1-8/+19
Better compatibility, since od output isn't consistent on FreeBSD. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Tue Mar 10 09:17:12 UTC 2020 on sn-devel-184
2020-02-12ctdb-tests: Fix return value of DB test tool delete commandMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-11-14ctdb-tests: Add tests for cmdline_add() apiAmitay Isaacs1-0/+89
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): Thu Nov 14 12:03:46 UTC 2019 on sn-devel-184
2019-11-14ctdb-tests: Update cmdline tests for section nameAmitay Isaacs1-1/+1
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-11-14ctdb-common: Add section to group commands in cmdlineAmitay Isaacs2-10/+55
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-11-14ctdb-common: Generate usage message from cmdline_parse()Amitay Isaacs1-6/+2
If any of the option parsing or command parsing fails, generate usage message. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-10-24ctdb-tests: Add ctdb-db-test toolMartin Schwenke1-0/+790
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-10-24ctdb-protocol: Add marshalling for control DB_VACUUMMartin Schwenke2-1/+16
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-10-24ctdb-protocol: Add marshalling for struct ctdb_db_vacuumMartin Schwenke3-0/+19
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-10-24ctdb-tests: Add marshalling tests for new controlAmitay Isaacs2-1/+16
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-10-24ctdb-tests: Drop code releated to obsolete controlsAmitay Isaacs1-78/+0
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-08-26ctdb-tests: fix mem leak in ltdb_fetchSwen Schillig1-1/+3
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-21ctdb-tests: Wait for child process when killing cluster mutex helperMartin Schwenke1-1/+17
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>