1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
samba-mirror/ctdb/tests
Martin Schwenke aed7faeab4 ctdb-tests: Fix some harmless CIDs
CID 1420632: Resource leaks (RESOURCE LEAK)
CID 1420631: Security best practices violations (TOCTOU)
CID 1417432: Resource leaks (RESOURCE LEAK)
CID 1417429: Security best practices violations (TOCTOU)
CID 1417427: Resource leaks (RESOURCE LEAK)

These are all in test code and constrained to the test environment, so
can't result in privilege escape.  No backport necessary.  However, we
might as well get them off the list.

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): Wed Nov  8 11:28:40 CET 2017 on sn-devel-144
2017-11-08 11:28:40 +01:00
..
complex ctdb-tests: Add tests to ensure reset of server end of connections 2017-09-01 00:13:06 +02:00
cunit ctdb-tests: Add sock_daemon test for stale socket handling 2017-11-07 07:51:02 +01:00
eventd ctdb-tests: Wait for ctdb_eventd to start, fail if it doesn't 2017-10-26 09:35:25 +02:00
events.d ctdb-tests: Update integration tests to use ctdb -X 2014-12-05 21:02:40 +01:00
eventscripts ctdb-tests: Add 31.clamd eventscript unit tests 2017-09-12 16:14:12 +02:00
onnode ctdb-tests: Drop onnode test README file and buggy onnode example 2017-09-01 00:13:06 +02:00
scripts ctdb-tests: Allow wait_until() to be used in unit tests 2017-10-26 09:35:25 +02:00
shellcheck ctdb-tests: Fix name of the variable representing init script 2017-01-16 15:46:42 +01:00
simple ctdb-tests: Add test for tunnels 2017-10-10 11:45:19 +02:00
src ctdb-tests: Fix some harmless CIDs 2017-11-08 11:28:40 +01:00
takeover ctdb-tests: Add a big no-op LCP2 IP takeover test 2017-08-10 10:30:58 +02:00
takeover_helper ctdb-takeover: Don't release IPs from nodes where they are not known 2017-02-24 11:50:36 +01:00
tool ctdb-tests: Process-exists unit tests should wait until PID is registered 2017-10-26 13:32:24 +02:00
README ctdb:tests: update README 2013-12-05 00:47:43 +01:00
run_cluster_tests.sh tests: Fix wrapper scripts to handle options and tests without breakage 2012-05-14 15:02:19 +10:00
run_tests.sh ctdb-tests: run_tests.sh sets evironment variable CTDB_TEST_DIR 2017-08-14 05:15:25 +02: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 tests (onnode, takeover, tool, eventscripts) and
the tests against local daemons (simple) using the script
tests/run_tests.sh.

When running tests against a real or virtual cluster the script
tests/run_cluster_tests.sh can be used.  This runs all integration
tests (simple, complex).

Both of these scripts can also take a list of tests to run.  You can
also pass options, which are then passed to run_tests.  However, if
you just try to pass options to run_tests then you lose the default
list of tests that are run.  You can't have everything...

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

This script can be used to manually run all or selected unit tests and
simple integration tests against local daemons. Test selection is done
by specifying optional call parameters. If no parameter is given,
all unit tests and simple integration tests are run.

This runs all unit tests of the "tool" category:

  ./tests/run_tests.sh tool

In order to run a single test, one simply specifies the path of the
test script to run as the last parameter, e.g.:

  ./tests/run_tests.sh ./tests/eventscripts/00.ctdb.monitor.001
  ./tests/run_tests.sh ./tests/simple/76_ctdb_pdb_recovery.sh

One can also specify multiple test suites and tests:

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

The script also has number of command-line switches.
Some of the more useful options include:

  -s  Print a summary of tests results after running all tests

  -l  Use local daemons for integration tests

      This allows the tests in "simple" to be run against local
      daemons.

      All integration tests communicate with cluster nodes using
      onnode or the ctdb tool, which both have some test hooks to
      support local daemons.

      By default 3 daemons are used.  If you want to use a different
      number of daemons then do not use this option but set
      TEST_LOCAL_DAEMONS to the desired number of daemons instead.
      The -l option just sets TEST_LOCAL_DAEMONS to 3...  :-)

  -e  Exit on the first test failure

  -C  Clean up - kill daemons and remove $TEST_VAR_DIR when done

      Tests uses a temporary/var directory for test state.  By default,
      this directory is not removed when tests are complete, so you
      can do forensics or, for integration tests, re-run tests that
      have failed against the same directory (with the same local
      daemons setup).  So this option cleans things up.

      Also kills local daemons associated with directory.

  -V  Use <dir> as $TEST_VAR_DIR

      Use the specified temporary temporary/var directory.

  -H  No headers - for running single test with other wrapper

      This allows tests to be embedded in some other test framework
      and executed one-by-one with all the required
      environment/infrastructure.

      This replaces the old ctdb_test_env script.

How do the tests find remote test programs?
-------------------------------------------

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.

If cluster nodes do not have the CTDB git tree then
CTDB_TEST_REMOTE_DIR can be set to a directory that, on each cluster
node, contains the contents of tests/scripts/ and tests/bin/.

In the future this will hopefully (also) be supported via a ctdb-test
package.

Running the ctdb tool under valgrind
------------------------------------

The easiest way of doing this is something like:

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

This can be used to cause all invocations of the ctdb client (and,
with local daemons, the ctdbd daemons themselves) to occur under
valgrind.

NOTE: Some libc calls seem to do weird things and perhaps cause
spurious output from ctdbd at start time.  Please read valgrind output
carefully before reporting bugs.  :-)

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"