xref: /aosp_15_r20/external/elfutils/tests/run-debuginfod-webapi-concurrency.sh (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1#!/usr/bin/env bash
2#
3# Copyright (C) 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=12000
28get_ports
29
30export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
31
32cp -rvp ${abs_srcdir}/debuginfod-tars Z
33tempfiles Z
34
35
36for Cnum in "" "-C" "-C10" "-C100"
37do
38    env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE $Cnum -d :memory: -Z .tar.xz -Z .tar.bz2=bzcat -p $PORT1 -t0 -g0 -v --fdcache-fds=0 --fdcache-prefetch-fds=0 Z >> vlog$PORT1 2>&1 &
39    PID1=$!
40    tempfiles vlog$PORT1
41    errfiles vlog$PORT1
42
43    wait_ready $PORT1 'ready' 1
44    # Wait for server to finish indexing
45    wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
46    wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
47    wait_ready $PORT1 'thread_busy{role="scan"}' 0
48
49    # Do a bunch of lookups in parallel
50    lookup_nr=64
51    for jobs in `seq $lookup_nr`; do
52        curl -s http://localhost:$PORT1/buildid/cee13b2ea505a7f37bd20d271c6bc7e5f8d2dfcb/debuginfo > /dev/null &
53    done
54
55    # all curls should succeed
56    wait_ready $PORT1 'http_responses_transfer_bytes_count{code="200",type="debuginfo"}' $lookup_nr
57
58    (sleep 5;
59     curl -s http://localhost:$PORT1/metrics | grep -E 'error|responses';
60     kill $PID1) &
61    wait # for all curls, the ()& from just above, and for debuginfod
62    PID1=0
63done
64
65# Note this xfail comes too late, the above wait_ready for
66# http_responses_transfer_bytes_count will have failed.
67xfail "grep Server.reached.connection vlog$PORT1" # PR28661
68
69exit 0
70