summaryrefslogtreecommitdiff
path: root/ctdb/tests
AgeCommit message (Collapse)AuthorFilesLines
2026-04-17ctdb-scripts: Support interface altnamesMartin Schwenke1-3/+1
This avoids generating a warning like: WARNING: Public IP <ip> hosted on interface <iface> but VNN says <altname> every time a public IP is removed from an interface that is configured via an altname. The new check will nearly always be successful because the IP will be on the expected interface during releaseip/updateip. The original check is now used as a backup when the IP is not on the expected interface. To allow the mask bits check to cover both cases, the original check and the associated interface check needs to be inside the else clause. Update the unit test to reflect the change. Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Apr 17 00:11:50 UTC 2026 on atb-devel-224
2026-04-16ctdb-tests: Add addip/releaseip altname unit testMartin Schwenke1-0/+21
This shows that a warning is generated whenever an IP address is removed using an altname. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Implement altname property for ip link/addrMartin Schwenke1-0/+54
Only implemented for these commands. I don't even want to think about doing this for ip route right now. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Implement -brief option for ip addr show stubMartin Schwenke1-12/+36
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-tests: Fix a typo in "ip link show" stub outputMartin Schwenke1-1/+1
Status is different to state and should not be repeated. For example: eth0 UP aa:bb:cc:dd:ee:ff <BROADCAST,MULTICAST,UP,LOWER_UP> Clearly nothing looks at this field but it should be correct. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-04-16ctdb-scripts: Only warn when removing an unassigned public IPMartin Schwenke1-1/+1
get_iface_ip_maskbits() now sets iface="" when the IP is unassigned, allowing dependent code to be conditional. Currently, ctdb_takeover.c:ctdb_control_release_ip() ensures no releaseip event is triggered if the public address is not on the node. So, no change of behaviour for releaseip. The previous attempt at making updateip behave more like takeip when the IP isn't currently assigned caused commands with missing mask bits to be run. Avoid this. Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com>
2026-03-18ctdb-tests: Tweak some NFS monitoring tests for portabilityMartin Schwenke2-4/+8
FreeBSD doesn't have an option to print time in nanoseconds. We need to run something to produce fake "statistics" that are guaranteed to change. I think this will do - the chances of getting the same 256 bytes twice in a row seems small enough. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Mar 18 12:33:13 UTC 2026 on atb-devel-224
2026-03-18ctdb-tests: Skip statd-callout tests on FreeBSDMartin Schwenke1-0/+2
NFS is probably wildly different on FreeBSD and statd_callout_helper uses chown with the --reference option. Too hard. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Update READMEMartin Schwenke1-2/+6
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Reorder and group script variables, add commentsMartin Schwenke1-9/+18
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove unused helper variable CTDB_SCRIPTS_HELPER_BINDIRMartin Schwenke1-3/+0
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_CLUSTER_MUTEX_HELPERMartin Schwenke4-85/+0
Use path_helperdir() to help construct the path and then cache the result in the existing static buffer (with length adjusted because POSIX says the +1 is not necessary). Given the way this is used by cluster_mutex_test, there is no (other) sane place to cache it. path_helperdir_append() could be used to construct the path, but then there would be an unnecessary talloc() result to free. The flexibility in unit test cluster_mutex_003.sh was never used, so remove this test. If other cluster mutex helpers are added then they can be tested by separate tests. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_LOCK_HELPERMartin Schwenke1-1/+0
Replace with a lock_helper member in ctdb_context, set using path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-daemon: Remove helper variable CTDB_EVENTDMartin Schwenke1-1/+0
Simplify the initialisation of the path to eventd in eventd_context using path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-recoverd: Remove some helper variablesMartin Schwenke1-2/+0
Remove CTDB_RECOVERY_HELPER, CTDB_TAKEOVER_HELPER. Add new struct members in ctdb_recoverd to contain the paths, set via path_helperdir_append(). Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tools: Remove some helper variablesMartin Schwenke3-6/+0
Remove CTDB_EVENT_HELPER, CTDB_LVS_HELPER, CTDB_NATGW_HELPER. Use path_helperdir_append() instead. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Drop an unnecessary use of CTDB_SCRIPTS_HELPER_BINDIRMartin Schwenke1-2/+1
As a helper, ctdb-path is in $CTDB_TEST_HELPER_BINDIR, which is in $PATH. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Use CTDB_TEST_HELPER_BINDIR inlineMartin Schwenke9-14/+14
Replace most remaining uses of CTDB_SCRIPTS_TOOLS_HELPER_DIR and CTDB_SCRIPTS_HELPER_BINDIR. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove redundant PATH addsMartin Schwenke11-24/+0
These are covered because CTDB_TEST_HELPER_BINDIR is now added to PATH. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Add CTDB_TEST_HELPER_BINDIRMartin Schwenke2-3/+10
Now that generated scripts are linked into bin/, nothing needs to be run from the tools/ directory anymore during self-test. So, introduce CTDB_TEST_HELPER_BINDIR to replace both CTDB_SCRIPTS_TOOLS_HELPER_DIR and CTDB_SCRIPTS_HELPER_BINDIR. Add this directory to PATH. CTDB_TEST_HELPER_BINDIR will also be used in combination with CTDB_TEST_MODE to allow helpers to be found via a single mechanism that uses this single variable. This will replace the multiple mechanisms and variables currently used. For simplicity, leave the old variables alone for now. Replacing them in a comprehensible way will take a few steps. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Silence some shellcheck complaintsMartin Schwenke5-9/+23
Add most of the fixed files to the associated shellcheck unit test. Include a couple of formatting fixups. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Reformat with "shfmt -w -i 0 -fn"Martin Schwenke16-210/+230
Best reviewed with "git show -w" or similar. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Add a useful commentMartin Schwenke1-0/+3
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-25ctdb-tests: Remove unused variablesMartin Schwenke1-4/+0
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-20ctdb-tools: add some tests cases for ctdb status --jsonJohn Mulligan3-0/+261
Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-20ctdb-tests: add wrapper helper over JSON-mode commandShachar Sharon1-0/+8
Run ctdb sub-command with '--json' flag only when code has been compiled with json support. Otherwise, ignore the test silently. Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-18ctdb-failover: Add sm-notify to statd_calloutPeter Schwenke4-0/+27
sm-notify is required when an NFS client reboots. rpc-statd on the client will send an sm-notify to rpc-statd on the NFS sever. Add a test case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15938 Signed-off-by: Peter Schwenke <pschwenke@ddn.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Feb 18 12:29:16 UTC 2026 on atb-devel-224
2026-02-18ctdb-scripts: Only send notifies for newly taken IPsPeter Schwenke7-3/+85
We no longer delete shared state (and send notifies) for IPs previously held by the current node. The NFS lock manager won't have released locks for these IPs, so won't generate SM_MON on reclaim attempts. Therefore, there will be no add-client to put them back. We now record newly taken IP addresses in takeip, and only send notifies for those during ipreallocated. The extra notifies were also confusing statd. Update existing tests to always simulate taking all of a node's IPs. This causes no output changes. Test updates confirm the subtleties of the statd_callout_helper behaviour change. These pretend to only take a single IP, so SM_NOTIFY must not be sent for other IPs. Shared state should remain for these other files. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15939 Signed-off-by: Peter Schwenke <pschwenke@ddn.com> Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-18ctdb-tests: Update statd-callout unit test infrastructureMartin Schwenke6-30/+52
Don't cheat. Keep some state about what is happening, similar to what statd_callout and statd_callout_helper are expected to keep. This means hinting arguments to check_shared_storage_statd_state() and check_statd_callout_smnotify() can be dropped. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15939 Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-09ctdb-tests: Fix tunables test when run as rootMartin Schwenke1-1/+1
When run as root, this test's expected output is missing: Loading tunables from ... at the top. Fix this by using the correct function to construct the expected output. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-10-17ctdb-scripts: Avoid failing updateip when IP is not assignedMartin Schwenke1-1/+1
There is no use failing this when it could behave more like takeip. Use old interface of "__none__" as a hint that ctdbd doesn't think the IP is assigned either. In this case print a warning instead of an error. Take some care to avoid spurious errors in updateip. After commit 0536d7a98b832fc00d26b09c26bf14fb63dbf5fb (which improves IP address state checking), this will almost certainly not occur on platforms with getifaddrs(3) (e.g. Linux). This means it is only likely to occur in 4.21 when net.ipv4.ip_nonlocal_bind=1. Update test to match. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15935 Reported-by: Bailey Allison <ballison@45drives.com> Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Fri Oct 17 06:28:30 UTC 2025 on atb-devel-224
2025-10-17ctdb-tests: Add an event script unit test for updateipMartin Schwenke1-0/+16
This illustrates the current failure where an unassigned public IP address causes updateip to fail. After commit 0536d7a98b832fc00d26b09c26bf14fb63dbf5fb (which improves IP address state checking), this will almost certainly not occur on platforms with getifaddrs(3) (e.g. Linux). This means it is only likely to occur in 4.21 when net.ipv4.ip_nonlocal_bind=1. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15935 Reported-by: Bailey Allison <ballison@45drives.com> Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-10-14ctdb-tests: Don't hard code creation of $CTDB_BASE/events/legacy/Martin Schwenke1-2/+0
setup_ctdb_base() should always create from etc-ctdb/. That directory may be changed to not include the legacy/ component subdirectory, so don't hard-code this particular subdirectory. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Tue Oct 14 17:57:49 UTC 2025 on atb-devel-224
2025-10-14ctdb-tests: Improve setup_ctdb_base() to fix local_daemons.sh bugMartin Schwenke1-0/+13
$ ctdb/tests/local_daemons.sh foo onnode 0 ctdb event script list legacy Unable to find event script installation directory: foo/node.0/share/events/legacy This happens if the $CTDB_BASE/share/events/legacy/ directory does not exist. This directory is (theoretically) for installed but not necessarily enabled event scripts. ctdb/tests/etc-ctdb/ contains events/legacy/ but setup_ctdb_base() currently does not ensure creation of the corresponding directory under $CTDB_BASE/share/. Ensure that an event script component installation subdirectory exists for each corresponding configuration subdirectory. An alternative would be to continue to allow the existing failure, but create directory ctdb/tests/etc-ctdb/share/events/legacy/ specifically to make local_daemons.sh work. However, it took 5 years to find the current bug, so this may be too subtle for other users of local_daemons.sh. Anyone wanting to test the failure case can remove unwanted subdirectories after "local_daemons.sh setup". Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-10-14ctdb-event: Improve error messageMartin Schwenke1-1/+2
The current message: Command script list finished with result=2 does not clearly explain the problem. Improve it. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-10-14ctdb-tests: Reformat with "shfmt -w -i 0 -fn "Martin Schwenke6-420/+436
Best reviewed with "git show -w". Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-09-25ctdb-common: Only respect CTDB_SOCKET in CTDB_TEST_MODEMartin Schwenke1-1/+9
At the moment CTDB_SOCKET can be used outside of test mode even though nobody should do this. So, no longer allow this. This means ensuring CTDB_TEST_MODE is set in the in the "clusteredmember" selftest environment, so that CTDB_SOCKET is respected there.. Details... The associated use of chown(2) and chmod(2), used to secure the socket in ctdb_daemon.c:ux_socket_bind(), potentially enables a symlink race attack. However, the chown(2) is currently not done in test mode, so restricting the use of CTDB_SOCKET to test mode solves the potential security issue. Also, sprinkle warnings about use of CTDB_TEST_MODE in appropriate places, just to attempt to limit unwanted behaviour. An alternative could be to use the socket file descriptor with fchown(2) and fchmod(2). However, these system calls are not well defined on sockets. Still, this was previously done in CTDB's early days (using the poorly documented method where they are allowed in Linux (only?) before calling bind(2)). It was removed (due to portability issues, via commits cf1056df94943ddcc3d547d4533b4bc04f57f265 and 2da3fe1b175a468fdff4aa4f65627facd2c28394) and replaced with the current post-bind chown(2) and chmod(2). I would like to remove the CTDB_SOCKET environment variable entirely, since setting CTDB_TEST_MODE and CTDB_BASE covers all reasonable test environments. However, I have a feeling that people use it for interactive testing, and that can still be done in CTDB_TEST_MODE. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15921 Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reported-by: *GUIAR OQBA * <techokba@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Sep 25 09:02:06 UTC 2025 on atb-devel-224
2025-07-28ctdb-tests: Fix CID 1659221 - Error handling issues (CHECKED_RETURN)Martin Schwenke1-1/+4
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Mon Jul 28 06:45:51 UTC 2025 on atb-devel-224
2025-07-28ctdb-tests: Fix CID 1373387 - Time of check time of use (TOCTOU)Martin Schwenke1-4/+4
Coverity doesn't like the fopen(3) after stat(2). This is test code that runs in a simple test environment, so this doesn't really matter. However, reorder the code to put the stat(2) after the fopen(3). This means that the test still does all the same checks and it should now make Coverity happy. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-07-22ctdb-tests: Add tests for tunables directory loadingMartin Schwenke2-7/+116
The missing 2nd file testcase becomes the missing directory testcase, because you can't easily have both. See the comment in tunable_test.c. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-tests: Allow tunables unit test to process a second fileMartin Schwenke2-5/+64
The second file is optional. Make $tfile the default to avoid having to update all of the single file testcases. Add test cases for second file. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-common: Log tunables filename instead of function nameMartin Schwenke1-14/+14
When loading multiple files, this is more informative. Tweak a couple of error messages to ensure they all mention "tunables". Update the unit testcases to match. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-common: Log a message if the tunables file does not existMartin Schwenke1-1/+2
Switch the unit test script to INFO debug level to ensure this output appears when expected. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-tests: Add logging support to the tunables unit testMartin Schwenke2-4/+44
Make tunable_test respect CTDB_DEBUGLEVEL. Using test_options.[ch] would be overkill here. This means including logging.c - we can't link to the subsystem containing logging.c because the file being tested (tunable.c) is part of that subsystem. Support logging in the test script. tunable_ok() builds the logging output for the good path. Set the debug level to NOTICE and update expected results for individual failure path tests. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-common: Require separate initialisation of tunable defaultsMartin Schwenke2-10/+24
Dropping this from ctdb_tunable_load_file() allows that function to be called multiple times for different files. The caller sets the defaults. In the test script, factor out the handling of a single tunables file in a similar way. Ignoring missing/unreadable files is OK because this function will only be called for test successes (hence "ok" in the name). There will never be existing, unreadable files. The code being tested ignores missing files, so do that here too. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-07-22ctdb-tests: Reformat with "shfmt -w -p -i 0 -fn"Martin Schwenke1-6/+6
Best reviewed with "git show -w". Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-05-29ctdb-daemon: Add configuration option shutdown extra timeoutMartin Schwenke1-0/+1
See documentation change for details. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15858 Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2025-05-29ctdb-daemon: Add configuration option shutdown failover timeoutMartin Schwenke1-0/+1
Allows the timeout for failover during shutdown to be modified. Defaults to 10s. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15858 Signed-off-by: Martin Schwenke <mschwenke@ddn.com> SQ Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2024-12-13ctdb-scripts: Change default persistent DB for statd_callout_helperMartin Schwenke1-2/+2
This database isn't use throughout CTDB, so name the it more specifically. Note that this might cause locks to be lost during upgrade to the first version containing this change. For testing, a different name is chosen to exercise related functionality. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Dec 13 15:01:10 UTC 2024 on atb-devel-224
2024-12-13ctdb-scripts: Support CTDB_STATD_CALLOUT_SHARED_STORAGE=noneMartin Schwenke8-0/+51
Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com>