diff options
| author | Martin Schwenke <martin@meltin.net> | 2015-03-04 11:51:20 +1100 |
|---|---|---|
| committer | Amitay Isaacs <amitay@samba.org> | 2015-03-04 10:42:27 +0100 |
| commit | 22602f76bc1ec91e807a8f1cd45ba6fb4c05e622 (patch) | |
| tree | 0e98202bb2e67661eb62b09f460d170bf67ea4a3 /ctdb/tests/eventscripts/scripts | |
| parent | d98c7ba382189161c5b8cbbebbdfbe36f1456572 (diff) | |
| download | samba-22602f76bc1ec91e807a8f1cd45ba6fb4c05e622.tar.gz samba-22602f76bc1ec91e807a8f1cd45ba6fb4c05e622.tar.xz samba-22602f76bc1ec91e807a8f1cd45ba6fb4c05e622.zip | |
ctdb-tests: Unit tests for statd-callout
With improvements to unit test infrastructure to support. This
includes linking the real statd-callout into etc-ctdb/ in place of the
placeholder script.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests/eventscripts/scripts')
| -rw-r--r-- | ctdb/tests/eventscripts/scripts/local.sh | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh index 163a8fb3ac..fe4ae1eec3 100644 --- a/ctdb/tests/eventscripts/scripts/local.sh +++ b/ctdb/tests/eventscripts/scripts/local.sh @@ -538,6 +538,65 @@ EOF ###################################################################### +ctdb_catdb_format_pairs () +{ + _count=0 + + while read _k _v ; do + _kn=$(echo -n "$_k" | wc -c) + _vn=$(echo -n "$_v" | wc -c) + cat <<EOF +key(${_kn}) = "${_k}" +dmaster: 0 +rsn: 1 +data(${_vn}) = "${_v}" + +EOF + _count=$(($_count + 1)) + done + + echo "Dumped ${_count} records" +} + +check_ctdb_tdb_statd_state () +{ + ctdb_get_my_public_addresses | + while read _x _sip _x ; do + for _cip ; do + echo "statd-state@${_sip}@${_cip}" "$FAKE_DATE_OUTPUT" + done + done | + ctdb_catdb_format_pairs | { + ok + simple_test_command ctdb catdb ctdb.tdb + } +} + +check_statd_callout_smnotify () +{ + _state_even=$(( $(date '+%s') / 2 * 2)) + _state_odd=$(($_state_even + 1)) + + nfs_load_config + + ctdb_get_my_public_addresses | + while read _x _sip _x ; do + for _cip ; do + cat <<EOF +--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_even} +--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_even} +--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_odd} +--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_odd} +EOF + done + done | { + ok + simple_test_event "notify" + } +} + +###################################################################### + setup_ctdb_natgw () { debug "Setting up NAT gateway" @@ -810,6 +869,19 @@ rpc_services_up () done } + +nfs_load_config () +{ + _etc="$CTDB_ETCDIR" # shortcut for readability + for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs" ; do + if [ -r "$_c" ] ; then + . "$_c" + break + fi + done +} + + # Set the required result for a particular RPC program having failed # for a certain number of iterations. This is probably still a work # in progress. Note that we could hook aggressively @@ -826,13 +898,7 @@ rpc_set_service_failure_response () # the flexibility to set the number of failures. _numfails="${2:-${iteration}}" - _etc="$CTDB_ETCDIR" # shortcut for readability - for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs" ; do - if [ -r "$_c" ] ; then - . "$_c" - break - fi - done + nfs_load_config # A handy newline. :-) _nl=" |
