This document describes how to test the CloudProxy application, focusing on the test_cloudproxy.sh end-to-end test script.
The test_cloudproxy.sh script provides comprehensive end-to-end testing of CloudProxy, including:
- API testing
- Cloud provider integration
- Proxy deployment
- Proxy connectivity
- Cleanup
To run the end-to-end tests, you'll need:
- Docker installed
- jq installed (
apt install jq) - Cloud provider credentials configured via environment variables or
.envfile - Internet connectivity
The test script requires various environment variables to interact with cloud providers:
Authentication (Optional):
PROXY_USERNAME: Username for proxy authenticationPROXY_PASSWORD: Password for proxy authentication
DigitalOcean (Enabled by default):
DO_TOKEN: DigitalOcean API token
AWS (Enabled by default):
AWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret key
Hetzner (Disabled by default):
HETZNER_TOKEN: Hetzner API tokenHETZNER_ENABLED=true: To enable Hetzner
GCP (Disabled by default):
GCP_SERVICE_ACCOUNT: Path to GCP service account fileGCP_ENABLED=true: To enable GCP
Azure (Disabled by default):
AZURE_CLIENT_ID: Azure client IDAZURE_CLIENT_SECRET: Azure client secretAZURE_TENANT_ID: Azure tenant IDAZURE_SUBSCRIPTION_ID: Azure subscription IDAZURE_ENABLED=true: To enable Azure
The test script supports several command-line options:
Usage: ./test_cloudproxy.sh [OPTIONS]
Options:
--no-cleanup Don't automatically clean up resources
--skip-connection-test Skip testing proxy connectivity
--proxy-wait=SECONDS Wait time for proxy initialization (default: 30)
--help Show this help message
The script performs these operations in sequence:
- Environment Check: Verifies required environment variables
- Docker Build: Builds the CloudProxy Docker image
- Container Setup: Runs the CloudProxy container
- API Tests: Tests all REST API endpoints
- Provider Configuration: Sets scaling parameters for enabled providers
- Proxy Creation: Waits for proxy instances to be created
- Connectivity Test: Tests connectivity through a random proxy
- Proxy Management: Tests proxy deletion and restart functionality
- Scaling Down: Tests scaling down providers
- Web Interface Check: Verifies the UI and API docs are accessible
- Cleanup: Scales down all providers and removes resources
If proxy connectivity tests fail:
- Check the logs for the specific proxy instance (the script shows these)
- Verify your cloud provider firewall allows access to port 8899
- Confirm the proxy authentication settings match your environment variables
- Try increasing the
--proxy-waittime (some providers take longer to initialize) - SSH into a proxy instance to check the logs directly:
- System logs
- Proxy service status
- Network configuration
IMPORTANT: This test script creates real cloud instances that cost money.
To minimize costs:
- Always allow the cleanup process to run (don't use
--no-cleanupunless necessary) - Keep testing sessions short
- Set lower min/max scaling values if you're just testing functionality
CloudProxy also includes unit tests that can be run with pytest:
pytest -vThese tests use mocks and don't create actual cloud instances, making them safe to run without incurring costs.