]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
metaplugin: Update regression test for restore with core.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Mon, 12 Apr 2021 16:43:58 +0000 (18:43 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:01 +0000 (09:03 +0100)
bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c
regress/scripts/metaplugin-protocol-tests.sh

index 9cd98d5b83b2b4bf84071a3251a350d01e1477b6..ff683e7195b3438ed63adf3a2abdb7585420188e 100644 (file)
@@ -258,6 +258,7 @@ void perform_backup()
    }
 
    // next file
+   // this file we will restore using Bacula Core functionality, so it is crucial
    write_plugin('I', "TEST6");
    snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/etc/issue\n", PLUGINPREFIX, mypid);
    write_plugin('C', buf);
@@ -694,6 +695,8 @@ void perform_restore(){
    int len;
    int fsize;
    bool loopgo = true;
+   bool restore_skip_create = false;
+   bool restore_with_core = false;
 
    if (regress_error_restore_stderr) {
       // test some stderror handling
@@ -729,16 +732,29 @@ void perform_restore(){
       }
       /* check if FNAME then follow file parameters */
       if (strncmp(buf, "FNAME:", 6) == 0) {
+         restore_with_core = strstr(buf, "/_restore_with_core/") != NULL && strstr(buf, "/etc/issue") != NULL;
+         restore_skip_create = strstr(buf, "/_restore_skip_create/") != NULL;
+
          /* we read here a file parameters */
          while (read_plugin(buf) > 0);
-         /* signal OK */
-#if 1
+
+         if (restore_skip_create){
+            // simple skipall
+            write_plugin('I', "TEST5R - create file skipped.");
+            write_plugin('C', "SKIP\n");
+            continue;
+         }
+
+         if (restore_with_core){
+            // signal Core
+            write_plugin('I', "TEST5R - handle file with Core.");
+            write_plugin('C', "CORE\n");
+            continue;
+         }
+
+         // signal OK
          write_plugin('I', "TEST5R - create file ok.");
          write_plugin('C', "OK\n");
-#else
-         write_plugin('I', "TEST5R - create file skipped.");
-         write_plugin('C', "SKIP\n");
-#endif
          continue;
       }
 
@@ -747,6 +763,8 @@ void perform_restore(){
          // handle metadata
          read_plugin_data_stream();
          /* signal OK */
+         LOG("#> METADATA_STREAM data saved.");
+         write_plugin('I', "TEST5R - metadata saved.");
          write_plugin('C', "OK\n");
          continue;
       }
index 0bb9390523139a1da08a419d7cbdd2e6a476d519..9876f408872a9156ac010536c3346ad096603f8a 100755 (executable)
@@ -198,6 +198,46 @@ END_OF_DATA
 
 run_bconsole
 
+# restore with skip all files
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@#
+@# Restore
+@#
+@output /dev/null
+messages
+@$out ${cwd}/tmp/rlog3.out
+setdebug level=500 client=$CLIENT trace=1
+restore fileset=$FilesetBackup5 where=${cwd}/tmp/_restore_skip_create/ select all storage=File done
+yes
+wait
+messages
+llist job=RestoreFiles
+@output
+quit
+END_OF_DATA
+
+run_bconsole
+
+# restore with core
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@#
+@# Restore
+@#
+@output /dev/null
+messages
+@$out ${cwd}/tmp/rlog4.out
+setdebug level=500 client=$CLIENT trace=1
+restore fileset=$FilesetBackup5 where=${cwd}/tmp/_restore_with_core/ select all storage=File done
+yes
+wait
+messages
+llist job=RestoreFiles
+@output
+quit
+END_OF_DATA
+
+run_bconsole
+
 # and finally test listing mode
 TEST=1
 for ppath in / containers containers/bucket1 containers/bucket2
@@ -317,7 +357,25 @@ REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog2.out)
 if [ "x$RET" != "xT" ] || [ "$REND" -ne 1 ]
 then
    echo "rlog2" "$RET" "$REND"
-   rstat=1
+   rstat=2
+fi
+
+RET=$(grep "jobstatus:" ${cwd}/tmp/rlog3.out | tail -1 | awk '{print $2}')
+REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog3.out)
+if [ "x$RET" != "xT" ] || [ "$REND" -ne 1 ]
+then
+   echo "rlog3" "$RET" "$REND"
+   rstat=3
+fi
+
+RET=$(grep "jobstatus:" ${cwd}/tmp/rlog4.out | tail -1 | awk '{print $2}')
+REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog4.out)
+diff ${cwd}/tmp/_restore_with_core/*/bucket/*/etc/issue /etc/issue > /dev/null 2>&1
+RDIFF=$?
+if [ "x$RET" != "xT" ] || [ "$REND" -ne 1 ] || [ $RDIFF -ne 0 ]
+then
+   echo "rlog4" "$RET" "$REND"
+   rstat=4
 fi
 
 end_test