pub struct TestCommandHandler { /* private fields */ }Expand description
TestCommandHandler orchestrates smoke testing for running Torrust Tracker services
Purpose: Post-deployment smoke test to verify the application is running and accessible
This handler validates that deployed services are operational and accessible from external clients by performing comprehensive health checks on the Tracker API and HTTP Tracker endpoints.
§Validation Steps
- Service Status - Verifies Docker Compose services are running via SSH
- Tracker API Health (required) - Tests external accessibility of HTTP API
- HTTP Tracker Health (optional) - Tests external accessibility of HTTP tracker
§Port Discovery
The handler extracts tracker ports from the environment’s tracker configuration:
- HTTP API port from
tracker.http_api.bind_address - HTTP Tracker port from
tracker.http_trackers[0].bind_address
§Design Rationale
This command accepts an EnvironmentName in its execute method to align with other
command handlers (ProvisionCommandHandler, ConfigureCommandHandler). This design:
- Loads environment from repository (consistent pattern across all handlers)
- Allows testing environments regardless of compile-time state (runtime validation)
- Requires the environment to have an instance IP set (checked at runtime)
- Enables repository integration for future enhancements (e.g., tracking test history)
Implementations§
Source§impl TestCommandHandler
impl TestCommandHandler
Sourcepub fn new(repository: Arc<dyn EnvironmentRepository>) -> Self
pub fn new(repository: Arc<dyn EnvironmentRepository>) -> Self
Create a new TestCommandHandler
Sourcepub async fn execute(
&self,
env_name: &EnvironmentName,
) -> Result<TestResult, TestCommandHandlerError>
pub async fn execute( &self, env_name: &EnvironmentName, ) -> Result<TestResult, TestCommandHandlerError>
Execute the complete testing and validation workflow
Validates that the Torrust Tracker services are running and accessible by performing external health checks on the deployed services. Also performs advisory DNS resolution checks for configured domains.
Returns a structured TestResult containing any DNS warnings found.
The presentation layer is responsible for rendering these warnings.
§Arguments
env_name- The name of the environment to test
§Returns
Ok(TestResult)- Test passed, may contain advisory DNS warnings
§Errors
Returns an error if:
- Environment not found
- Environment does not have an instance IP set
- Tracker configuration is invalid or missing required ports
- Running services validation fails:
- Services are not running
- Health check endpoints are not accessible
- Firewall rules block external access
Auto Trait Implementations§
impl Freeze for TestCommandHandler
impl !RefUnwindSafe for TestCommandHandler
impl !Send for TestCommandHandler
impl !Sync for TestCommandHandler
impl Unpin for TestCommandHandler
impl UnsafeUnpin for TestCommandHandler
impl !UnwindSafe for TestCommandHandler
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