2009-07-08 07:37:52 +04:00
#!/bin/bash
2019-09-11 09:07:49 +03:00
# Verify that a mounted NFS share is still operational after failover.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# We mount an NFS share from a node, write a file via NFS and then
# confirm that we can correctly read the file after a failover.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# Prerequisites:
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# * An active CTDB cluster with at least 2 nodes with public addresses.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# * Test must be run on a real or virtual cluster rather than against
# local daemons.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# * Test must not be run from a cluster node.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# Steps:
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# 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. Mount the selected NFS share.
# 5. Create a file in the NFS mount and calculate its checksum.
# 6. Disable the selected node.
# 7. Read the file and calculate its checksum.
# 8. Compare the checksums.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# Expected results:
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
# * When a node is disabled the public address fails over and it is
# possible to correctly read a file over NFS. The checksums should be
# the same before and after.
2009-07-08 07:37:52 +04:00
2019-09-11 09:07:49 +03:00
. " ${ TEST_SCRIPTS_DIR } /cluster.bash "
2009-07-08 07:37:52 +04:00
set -e
2018-10-08 07:04:24 +03:00
ctdb_test_init
2009-07-08 07:37:52 +04:00
2013-07-22 08:32:13 +04:00
nfs_test_setup
2009-07-08 07:37:52 +04:00
echo "Create file containing random data..."
2013-07-22 08:32:13 +04:00
dd if = /dev/urandom of = $nfs_local_file bs = 1k count = 1
original_sum = $( sum $nfs_local_file )
2009-07-08 07:37:52 +04:00
[ $? -eq 0 ]
gratarp_sniff_start
echo " Disabling node $test_node "
try_command_on_node 0 $CTDB disable -n $test_node
2009-09-11 10:15:31 +04:00
wait_until_node_has_status $test_node disabled
2009-07-08 07:37:52 +04:00
gratarp_sniff_wait_show
2013-07-22 08:32:13 +04:00
new_sum = $( sum $nfs_local_file )
2009-07-08 07:37:52 +04:00
[ $? -eq 0 ]
if [ " $original_md5 " = " $new_md5 " ] ; then
echo "GOOD: file contents unchanged after failover"
else
2018-10-08 04:59:33 +03:00
die "BAD: file contents are different after failover"
2009-07-08 07:37:52 +04:00
fi