tests: Make sure to wait for initial scan and groom cycle earlier
authorMark Wielaard <mark@klomp.org>
Tue, 7 Sep 2021 21:56:42 +0000 (23:56 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 7 Sep 2021 21:56:42 +0000 (23:56 +0200)
At startup the debuginfod server does a scan and groom cycle. Make
sure to wait for that before making any changes to the scan dirs.  And
not just right before triggering a new one with SIGUSR1 for scan or
SIGURS2 for groom.

Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/run-debuginfod-archive-groom.sh
tests/run-debuginfod-archive-rename.sh
tests/run-debuginfod-artifact-running.sh
tests/run-debuginfod-dlopen.sh
tests/run-debuginfod-extraction.sh
tests/run-debuginfod-federation-link.sh

index 61080c5..42989d1 100644 (file)
@@ -1,3 +1,15 @@
+2021-09-07  Mark Wielaard  <mark@klomp.org>
+
+       * run-debuginfod-archive-groom.sh: Wait for initial scan and groom
+       cycle before making any changes to the scan dirs.
+       * run-debuginfod-archive-rename.sh: Likewise.
+       * run-debuginfod-artifact-running.sh: Wait for initial scan cycle
+       before making any changes to the scan dirs.
+       * run-debuginfod-dlopen.sh: Likewise.
+       * run-debuginfod-extraction.sh: Likewise.
+       * run-debuginfod-federation-link.sh: Don't wait twice for the initial
+       scan.
+
 2021-09-06  Mark Wielaard  <mark@klomp.org>
 
        * run-debuginfod-archive-groom.sh: Wait for initial scan and groom
index 1e7bd67..7813ee2 100755 (executable)
@@ -46,6 +46,13 @@ ps -q $PID1 -e -L -o '%p %c %a' | grep groom
 ps -q $PID1 -e -L -o '%p %c %a' | grep scan
 ps -q $PID1 -e -L -o '%p %c %a' | grep traverse
 
+# wait till the initial scan is done before triggering a new one
+# and before dropping new file into the scan dirs
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+# Same for the initial groom cycle, we don't want it to be done
+# half way initializing the file setup
+wait_ready $PORT1 'thread_work_total{role="groom"}' 1
+
 # Build a non-stripped binary
 echo "int main() { return 0; }" > ${PWD}/F/prog.c
 gcc -Wl,--build-id -g -o ${PWD}/F/prog ${PWD}/F/prog.c
@@ -58,8 +65,6 @@ if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
     rm -vrf R/debuginfod-rpms/fedora31
 fi
 
-# wait till the initial scan is done before triggering a new one
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
 kill -USR1 $PID1
 # Now there should be 1 files in the index
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
@@ -140,7 +145,6 @@ RPM_BUILDID=d44d42cbd7d915bc938c81333a21e355a6022fb7 # in rhel6/ subdir
 # debuginfod has forgotten them, but remembers others
 rm -r R/debuginfod-rpms/rhel6/*
 
-wait_ready $PORT1 'thread_work_total{role="groom"}' 1
 kill -USR2 $PID1  # groom cycle
 ## 1 groom cycle already took place at/soon-after startup, so -USR2 makes 2
 wait_ready $PORT1 'thread_work_total{role="groom"}' 2
index 4fc1b44..5369949 100755 (executable)
@@ -44,13 +44,18 @@ ps -q $PID1 -e -L -o '%p %c %a' | grep groom
 ps -q $PID1 -e -L -o '%p %c %a' | grep scan
 ps -q $PID1 -e -L -o '%p %c %a' | grep traverse
 
+# wait till the initial scan is done before triggering a new one
+# and before dropping new file into the scan dirs
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+# Same for the initial groom cycle, we don't want it to be done
+# half way initializing the file setup
+wait_ready $PORT1 'thread_work_total{role="groom"}' 1
+
 cp -rvp ${abs_srcdir}/debuginfod-rpms R
 if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
     rm -vrf R/debuginfod-rpms/fedora31
 fi
 
-# Make sure the initial scan is done
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
 kill -USR1 $PID1
 # Now there should be 1 files in the index
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
@@ -65,8 +70,6 @@ SHA=f4a1a8062be998ae93b8f1cd744a398c6de6dbb1
 # there are two copies of the same buildid in the index, one for the
 # no-longer-existing file name, and one under the new name.
 
-# Make sure the initial groom cycle has been done
-wait_ready $PORT1 'thread_work_total{role="groom"}' 1
 # run a groom cycle to force server to drop its fdcache
 kill -USR2 $PID1  # groom cycle
 wait_ready $PORT1 'thread_work_total{role="groom"}' 2
index 4eae020..51fa9c0 100755 (executable)
@@ -42,6 +42,13 @@ env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d
 PID1=$!
 tempfiles vlog$PORT1
 errfiles vlog$PORT1
+
+# Server must become ready
+wait_ready $PORT1 'ready' 1
+# And the initial scan should have been done before moving
+# files under the scan dirs.
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+
 mv prog F
 mv prog.debug F
 tempfiles prog/F
@@ -49,11 +56,6 @@ tempfiles prog/F
 # Be patient when run on a busy machine things might take a bit.
 export DEBUGINFOD_TIMEOUT=10
 
-# Server must become ready
-wait_ready $PORT1 'ready' 1
-# And the initial scan should have been done
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
-
 kill -USR1 $PID1
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
 wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
index 5f33394..39ee519 100755 (executable)
@@ -51,6 +51,10 @@ ps -q $PID1 -e -L -o '%p %c %a' | grep groom
 ps -q $PID1 -e -L -o '%p %c %a' | grep scan
 ps -q $PID1 -e -L -o '%p %c %a' | grep traverse
 
+# Make sure the initial scan has finished.
+# Before moving files under the scan dirs.
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+
 # We use -t0 and -g0 here to turn off time-based scanning & grooming.
 # For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process.
 
@@ -71,9 +75,6 @@ BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
 mv p+r%o\$g F
 mv p+r%o\$g.debug F
 
-# Make sure the initial scan has finished.
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
-
 kill -USR1 $PID1
 # Wait till both files are in the index.
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
index 4750f18..06f60e7 100755 (executable)
@@ -47,6 +47,10 @@ ps -q $PID1 -e -L -o '%p %c %a' | grep groom
 ps -q $PID1 -e -L -o '%p %c %a' | grep scan
 ps -q $PID1 -e -L -o '%p %c %a' | grep traverse
 
+# Make sure the initial scan has finished before copying the new files in
+# We might remove some, which we don't want to be accidentially scanned.
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+
 cp -rvp ${abs_srcdir}/debuginfod-rpms R
 if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
     rm -vrf R/debuginfod-rpms/fedora31
@@ -54,8 +58,6 @@ fi
 
 cp -rvp ${abs_srcdir}/debuginfod-tars Z
 
-# Make sure the initial scan has finished
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
 kill -USR1 $PID1
 # Wait till both files are in the index and scan/index fully finished
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
index 1aef717..050bcbc 100755 (executable)
@@ -43,6 +43,7 @@ tempfiles vlog$PORT1
 errfiles vlog$PORT1
 
 wait_ready $PORT1 'ready' 1
+# Make sure initial scan was done
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
 wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
 wait_ready $PORT1 'thread_busy{role="scan"}' 0
@@ -63,8 +64,6 @@ BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
 mv prog F
 mv prog.debug F
 
-# Make sure initial scan was done
-wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
 kill -USR1 $PID1
 # Wait till both files are in the index.
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2