Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force install of deb packages in tests #6741

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -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
}
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
Loading