Verify that provisioned and configured infrastructure meets all requirements.
Validates infrastructure readiness by running comprehensive tests against the configured environment. This command confirms the environment is in a working state and ready for deployment.
torrust-tracker-deployer test <ENVIRONMENT><ENVIRONMENT>(required) - Name of the environment to test
- Environment configured - Must run
configurefirst - VM running - Instance must be accessible
- Docker installed - Docker and Docker Compose must be available
- SSH connectivity - Network access to VM
Tests verify the environment is in "Configured" state and all components work correctly.
When you test an environment:
- Validates environment state - Ensures environment is configured
- Checks VM connectivity - Verifies SSH access
- Tests Docker installation - Validates Docker daemon
- Tests Docker Compose - Validates Docker Compose plugin
- Verifies user permissions - Confirms non-root Docker access
- Runs infrastructure tests - Executes comprehensive test suite
- Reports results - Provides detailed pass/fail status
# Test the environment
torrust-tracker-deployer test my-environment
# Output:
# ✓ Validating environment state...
# ✓ Checking VM connectivity...
# ✓ Testing Docker installation...
# ✓ Testing Docker Compose...
# ✓ Verifying user permissions...
# ✓ Running infrastructure tests...
# ✓ All tests passed# Full setup and verification
torrust-tracker-deployer create environment -f config.json
torrust-tracker-deployer provision my-environment
torrust-tracker-deployer configure my-environment
torrust-tracker-deployer test my-environment
# If all tests pass, environment is ready#!/bin/bash
set -e
ENV_NAME="ci-${BUILD_ID}"
# Setup
torrust-tracker-deployer create environment -f ci.json
torrust-tracker-deployer provision ${ENV_NAME}
torrust-tracker-deployer configure ${ENV_NAME}
# Verify infrastructure readiness
if torrust-tracker-deployer test ${ENV_NAME}; then
echo "Infrastructure ready for deployment"
# Deploy your application...
else
echo "Infrastructure tests failed"
exit 1
fi
# Cleanup
torrust-tracker-deployer destroy ${ENV_NAME}- SSH Access - Verifies SSH connection to VM
- Network Reachability - Confirms VM can reach internet
- DNS Resolution - Validates DNS configuration
- Docker Daemon - Checks Docker service is running
- Docker CLI - Verifies Docker commands work
- Docker Info - Validates Docker system information
- Docker Version - Confirms Docker version
- Compose Plugin - Verifies Docker Compose is installed
- Compose Version - Confirms Docker Compose version
- Compose Functionality - Tests basic Compose operations
- Non-root Access - Confirms user can run Docker without sudo
- Docker Group - Verifies user is in docker group
- Socket Access - Validates docker socket permissions
The test command provides:
- Test results - Pass/fail status for each test
- Detailed logs - Information about any failures
- Exit code - 0 for success, non-zero for failure
Test logs are written to:
data/logs/test-<timestamp>.log
After testing:
# If tests pass, environment is ready
# Deploy your application
# SSH into the environment
ssh -i <private-key> torrust@<vm-ip>
# Or proceed with application deployment
# (application deployment features coming in future releases)Problem: Cannot test an environment that hasn't been configured
Solution: Configure the environment first
# Check environment state
cat data/my-environment/state.json
# If state is "Provisioned", configure first
torrust-tracker-deployer configure my-environmentProblem: Cannot establish SSH connection to VM
Solution: Check VM status and network
# Verify VM is running
lxc list
# Get VM IP
lxc list --format json | jq -r '.[].state.network.eth0.addresses[0].address'
# Try manual SSH
ssh -i <private-key> torrust@<vm-ip>
# Check SSH key permissions
ls -l <private-key>
chmod 600 <private-key>Problem: Docker service is not running
Solution: Check Docker service status on VM
# SSH into VM
ssh -i <private-key> torrust@<vm-ip>
# Check Docker status
sudo systemctl status docker
# Start Docker if needed
sudo systemctl start docker
# Enable Docker to start on boot
sudo systemctl enable dockerProblem: Docker Compose is not installed or not in PATH
Solution: Verify Docker Compose installation
# SSH into VM
ssh -i <private-key> torrust@<vm-ip>
# Check Docker Compose
docker compose version
# If not found, reconfigure
exit
torrust-tracker-deployer configure my-environmentProblem: User cannot run Docker without sudo
Solution: Verify user is in docker group
# SSH into VM
ssh -i <private-key> torrust@<vm-ip>
# Check groups
groups
# If docker group missing, add it
sudo usermod -aG docker $USER
# Log out and back in
exit
ssh -i <private-key> torrust@<vm-ip>
# Verify
docker psProblem: VM cannot reach external networks
Solution: Check LXD network configuration
# Check LXD network
lxc network list
# Check instance network config
lxc config device show <instance-name>
# Check VM network inside
lxc exec <instance-name> -- ip addr
lxc exec <instance-name> -- ping -c 3 8.8.8.8#!/bin/bash
set -e
# Setup infrastructure
./scripts/setup-environment.sh my-environment
# Run comprehensive tests
if torrust-tracker-deployer test my-environment; then
echo "✓ Infrastructure validated successfully"
# Deploy application
./scripts/deploy-app.sh my-environment
else
echo "✗ Infrastructure validation failed"
# Collect diagnostics
./scripts/collect-logs.sh my-environment
exit 1
fi# After making infrastructure changes
torrust-tracker-deployer configure my-environment
# Verify changes didn't break anything
torrust-tracker-deployer test my-environment
# If tests pass, continue development# Staging environment verification
torrust-tracker-deployer test staging
# Production environment verification
torrust-tracker-deployer test production
# Only deploy if both passTests are implemented using:
- SSH Client - Remote command execution
- Assertions - Validates expected outcomes
- Error Handling - Provides detailed failure messages
- State Validation - Checks environment JSON state
- SSH Connection - Establishes connection to VM
- Docker Checks - Runs docker commands remotely
- Compose Checks - Runs docker compose commands remotely
- Permission Checks - Validates non-root access
- Result Aggregation - Collects all test results
- Reporting - Outputs pass/fail status
- 0 - All tests passed
- 1 - One or more tests failed
- 2 - Invalid environment state
- 3 - SSH connection failed