1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/ctdb/tests
Martin Schwenke 238056e5aa ctdb-scripts: Avoid using testparm to process its own output
When testparm processes the output of "testparm -v" (which includes
default values) it appears to do global checks (or some other sort of
initialisation logic) for all specified values.  This includes a DNS
lookup for the node's hostname, as a side-effect of a libldap
ldap_set_option() call when processing "ldap debug level".  If DNS
servers are down then this can induce timeouts, possibly resulting in
monitor timeouts.

Avoid this by using sed to extract configuration values from the
testparm cache file.

This is already shown to work when retrieving share paths, where
testparm is basically used as cat.  Update the sed pattern to avoid
matching empty values on the right-hand side of the equals ('=') -
this avoids the default empty path value (and "smb ports" never has an
empty value).

Corresponding test changes:

* 50.samba.monitor.111.sh no longer expects a failure from being
  unable to set smb ports, since testparm is no longer used in that
  code path.

* smb ports needs to be set in fake smb.conf so it is in the default
  output and can be extracted using sed.

* Although testparm --parameter-name is no longer used in
  50.samba.script, update the stub implementation (in case it is ever
  used again) to extract from fake smb.conf, since "smb ports" is now
  set there.  The change from $parameter to $param allows a long line
  to stay below 80 columns.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Feb 14 08:43:53 UTC 2023 on atb-devel-224
2023-02-14 08:43:53 +00:00
..
CLUSTER/complex ctdb-tests: Avoid shellcheck warnings 2022-08-25 16:15:45 +00:00
etc-ctdb/events/legacy ctdb-tests: Use local_daemons.sh in local_daemons.bash 2018-11-06 07:16:17 +01:00
INTEGRATION ctdb-mutex: Rename recheck_time to recheck_interval 2022-07-28 10:09:34 +00:00
scripts ctdb-scripts: Avoid ShellCheck warning SC2295 2022-07-22 16:09:31 +00:00
src ctdb-common: CID 1507498: Control flow issues (DEADCODE) 2022-08-01 09:19:55 +00:00
UNIT ctdb-scripts: Avoid using testparm to process its own output 2023-02-14 08:43:53 +00:00
local_daemons.sh ctdb-tests: Support commenting out local daemons configuration options 2022-01-17 10:21:33 +00:00
README ctdb-tests: Add -l option to set number of local daemons 2019-10-22 21:02:11 +00:00
run_cluster_tests.sh
run_tests.sh ctdb-scripts: Avoid ShellCheck warning SC2295 2022-07-22 16:09:31 +00:00
test_check_tcp_ports.sh ctdb-scripts: CTDB_BASE must be set when including functions file 2015-09-15 08:56:21 +02:00
TODO

Introduction
------------

For a developer, the simplest way of running most tests on a local
machine from within the git repository is:

  make test

This runs all UNIT and INTEGRATION tests.

tests/run_tests.sh
------------------

This script can be used to manually run all tests or selected tests,
with a variety of options.  For usage, run:

  tests/run_tests.sh -h

If no tests are specified this runs all of the UNIT and INTEGRATION
tests.

By default:

* INTEGRATION tests are run against 3 local daemons

* When testing is complete, a summary showing a list is printed
  showing the tests run and their results

Tests can be selected in various ways:

* tests/run_tests.sh UNIT INTEGRATION

  runs all UNIT and INTEGRATION tests, and is like specifying no tests

* tests/run_tests.sh UNIT/tool

  runs all of the "tool" UNIT tests

* tests/run_tests.sh tests/UNIT/eventscripts/00.ctdb.setup.001.sh
  tests/run_tests.sh tests/INTEGRATION/simple/basics.001.listnodes.sh

  each runs a single specified test case

* tests/run_tests.sh UNIT/eventscripts UNIT/tool tests/UNIT/onnode/0001.sh

  runs a combination of UNIT test suites and a single UNIT test

Testing on a cluster
--------------------

INTEGRATION and CLUSTER tests can be run on a real or virtual cluster
using tests/run_cluster_tests.sh (or "tests/run_tests.sh -c").  The
test code needs to be available on all cluster nodes, as well as the
test client node.  The test client node needs to have a nodes file
where the onnode(1) command will find it.

If the all of the cluster nodes have the CTDB git tree in the same
location as on the test client then no special action is necessary.
The simplest way of doing this is to share the tree to cluster nodes
and test clients via NFS.

Alternatively, the tests can be installed on all nodes.  One technique
is to build a package containing the tests and install it on all
nodes.  CTDB developers do a lot of testing this way using the
provided sample packaging, which produces a ctdb-tests RPM package.

Finally, if the test code is installed in a different place on the
cluster nodes, then CTDB_TEST_REMOTE_DIR can be set on the test client
node to point to a directory that contains the test_wrap script on the
cluster nodes.

Running tests under valgrind
----------------------------

The easiest way of doing this is something like:

  VALGRIND="valgrind -q" tests/run_tests ...

This can be used to cause all invocations of the ctdb tool, test
programs and, with local daemons, the ctdbd daemons themselves to run
under valgrind.

How is the ctdb tool invoked?
-----------------------------

$CTDB determines how to invoke the ctdb client.  If not already set
and if $VALGRIND is set, this is set to "$VALGRIND ctdb".  If this is
not already set but $VALGRIND is not set, this is simply set to "ctdb"

Test and debugging variable options
-----------------------------------

       CTDB_TEST_MODE

	   Set this environment variable to enable test mode.

	   This enables daemons and tools to locate their socket and
	   PID file relative to CTDB_BASE.

	   When testing with multiple local daemons on a single
	   machine this does 3 extra things:

	   * Disables checks related to public IP addresses

	   * Speeds up the initial recovery during startup at the
	     expense of some consistency checking

	   * Disables real-time scheduling

       CTDB_DEBUG_HUNG_SCRIPT_LOGFILE=FILENAME
	   FILENAME specifies where log messages should go when
	   debugging hung eventscripts. This is a testing option. See
	   also CTDB_DEBUG_HUNG_SCRIPT.

	   No default. Messages go to stdout/stderr and are logged to
	   the same place as other CTDB log messages.

       CTDB_SYS_ETCDIR=DIRECTORY
	   DIRECTORY containing system configuration files. This is
	   used to provide alternate configuration when testing and
	   should not need to be changed from the default.

	   Default is /etc.

       CTDB_RUN_TIMEOUT_MONITOR=yes|no
	   Whether CTDB should simulate timing out monitor
	   events in local daemon tests.

	   Default is no.

       CTDB_TEST_SAMBA_VERSION=VERSION

	    VERSION is a 32-bit number containg the Samba major
	    version in the most significant 16 bits and the minor
	    version in the least significant 16 bits.  This can be
	    used to test CTDB's checking of incompatible versions
	    without installing an incompatible version.  This is
	    probably best set like this:

		export CTDB_TEST_SAMBA_VERSION=$(( (4 << 16) | 12 ))

       CTDB_VARDIR=DIRECTORY
	   DIRECTORY containing CTDB files that are modified at runtime.

	   Defaults to /usr/local/var/lib/ctdb.