1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/ctdb/tests/CLUSTER/complex/44_failover_nfs_oneway.sh
Martin Schwenke 38138b42f7 ctdb-tests: Update preamble for CLUSTER tests
The main change is to source cluster.bash instead of integration.bash.

While touching the preamble, the following additional changes are also
made:

* Drop test_info() definition and replace it with a comment

  The use of test_info() is pointless.

* Drop call to ctdb_test_check_real_cluster()

  cluster.bash now does this.

* Drop call to cluster_is_healthy()

  This is a holdover from when the previous test would restart daemons
  to get things ready for a test.  There was also a bug where going
  into recovery during the restart would sometimes cause the cluster
  to become unhealthy.  If we really need something like this then we
  can add it to ctdb_test_init().

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2019-10-04 09:41:28 +00:00

83 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# Verify that a file created on a node is readable via NFS after a failover.
# We write a file into an exported directory on a node, mount the NFS
# share from a node, verify that we can read the file via NFS and that
# we can still read it after a failover.
# Prerequisites:
# * An active CTDB cluster with at least 2 nodes with public addresses.
# * Test must be run on a real or virtual cluster rather than against
# local daemons.
# * Test must not be run from a cluster node.
# Steps:
# 1. Verify that the cluster is healthy.
# 2. Select a public address and its corresponding node.
# 3. Select the 1st NFS share exported on the node.
# 4. Write a file into exported directory on the node and calculate its
# checksum.
# 5. Mount the selected NFS share.
# 6. Read the file via the NFS mount and calculate its checksum.
# 7. Compare checksums.
# 8. Disable the selected node.
# 9. Read the file via NFS and calculate its checksum.
# 10. Compare the checksums.
# Expected results:
# * Checksums for the file on all 3 occasions should be the same.
. "${TEST_SCRIPTS_DIR}/cluster.bash"
set -e
ctdb_test_init
nfs_test_setup
echo "Create file containing random data..."
local_f=$(mktemp)
ctdb_test_exit_hook_add rm -f "$local_f"
dd if=/dev/urandom of=$local_f bs=1k count=1
local_sum=$(sum $local_f)
scp -p "$local_f" "[${test_ip}]:${nfs_remote_file}"
try_command_on_node $test_node "chmod 644 $nfs_remote_file"
nfs_sum=$(sum $nfs_local_file)
if [ "$local_sum" = "$nfs_sum" ] ; then
echo "GOOD: file contents read correctly via NFS"
else
echo "BAD: file contents are different over NFS"
echo " original file: $local_sum"
echo " NFS file: $nfs_sum"
exit 1
fi
gratarp_sniff_start
echo "Disabling node $test_node"
try_command_on_node 0 $CTDB disable -n $test_node
wait_until_node_has_status $test_node disabled
gratarp_sniff_wait_show
new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$nfs_sum" = "$new_sum" ] ; then
echo "GOOD: file contents unchanged after failover"
else
echo "BAD: file contents are different after failover"
echo " original file: $nfs_sum"
echo " NFS file: $new_sum"
exit 1
fi