Skip to main content

Machine

Struct Machine 

Source
pub struct Machine {
    pub name: String,
    pub ssh_host: String,
    pub ssh_port: u16,
    pub work_dir: PathBuf,
    /* private fields */
}
Expand description

A running QEMU VM for E2E testing.

Fields§

§name: String§ssh_host: String§ssh_port: u16§work_dir: PathBuf

Implementations§

Source§

impl Machine

Source

pub async fn assert_service_active(&self, unit: &str) -> Result<()>

Source

pub async fn assert_service_inactive(&self, unit: &str) -> Result<()>

Source

pub async fn assert_curl(&self, url: &str, expected_status: u16) -> Result<()>

Source

pub async fn assert_journal_clean(&self, unit: &str) -> Result<()>

Source

pub async fn assert_file_exists(&self, path: &str) -> Result<()>

Source

pub async fn assert_file_not_exists(&self, path: &str) -> Result<()>

Source

pub async fn wait_for_service( &self, unit: &str, timeout: Duration, prefix: &str, ) -> Result<()>

Source§

impl Machine

Source

pub async fn spawn( image: &Image, test_id: &str, ssh_port: u16, opts: &SpawnOpts, ) -> Result<Self>

Source

pub async fn exec(&self, cmd: &str) -> Result<ExecOutput>

Run a command inside the VM via SSH.

Source

pub async fn exec_streaming( &self, cmd: &str, prefix: &str, ) -> Result<ExecOutput>

Run a command inside the VM via SSH, streaming stdout/stderr to the terminal. Returns the exit status (Ok if success, Err if non-zero).

Source

pub async fn wait_for_exit(&mut self, timeout: Duration)

Wait for the qemu process to exit on its own (e.g., after a clean sudo poweroff). Returns once the process is gone or timeout elapses. Used before snapshotting so the disk is fully released.

Source

pub async fn destroy(self) -> Result<()>

Shut down the VM and clean up files.

Source

pub fn keep_alive(self)

Print SSH connection info for debugging, then detach. VM keeps running until the user kills it or the process exits.

Trait Implementations§

Source§

impl Drop for Machine

Source§

fn drop(&mut self)

Kill the QEMU process if it’s still alive. Needed because tokio’s Child::drop does NOT reap the process by default, so any early return from spawn_* (e.g. SSH timeout during wait_for_ssh) would otherwise orphan a QEMU holding the forwarded SSH port. Async destroy paths that want to survive this (keep_alive) use std::mem::forget to skip Drop entirely.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V