From: Radosław Korzeniewski Date: Thu, 10 Jun 2021 15:34:55 +0000 (+0200) Subject: metaplugin: Add Error message tests to protocol. X-Git-Tag: Release-11.3.2~497 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3a17cca04595e3b4eb0b36492d1ac676c3bb47e;p=thirdparty%2Fbacula.git metaplugin: Add Error message tests to protocol. --- diff --git a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp index b043f9d7f..ccc8be8d4 100644 --- a/bacula/src/plugins/fd/pluginlib/metaplugin.cpp +++ b/bacula/src/plugins/fd/pluginlib/metaplugin.cpp @@ -2018,7 +2018,8 @@ bRC METAPLUGIN::startBackupFile(bpContext *ctx, struct save_pkt *sp) metadatas.reset(); metadatas_list.destroy(); - while (backend.ctx->read_command(ctx, cmd) > 0){ + while (backend.ctx->read_command(ctx, cmd) > 0) + { DMSG(ctx, DINFO, "read_command(2): %s\n", cmd.c_str()); // int nrscan = sscanf(cmd.c_str(), "STAT:%c %ld %d %d %o %d", &type, &size, &uid, &gid, &perms, &nlinks); nfi = -1; diff --git a/bacula/src/plugins/fd/pluginlib/ptcomm.cpp b/bacula/src/plugins/fd/pluginlib/ptcomm.cpp index f8bfb1ec7..3723236e0 100644 --- a/bacula/src/plugins/fd/pluginlib/ptcomm.cpp +++ b/bacula/src/plugins/fd/pluginlib/ptcomm.cpp @@ -384,6 +384,48 @@ int32_t PTCOMM::recvbackend_header(bpContext *ctx, char cmd) JMSG(ctx, M_INFO, "%s", errmsg.c_str()); continue; + case 'S': + // handle saved message + DMSG(ctx, DDEBUG, "%s", errmsg.c_str()); + JMSG(ctx, M_SAVED, "%s", errmsg.c_str()); + continue; + + case 'N': + // handle not-saved message + DMSG(ctx, DDEBUG, "%s", errmsg.c_str()); + JMSG(ctx, M_NOTSAVED, "%s", errmsg.c_str()); + continue; + + case 'R': + // handle restored message + DMSG(ctx, DINFO, "%s", errmsg.c_str()); + JMSG(ctx, M_RESTORED, "%s", errmsg.c_str()); + continue; + + case 'P': + // handle skipped message + DMSG(ctx, DINFO, "%s", errmsg.c_str()); + JMSG(ctx, M_SKIPPED, "%s", errmsg.c_str()); + continue; + + case 'O': + // handle operator message (now it is only M_MOUNT) + DMSG(ctx, DINFO, "%s", errmsg.c_str()); + JMSG(ctx, M_MOUNT, "%s", errmsg.c_str()); + continue; + + case 'V': + // handle event message + DMSG(ctx, DINFO, "%s", errmsg.c_str()); + JMSG(ctx, M_EVENTS, "%s", errmsg.c_str()); + continue; + + case 'Q': + // handle event message + DMSG(ctx, DERROR, "%s", errmsg.c_str()); + JMSG(ctx, M_ERROR, "%s", errmsg.c_str()); + continue; + default: DMSG1(ctx, DERROR, "Protocol error. Unknown packet: %c\n", header.status); JMSG1(ctx, M_FATAL, "Protocol error. Unknown packet: %c\n", header.status); diff --git a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c index e62e061ab..8894df3d6 100644 --- a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c +++ b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c @@ -391,11 +391,6 @@ void perform_backup() write_plugin('I', "TEST8-Error-Start"); /* here comes a file data contents */ write_plugin('E', "TEST8-Error: Standard IO Error goes Here"); - // write_plugin('C', "DATA\n"); - // write_plugin('D', "/* here comes a file data contents */"); - // write_plugin('D', "/* here comes another file line */"); - // write_plugin('D', "/* here comes another file line */"); - // write_plugin('D', "/* here comes another file line */"); write_plugin('I', "TEST8-Error-End"); // signal_eod(); } @@ -654,6 +649,19 @@ void perform_backup() write_plugin('I', "TEST PluginObject Last - END"); } + write_plugin('I', "M_INFO test message\n"); + write_plugin('W', "M_WARNING test message\n"); + write_plugin('S', "M_SAVED test message\n"); + write_plugin('N', "M_NOTSAVED test message\n"); + write_plugin('R', "M_RESTORED test message\n"); + write_plugin('P', "M_SKIPPED test message\n"); + write_plugin('O', "M_OPER?MOUNT test message\n"); + write_plugin('V', "M_EVENTS test message\n"); + if (regress_standard_error_backup) + { + write_plugin('Q', "M_ERROR test message\n"); + } + /* this is the end of all data */ signal_eod(); } @@ -686,7 +694,6 @@ void perform_estimate(){ write_plugin('C', "STAT:E 0 300 300 0100640 1\n"); write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n"); signal_eod(); - // write_plugin('I', "TEST5B"); snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/vmsnap.iso\n", PLUGINPREFIX, mypid); write_plugin('C', buf); @@ -695,21 +702,18 @@ void perform_estimate(){ snprintf(buf, BIGBUFLEN, "LSTAT:/bucket/%d/vm1.iso\n", mypid); write_plugin('C', buf); signal_eod(); - // write_plugin('I', "TEST5B"); snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/\n", PLUGINPREFIX, mypid); write_plugin('C', buf); write_plugin('C', "STAT:D 1024 100 100 040755 1\n"); write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n"); signal_eod(); - // write_plugin('I', "TEST5 - dir"); snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/\n", PLUGINPREFIX); write_plugin('C', buf); write_plugin('C', "STAT:D 1024 100 100 040755 1\n"); write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n"); signal_eod(); - // write_plugin('I', "TEST5 - another dir"); /* this is the end of all data */ signal_eod(); diff --git a/regress/scripts/kubernetes-plugin-test-bacula-dir.conf.in b/regress/scripts/kubernetes-plugin-test-bacula-dir.conf.in index 357d243b5..e86f23650 100644 --- a/regress/scripts/kubernetes-plugin-test-bacula-dir.conf.in +++ b/regress/scripts/kubernetes-plugin-test-bacula-dir.conf.in @@ -300,7 +300,7 @@ Messages { operatorcommand = "@sbindir@/bsmtp -h localhost -f \"\(Bacula regression\) %r\" -s \"Regression: Intervention needed for %j\" %r" # MailOnError = @job_email@ = all, !terminate # operator = @job_email@ = mount - console = all, !skipped, !terminate + console = all append = "@working_dir@/log" = all, !skipped catalog = all, !skipped diff --git a/regress/scripts/metaplugin-protocol-tests.sh b/regress/scripts/metaplugin-protocol-tests.sh index 6fc8e7e1e..19a9464bd 100755 --- a/regress/scripts/metaplugin-protocol-tests.sh +++ b/regress/scripts/metaplugin-protocol-tests.sh @@ -23,7 +23,7 @@ # . scripts/metaplugin-protocol-tests.sh # -if [ "x$JobBackup1" = "x" ] || [ "x$JobBackup2" = "x" ] || [ "x$JobBackup3" = "x" ] || [ "x$JobBackup4" = "x" ] || [ "x$FilesetBackup1" = "x" ] +if [ "x$JobBackup1" = "x" ] || [ "x$JobBackup2" = "x" ] || [ "x$JobBackup3" = "x" ] || [ "x$JobBackup4" = "x" ] || [ "x$JobBackup5" = "x" ] || [ "x$JobBackup6" = "x" ] || [ "x$FilesetBackup1" = "x" ] then echo "You have to setup required variables!" exit 2 @@ -140,6 +140,27 @@ END_OF_DATA run_bconsole +# now backup standard error information +cat <${cwd}/tmp/bconcmds +@# +@# Backup with error +@# +@output /dev/null +messages +@$out ${cwd}/tmp/log8.out +status client=$CLIENT +setdebug level=500 client=$CLIENT trace=1 +run job=$JobBackup6 yes +wait +status client=$CLIENT +messages +llist job=$JobBackup6 +@output +quit +END_OF_DATA + +run_bconsole + # now test estimate job cat <${cwd}/tmp/bconcmds @@ -378,6 +399,25 @@ then bstat=$((bstat+32)) fi +RET=$(grep "jobstatus:" ${cwd}/tmp/log8.out | awk '{print $2}') +META=$(grep -c "TEST14 - backup metadata" ${cwd}/tmp/log7.out) +BEND=$(grep -w -c "TESTEND" ${cwd}/tmp/log7.out) +if [ "x$RET" != "xT" ] || [ "$META" -ne 1 ] || [ "$BEND" -ne 1 ] +then + echo "log8" "$RET" "$META" "$BEND" + bstat=$((bstat+64)) +fi + +MINFO=$(grep -c M_INFO ${cwd}/tmp/log8.out) +MWARNING=$(grep -c M_WARNING ${cwd}/tmp/log8.out) +MSAVED=$(grep -c M_SAVED ${cwd}/tmp/log8.out) +MNOTSAVED=$(grep -c M_NOTSAVED ${cwd}/tmp/log8.out) +if [ "$MINFO" -ne 1 ] || [ "$MWARNING" -ne 1 ] || [ "$MNOTSAVED" -ne 1 ] +then + echo "log8msg" "$MINFO" "$MWARNING" "$MNOTSAVED" + bstat=$((bstat+128)) +fi + EFILE1=$(grep -c vm1.iso ${cwd}/tmp/log3.out) EFILE2=$(grep -c vm2.iso ${cwd}/tmp/log3.out) EFILE3=$(grep -c lockfile ${cwd}/tmp/log3.out)