]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Adapt regress for new BTRFS
authorEric Bollengier <eric@baculasystems.com>
Thu, 19 May 2022 15:18:34 +0000 (17:18 +0200)
committerEric Bollengier <eric@baculasystems.com>
Fri, 27 May 2022 08:32:01 +0000 (10:32 +0200)
regress/tests/snapshot-btrfs-test

index 9af2e38dc1a26bd8b1d9a25bebd7756eb2106310..5f9004104d0001c56f3d7ab842631ee2a8578a70 100755 (executable)
@@ -12,6 +12,8 @@ TestName="snapshot-btrfs-test"
 JobName=Incremental
 . scripts/functions
 
+require_linux
+
 ${rscripts}/cleanup
 ${rscripts}/copy-test-confs
 
@@ -56,6 +58,7 @@ cd $cwd
 make -C $cwd/build/src/tools install-bsnapshot
 
 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Enable Snapshot", "yes", "FileSet")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Snapshot Retention", "300", "Client")'
 
 change_jobname CompressedTest $JobName
 start_test
@@ -72,9 +75,67 @@ wait
 messages
 @output ${tmp}/list1
 list files jobid=1
+@$out ${tmp}/list1.snap_list
+.jlist snapshot
+@$out ${tmp}/list1.snap_listclient
+snapshot listclient
+@$out ${tmp}/list1.snap_update
+snapshot update client snapshotid=1 comment="test1"
+snapshot update client snapshotid=1 retention=3
+@$out ${tmp}/list1.snap_list2
+.jlist snapshot snapshotid=1
+@$out ${tmp}/list1.snap_list22
+.jlist snapshot snapshotid=3
+@$out ${tmp}/list1.snap_prune
+@sleep 4
+snapshot prune client yes
+@$out ${tmp}/list1.snap_list3
+.jlist snapshot
+@$out ${tmp}/list1.snap_listclient2
+snapshot listclient
+quit
 END_OF_DATA
 
 run_bacula
+
+grep '{' $tmp/list1.snap_list | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 1);'
+
+if [ $? != 1 ]; then
+    print_debug "ERROR: Incorrect data in $tmp/list1.snap_list"
+    estat=1
+fi
+
+nb=`grep deleted $tmp/list1.snap_prune | wc -l`
+if [ $nb != 1 ]; then
+    print_debug "ERROR: Should prune one snapshots"
+    estat=1
+fi
+
+# snapshot updated
+grep '{' $tmp/list1.snap_list2 | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 1 && $j->{data}->[0]->{comment} eq "test1" && $j->{data}->[0]->{retention} == 3);'
+
+if [ $? != 1 ]; then
+    print_debug "ERROR: Incorrect data in $tmp/list1.snap_list2"
+    estat=1
+fi
+
+# One snapshot gone
+grep '{' $tmp/list1.snap_list3 | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 0);'
+
+if [ $? != 1 ]; then
+    print_debug "ERROR: Incorrect data in $tmp/list1.snap_list3"
+    estat=1
+fi
+
 check_for_zombie_jobs storage=File
 
 cat <<END_OF_DATA >${tmp}/bconcmds
@@ -136,8 +197,11 @@ $USE_SUDO btrfs subvolume list $cwd/btrfs
 $USE_SUDO chown $USER:$GID $cwd/btrfs/subvol
 cp $cwd/build/README $cwd/btrfs/subvol
 
+sed -i "s/Snapshot Retention/#Snapshot Retention/" $conf/bacula-dir.conf
+
 cat <<END_OF_DATA >${tmp}/bconcmds
 @$out ${tmp}/log3.out
+reload
 setdebug level=20 tags=snapshot fd trace=1
 run level=full job=$JobName yes
 wait
@@ -152,11 +216,26 @@ restore where=${tmp}/bacula-restores4 storage=File select all yes done
 wait
 status client
 messages
+snapshot list
+snapshot listclient
+snapshot
+6
+7
+snapshot list
+sql
+update Snapshot SET Retention=1;
+
+snapshot prune client yes
+snapshot list
+snapshot listclient 
 quit
 END_OF_DATA
 
 run_bconsole
 
+echo pause
+read a
+
 cp $f $working/job3.trace
 
 grep -E "Adding $cwd/btrfs dev=[0-9]+ snap.=1 to the mount list" $working/job3.trace > /dev/null
@@ -189,7 +268,7 @@ if [ $? -ne 0 ]; then
     estat=1
 fi
 
-grep "fname=$cwd/btrfs/subvol/.snapshots/Incremental.*/README stripped=$cwd/btrfs/subvol/README link=$cwd/btrfs/subvol/README" $working/job3.trace > /dev/null
+grep "fname=$cwd/btrfs/subvol/README snap=$cwd/btrfs/subvol/.snapshots/Incremental.*/README link=$cwd/btrfs/subvol/README" $working/job3.trace > /dev/null
 if [ $? -ne 0 ]; then
     print_debug "ERROR: Should path convertion in FD $working/job3.trace trace file"
     estat=1