s3:script/tests: add a test for VSS write behaviour
authorRalph Boehme <slow@samba.org>
Fri, 23 Nov 2018 09:18:44 +0000 (10:18 +0100)
committerRalph Boehme <slow@samba.org>
Tue, 27 Nov 2018 06:13:13 +0000 (07:13 +0100)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.blackbox [new file with mode: 0644]
selftest/target/Samba3.pm
source3/script/tests/test_shadow_copy_torture.sh [new file with mode: 0755]
source3/selftest/tests.py

diff --git a/selftest/knownfail.d/samba3.blackbox b/selftest/knownfail.d/samba3.blackbox
new file mode 100644 (file)
index 0000000..16537e5
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.shadow_copy_torture.writing to shadow copy of a file\(fileserver\)
index 363840e45215d93e8569d93eac9f6723925e0348..0e1ffd1101aa1b552872f795ba9a0c974b904512 100755 (executable)
@@ -2190,6 +2190,15 @@ sub provision($$$$$$$$$)
        vfs objects = shadow_copy2
        shadow:mountpoint = $shadow_mntdir
        wide links = yes
+
+[shadow_write]
+       path = $shadow_tstdir
+       comment = previous versions snapshots under mount point
+       vfs objects = shadow_copy2 error_inject
+       aio write size = 0
+       error_inject:pwrite = EBADF
+       shadow:mountpoint = $shadow_tstdir
+
 [dfq]
        path = $shrdir/dfree
        vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
diff --git a/source3/script/tests/test_shadow_copy_torture.sh b/source3/script/tests/test_shadow_copy_torture.sh
new file mode 100755 (executable)
index 0000000..d47cd51
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# Blackbox test for shadow_copy2 VFS.
+#
+
+if [ $# -lt 7 ]; then
+cat <<EOF
+Usage: test_shadow_copy SERVER SERVER_IP DOMAIN USERNAME PASSWORD WORKDIR SMBTORTURE
+EOF
+exit 1;
+fi
+
+SERVER=${1}
+SERVER_IP=${2}
+DOMAIN=${3}
+USERNAME=${4}
+PASSWORD=${5}
+WORKDIR=${6}
+SMBTORTURE="$VALGRIND ${7}"
+shift 7
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+SNAPSHOT="@GMT-2015.10.31-19.40.30"
+
+failed=0
+
+# build a hierarchy of files, symlinks, and directories
+build_files()
+{
+    local destdir
+    destdir=$1
+
+    echo "$content" > $destdir/foo
+}
+
+# build a snapshots directory
+build_snapshots()
+{
+    local snapdir
+
+    snapdir=$WORKDIR/.snapshots
+
+    mkdir -p $snapdir
+    mkdir $snapdir/$SNAPSHOT
+
+    build_files $snapdir/$SNAPSHOT
+}
+
+test_shadow_copy_write()
+{
+    local msg
+
+    msg=$1
+
+    #delete snapshots from previous tests
+    find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
+    build_snapshots
+
+    testit "writing to shadow copy of a file" \
+          $SMBTORTURE \
+          -U$USERNAME%$PASSWORD \
+          "//$SERVER/shadow_write" \
+          --option="torture:twrp_file=foo" \
+          --option="torture:twrp_snapshot=$SNAPSHOT" \
+          smb2.twrp.write || \
+        failed=`expr $failed + 1`
+}
+
+build_files $WORKDIR
+
+# test open for writing and write behaviour of snapshoted files
+test_shadow_copy_write "write behaviour of snapshoted files"
+
+exit $failed
index f3c5c39664b4f5db0dfdf01c57b8fa09db5d5280..bfe875e19fa6f6b5559502e3dd1f768a649c153a 100755 (executable)
@@ -24,7 +24,7 @@ sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(__file__), "../
 import selftesthelpers
 from selftesthelpers import bindir, srcdir, scriptdir, binpath
 from selftesthelpers import plantestsuite, samba3srcdir
-from selftesthelpers import smbtorture3, configuration, smbclient3
+from selftesthelpers import smbtorture3, configuration, smbclient3, smbtorture4
 from selftesthelpers import net, wbinfo, dbwrap_tool, rpcclient, python
 from selftesthelpers import smbget, smbcacls, smbcquotas, ntlm_auth3
 from selftesthelpers import valgrindify, smbtorture4_testsuites
@@ -310,6 +310,7 @@ for env in ["fileserver"]:
     plantestsuite("samba3.blackbox.offline (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3])
     plantestsuite("samba3.blackbox.shadow_copy2 NT1 (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'NT1'])
     plantestsuite("samba3.blackbox.shadow_copy2 SMB3 (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'SMB3'])
+    plantestsuite("samba3.blackbox.shadow_copy_torture", env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy_torture.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbtorture4])
     plantestsuite("samba3.blackbox.smbclient.forceuser_validusers (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_forceuser_validusers.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', smbclient3])
     plantestsuite("samba3.blackbox.smbget (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbget.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', 'smbget_user', '$PASSWORD', '$LOCAL_PATH/smbget', smbget])
     plantestsuite("samba3.blackbox.netshareenum (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shareenum.sh"), '$SERVER', '$USERNAME', '$PASSWORD', rpcclient])