Skip to main content

E2eTestRunner

Struct E2eTestRunner 

Source
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

Source

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.

Source

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.

Source

pub fn environment_name(&self) -> &str

Returns the environment name.

Source

pub fn cleanup_on_failure(&self) -> bool

Returns whether cleanup on failure is enabled.

Source

pub fn create_environment(&self, config_path: &Path) -> Result<()>

Creates the environment from the configuration file.

§Arguments
  • config_path - Path to the environment configuration file
§Errors

Returns an error if the create command fails.

§Panics

Panics if the config path contains invalid UTF-8.

Source

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.

Source

pub fn register_instance( &self, instance_ip: &str, ssh_port: Option<u16>, ) -> Result<()>

Registers an existing instance with the environment.

This is an alternative to provision_infrastructure for use with existing VMs, physical servers, or containers.

§Arguments
  • instance_ip - IP address of the existing instance to register
§Errors

Returns an error if the register command fails.

Source

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.

Source

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.

Source

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.

Source

pub fn validate_deployment(&self) -> Result<()>

Validates the deployment by running the test command.

§Errors

Returns an error if the test command fails.

Source

pub fn destroy_infrastructure(&self) -> Result<()>

Destroys the infrastructure for the environment.

§Errors

Returns an error if the destroy command fails.

Source

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§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoResult<T> for T

Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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

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