1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

tests/complex: Fix NFS tests to work with root_squash

Refactor the NFS test setup/cleanup code into new common functions.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit 29e98017221326bdc9b1c4f7c05b3b495c1de29b)
This commit is contained in:
Martin Schwenke 2013-07-22 14:32:13 +10:00
parent 1584f296b4
commit 6882625cfe
4 changed files with 51 additions and 50 deletions

View File

@ -49,22 +49,11 @@ cluster_is_healthy
# Reset configuration
ctdb_restart_when_done
select_test_node_and_ips
first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
mnt_d=$(mktemp -d)
test_file="${mnt_d}/$RANDOM"
ctdb_test_exit_hook_add rm -f "$test_file"
ctdb_test_exit_hook_add umount -f "$mnt_d"
ctdb_test_exit_hook_add rmdir "$mnt_d"
echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
nfs_test_setup
echo "Create file containing random data..."
dd if=/dev/urandom of=$test_file bs=1k count=1
original_sum=$(sum $test_file)
dd if=/dev/urandom of=$nfs_local_file bs=1k count=1
original_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
gratarp_sniff_start
@ -75,7 +64,7 @@ wait_until_node_has_status $test_node disabled
gratarp_sniff_wait_show
new_sum=$(sum $test_file)
new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$original_md5" = "$new_md5" ] ; then

View File

@ -51,31 +51,18 @@ cluster_is_healthy
# Reset configuration
ctdb_restart_when_done
select_test_node_and_ips
first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
local_f=$(mktemp)
mnt_d=$(mktemp -d)
nfs_f="${mnt_d}/$RANDOM"
remote_f="${test_ip}:${first_export}/$(basename $nfs_f)"
ctdb_test_exit_hook_add rm -f "$local_f"
ctdb_test_exit_hook_add rm -f "$nfs_f"
ctdb_test_exit_hook_add umount -f "$mnt_d"
ctdb_test_exit_hook_add rmdir "$mnt_d"
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
chmod 644 "$local_f" # needed for *_squash?
local_sum=$(sum $local_f)
[ $? -eq 0 ]
scp -p "$local_f" "$remote_f"
scp -p "$local_f" "${test_ip}:${nfs_remote_file}"
try_command_on_node $test_node "chmod 644 $nfs_remote_file"
echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
nfs_sum=$(sum $nfs_f)
nfs_sum=$(sum $nfs_local_file)
if [ "$local_sum" = "$nfs_sum" ] ; then
echo "GOOD: file contents read correctly via NFS"
@ -94,7 +81,7 @@ wait_until_node_has_status $test_node disabled
gratarp_sniff_wait_show
new_sum=$(sum $nfs_f)
new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$nfs_sum" = "$new_sum" ] ; then

View File

@ -49,22 +49,11 @@ cluster_is_healthy
# Reset configuration
ctdb_restart_when_done
select_test_node_and_ips
first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
mnt_d=$(mktemp -d)
test_file="${mnt_d}/$RANDOM"
ctdb_test_exit_hook_add rm -f "$test_file"
ctdb_test_exit_hook_add umount -f "$mnt_d"
ctdb_test_exit_hook_add rmdir "$mnt_d"
echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
nfs_test_setup
echo "Create file containing random data..."
dd if=/dev/urandom of=$test_file bs=1k count=1
original_sum=$(sum $test_file)
dd if=/dev/urandom of=$nfs_local_file bs=1k count=1
original_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
gratarp_sniff_start
@ -77,7 +66,7 @@ wait_until_node_has_status $test_node disconnected
gratarp_sniff_wait_show
new_sum=$(sum $test_file)
new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$original_md5" = "$new_md5" ] ; then

View File

@ -949,6 +949,42 @@ wait_for_monitor_event ()
}
#######################################
nfs_test_setup ()
{
select_test_node_and_ips
nfs_first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
echo "Creating test subdirectory..."
try_command_on_node $test_node "mktemp -d --tmpdir=$nfs_first_export"
nfs_test_dir="$out"
try_command_on_node $test_node "chmod 777 $nfs_test_dir"
nfs_mnt_d=$(mktemp -d)
nfs_local_file="${nfs_mnt_d}/${nfs_test_dir##*/}/TEST_FILE"
nfs_remote_file="${nfs_test_dir}/TEST_FILE"
ctdb_test_exit_hook_add nfs_test_cleanup
echo "Mounting ${test_ip}:${nfs_first_export} on ${nfs_mnt_d} ..."
mount -o timeo=1,hard,intr,vers=3 \
${test_ip}:${nfs_first_export} ${nfs_mnt_d}
}
nfs_test_cleanup ()
{
rm -f "$nfs_local_file"
umount -f "$nfs_mnt_d"
rmdir "$nfs_mnt_d"
onnode -q $test_node rmdir "$nfs_test_dir"
}
#######################################
# Make sure that $CTDB is set.
: ${CTDB:=ctdb}