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 7bfc19d635 Clean up handling the of CTDB restarts in testcases.
Glitches during restarts of the CTDB cluster have been causing some
tests to fail.  This is because restarts are initiated in the body of
many tests.  This adds a simple function ctdb_restart_when_done, which
schedules a restart using an existing hook in the test exit code.
This function is now used in tests that need to restart CTDB.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit fc69b6a66282d5be6edeb286bf72aeafb252e6dd)
2009-06-19 18:03:14 +10:00
..
complex New tests for NFS and CIFS tickles. 2009-06-18 09:04:43 +10:00
events.d merge async recovery changes from Ronnie 2008-01-29 13:59:28 +11:00
scripts Clean up handling the of CTDB restarts in testcases. 2009-06-19 18:03:14 +10:00
simple Clean up handling the of CTDB restarts in testcases. 2009-06-19 18:03:14 +10:00
src Whitespace changes and using the CTDB_NO_MEMORY() macro changes to 2009-05-21 11:49:16 +10:00
README Add tests/README. ctdb_test_env and, therefore, run_tests can now be 2009-01-09 17:52:38 +11:00
recover.sh more code rearrangement 2007-06-07 22:16:48 +10:00
run_tests.sh For now, make tests/run_tests.sh runs the new test suite. Add 2009-01-12 15:47:12 +11:00
test_check_tcp_ports.sh add a simple test script to test ctdb_check_tcp_ports 2009-01-30 22:49:17 +01:00
TODO For now, make tests/run_tests.sh runs the new test suite. Add 2009-01-12 15:47:12 +11:00

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

The run_tests script can be run as follows:

  scripts/run_tests simple/*.sh

It can also be run from other places (e.g. the top level ctdb source
directory), as it works out where the tree is.

The pseudo-test simple/00_ctdb_init.sh causes ctdb to be (re)started
on all nodes to attempt to force the cluster into a healthy state.  By
default (i.e. if CTDB_TEST_REAL_CLUSTER is unset - see below) this
causes some local daemons to be started on the local machine.  Tests
can also be run against a real or virtual cluster.  All tests
communicate with cluster nodes using onnode - when using local daemons
this is accomplished via some test hooks in onnode and the ctdb
client.

Command-line options
--------------------

The most useful option is "-s", which causes a summary of test results
to be printed at the end of testing.

Environment variables
---------------------

run_tests supports several environment variables, mostly implemented
in scripts/ctdb_test_env.  These are:

* CTDB_TEST_REAL_CLUSTER

  If set, testing will occur on a real or virtual cluster.

  Assumptions:

  - The ctdb client command can be found via $PATH on the nodes.

  - Password-less ssh access to the cluster nodes is permitted from
    the test host.

  - $CTDB_NODES_FILE is set to the location of a file similar to
    /etc/ctdb/nodes.  The file can be obtained by scping it from one
    of the cluster nodes.

  - See CTDB_TEST_REMOTE_DIR.

  If not set, testing will proceed against local daemons.

* CTDB_TEST_REMOTE_DIR

  This may be required when running against a real or virtual cluster
  (as opposed to local daemons).

  If set, this points to a directory containing the contents of the
  tests/scripts/ directory, as well as all of the test binaries.  This
  can be accomplished in a couple of ways:

  * By copying the relevant scripts/binaries to some directory.

  * Building an RPM containing all of the test code that is required
    on the cluster nodes and installing it on each node.  Hopefully
    this will be supported in a future version of the CTDB packaging
    process.

  If not set, the test system assumes that the CTDB tree is available
  in the same location on the cluster nodes as on the test host.  This
  could be accomplished by copying or by sharing with NFS (or
  similar).

* VALGRIND

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

  The easiest way of doing this is something like:

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

  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.  :-)

* CTDB

  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"

Look, no run_test!
------------------

If you want to integrate individual tests into some other test
environment you can use scripts/ctdb_test_env to wrap individual
tests.  They will return 0 on success, non-zero otherwise, and will
print the output omitting the test header/footer that surrounds test
output when tests are run using run_tests.  So, you can do something
like:

  for i in simple/*.sh ; do
      my_test_framework_wrapper scripts/ctdb_test_env $i
  done

to have your own framework process the test results and output.