pub struct E2eTestRunner { /* private fields */ }Expand description
A process runner bound to a specific E2E test environment.
This provides a higher-level abstraction for running E2E test tasks against a named environment, eliminating the need to pass both the runner and environment name to every task function.
§Example
use torrust_tracker_deployer_lib::testing::e2e::tasks::black_box::E2eTestRunner;
let test_runner = E2eTestRunner::new("e2e-provision")
.with_cleanup_on_failure(true);
test_runner.provision_infrastructure()?;
test_runner.destroy_infrastructure()?;Implementations§
Source§impl E2eTestRunner
impl E2eTestRunner
Sourcepub fn new(environment_name: impl Into<String>) -> Self
pub fn new(environment_name: impl Into<String>) -> Self
Creates a new E2E test runner for the specified environment.
By default, cleanup on failure is disabled. Use with_cleanup_on_failure
to enable automatic infrastructure destruction when tasks fail.
Sourcepub fn with_cleanup_on_failure(self, cleanup: bool) -> Self
pub fn with_cleanup_on_failure(self, cleanup: bool) -> Self
Enables or disables automatic cleanup on failure.
When enabled, if a task like provision_infrastructure or configure_services
fails, the runner will attempt to destroy the infrastructure before returning
the error.
Sourcepub fn environment_name(&self) -> &str
pub fn environment_name(&self) -> &str
Returns the environment name.
Sourcepub fn cleanup_on_failure(&self) -> bool
pub fn cleanup_on_failure(&self) -> bool
Returns whether cleanup on failure is enabled.
Sourcepub fn create_environment(&self, config_path: &Path) -> Result<()>
pub fn create_environment(&self, config_path: &Path) -> Result<()>
Sourcepub fn provision_infrastructure(&self) -> Result<()>
pub fn provision_infrastructure(&self) -> Result<()>
Provisions the infrastructure for the environment.
§Errors
Returns an error if the provision command fails.
If cleanup_on_failure is enabled, attempts to destroy infrastructure before returning.
Sourcepub fn configure_services(&self) -> Result<()>
pub fn configure_services(&self) -> Result<()>
Configures services on the provisioned infrastructure.
§Errors
Returns an error if the configure command fails.
If cleanup_on_failure is enabled, attempts to destroy infrastructure before returning.
Sourcepub fn release_software(&self) -> Result<()>
pub fn release_software(&self) -> Result<()>
Releases software to the provisioned and configured infrastructure.
§Errors
Returns an error if the release command fails.
If cleanup_on_failure is enabled, attempts to destroy infrastructure before returning.
Sourcepub fn run_services(&self) -> Result<()>
pub fn run_services(&self) -> Result<()>
Runs services on the released infrastructure.
§Skip Condition
When TORRUST_TD_SKIP_RUN_IN_CONTAINER environment variable is set to "true",
this step is skipped because Docker daemon is not available in the test container
(no Docker-in-Docker configuration).
§Errors
Returns an error if the run command fails.
If cleanup_on_failure is enabled, attempts to destroy infrastructure before returning.
Sourcepub fn validate_deployment(&self) -> Result<()>
pub fn validate_deployment(&self) -> Result<()>
Validates the deployment by running the test command.
§Errors
Returns an error if the test command fails.
Sourcepub fn destroy_infrastructure(&self) -> Result<()>
pub fn destroy_infrastructure(&self) -> Result<()>
Destroys the infrastructure for the environment.
§Errors
Returns an error if the destroy command fails.
Sourcepub fn purge_environment(&self) -> Result<()>
pub fn purge_environment(&self) -> Result<()>
Purges all local environment data (build/, data/ directories).
This removes all local state for the environment, including:
- Build directory (
build/{env-name}/) - Data directory (
data/{env-name}/) - Environment entry in the repository
Important: This does NOT destroy infrastructure - only local files.
Use destroy_infrastructure() to tear down VMs/servers before purging.
§Errors
Returns an error if the purge command fails.
Auto Trait Implementations§
impl Freeze for E2eTestRunner
impl RefUnwindSafe for E2eTestRunner
impl Send for E2eTestRunner
impl Sync for E2eTestRunner
impl Unpin for E2eTestRunner
impl UnsafeUnpin for E2eTestRunner
impl UnwindSafe for E2eTestRunner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request