Skip to content

Commit

Permalink
Add 'assume yes' to package installs in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Sep 4, 2024
1 parent 4491033 commit 0cdc714
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions test/scripts/ssh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -qyf -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
}
Expand Down
26 changes: 16 additions & 10 deletions test/test-runner/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -149,11 +145,7 @@ async fn install_apt(path: &Path) -> Result<()> {
#[cfg(target_os = "linux")]
async fn uninstall_apt(name: &str, env: HashMap<String, String>, 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]);
Expand All @@ -173,6 +165,20 @@ async fn uninstall_apt(name: &str, env: HashMap<String, String>, 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;
Expand Down

0 comments on commit 0cdc714

Please sign in to comment.