]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
metaplugin: Add Error message tests to protocol.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Thu, 10 Jun 2021 15:34:55 +0000 (17:34 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:02 +0000 (09:03 +0100)
bacula/src/plugins/fd/pluginlib/metaplugin.cpp
bacula/src/plugins/fd/pluginlib/ptcomm.cpp
bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c
regress/scripts/kubernetes-plugin-test-bacula-dir.conf.in
regress/scripts/metaplugin-protocol-tests.sh

index b043f9d7f47bb0244235f5869ce398e5f65f3082..ccc8be8d4785d0414a0f3f4f982612cedf6bae70 100644 (file)
@@ -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;
index f8bfb1ec749d896ca82d949dca8fec424ba8d492..3723236e04e0c9f0e0966ae0bbc940d5a1ba9404 100644 (file)
@@ -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);
index e62e061ab717647bd12cf243f813ace9b3f2236c..8894df3d62cab74f7cf941763f37ff7cbaf69a67 100644 (file)
@@ -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();
index 357d243b5d2c986f164003797c9657f896f21af9..e86f2365055fdd83686fb3d2f62b33fc10fec195 100644 (file)
@@ -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
index 6fc8e7e1e642a8a6546e92dba7c35e1e2ff2b3b1..19a9464bdea278d0083de117ec763c1d5b3d5162 100755 (executable)
@@ -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 <<END_OF_DATA >${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 <<END_OF_DATA >${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)