1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/source3/script/tests/test_force_close_share.sh
Jeremy Allison 566658d914 s3: tests: Slight tweak to the force-close share test.
Turns out on a fast desktop machine 10MB is too small,
and by the time we've done the 'sleep 1' to make sure
the smbclient got scheduled and started processing
the 'put' command, it's already done.

Tweak the file size to be 20MB from 10MB. 10MB
seems to work reliably on gitlab-ci and on
sn-devel, but making the put size 20MB makes
sure it's still in flight when we force-close
the share, even on a fast desktop box. 20MB
shouldn't be too burdonsome even on ci VM's.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-03-18 18:03:28 +00:00

101 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
#
# Test smbcontrol close-share command.
#
# Copyright (C) 2020 Volker Lendecke
# Copyright (C) 2020 Jeremy Allison
#
# Note this is designed to be run against
# the aio_delay_inject share which is preconfigured
# with 2 second delays on pread/pwrite.
if [ $# -lt 5 ]; then
echo Usage: test_share_force_close.sh \
SERVERCONFFILE SMBCLIENT SMBCONTROL IP aio_delay_inject_sharename
exit 1
fi
CONF=$1
SMBCLIENT=$2
SMBCONTROL=$3
SERVER=$4
SHARE=$5
incdir=$(dirname $0)/../../../testprogs/blackbox
. $incdir/subunit.sh
failed=0
# Create the smbclient communication pipes.
rm -f smbclient-stdin smbclient-stdout smbclient-stderr
mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
# Create a large-ish testfile
rm testfile
head -c 20MB /dev/zero >testfile
CLI_FORCE_INTERACTIVE=1; export CLI_FORCE_INTERACTIVE
${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
< smbclient-stdin > smbclient-stdout 2>smbclient-stderr &
CLIENT_PID=$!
sleep 1
exec 100>smbclient-stdin 101<smbclient-stdout 102<smbclient-stderr
# consume the smbclient startup messages
head -n 1 <&101
head -n 1 <&102
# Ensure we're putting a fresh file.
echo "del testfile" >&100
echo "put testfile" >&100
sleep 1
# Close the aio_delay_inject share whilst we have outstanding writes.
testit "smbcontrol" ${SMBCONTROL} ${CONF} smbd close-share ${SHARE} ||
failed=$(expr $failed + 1)
sleep 1
# If we get one or more NT_STATUS_NETWORK_NAME_DELETED
# or NT_STATUS_INVALID_HANDLE on stderr from the writes we
# know the server stayed up and didn't crash when the
# close-share removed the share.
#
# BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
#
COUNT=$(head -n 2 <&102 |
grep -e NT_STATUS_NETWORK_NAME_DELETED -e NT_STATUS_INVALID_HANDLE |
wc -l)
testit "Verify close-share did cancel the file put" \
test $COUNT -ge 1 || failed=$(expr $failed + 1)
kill ${CLIENT_PID}
# Rerun smbclient to remove the testfile on the server.
rm -f smbclient-stdin smbclient-stdout smbclient-stderr testfile
mkfifo smbclient-stdin smbclient-stdout
${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
< smbclient-stdin > smbclient-stdout &
CLIENT_PID=$!
sleep 1
exec 100>smbclient-stdin 101<smbclient-stdout
echo "del testfile" >&100
sleep 1
kill ${CLIENT_PID}
rm -f smbclient-stdin smbclient-stdout testfile
testok $0 $failed