]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add tests for the new alljobs option of the list metadata command
authorEric Bollengier <eric@baculasystems.com>
Thu, 17 Mar 2022 18:01:33 +0000 (19:01 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
regress/tests/metadata-test

index 05df3f34eedaf8ac6c38d2bfeed8a076d1ab8cd2..6a36897a32618149217c5b5bf36cb5c8b1232c7f 100755 (executable)
@@ -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 = <>;