tests: Restructure run-debuginfod-response-headers.sh

Message ID 20231119141128.2584112-1-mark@klomp.org
State Committed
Headers
Series tests: Restructure run-debuginfod-response-headers.sh |

Commit Message

Mark Wielaard Nov. 19, 2023, 2:11 p.m. UTC
  run-debuginfod-response-headers.sh does occassionally fail because
it might scan an rpm more than once. Try to fix this by making sure
all files that debuginfod is supposed to scan are ready before the
server starts. And to explicitly wait till the first scan is ready
and done before testing 'scanned_files_total{source=".rpm archive"}'
instead of sending an kill -USR1.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tests/run-debuginfod-response-headers.sh | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
  

Comments

Mark Wielaard Nov. 19, 2023, 4 p.m. UTC | #1
Hi,

On Sun, Nov 19, 2023 at 03:11:28PM +0100, Mark Wielaard wrote:
> run-debuginfod-response-headers.sh does occassionally fail because
> it might scan an rpm more than once. Try to fix this by making sure
> all files that debuginfod is supposed to scan are ready before the
> server starts. And to explicitly wait till the first scan is ready
> and done before testing 'scanned_files_total{source=".rpm archive"}'
> instead of sending an kill -USR1.

The try builds look good and on irc Frank said the code looks good.
Pushed. Lets hope this gets rid of the flakyiness of the testcase.

Cheers,

Mark

> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
>  tests/run-debuginfod-response-headers.sh | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/tests/run-debuginfod-response-headers.sh b/tests/run-debuginfod-response-headers.sh
> index fbb6a484..ea516ced 100755
> --- a/tests/run-debuginfod-response-headers.sh
> +++ b/tests/run-debuginfod-response-headers.sh
> @@ -32,14 +32,6 @@ export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
>  base=9500
>  get_ports
>  mkdir F R
> -env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 -v R F > vlog$PORT1 2>&1 &
> -PID1=$!
> -tempfiles vlog$PORT1
> -errfiles vlog$PORT1
> -# Server must become ready
> -wait_ready $PORT1 'ready' 1
> -export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/   # or without trailing /
> -########################################################################
>  
>  # Compile a simple program, strip its debuginfo and save the build-id.
>  # Also move the debuginfo into another directory so that elfutils
> @@ -57,12 +49,25 @@ if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
>      rm -vrf R/debuginfod-rpms/fedora31
>  fi
>  
> -kill -USR1 $PID1
> +env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 -v R F > vlog$PORT1 2>&1 &
> +PID1=$!
> +tempfiles vlog$PORT1
> +errfiles vlog$PORT1
> +# Server must become ready
> +wait_ready $PORT1 'ready' 1
> +export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/   # or without trailing /
> +########################################################################
> +
>  # Wait till both files are in the index and scan/index fully finished
> +wait_ready $PORT1 'ready' 1
>  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
> +
>  # All rpms need to be in the index, except the dummy permission-000 one
>  rpms=$(find R -name \*rpm | grep -v nothing | wc -l)
>  wait_ready $PORT1 'scanned_files_total{source=".rpm archive"}' $rpms
> +
>  kill -USR1 $PID1  # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
>  # Wait till both files are in the index and scan/index fully finished
>  wait_ready $PORT1 'thread_work_total{role="traverse"}' 2
> -- 
> 2.39.3
>
  

Patch

diff --git a/tests/run-debuginfod-response-headers.sh b/tests/run-debuginfod-response-headers.sh
index fbb6a484..ea516ced 100755
--- a/tests/run-debuginfod-response-headers.sh
+++ b/tests/run-debuginfod-response-headers.sh
@@ -32,14 +32,6 @@  export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
 base=9500
 get_ports
 mkdir F R
-env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 -v R F > vlog$PORT1 2>&1 &
-PID1=$!
-tempfiles vlog$PORT1
-errfiles vlog$PORT1
-# Server must become ready
-wait_ready $PORT1 'ready' 1
-export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/   # or without trailing /
-########################################################################
 
 # Compile a simple program, strip its debuginfo and save the build-id.
 # Also move the debuginfo into another directory so that elfutils
@@ -57,12 +49,25 @@  if [ "$zstd" = "false" ]; then  # nuke the zstd fedora 31 ones
     rm -vrf R/debuginfod-rpms/fedora31
 fi
 
-kill -USR1 $PID1
+env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 -v R F > vlog$PORT1 2>&1 &
+PID1=$!
+tempfiles vlog$PORT1
+errfiles vlog$PORT1
+# Server must become ready
+wait_ready $PORT1 'ready' 1
+export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/   # or without trailing /
+########################################################################
+
 # Wait till both files are in the index and scan/index fully finished
+wait_ready $PORT1 'ready' 1
 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
+
 # All rpms need to be in the index, except the dummy permission-000 one
 rpms=$(find R -name \*rpm | grep -v nothing | wc -l)
 wait_ready $PORT1 'scanned_files_total{source=".rpm archive"}' $rpms
+
 kill -USR1 $PID1  # two hits of SIGUSR1 may be needed to resolve .debug->dwz->srefs
 # Wait till both files are in the index and scan/index fully finished
 wait_ready $PORT1 'thread_work_total{role="traverse"}' 2