]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add command line tests for the snapshot command
authorEric Bollengier <eric@baculasystems.com>
Wed, 18 May 2022 11:57:43 +0000 (13:57 +0200)
committerEric Bollengier <eric@baculasystems.com>
Fri, 27 May 2022 08:31:49 +0000 (10:31 +0200)
regress/tests/snapshot-lvm-test

index b6e95957e7097ea1158fc58ec38425ac77071cf6..3339d9794a364f5f6b122e60ba7de7b638addc35 100755 (executable)
@@ -5,7 +5,7 @@
 #
 # create LVM volume and play with snapshots
 #
-set -x
+
 TestName="snapshot-lvm-test"
 JobName=Incremental
 . scripts/functions
@@ -90,6 +90,7 @@ $USE_SUDO lvdisplay
 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
@@ -104,11 +105,74 @@ run job=$JobName yes
 status client
 wait
 messages
+list
 @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
+# Can be used to issue commands from an other terminal
+#echo pause
+#read a
+
+grep '{' $tmp/list1.snap_list | perl -MJSON -e '
+$l = <>;
+$j = JSON::decode_json($l) ;
+exit (scalar(@{$j->{data}}) == 2);'
+
+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}}) == 1);'
+
+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