From: Eric Bollengier Date: Wed, 18 May 2022 11:57:43 +0000 (+0200) Subject: regress: Add command line tests for the snapshot command X-Git-Tag: Release-13.0.0~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=665143015a96d45a23eab7c953083509b6ff3bc7;p=thirdparty%2Fbacula.git regress: Add command line tests for the snapshot command --- diff --git a/regress/tests/snapshot-lvm-test b/regress/tests/snapshot-lvm-test index b6e95957e..3339d9794 100755 --- a/regress/tests/snapshot-lvm-test +++ b/regress/tests/snapshot-lvm-test @@ -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 <${tmp}/bconcmds