shadow_copy2: Add test cases to cover shadow:format
authorRajesh Joseph <rjoseph@redhat.com>
Tue, 12 Jul 2016 09:33:29 +0000 (09:33 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 28 Jul 2016 08:06:13 +0000 (10:06 +0200)
Added test cases which will filter snapshot names based
on shadow:format option in smb.conf

Signed-off-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
selftest/target/Samba3.pm
source3/script/tests/test_shadow_copy.sh

index 5076c43bf185dc3cc9c44a1722c49d77e07291c5..5c3f8e150956849b8fc7a2031523b05ebe720d4d 100755 (executable)
@@ -1694,6 +1694,50 @@ sub provision($$$$$$$$)
        shadow:snapdir = $shadow_tstdir/.snapshots
        shadow:snapsharepath = share
 
+[shadow_fmt0]
+       comment = Testing shadow:format with default option
+       vfs object = shadow_copy2
+       path = $shadow_shrdir
+       read only = no
+       guest ok = yes
+       shadow:mountpoint = $shadow_mntdir
+       shadow:basedir = $shadow_basedir
+       shadow:snapdir = $shadow_basedir/.snapshots
+       shadow:format = \@GMT-%Y.%m.%d-%H.%M.%S
+
+[shadow_fmt1]
+       comment = Testing shadow:format with only date component
+       vfs object = shadow_copy2
+       path = $shadow_shrdir
+       read only = no
+       guest ok = yes
+       shadow:mountpoint = $shadow_mntdir
+       shadow:basedir = $shadow_basedir
+       shadow:snapdir = $shadow_basedir/.snapshots
+       shadow:format = \@GMT-%Y-%m-%d
+
+[shadow_fmt2]
+       comment = Testing shadow:format with some hardcoded prefix
+       vfs object = shadow_copy2
+       path = $shadow_shrdir
+       read only = no
+       guest ok = yes
+       shadow:mountpoint = $shadow_mntdir
+       shadow:basedir = $shadow_basedir
+       shadow:snapdir = $shadow_basedir/.snapshots
+       shadow:format = snap\@GMT-%Y.%m.%d-%H.%M.%S
+
+[shadow_fmt3]
+       comment = Testing shadow:format with modified format
+       vfs object = shadow_copy2
+       path = $shadow_shrdir
+       read only = no
+       guest ok = yes
+       shadow:mountpoint = $shadow_mntdir
+       shadow:basedir = $shadow_basedir
+       shadow:snapdir = $shadow_basedir/.snapshots
+       shadow:format = \@GMT-%Y.%m.%d-%H_%M_%S-snap
+
 [shadow_wl]
        path = $shadow_shrdir
        comment = previous versions with wide links allowed
index 171008da18b73953136313249ab01c249cbf870c..ef1f4e4881a0c7b6175c5afefcbe217752a49966 100755 (executable)
@@ -34,6 +34,12 @@ SNAPSHOTS[6]='@GMT-2021.10.31-19.40.30'
 SNAPSHOTS[7]='@GMT-2022.10.31-19.40.30'
 SNAPSHOTS[8]='@GMT-2023.10.31-19.40.30'
 SNAPSHOTS[9]='@GMT-2024.10.31-19.40.30'
+SNAPSHOTS[10]='@GMT-2010-11-11'
+SNAPSHOTS[11]='@GMT-2011.11.11-11.40.30'
+SNAPSHOTS[12]='snap@GMT-2012.11.11-11.40.30'
+SNAPSHOTS[13]='@GMT-2013.11.11-11_40_33-snap'
+SNAPSHOTS[14]='@GMT-2014.11.11-11.40.30'
+SNAPSHOTS[15]='daily@GMT-2015.11.11-11.40.30'
 
 # build a hierarchy of files, symlinks, and directories
 build_files()
@@ -261,6 +267,29 @@ test_shadow_copy_everywhere()
 
 }
 
+test_shadow_copy_format()
+{
+    local share     #share to contact
+    local where     #where to place snapshots
+    local prefix    #prefix to files inside snapshot
+    local ncopies_allowd
+    local msg
+
+    share=$1
+    where=$2
+    prefix=$3
+    ncopies_allowed=$4
+    msg=$5
+
+    #delete snapshots from previous tests
+    find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
+    build_snapshots $WORKDIR/$where "$prefix" 10 15
+
+    testit "$msg - regular file" \
+        test_count_versions $share foo $ncopies_allowed || \
+        failed=`expr $failed + 1`
+}
+
 #build "latest" files
 build_files $WORKDIR/mount base/share "latest"
 
@@ -288,4 +317,10 @@ test_shadow_copy_fixed shadow7 mount/base/share "" "'everywhere' share snapshots
 # a test for snapshots everywhere - multiple snapshot locations
 test_shadow_copy_everywhere shadow7
 
+# tests for testing snapshot selection via shadow:format
+test_shadow_copy_format shadow_fmt0 mount/base share 3 "basic shadow:format test"
+test_shadow_copy_format shadow_fmt1 mount/base share 2 "shadow:format with only date"
+test_shadow_copy_format shadow_fmt2 mount/base share 2 "shadow:format with some prefix"
+test_shadow_copy_format shadow_fmt3 mount/base share 2 "shadow:format with modified format"
+
 exit $failed