diff options
author | Jeremy Allison <jra@samba.org> | 2020-03-03 13:31:18 -0800 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2020-04-07 08:12:36 +0000 |
commit | 58723f78af08dac2959e14705f0023f5a6517a32 (patch) | |
tree | 6f1ecb4d2d811803a737d762d712a0c45866afdb | |
parent | a108dece4fb11c36af321f5673097e76433c28ad (diff) | |
download | samba-58723f78af08dac2959e14705f0023f5a6517a32.tar.gz |
s3: tests: Add samba3.blackbox.force-close-share
Checks server stays up whilst writing to a force closed share.
Uses existing aio_delay_inject share to delay writes while
we force close the share.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Mar 8 19:34:14 UTC 2020 on sn-devel-184
(cherry picked from commit bb22be08b077b7d5911ccdeb1012f4dea85647e5)
(cherry picked from commit 566658d914176c41942e3c6aba404ae369aeb123)
-rwxr-xr-x | source3/script/tests/test_force_close_share.sh | 100 | ||||
-rwxr-xr-x | source3/selftest/tests.py | 9 |
2 files changed, 109 insertions, 0 deletions
diff --git a/source3/script/tests/test_force_close_share.sh b/source3/script/tests/test_force_close_share.sh new file mode 100755 index 00000000000..da78b5a752e --- /dev/null +++ b/source3/script/tests/test_force_close_share.sh @@ -0,0 +1,100 @@ +#!/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 diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index dddcb03230c..6bdbb6f97a4 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -802,6 +802,15 @@ plantestsuite("samba3.blackbox.close-denied-share", "simpleserver:local", '$SERVER_IP', "tmp"]) +plantestsuite("samba3.blackbox.force-close-share", "simpleserver:local", + [os.path.join(samba3srcdir, + "script/tests/test_force_close_share.sh"), + configuration, + os.path.join(bindir(), "smbclient"), + os.path.join(bindir(), "smbcontrol"), + '$SERVER_IP', + "aio_delay_inject"]) + plantestsuite("samba3.blackbox.open-eintr", "simpleserver:local", [os.path.join(samba3srcdir, "script/tests/test_open_eintr.sh"), |