# 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
gratarp_sniff_wait_show
-new_sum=$(sum $test_file)
+new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$original_md5" = "$new_md5" ] ; then
# Reset configuration
ctdb_restart_when_done
-select_test_node_and_ips
+nfs_test_setup
-first_export=$(showmount -e $test_ip | sed -n -e '2s/ .*//p')
+echo "Create file containing random data..."
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"
-
-echo "Create file containing random data..."
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"
-echo "Mounting ${test_ip}:${first_export} on ${mnt_d} ..."
-mount -o timeo=1,hard,intr,vers=3 ${test_ip}:${first_export} ${mnt_d}
+scp -p "$local_f" "${test_ip}:${nfs_remote_file}"
+try_command_on_node $test_node "chmod 644 $nfs_remote_file"
-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"
gratarp_sniff_wait_show
-new_sum=$(sum $nfs_f)
+new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$nfs_sum" = "$new_sum" ] ; then
# 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
gratarp_sniff_wait_show
-new_sum=$(sum $test_file)
+new_sum=$(sum $nfs_local_file)
[ $? -eq 0 ]
if [ "$original_md5" = "$new_md5" ] ; then
}
+#######################################
+
+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}