]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Test new APIv2 json output with status commands
authorEric Bollengier <eric@baculasystems.com>
Mon, 4 Oct 2021 16:58:20 +0000 (18:58 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 07:49:01 +0000 (09:49 +0200)
regress/scripts/functions
regress/tests/bconsole-test
regress/tests/show-acl-test

index c1d1b88ff26ea1f0868d0f20bedc99c0a1bd9c03..6e16427ff26c2fceefa65f58b6a3b7805a390b5b 100755 (executable)
@@ -617,6 +617,47 @@ stop_bacula()
    if [ x$FORCE_DOT_STATUS = xyes ]; then
       rm -f $tmp/check_dot_status.ctrl
    fi
+   if [ "$CHECK_API2_JSON" != 0 ]; then
+      rm -f $tmp/json.$$.out $tmp/json.$$.list $tmp/1.json
+      cat << EOF > $tmp/json.$$
+@output /dev/null
+message
+@output $tmp/json.$$.out
+gui on
+.api 2 api_opts=j
+.status dir header
+.status dir running
+.status dir terminated
+.status storage header
+.status storage running
+.status storage terminated
+.status client header
+.status client running
+.status client terminated
+quit
+EOF
+      local nb=0
+      cat  $tmp/json.$$ | $bin/bconsole -c $conf/bconsole.conf -u 1 2>&1 > /dev/null
+      grep '{' $tmp/json.$$.out > $tmp/json.$$.list
+      while read line
+      do
+          cat <<EOF > $tmp/1.json
+$line
+EOF
+          $bperl -e 'check_json("$tmp/1.json")'
+          if [ $? -ne 0 ]; then
+             echo "ERROR: Unable to validate json output in $tmp/1.json";
+             cat $tmp/1.json
+             exit 1
+          else
+              nb=`expr $nb + 1`
+          fi
+      done < $tmp/json.$$.list
+      if [ $nb = 0 ]; then
+          echo "ERROR: Unable to find json output in $tmp/json.$$.out"
+          exit 1
+      fi
+   fi
    if [ "$CHECK_OPENFILE" != 0 ]; then
       rm -f $tmp/stop.$$.out
       cat << EOF > $tmp/stop.$$
index 9e305830321e1fdb1f97790249d21e42e86c8240..9c106972412d8e48c7e1764b837e89d180e6d096 100755 (executable)
@@ -9,6 +9,9 @@ TestName="bconsole-test"
 JobName=backup
 . scripts/functions
 
+# Disable automatic APIv2 JSON test
+CHECK_API2_JSON=0
+
 scripts/cleanup
 scripts/copy-test-confs
 
index 62fdbfde0c46aebc7a64f45168d9d54ebbfea39f..a21e7aef7ea07813992201d1916fc23f096abb78 100755 (executable)
@@ -9,6 +9,9 @@ TestName="show-acl-test"
 JobName=backup
 . scripts/functions
 
+# Disable automatic APIv2 JSON test
+CHECK_API2_JSON=0
+
 scripts/cleanup
 scripts/copy-test-confs
 
@@ -109,7 +112,7 @@ if [ $? != 0 ]; then
 fi
 
 grep name=$job3 $tmp/log1.out > /dev/null
-if [ $? == 0 ]; then
+if [ $? = 0 ]; then
     print_debug "ERROR: should NOT find job definition for $job3 in $tmp/log1.out"
     estat=3
 fi