Skip to content

Commit

Permalink
Fix test-runner bootstrap failing if apt lock is already held
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Sep 2, 2024
1 parent 3454ded commit 6ab25c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/scripts/ssh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions test/test-runner/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6ab25c6

Please sign in to comment.