Skip to content

Commit

Permalink
Exit immediately if ssh-setup.sh fails
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jan 9, 2024
1 parent 5d0bcc2 commit da7cbf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions test/scripts/ssh-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,8 @@ fi
setup_systemd

# Install required packages
which apt &>/dev/null && apt install -f xvfb wireguard-tools
which dnf &>/dev/null && dnf install -y xorg-x11-server-Xvfb wireguard-tools
if which apt &>/dev/null; then
apt install -f xvfb wireguard-tools
elif which dnf &>/dev/null; then
dnf install -y xorg-x11-server-Xvfb wireguard-tools
fi
11 changes: 10 additions & 1 deletion test/test-manager/src/vm/provision.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::config::{OsType, Provisioner, VmConfig};
use crate::package;
use anyhow::{Context, Result};
use anyhow::{bail, Context, Result};
use ssh2::Session;
use std::fs::File;
use std::io::{self, Read};
Expand Down Expand Up @@ -203,5 +203,14 @@ fn ssh_exec(session: &Session, command: &str) -> Result<String> {
channel.send_eof()?;
channel.wait_eof()?;
channel.wait_close()?;

let exit_status = channel
.exit_status()
.context("Failed to obtain exit status")?;
if exit_status != 0 {
log::error!("command failed: {command}\n{output}");
bail!("command failed: {exit_status}");
}

Ok(output)
}

0 comments on commit da7cbf1

Please sign in to comment.