From: Radosław Korzeniewski Date: Tue, 20 Jul 2021 14:15:43 +0000 (+0200) Subject: metaplugin: Update regression to check large RestoreObject. X-Git-Tag: Release-11.3.2~374 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90656588c4472a6b7620aa8507c1571b9cbee974;p=thirdparty%2Fbacula.git metaplugin: Update regression to check large RestoreObject. --- diff --git a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c index 65a532b42..9fd4b2402 100644 --- a/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c +++ b/bacula/src/plugins/fd/pluginlib/test_metaplugin_backend.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifndef LOGDIR @@ -74,7 +75,7 @@ bool regress_cancel_restore = false; #define BUFLEN 4096 -#define BIGBUFLEN 65536 +#define BIGBUFLEN 131072 /** * @brief saves the log text to logfile @@ -110,9 +111,9 @@ void LOG(const char *txt) */ int read_plugin(char * buf) { - int len; - int nread; - int size; + size_t len; + size_t nread; + size_t size; char header[8]; len = read(STDIN_FILENO, &header, 8); @@ -130,26 +131,36 @@ int read_plugin(char * buf) close(logfd); exit(EXIT_SUCCESS); } - size = atoi(header+1); - if (size > BIGBUFLEN){ - LOG("#> Err: message too long"); - close(logfd); - exit(EXIT_BACKEND_MESSAGE_TOOLONG); - } + size = atoi(header + 1); if (header[0] == 'C'){ + if (size > BIGBUFLEN){ + LOG("#> Err: message too long"); + close(logfd); + exit(EXIT_BACKEND_MESSAGE_TOOLONG); + } len = read(STDIN_FILENO, buf, size); buf[len] = 0; snprintf(buflog, BUFLEN, "> %s", buf); LOG(buflog); } else { - snprintf(buflog, BUFLEN, "> Data:%i", size); + snprintf(buflog, BUFLEN, "> Data:%lu", size); LOG(buflog); len = 0; - while (len < size){ - nread = read(STDIN_FILENO, buf, size - len); + while (len < size) { + int nbytes; + ioctl(STDIN_FILENO, FIONREAD, &nbytes); + snprintf(buflog, BUFLEN, ">> FIONREAD:%i", nbytes); + LOG(buflog); + if (nbytes < size){ + ioctl(STDIN_FILENO, FIONREAD, &nbytes); + snprintf(buflog, BUFLEN, ">> Second FIONREAD:%i", nbytes); + LOG(buflog); + } + size_t bufread = size - len > BIGBUFLEN ? BIGBUFLEN : size - len; + nread = read(STDIN_FILENO, buf, bufread); len += nread; - snprintf(buflog, BUFLEN, "> Dataread:%i", nread); + snprintf(buflog, BUFLEN, ">> Dataread:%lu", nread); LOG(buflog); } } @@ -740,6 +751,19 @@ void perform_backup() write_plugin('D', r_data); signal_eod(); + // long restore object + snprintf(buf, BIGBUFLEN, "RESTOREOBJ:LongObject%d\n", mypid); + write_plugin('C', buf); + const size_t longobject_num = 6; + snprintf(buf, BIGBUFLEN, "RESTOREOBJ_LEN:%lu\n", BIGBUFLEN * longobject_num); + write_plugin('C', buf); + memset(buf, 'A', BIGBUFLEN); + for (size_t a = 0; a < longobject_num; a++) + { + write_plugin_bin((unsigned char*)buf, BIGBUFLEN); + } + signal_eod(); + // next file snprintf(buf, BIGBUFLEN, "FNAME:%s/bucket/%d/vm222-other-file.iso\n", PLUGINPREFIX, mypid); write_plugin('C', buf); @@ -1434,6 +1458,10 @@ int main(int argc, char** argv) { } //sleep(30); + int pipesize = fcntl(STDIN_FILENO, F_GETPIPE_SZ); + snprintf(buflog, BUFLEN, "#> F_GETPIPE_SZ:%i", pipesize); + LOG(buflog); + /* handshake (1) */ len = read_plugin(buf); #if 1 diff --git a/regress/scripts/metaplugin-protocol-tests.sh b/regress/scripts/metaplugin-protocol-tests.sh index 30f775d03..ecaa4b8c5 100755 --- a/regress/scripts/metaplugin-protocol-tests.sh +++ b/regress/scripts/metaplugin-protocol-tests.sh @@ -560,7 +560,7 @@ fi RET=$(grep "jobstatus:" ${cwd}/tmp/rlog6.out | tail -1 | awk '{print $2}') REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog6.out) RRO=$(grep -c "TEST6R" ${cwd}/tmp/rlog6.out) -if [ "x$RET" != "xT" ] || [ "$REND" -ne 2 ] || [ "$RRO" -ne 2 ] +if [ "x$RET" != "xT" ] || [ "$REND" -ne 2 ] || [ "$RRO" -ne 3 ] then echo "rlog6" "$RET" "$REND" "$RRO" rstat=6