Skip to main content

TestHarness

Struct TestHarness 

Source
pub struct TestHarness {
    pub config: HarnessConfig,
    pub logger: TestLogger,
    /* private fields */
}
Expand description

E2E Test Harness for managing test execution

Fields§

§config: HarnessConfig§logger: TestLogger

Implementations§

Source§

impl TestHarness

Source

pub fn new(test_name: &str, config: HarnessConfig) -> HarnessResult<Self>

Create a new test harness with the given configuration

Source

pub fn default_for_test(test_name: &str) -> HarnessResult<Self>

Create a harness with default configuration

Source

pub fn test_dir(&self) -> &Path

Get the test directory path

Source

pub fn run_reliability_scenario( &self, scenario: &ReliabilityScenarioSpec, ) -> HarnessResult<ReliabilityScenarioReport>

Run a reliability scenario with deterministic setup/execute/verify/cleanup phases.

This is the shared foundation consumed by scenario-specific suites (path dependencies, repo convergence, disk pressure, and process triage) so they can reuse one orchestration engine instead of bespoke scaffolding.

Source

pub fn create_dir(&self, name: &str) -> HarnessResult<PathBuf>

Create a subdirectory in the test directory

Source

pub fn create_file(&self, name: &str, content: &str) -> HarnessResult<PathBuf>

Create a file in the test directory

Source

pub fn create_daemon_config( &self, config_content: &str, ) -> HarnessResult<PathBuf>

Create a config file for the daemon

Source

pub fn create_workers_config( &self, config_content: &str, ) -> HarnessResult<PathBuf>

Create a workers config file

Source

pub fn spawn_process<I, S>( &self, name: &str, program: &Path, args: I, env: Option<&HashMap<String, String>>, ) -> HarnessResult<u32>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Spawn a managed process

Source

pub fn start_daemon(&self, extra_args: &[&str]) -> HarnessResult<u32>

Start the daemon process

Source

pub fn stop_process(&self, name: &str) -> HarnessResult<()>

Stop a managed process by name

Source

pub fn wait_for_process_exit( &self, name: &str, timeout: Duration, ) -> HarnessResult<ExitStatus>

Wait for a managed process to exit without killing it.

Source

pub fn stop_all_processes(&self)

Stop all managed processes

Source

pub fn exec<I, S>(&self, program: &str, args: I) -> HarnessResult<CommandResult>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute a command and capture output

Source

pub fn exec_with_timeout<I, S>( &self, program: &str, args: I, timeout: Duration, ) -> HarnessResult<CommandResult>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute a command with a specific timeout

Terminates the process if it exceeds the provided timeout.

Source

pub fn exec_rch<I, S>(&self, args: I) -> HarnessResult<CommandResult>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute the rch binary

Source

pub fn exec_rchd<I, S>(&self, args: I) -> HarnessResult<CommandResult>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute the rchd binary

Source

pub fn exec_rch_wkr<I, S>(&self, args: I) -> HarnessResult<CommandResult>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute the rch-wkr binary

Source

pub fn wait_for<F>( &self, description: &str, timeout: Duration, interval: Duration, condition: F, ) -> HarnessResult<()>
where F: Fn() -> bool,

Wait for a condition to become true

Source

pub fn wait_for_file(&self, path: &Path, timeout: Duration) -> HarnessResult<()>

Wait for a file to exist

Source

pub fn wait_for_socket( &self, socket_path: &Path, timeout: Duration, ) -> HarnessResult<()>

Wait for a socket to be available

Source

pub fn wait_for_socket_with_backoff( &self, socket_path: &Path, max_wait: Duration, ) -> HarnessResult<()>

Wait for a socket using exponential backoff for more reliable detection.

Starts with a 10ms delay and doubles up to a maximum of 500ms per iteration. This reduces CPU usage while maintaining responsiveness for fast-starting daemons.

Source

pub fn mark_passed(&self)

Mark the test as passed

Source

pub fn mark_failed(&self, reason: &str)

Mark the test as failed with a reason

Source

pub fn passed(&self) -> bool

Check if the test passed

Source

pub fn assert(&self, condition: bool, message: &str) -> HarnessResult<()>

Assert that a condition is true

Source

pub fn assert_eq<T: PartialEq + Debug>( &self, actual: T, expected: T, message: &str, ) -> HarnessResult<()>

Assert that two values are equal

Source

pub fn assert_success( &self, result: &CommandResult, context: &str, ) -> HarnessResult<()>

Assert that a command result succeeded

Source

pub fn assert_stdout_contains( &self, result: &CommandResult, pattern: &str, context: &str, ) -> HarnessResult<()>

Assert that a command result contains expected output

Source

pub fn cleanup(&self)

Perform cleanup

Trait Implementations§

Source§

impl Drop for TestHarness

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more