From 95cab9fe562dfc5d446227ef0a0e86be00dd30c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Wed, 4 Sep 2024 20:27:21 +0200 Subject: [PATCH] Add 'assume yes' to package installs in tests --- test/scripts/ssh-setup.sh | 6 +++--- test/test-runner/src/package.rs | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/test/scripts/ssh-setup.sh b/test/scripts/ssh-setup.sh index dd72bca4f88f..08887d4aba6d 100644 --- a/test/scripts/ssh-setup.sh +++ b/test/scripts/ssh-setup.sh @@ -129,15 +129,15 @@ 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 "$@" + DEBIAN_FRONTEND=noninteractive apt-get -qy -o DPkg::Lock::Timeout=60 "$@" } function install_packages_apt { echo "Installing required apt packages" robust_apt update - robust_apt install -yf xvfb wireguard-tools curl + robust_apt install xvfb wireguard-tools curl if ! which ping &>/dev/null; then - robust_apt install -yf iputils-ping + robust_apt install 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 60daf34d70f8..8de1f32c3fc3 100644 --- a/test/test-runner/src/package.rs +++ b/test/test-runner/src/package.rs @@ -128,11 +128,7 @@ pub async fn install_package(package: Package) -> Result<()> { #[cfg(target_os = "linux")] async fn install_apt(path: &Path) -> Result<()> { - let mut cmd = Command::new("/usr/bin/apt"); - // 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"]); + let mut cmd = apt_command(); cmd.arg("install"); cmd.arg(path.as_os_str()); cmd.kill_on_drop(true); @@ -149,11 +145,7 @@ async fn install_apt(path: &Path) -> Result<()> { #[cfg(target_os = "linux")] async fn uninstall_apt(name: &str, env: HashMap, purge: bool) -> Result<()> { let action; - let mut cmd = Command::new("/usr/bin/apt"); - // 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"]); + let mut cmd = apt_command(); if purge { action = "apt purge"; cmd.args(["purge", name]); @@ -173,6 +165,20 @@ async fn uninstall_apt(name: &str, env: HashMap, purge: bool) -> .and_then(|output| result_from_output(action, output)) } +#[cfg(target_os = "linux")] +fn apt_command() -> Command { + let mut cmd = Command::new("/usr/bin/apt-get"); + // 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("-qy"); + + cmd.env("DEBIAN_FRONTEND", "noninteractive"); + + cmd +} + #[cfg(target_os = "linux")] async fn install_rpm(path: &Path) -> Result<()> { use std::time::Duration;