1#!/usr/bin/env bash 2# 3# Copyright (C) 2019-2021 Red Hat, Inc. 4# This file is part of elfutils. 5# 6# This file is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# elfutils is distributed in the hope that it will be useful, but 12# WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19. $srcdir/debuginfod-subr.sh 20 21# for test case debugging, uncomment: 22set -x 23 24mkdir Z 25# This variable is essential and ensures no time-race for claiming ports occurs 26# set base to a unique multiple of 100 not used in any other 'run-debuginfod-*' test 27base=11000 28get_ports 29 30DB=${PWD}/.debuginfod.sqlite 31tempfiles $DB 32export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache 33 34cp -rvp ${abs_srcdir}/debuginfod-tars Z 35tempfiles Z 36 37env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -d $DB -Z .tar.xz -Z .tar.bz2=bzcat -p $PORT1 -t0 -g0 -v Z > vlog$PORT1 2>&1 & 38PID1=$! 39tempfiles vlog$PORT1 40errfiles vlog$PORT1 41 42wait_ready $PORT1 'ready' 1 43 44# Start second passive server with same database 45env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE --passive -d $DB -Z .tar.xz -Z .tar.bz2=bzcat -p $PORT2 -v > vlog$PORT2 2>&1 & 46PID2=$! 47 48tempfiles vlog$PORT2 49errfiles vlog$PORT2 50 51wait_ready $PORT2 'ready' 1 52 53# Wait for first server to finish indexing 54wait_ready $PORT1 'thread_work_total{role="traverse"}' 1 55wait_ready $PORT1 'thread_work_pending{role="scan"}' 0 56wait_ready $PORT1 'thread_busy{role="scan"}' 0 57 58# No similar metrics for the passive server 59! (curl http://localhost:$PORT2/metrics | grep -E 'role="scan"|role="groom"|role="traverse"') 60 61# Confirm no active threads 62! (ps -q $PID2 -e -L -o '%p %c %a' | grep -E 'scan|groom|traverse') 63 64# Do a random lookup via passive server 65env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS=http://localhost:$PORT2 ${abs_builddir}/../debuginfod/debuginfod-find debuginfo cee13b2ea505a7f37bd20d271c6bc7e5f8d2dfcb 66 67tempfiles $DB* 68 69kill $PID1 70wait $PID1 71PID1=0 72 73kill $PID2 74wait $PID2 75PID2=0 76 77exit 0 78