From 6ab25c677b8404c874c81fcf78797aba4c6c2894 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Thu, 29 Aug 2024 15:32:09 +0200 Subject: [PATCH] Fix `test-runner` bootstrap failing if `apt` lock is already held --- test/scripts/ssh-setup.sh | 14 +++++++++++--- test/test-runner/src/package.rs | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/scripts/ssh-setup.sh b/test/scripts/ssh-setup.sh index 0bbea4f0b922..dd72bca4f88f 100644 --- a/test/scripts/ssh-setup.sh +++ b/test/scripts/ssh-setup.sh @@ -124,12 +124,20 @@ fi setup_systemd +# Run apt with some arguments +robust_apt () { + # We don't want to fail due to the global apt lock being + # held, which happens sporadically. It is fine to wait for + # some time if it means that the test run can continue. + apt -o DPkg::Lock::Timeout=60 "$@" +} + function install_packages_apt { echo "Installing required apt packages" - apt update - apt install -yf xvfb wireguard-tools curl + robust_apt update + robust_apt install -yf xvfb wireguard-tools curl if ! which ping &>/dev/null; then - apt install -yf iputils-ping + robust_apt install -yf iputils-ping fi curl -fsSL https://get.docker.com | sh } diff --git a/test/test-runner/src/package.rs b/test/test-runner/src/package.rs index 5312da95d956..674fc9987f4b 100644 --- a/test/test-runner/src/package.rs +++ b/test/test-runner/src/package.rs @@ -129,6 +129,10 @@ pub async fn install_package(package: Package) -> Result<()> { #[cfg(target_os = "linux")] async fn install_dpkg(path: &Path) -> Result<()> { let mut cmd = Command::new("/usr/bin/dpkg"); + // We don't want to fail due to the global apt lock being + // held, which happens sporadically. Wait to acquire the lock + // instead. + cmd.args(["-o", "DPkg::Lock::Timeout=60"]); cmd.arg("-i"); cmd.arg(path.as_os_str()); cmd.kill_on_drop(true);