Why self host?
Self-hosting TestDriver gives you complete control over your test execution environment:- Enhanced security: Get complete control over ingress and egress rules.
- Complete customization: Modify the TestDriver Golden Image (our pre-configured AMI) to include custom dependencies, software, and configurations at launch time.
- Powerful Infrastructure: Run tests on bare metal infrastructure that support emulators and simulators.
Overview
By the end of this guide, you’ll have a complete self-hosted testing infrastructure that can:- Spawn TestDriver instances on-demand in your AWS account
- Run tests on your own AWS infrastructure with custom configurations
- Integrate seamlessly with GitHub Actions CI/CD workflows
- Automatically clean up resources after test completion
- CloudFormation Infrastructure: Deploy our
setup/aws/cloudformation.yaml
template to create the foundational AWS resources (VPC, security groups, IAM roles, and a launch template for instance creation). - On-Demand Instance Spawning: Use
setup/aws/spawn-runner.sh
with your Launch Template ID to programmatically spawn TestDriver instances whenever you need to run tests. - GitHub Actions Integration: Use
.github/workflows/self-hosted.yml
as a template for running tests in CI. This workflow demonstrates the complete lifecycle: spawning an instance, running tests, and shutting down the instance to minimize costs.
Prerequisites
- AWS account with permissions to run CloudFormation.
-
AWS CLI installed locally.
Be sure to run
aws configure
with your credentials -
Access to the TestDriver AMI (Golden Image)
Contact us with your preferred AWS Region for access. - A GitHub repository for committing your tests & workflow.
Step 1: Set Up AWS Infrastructure
Deploy CloudFormation Stack
Oursetup/aws/cloudformation.yaml
template creates:
- Dedicated VPC with public subnet
- Security group with proper port access
- IAM roles and instance profiles
- EC2 launch template for programmatic instance creation
Security: Replace
AllowedIngressCidr=0.0.0.0/0
with your specific IP
ranges to lock down access to your VPC.Get Launch Template ID
After CloudFormation completes, find the launch template ID in the stack outputs:Save this ID – you’ll need it for the next step.
Step 2: Spawn a New TestDriver Runner
This step is performed every time you want to run tests. Thespawn-runner.sh
script launches a new EC2 instance on-demand for test execution.
Using spawn-runner.sh
Oursetup/aws/spawn-runner.sh
script:
- Launches a new EC2 instance using your launch template from Step 1
- Waits for the instance to become ready
- Completes the TestDriver handshake
- Returns instance details (IP, instance ID) for CLI usage
Instance Lifecycle: Instances spawned by this script will continue running
until you manually terminate them. They are automatically tagged with
Name=TestDriverRunner
and Project=[your ProjectTag value]
for easy
identification in the AWS console.Changing Resolution in Lifecycle Files
You can also change the resolution before running tests by adding anexec
command in your lifecycle/provision.yaml
file:
lifecycle/provision.yaml
CLI Usage
Once you have an instance IP, run tests directly:PUBLIC_IP
to target the instance you just spawned via ./setup/aws/spawn-runner.sh
:
Terminating Instances
After your tests complete, terminate the instance to avoid unnecessary costs:Name=TestDriverRunner
.
Step 3: GitHub Actions Integration
This step shows you how to automate the entire test lifecycle in CI/CD.Example Workflow
Our.github/workflows/self-hosted.yml
demonstrates the complete workflow: spawning an EC2 instance, running your tests, and shutting down the instance automatically to minimize costs.
The workflow uses the GitHub secrets you configure (see below) to authenticate with AWS and spawn instances on-demand:
Required Secrets
Configure these secrets in your GitHub repository:Secret | Description | Example |
---|---|---|
AWS_ACCESS_KEY_ID | AWS access key | AKIAIOSFODNN7EXAMPLE |
AWS_REGION | AWS Region | us-east-2 |
AWS_SECRET_ACCESS_KEY | AWS secret key | wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
AWS_LAUNCH_TEMPLATE_ID | Launch template from CloudFormation | lt-07c53ce8349b958d1 |
AMI_ID | TestDriver AMI ID | ami-085f872ca0cd80fed |
TD_API_KEY | TestDriver API key | Your API key from the dashboard |
AMI Customization
Using the Base AMI
Our TestDriver Golden Image (AMI) comes pre-configured with everything you need to run tests: Operating System & Environment:- Windows Server with desktop environment
- VNC + web server for remote desktop access through the browser
- Python (with pip)
- Node.js (with npm)
- Git
- TestDriver agent and dependencies
- Optimized settings for test execution
- Pre-configured networking for TestDriver CLI communication
Modifying the AMI
You can customize the AMI for your specific needs:- Launch an instance from our base AMI
- Make your changes (install software, configure settings)
- Create a new AMI from your modified instance
- Update your workflow to use the new AMI ID
Amazon Image Builder
For automated AMI builds, use Amazon EC2 Image Builder:Security Considerations
Network Security
- Restrict CIDR blocks: Only allow access from your known IP ranges
- Use VPC endpoints: For private communication with AWS services
- Enable VPC Flow Logs: For network monitoring and debugging
AWS Authentication
Use OIDC for GitHub Actions instead of long-term credentials:Instance Security
- Terminate instances immediately after use
- Monitor costs with AWS billing alerts
- Use least-privilege IAM roles for instance profiles
- Enable CloudTrail for audit logging
Troubleshooting
Common Issues
Instance not responding in TestDriver CLI: When the CLI displays connection errors or timeouts, check:- Security group rules: The CloudFormation template configures all necessary ports (RDP 3389, VNC 5900, and TestDriver communication ports). Verify your security group hasn’t been modified.
- Instance status checks: Ensure the instance has passed both system and instance status checks in the AWS console.
- AMI compatibility: Verify the AMI is compatible with your selected instance type (some instance types don’t support certain AMIs).
- Verify network connectivity from runner to instance
- Check VPC routing and internet gateway configuration
- Confirm instance is in correct subnet
- Validate AWS credentials and permissions
- Check AWS service quotas and limits
- Verify region consistency across all resources
Getting Help
For enterprise customers:- Contact your account manager for AMI access issues
- Use support channels for infrastructure questions
- Check the TestDriver documentation for CLI usage