From: Eric Bollengier Date: Mon, 4 Oct 2021 16:58:20 +0000 (+0200) Subject: regress: Test new APIv2 json output with status commands X-Git-Tag: Beta-15.0.0~863 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eda3a0aebbfaf83092f4531638130793c7fb8f63;p=thirdparty%2Fbacula.git regress: Test new APIv2 json output with status commands --- diff --git a/regress/scripts/functions b/regress/scripts/functions index c1d1b88ff..6e16427ff 100755 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -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 < $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.$$ diff --git a/regress/tests/bconsole-test b/regress/tests/bconsole-test index 9e3058303..9c1069724 100755 --- a/regress/tests/bconsole-test +++ b/regress/tests/bconsole-test @@ -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 diff --git a/regress/tests/show-acl-test b/regress/tests/show-acl-test index 62fdbfde0..a21e7aef7 100755 --- a/regress/tests/show-acl-test +++ b/regress/tests/show-acl-test @@ -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