pub struct TestHarness {
pub config: HarnessConfig,
pub logger: TestLogger,
/* private fields */
}Expand description
E2E Test Harness for managing test execution
Fields§
§config: HarnessConfig§logger: TestLoggerImplementations§
Source§impl TestHarness
impl TestHarness
Sourcepub fn new(test_name: &str, config: HarnessConfig) -> HarnessResult<Self>
pub fn new(test_name: &str, config: HarnessConfig) -> HarnessResult<Self>
Create a new test harness with the given configuration
Sourcepub fn default_for_test(test_name: &str) -> HarnessResult<Self>
pub fn default_for_test(test_name: &str) -> HarnessResult<Self>
Create a harness with default configuration
Sourcepub fn run_reliability_scenario(
&self,
scenario: &ReliabilityScenarioSpec,
) -> HarnessResult<ReliabilityScenarioReport>
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.
Sourcepub fn create_dir(&self, name: &str) -> HarnessResult<PathBuf>
pub fn create_dir(&self, name: &str) -> HarnessResult<PathBuf>
Create a subdirectory in the test directory
Sourcepub fn create_file(&self, name: &str, content: &str) -> HarnessResult<PathBuf>
pub fn create_file(&self, name: &str, content: &str) -> HarnessResult<PathBuf>
Create a file in the test directory
Sourcepub fn create_daemon_config(
&self,
config_content: &str,
) -> HarnessResult<PathBuf>
pub fn create_daemon_config( &self, config_content: &str, ) -> HarnessResult<PathBuf>
Create a config file for the daemon
Sourcepub fn create_workers_config(
&self,
config_content: &str,
) -> HarnessResult<PathBuf>
pub fn create_workers_config( &self, config_content: &str, ) -> HarnessResult<PathBuf>
Create a workers config file
Sourcepub fn spawn_process<I, S>(
&self,
name: &str,
program: &Path,
args: I,
env: Option<&HashMap<String, String>>,
) -> HarnessResult<u32>
pub fn spawn_process<I, S>( &self, name: &str, program: &Path, args: I, env: Option<&HashMap<String, String>>, ) -> HarnessResult<u32>
Spawn a managed process
Sourcepub fn start_daemon(&self, extra_args: &[&str]) -> HarnessResult<u32>
pub fn start_daemon(&self, extra_args: &[&str]) -> HarnessResult<u32>
Start the daemon process
Sourcepub fn stop_process(&self, name: &str) -> HarnessResult<()>
pub fn stop_process(&self, name: &str) -> HarnessResult<()>
Stop a managed process by name
Sourcepub fn wait_for_process_exit(
&self,
name: &str,
timeout: Duration,
) -> HarnessResult<ExitStatus>
pub fn wait_for_process_exit( &self, name: &str, timeout: Duration, ) -> HarnessResult<ExitStatus>
Wait for a managed process to exit without killing it.
Sourcepub fn stop_all_processes(&self)
pub fn stop_all_processes(&self)
Stop all managed processes
Sourcepub fn exec<I, S>(&self, program: &str, args: I) -> HarnessResult<CommandResult>
pub fn exec<I, S>(&self, program: &str, args: I) -> HarnessResult<CommandResult>
Execute a command and capture output
Sourcepub fn exec_with_timeout<I, S>(
&self,
program: &str,
args: I,
timeout: Duration,
) -> HarnessResult<CommandResult>
pub fn exec_with_timeout<I, S>( &self, program: &str, args: I, timeout: Duration, ) -> HarnessResult<CommandResult>
Execute a command with a specific timeout
Terminates the process if it exceeds the provided timeout.
Sourcepub fn exec_rch<I, S>(&self, args: I) -> HarnessResult<CommandResult>
pub fn exec_rch<I, S>(&self, args: I) -> HarnessResult<CommandResult>
Execute the rch binary
Sourcepub fn exec_rchd<I, S>(&self, args: I) -> HarnessResult<CommandResult>
pub fn exec_rchd<I, S>(&self, args: I) -> HarnessResult<CommandResult>
Execute the rchd binary
Sourcepub fn exec_rch_wkr<I, S>(&self, args: I) -> HarnessResult<CommandResult>
pub fn exec_rch_wkr<I, S>(&self, args: I) -> HarnessResult<CommandResult>
Execute the rch-wkr binary
Sourcepub fn wait_for<F>(
&self,
description: &str,
timeout: Duration,
interval: Duration,
condition: F,
) -> HarnessResult<()>
pub fn wait_for<F>( &self, description: &str, timeout: Duration, interval: Duration, condition: F, ) -> HarnessResult<()>
Wait for a condition to become true
Sourcepub fn wait_for_file(&self, path: &Path, timeout: Duration) -> HarnessResult<()>
pub fn wait_for_file(&self, path: &Path, timeout: Duration) -> HarnessResult<()>
Wait for a file to exist
Sourcepub fn wait_for_socket(
&self,
socket_path: &Path,
timeout: Duration,
) -> HarnessResult<()>
pub fn wait_for_socket( &self, socket_path: &Path, timeout: Duration, ) -> HarnessResult<()>
Wait for a socket to be available
Sourcepub fn wait_for_socket_with_backoff(
&self,
socket_path: &Path,
max_wait: Duration,
) -> HarnessResult<()>
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.
Sourcepub fn mark_passed(&self)
pub fn mark_passed(&self)
Mark the test as passed
Sourcepub fn mark_failed(&self, reason: &str)
pub fn mark_failed(&self, reason: &str)
Mark the test as failed with a reason
Sourcepub fn assert(&self, condition: bool, message: &str) -> HarnessResult<()>
pub fn assert(&self, condition: bool, message: &str) -> HarnessResult<()>
Assert that a condition is true
Sourcepub fn assert_eq<T: PartialEq + Debug>(
&self,
actual: T,
expected: T,
message: &str,
) -> HarnessResult<()>
pub fn assert_eq<T: PartialEq + Debug>( &self, actual: T, expected: T, message: &str, ) -> HarnessResult<()>
Assert that two values are equal
Sourcepub fn assert_success(
&self,
result: &CommandResult,
context: &str,
) -> HarnessResult<()>
pub fn assert_success( &self, result: &CommandResult, context: &str, ) -> HarnessResult<()>
Assert that a command result succeeded
Sourcepub fn assert_stdout_contains(
&self,
result: &CommandResult,
pattern: &str,
context: &str,
) -> HarnessResult<()>
pub fn assert_stdout_contains( &self, result: &CommandResult, pattern: &str, context: &str, ) -> HarnessResult<()>
Assert that a command result contains expected output