Whamcloud - gitweb
LU-15740 tests: add more stats to runtests 65/47065/3
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 13 Apr 2022 20:18:32 +0000 (14:18 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 5 May 2022 18:45:10 +0000 (18:45 +0000)
Print out the space usage at the start, middle, and end of
runtests, so that it is easier to see where the space is
going, and how much is used at peak consumption.  The goal
of the test is to avoid space leakage in object create and
destroy, but it is OK if there is some usage for internal
files like llogs, quotas, etc.

Move the "mkdirmany" call to the first phase, add a statmany
to the middle phase, and "rmdirmany" to the end so that it
is also checking the directory validity after a remount.

Update createmany and statmany to be a bit easier to use.

Test-Parameters: trivial testlist=runtests env=SLOW=yes mdscount=2 mdtcount=4
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Iec8cb56501c7e75b620951a2d669b0dd6bb0a36f
Reviewed-on: https://review.whamcloud.com/47065
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: cliff white <cwhite@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/createmany.c
lustre/tests/runtests
lustre/tests/statmany.c

index b891102..732ae48 100644 (file)
@@ -82,6 +82,7 @@ int main(int argc, char ** argv)
 {
        bool do_open = false, do_keep = false, do_link = false;
        bool do_unlink = false, do_mknod = false, do_mkdir = false;
+       bool do_rmdir = false;
        char *filename, *progname;
        char *fmt = NULL, *fmt_unlink = NULL, *tgt = NULL;
        char *endp = NULL;
@@ -147,6 +148,8 @@ int main(int argc, char ** argv)
                fprintf(stderr, "error: only one of -o, -m, -l, -d\n");
                usage(progname);
        }
+       if (do_mkdir && do_unlink)
+               do_rmdir = true;
 
        if (!do_open && do_keep) {
                fprintf(stderr, "error: can only use -k with -o\n");
@@ -216,7 +219,12 @@ int main(int argc, char ** argv)
                                filename = get_file_name(fmt_unlink, begin,
                                                         unlink_has_fmt_spec);
 
-                       rc = do_mkdir ? rmdir(filename) : unlink(filename);
+                       rc = do_rmdir ? rmdir(filename) : unlink(filename);
+                       /* use rmdir if this is a directory */
+                       if (!do_rmdir && rc && errno == EISDIR) {
+                               do_rmdir = true;
+                               rc = rmdir(filename);
+                       }
                        if (rc) {
                                printf("unlink(%s) error: %s\n",
                                       filename, strerror(errno));
index 71d152b..8c9d7ab 100755 (executable)
@@ -12,6 +12,7 @@ RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
 [ "$SLOW" = "no" ] && COUNT=1000
 
 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
+[ "$STATMANY" ] || STATMANY="statmany -s"
 [ "$RMDIRMANY" ] || RMDIRMANY="unlinkmany -d"
 
 check_and_setup_lustre
@@ -19,6 +20,10 @@ check_and_setup_lustre
 test_1() {
        sleep 5 # let MDS refresh aggregated statfs
        # Include some extra space for the status file
+
+       echo "usage before starting test"
+       $LFS df
+       $LFS df -i
        local dfused=$(df -P $DIR | awk '{ print $3 }' | tail -n 1)
        local truncsize=123
 
@@ -84,6 +89,9 @@ test_1() {
        done
        [ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" )
 
+       # mkdirmany test (bug 589)
+       log "running $MKDIRMANY $dst/d $COUNT"
+       $MKDIRMANY $dst/d $COUNT || error "$MKDIRMANY failed"
        log "finished at $(date) ($(($(date +%s) - stime)))"
 
        stopall || error "stopall failed"
@@ -95,9 +103,18 @@ test_1() {
        done
        [ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" )
 
+       log "running $STATMANY $dst/d $COUNT $((COUNT * 2))"
+       $STATMANY $dst/d $COUNT $((COUNT * 2)) ||
+               error "$STATMANY $dst/d failed"
+       echo "usage after creating all files"
+       $LFS df
+       $LFS df -i
        stopall || error "stopall failed (2)"
        setupall || error "setupall failed (2)"
 
+       log "running $RMDIRMANY $dst/d $COUNT"
+       $RMDIRMANY $dst/d $COUNT || error "$RMDIRMANY cleanup failed"
+
        log "removing $dst"
        rm -r $dst || error "can't remove $dst"
 
@@ -115,17 +132,13 @@ test_1() {
                rm $hfile.2 || error "can't remove $hfile.2"
        fi
 
-       # mkdirmany test (bug 589)
-       test_mkdir -p $dst
-       log "running $MKDIRMANY $dst/d 100"
-       $MKDIRMANY $dst/d 100 || error "$MKDIRMANY failed"
-       log "running $RMDIRMANY $dst/d 100"
-       $RMDIRMANY $dst/d 100 || error "$RMDIRMANY cleanup failed"
-
        log "done"
 
        wait_delete_completed
        sleep 5 # let MDS refresh aggregated statfs
+       echo "usage after removing all files"
+       $LFS df
+       $LFS df -i
        local nowdfused=$(($(df -P $DIR | awk '{ print $3 }' | tail -n 1)))
        if [ $(expr $nowdfused - $dfused) -gt $(fs_log_size) ]; then
                error "Space not all freed: now ${nowdfused}kB, was ${dfused}kB"
index c7ee5ca..bf58277 100644 (file)
@@ -55,10 +55,13 @@ char *shortopts = "hlr:s0123456789";
 static int usage(char *prog, FILE *out)
 {
        fprintf(out,
-               "Usage: %s [-r rand_seed] {-s|-l} filenamebase total_files iterations\n"
-               "-r : random seed\n"
+               "random stat of files within a directory\n"
+               "usage: %s [-r rand_seed] {-s|-l} filenamebase total_files [iterations]\n"
+               "-r : random seed for repeatable sequence\n"
                "-s : regular stat() calls\n"
-               "-l : lookup ioctl only\n", prog);
+               "-l : llapi_file_lookup() ioctl only\n"
+               "iterations: default = total_files, or negative for seconds\n",
+               prog);
        exit(out == stderr);
 }
 
@@ -68,13 +71,19 @@ static int usage(char *prog, FILE *out)
 
 int main(int argc, char **argv)
 {
-       long i, count, iter = LONG_MAX, mode = 0, offset;
-       long int start, length = LONG_MAX, last;
+       long i, count, iter = 1, mode = 0, offset;
+       long int start, duration = LONG_MAX, last, now;
        char parent[4096], *t;
-       char *prog = argv[0], *base;
+       char *prog, *base;
        int seed = 0, rc;
        int fd = -1;
 
+       prog = strrchr(argv[0], '/');
+       if (prog)
+               prog++;
+       else
+               prog = argv[0];
+
        while ((rc = getopt_long(argc, argv, shortopts, longopts,
                                 NULL)) != -1) {
                char *e;
@@ -91,6 +100,10 @@ int main(int argc, char **argv)
                case 's':
                        mode = rc;
                        break;
+               /* a negative "count" argument (test duration in seconds,
+                * e.g. "-300") is treated as a command-line argument.
+                * Parse all of the digits here back into "duration".
+                */
                case '0':
                case '1':
                case '2':
@@ -101,10 +114,10 @@ int main(int argc, char **argv)
                case '7':
                case '8':
                case '9':
-                       if (length == LONG_MAX)
-                               length = rc - '0';
+                       if (duration == LONG_MAX)
+                               duration = rc - '0';
                        else
-                               length = length * 10 + (rc - '0');
+                               duration = duration * 10 + (rc - '0');
                        break;
                case 'h':
                        usage(prog, stdout);
@@ -113,7 +126,7 @@ int main(int argc, char **argv)
                }
        }
 
-       if (optind + 2 + (length == LONG_MAX) != argc) {
+       if (argc < optind + 2 || argc > optind + 3) {
                fprintf(stderr,
                        "missing filenamebase, total_files, or iterations\n");
                usage(prog, stderr);
@@ -138,11 +151,15 @@ int main(int argc, char **argv)
        srand(seed);
 
        count = strtoul(argv[optind + 1], NULL, 0);
-       if (length == LONG_MAX) {
-               iter = strtoul(argv[optind + 2], NULL, 0);
+       if (duration == LONG_MAX) {
+               if (argc > optind + 2)
+                       iter = strtoul(argv[optind + 2], NULL, 0);
+               else
+                       iter = count;
                printf("running for %lu iterations\n", iter);
        } else {
-               printf("running for %lu seconds\n", length);
+               iter = LONG_MAX;
+               printf("running for %lu seconds\n", duration);
        }
 
        start = time(0);
@@ -166,8 +183,8 @@ int main(int argc, char **argv)
                }
        }
 
-       for (i = 0; i < iter && time(0) - start < length; i++) {
-               char filename[4096];
+       for (i = 0, now = start; i < iter && now - start < duration; i++) {
+               char filename[4096] = "";
                int tmp;
 
                tmp = random() % count;
@@ -195,18 +212,19 @@ int main(int argc, char **argv)
                                break;
                        }
                }
-               if ((i % 10000) == 0) {
+               now = time(0);
+               if ((i > 0 && (i % 10000) == 0) || now - last > 10) {
                        printf(" - stat %lu (time %ld ; total %ld ; last %ld)\n",
-                              i, time(0), time(0) - start, time(0) - last);
-                       last = time(0);
+                              i, now, now - start, now - last);
+                       last = now;
                }
        }
 
        if (mode == 'l')
                close(fd);
 
-       printf("total: %lu stats in %ld seconds: %f stats/second\n", i,
-              time(0) - start, ((float)i / (time(0) - start)));
+       printf("total: %lu stats in %ld seconds: %f stats/second\n",
+              i, now - start, ((float)i / (now - start)));
 
-       exit(rc);
+       return rc;
 }