summaryrefslogtreecommitdiff
path: root/ctdb/tests/src
Commit message (Collapse)AuthorAgeFilesLines
* ctdb-tests: Avoid warning about NULL dereferenceMartin Schwenke2019-07-051-0/+1
| | | | | | | | | Static analysis finds that earlier in the call path, ctdb_string_len() checks for NULL, so complains that a NULL value can be passed to strlen() here. Avoid this by adding an assert(). Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Don't compare an unsigned value with -1Martin Schwenke2019-07-051-1/+1
| | | | | | | | The dummy reader should never be called, so contains an assert on the buffer length that should always trigger. Just abort() instead. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix signed/unsigned comparisons by castingMartin Schwenke2019-07-055-6/+6
| | | | | | | | These are all cases comparing a number of bytes written (int or ssize_t) with a size_t, so casting to size_t is appropriate. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix signed/unsigned comparisons by declaring as unsignedMartin Schwenke2019-07-0517-68/+76
| | | | | | | | Change declarations of variable and parameters, usually loop variables and limits, from int to unsigned int, size_t or uint32_t. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix signed/unsigned comparisons by castingMartin Schwenke2019-07-051-19/+19
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add a local variable for repeated calculationMartin Schwenke2019-07-051-8/+10
| | | | | | | | | This improves readability. Also, the asserts involving this expression get more complicated in the next commit, so this will keep those asserts within a single line. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Declare variable for return value of write(2) as ssize_tMartin Schwenke2019-07-051-4/+6
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix signed/unsigned comparison by declaring as unsignedMartin Schwenke2019-07-051-1/+2
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Avoid potentially uninitialised dataMartin Schwenke2019-06-051-2/+2
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Fix signed/unsigned comparison by using constantMartin Schwenke2019-06-051-1/+1
| | | | | | | Variable reqid is unsigned, so don't compare with -1. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb:tests: Add missing va_end() in ctdb_set_error()Andreas Schneider2019-05-241-0/+1
| | | | | | | Found by csbuild. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@samba.org>
* ctdb-tests: Add reqid wrapping testAmitay Isaacs2019-05-131-0/+16
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13930 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb: Fix format in db_hash_testAndreas Schneider2019-05-071-1/+1
| | | | | | | | | error: ‘%04d’ directive writing between 4 and 11 bytes into a region of size 5 [-Werror=format-overflow=] sprintf(key, "key%04d", i); Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* ctdb-test: Adding test case to verify queue resizeingSwen Schillig2019-04-101-0/+74
| | | | | | | | | | | | | | If a data packet arrives which exceeds the queue's current buffer size, the buffer needs to be increased to hold the full packet. Once the packet is processed the buffer size should be decreased to its standard size again. This test case verifies this process. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Wed Apr 10 00:17:37 UTC 2019 on sn-devel-144
* ctdb-test: Adding test case verifying data in buffer moveSwen Schillig2019-04-091-0/+76
| | | | | | Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Christof Schmitt <cs@samba.org>
* ctdb-test: Modify ctdb_io_test test_setup to provide queue referenceSwen Schillig2019-04-091-3/+7
| | | | | | | | | Some test scenarios require access to the created queue. Prepare the test_setup function to provide it as additional parameter. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Christof Schmitt <cs@samba.org>
* ctdb-tests: Add some testing for IPv4-mapped IPv6 address parsingMartin Schwenke2019-03-151-0/+19
| | | | | | | | | | | | | ctdb_sock_addr values are hashed in some contexts. This means that all of the memory used for the ctdb_sock_addr should be consistent regardless of how parsing is done. The first 2 cases are just sanity checks but the 3rd case involving an IPv4-mapped IPv6 address is the real target of this test addition. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13839 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@samba.org>
* ctdb-tests: Add test for ctdb_io.cChristof Schmitt2019-02-221-0/+196
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13791 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Fri Feb 22 03:51:37 CET 2019 on sn-devel-144
* ctdb: Use C99 initializer for poptOption in test_optionsAndreas Schneider2019-01-281-26/+79
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* debug: Use debuglevel_(get|set) functionAndreas Schneider2018-11-083-3/+3
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 8 11:03:11 CET 2018 on sn-devel-144
* ctdb-tests: Use path_socket() in dummy clientMartin Schwenke2018-11-061-13/+10
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Use path_socket() in test client toolsMartin Schwenke2018-11-061-8/+5
| | | | | | | | | Just leak the memory allocated by path_socket(). This is only used in short-lived test programs, so it isn't worth the hassle of plumbing a talloc context through several layers to get here. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Shut down transaction_loop clients more cleanlyMartin Schwenke2018-10-081-10/+18
| | | | | | | | | | | | | A transaction_loop client can exit with a transaction active when its time limit expires. This causes a recovery and causes problems with the test cleanup, which detects unwanted recoveries and fails. Set a flag when the time limit expires and exit cleanly before the next transaction is started. Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Drop code for RECEIVE_RECORDS controlAmitay Isaacs2018-10-081-20/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13641 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Fix CTDB -O3 --picky-developer build on CentOS 7Martin Schwenke2018-09-071-1/+1
| | | | | | | | | | | | | | gcc 4.8.5 complains: [319/381] Compiling ctdb/tests/src/system_socket_test.c ../tests/src/system_socket_test.c: In function ‘test_tcp’: ../tests/src/system_socket_test.c:196:20: error: ‘rst_out’ may be used uninitialized in this function [-Werror=maybe-uninitialized] assert((rst != 0) == (rst_out != 0)); ^ cc1: all warnings being treated as errors Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
* ctdb-tests: Check result of write() in ARP and TCP testsMartin Schwenke2018-09-061-2/+8
| | | | | | | | | | | CTDB -O3 --picky-developer build is failing. Not sure how this slipped through. 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): Thu Sep 6 08:33:59 CEST 2018 on sn-devel-144
* ctdb-tests: Extend TCP packet test to also do packet extractionMartin Schwenke2018-08-301-0/+48
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add tests for TCP packet marshallingMartin Schwenke2018-08-301-0/+69
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add tests for ARP and IPv6 NA marshallingMartin Schwenke2018-08-301-0/+65
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-tests: Add basic test to sanity check types in socket marshallingMartin Schwenke2018-08-301-0/+63
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Use script abstraction in run_eventMartin Schwenke2018-07-281-0/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13551 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Factor out basic script abstractionMartin Schwenke2018-07-281-0/+119
| | | | | | | | | Provides for listing of scripts and chmod enable/disable. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13551 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-common: Add fd argument to ctdb_connection_list_read()Amitay Isaacs2018-07-281-12/+6
| | | | | | | | | This makes testing easier. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Add line based I/OAmitay Isaacs2018-07-281-0/+102
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Porting tests should ignore unsupported featuresAmitay Isaacs2018-07-281-3/+7
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Add signal code matching utilityAmitay Isaacs2018-07-281-0/+120
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-client: Switch to ETIMEDOUT instead of ETIMEAmitay Isaacs2018-07-281-1/+1
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Add errno matching utilityAmitay Isaacs2018-07-281-0/+189
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-protocol: Add function ctdb_sock_addr_mask_from_string()Martin Schwenke2018-07-271-0/+35
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Drop the noiphost "node flags" bitmapMartin Schwenke2018-07-111-2/+0
| | | | | | | | This is no longer needed because inactive/disabled nodes no longer report any available public IP addresses. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Stop inactive/disabled nodes from reporting available IPsMartin Schwenke2018-07-112-2/+13
| | | | | | | | | | | | This can be done now that NoIPHostOnAllDisabled is gone and will allow the public IP address failover logic to be simplified. In the test code, still filter available IP addresses by node state. This code can't currently read information about available IP addresses but that will change in future Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Drop plumbing for obsolete tunable NoIPHostOnAllDisabledMartin Schwenke2018-07-111-9/+0
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb-daemon: Change default for tunable NoIPHostOnAllDisabled to 1Martin Schwenke2018-07-111-1/+1
| | | | | | | | | | | | | | | | | Defaulting to host public IP addresses when all nodes are unhealthy does not obey the principle of least surprise. It has caused much confusion over the years. It often leads to problems when all nodes are unhealthy due to something like a cluster filesystem being unmounted. Change the default value for this tunable as the first step of completely removing this behaviour. Remove tests that set NoIPHostOnAllDisabled=1 and update the expected result for other tests where no nodes are healthy. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* ctdb: close the correct pipe fd in a testRalph Boehme2018-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | This was discovered in an autobuild with a patched tevent that used the "poll" backend by default. Test failure: $ bin/sock_daemon_test /dev/shm/sock_daemon_test.pid /dev/shm/sock_daemon_test.sock 5 test5[28011]: daemon started, pid=28011 test5[28011]: listening on /dev/shm/sock_daemon_test.sock sock_daemon_test: ../ctdb/tests/src/sock_daemon_test.c:980: test5: Assertion `ret == i+1' failed. Abgebrochen (Speicherabzug geschrieben) metze@SERNOX14:~/devel/samba/4.0/master4-test$ test5[28011]: PID 28010 gone away, exiting test5[28011]: Shutting down sock_daemon_test: ../ctdb/tests/src/sock_daemon_test.c:964: test5: Assertion `ret == EINTR' failed. After an epic debugging session we spotted the problem. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ctdb-tests: Avoid segfault by initializing loggingAmitay Isaacs2018-07-051-0/+2
| | | | | | | | | | This is in addition to af697008531. 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 Jul 5 15:22:16 CEST 2018 on sn-devel-144
* ctdb-protocol: Remove protocol for old event daemonAmitay Isaacs2018-07-053-517/+0
| | | | | | | | This breaks the build. The new eventd protocol cannot be introduced without removing the old eventd protocol. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-common: Add client pid to connect callback in sock_daemonAmitay Isaacs2018-07-051-0/+1
| | | | | Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Separate testing code for basic data typesAmitay Isaacs2018-07-055-346/+404
| | | | | | | This will be used for testing other daemons' protocol code. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Avoid segfault by initializing loggingAmitay Isaacs2018-07-0411-2/+32
| | | | | | | | | | | | | Setting DEBUGLEVEL before calling debug_init() causes segmentation violation with gcc8. DEBUGLEVEL_CLASS is statically initialized to debug_class_list_initial which is defined as const. Only after debug_init() is called, DEBUGLEVEL_CLASS becomes a talloc'd array. So before modifying DEBUGLEVEL, ensure debug_init() is called via setup_logging(). (debug_init is a static function.) Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* ctdb-tests: Teach strace packet parser about non-octal escapesMartin Schwenke2018-07-021-12/+40
| | | | | | | | | | | strace output also encodes characters 7 to 13 as \a, \b, \t, \n, \v, \f, \r. 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): Mon Jul 2 11:30:29 CEST 2018 on sn-devel-144