diff options
| author | Ross Burton <ross.burton@arm.com> | 2023-01-10 16:20:37 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-26 23:39:06 +0000 |
| commit | c786012b44e2a0952a10c813731af0ef508170e7 (patch) | |
| tree | 2cd263f115e97620640d2a757cc3dbc62850fc66 /meta/lib | |
| parent | e3d6dfa24d57073047fcd70493f555ec69cb9a3f (diff) | |
| download | poky-c786012b44e2a0952a10c813731af0ef508170e7.tar.gz | |
oeqa/selftest/debuginfod: improve testcase
Primarily, before running the debuginfod-find tool, check that the
debuginfod server has finished sweeping the deploy directory. If we
make the request too soon then there's a rare chance that we run the
client before it has scanned the right packages, and the log gets
swamped with warnings from sqlite due to a race.
Also:
- unset DEBUGINFOD_URLS so the debuginfod doesn't proxy to an upstream
server provided by the host distro
- Lower concurrency to reduce system load and handle systems with lower
maximum open file counts but lots of cores (as the concurrency means
cores*2*2 open files)
- Set the refresh times to 0 so we never rescan during the test
- Only scan the packages for the format which the image is using
- Log the commands that are being invoked
(From OE-Core rev: fdce8ecdc27796955156b9c4a91ccaca80459ec5)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit d65729748253eaa640333198ca8aec05946cb9e8)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/debuginfod.py | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/meta/lib/oeqa/selftest/cases/debuginfod.py b/meta/lib/oeqa/selftest/cases/debuginfod.py index 3c40119282..37f51760fb 100644 --- a/meta/lib/oeqa/selftest/cases/debuginfod.py +++ b/meta/lib/oeqa/selftest/cases/debuginfod.py | |||
| @@ -12,6 +12,36 @@ from oeqa.utils.commands import bitbake, get_bb_var, runqemu | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | class Debuginfod(OESelftestTestCase): | 14 | class Debuginfod(OESelftestTestCase): |
| 15 | |||
| 16 | def wait_for_debuginfod(self, port): | ||
| 17 | """ | ||
| 18 | debuginfod takes time to scan the packages and requesting too early may | ||
| 19 | result in a test failure if the right packages haven't been scanned yet. | ||
| 20 | |||
| 21 | Request the metrics endpoint periodically and wait for there to be no | ||
| 22 | busy scanning threads. | ||
| 23 | |||
| 24 | Returns True if debuginfod is ready, False if we timed out | ||
| 25 | """ | ||
| 26 | import time, urllib | ||
| 27 | |||
| 28 | # Wait a minute | ||
| 29 | countdown = 6 | ||
| 30 | delay = 10 | ||
| 31 | |||
| 32 | while countdown: | ||
| 33 | time.sleep(delay) | ||
| 34 | try: | ||
| 35 | with urllib.request.urlopen("http://localhost:%d/metrics" % port) as f: | ||
| 36 | lines = f.read().decode("ascii").splitlines() | ||
| 37 | if "thread_busy{role=\"scan\"} 0" in lines: | ||
| 38 | return True | ||
| 39 | except urllib.error.URLError as e: | ||
| 40 | self.logger.error(e) | ||
| 41 | countdown -= 1 | ||
| 42 | return False | ||
| 43 | |||
| 44 | |||
| 15 | def test_debuginfod(self): | 45 | def test_debuginfod(self): |
| 16 | self.write_config( | 46 | self.write_config( |
| 17 | """ | 47 | """ |
| @@ -25,29 +55,50 @@ CORE_IMAGE_EXTRA_INSTALL += "elfutils" | |||
| 25 | cmd = [ | 55 | cmd = [ |
| 26 | os.path.join(native_sysroot, "usr", "bin", "debuginfod"), | 56 | os.path.join(native_sysroot, "usr", "bin", "debuginfod"), |
| 27 | "--verbose", | 57 | "--verbose", |
| 58 | # In-memory database, this is a one-shot test | ||
| 28 | "--database=:memory:", | 59 | "--database=:memory:", |
| 60 | # Don't use all the host cores | ||
| 61 | "--concurrency=8", | ||
| 62 | "--connection-pool=8", | ||
| 63 | # Disable rescanning, this is a one-shot test | ||
| 64 | "--rescan-time=0", | ||
| 65 | "--groom-time=0", | ||
| 29 | get_bb_var("DEPLOY_DIR"), | 66 | get_bb_var("DEPLOY_DIR"), |
| 30 | ] | 67 | ] |
| 31 | for format in get_bb_var("PACKAGE_CLASSES").split(): | 68 | |
| 32 | if format == "package_deb": | 69 | format = get_bb_var("PACKAGE_CLASSES").split()[0] |
| 33 | cmd.append("--scan-deb-dir") | 70 | if format == "package_deb": |
| 34 | elif format == "package_ipk": | 71 | cmd.append("--scan-deb-dir") |
| 35 | cmd.append("--scan-deb-dir") | 72 | elif format == "package_ipk": |
| 36 | elif format == "package_rpm": | 73 | cmd.append("--scan-deb-dir") |
| 37 | cmd.append("--scan-rpm-dir") | 74 | elif format == "package_rpm": |
| 75 | cmd.append("--scan-rpm-dir") | ||
| 76 | else: | ||
| 77 | self.fail("Unknown package class %s" % format) | ||
| 78 | |||
| 38 | # Find a free port | 79 | # Find a free port |
| 39 | with socketserver.TCPServer(("localhost", 0), None) as s: | 80 | with socketserver.TCPServer(("localhost", 0), None) as s: |
| 40 | port = s.server_address[1] | 81 | port = s.server_address[1] |
| 41 | cmd.append("--port=%d" % port) | 82 | cmd.append("--port=%d" % port) |
| 42 | 83 | ||
| 43 | try: | 84 | try: |
| 44 | debuginfod = subprocess.Popen(cmd) | 85 | # Remove DEBUGINFOD_URLS from the environment so we don't try |
| 86 | # looking in the distro debuginfod | ||
| 87 | env = os.environ.copy() | ||
| 88 | if "DEBUGINFOD_URLS" in env: | ||
| 89 | del env["DEBUGINFOD_URLS"] | ||
| 90 | |||
| 91 | self.logger.info(f"Starting server {cmd}") | ||
| 92 | debuginfod = subprocess.Popen(cmd, env=env) | ||
| 45 | 93 | ||
| 46 | with runqemu("core-image-minimal", runqemuparams="nographic") as qemu: | 94 | with runqemu("core-image-minimal", runqemuparams="nographic") as qemu: |
| 95 | self.assertTrue(self.wait_for_debuginfod(port)) | ||
| 96 | |||
| 47 | cmd = ( | 97 | cmd = ( |
| 48 | "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/debuginfod" | 98 | "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/debuginfod" |
| 49 | % (qemu.server_ip, port) | 99 | % (qemu.server_ip, port) |
| 50 | ) | 100 | ) |
| 101 | self.logger.info(f"Starting client {cmd}") | ||
| 51 | status, output = qemu.run_serial(cmd) | 102 | status, output = qemu.run_serial(cmd) |
| 52 | # This should be more comprehensive | 103 | # This should be more comprehensive |
| 53 | self.assertIn("/.cache/debuginfod_client/", output) | 104 | self.assertIn("/.cache/debuginfod_client/", output) |
