From: Eric Bollengier Date: Thu, 17 Mar 2022 18:01:33 +0000 (+0100) Subject: regress: Add tests for the new alljobs option of the list metadata command X-Git-Tag: Beta-15.0.0~618 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4781a1d0240984972dc64d3a512dcb087e2274b0;p=thirdparty%2Fbacula.git regress: Add tests for the new alljobs option of the list metadata command --- diff --git a/regress/tests/metadata-test b/regress/tests/metadata-test index 05df3f34e..6a36897a3 100755 --- a/regress/tests/metadata-test +++ b/regress/tests/metadata-test @@ -125,15 +125,19 @@ run job=NightlySave fileset=TestPluginSet2 pool=Default storage=File1 yes wait messages @$out $tmp/log.23.out -.jlist metadata type=email owner=xxxx tenant=xxxx +.jlist metadata type=email owner=xxxx tenant=xxxx alljobs @$out $tmp/log.24.out -.jlist metadata type=attachment tenant=xxxx owner=xxxx contenttype=application/octet-stream +.jlist metadata type=attachment tenant=xxxx owner=xxxx contenttype=application/octet-stream alljobs @$out $tmp/log.25.out -.jlist metadata type=attachment tenant=xxxx owner=xxxx contenttype=application/jpg +.jlist metadata type=attachment tenant=xxxx owner=xxxx contenttype=application/jpg alljobs @$out $tmp/log.26.out -.jlist metadata type=attachment tenant=xxxx owner=xxxx isinline=0 +.jlist metadata type=attachment tenant=xxxx owner=xxxx isinline=0 alljobs @$out $tmp/log.27.out .jlist metadata type=attachment tenant=xxxx owner=xxxx isinline=1 +@$out $tmp/log_console.28.out +.jlist metadata type=email owner=xxxx tenant=xxxx +@$out $tmp/log_console.29.out +.jlist metadata type=email owner=xxxx tenant=xxxx alljobs quit END_OF_DATA @@ -177,6 +181,10 @@ setdebug level=50 tags=sql dir .jlist metadata type=email tenant=xxxx @$out $tmp/log_restricted.22.out .jlist metadata type=email tenant=xxxx owner=x% +@$out $tmp/log_restricted.28.out +.jlist metadata type=email owner=xxxx tenant=xxxx +@$out $tmp/log_restricted.29.out +.jlist metadata type=email owner=xxxx tenant=xxxx alljobs setdebug level=0 tags= dir quit END_OF_DATA @@ -192,6 +200,14 @@ if [ $nb != 2 ]; then estat=1 fi + +# We use the PERL JSON module to check the output of the .jlist command +# The json data is stored in $j object +# the data array reference is stored in $j->{data} +# a member of the array can be accessed via $j->{data}->[0]->{member} +# the data array itself can be accessed by @{ $j->{data} } +# the size of the array is available via scalar( @{ $j->{data} } ) + for mode in console restricted do # Should find 1 mails with both words @@ -420,8 +436,43 @@ exit (scalar(@{$j->{data}}) == 1);' print_debug "ERROR: Incorrect data in $tmp/log_$mode.22.out" estat=1 fi + + # Should find 2 emails (unique, only the last occurrence) + grep '\[' $tmp/log_$mode.28.out | perl -MJSON -e ' +$l = <>; +$j = JSON::decode_json($l) ; +exit (scalar(@{$j->{data}}) == 2);' + + if [ $? != 1 ]; then + print_debug "ERROR: Incorrect data in $tmp/log_$mode.28.out" + estat=1 + fi done +# Should find 4 emails (all versions) +grep '\[' $tmp/log_console.29.out | perl -MJSON -e ' +$l = <>; +$j = JSON::decode_json($l) ; +exit (scalar(@{$j->{data}}) == 4);' + +if [ $? != 1 ]; then + print_debug "ERROR: Incorrect data in $tmp/log_console.29.out" + estat=1 +fi + +# Should find 2 emails (all versions, but with ACL applied) +grep '\[' $tmp/log_restricted.29.out | perl -MJSON -e ' +$l = <>; +$j = JSON::decode_json($l) ; +exit (scalar(@{$j->{data}}) == 2);' + +if [ $? != 1 ]; then + print_debug "ERROR: Incorrect data in $tmp/log_restricted.29.out" + estat=1 +fi + + + # Should find 4 email, owner/tenant filter. Same query for both grep '\[' $tmp/log.23.out | perl -MJSON -e ' $l = <>;