testdriverai 7.2.35 → 7.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/v7/aws-setup.mdx +155 -42
- package/package.json +1 -1
- package/setup/aws/cloudformation.yaml +8 -8
package/docs/v7/aws-setup.mdx
CHANGED
|
@@ -13,6 +13,18 @@ graph LR
|
|
|
13
13
|
B <--> C[Your AWS EC2 Instance]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
# Quickstart
|
|
17
|
+
|
|
18
|
+
<Card
|
|
19
|
+
title="Launch Stack"
|
|
20
|
+
icon="aws"
|
|
21
|
+
href="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://v7-cloudformation-template.s3.us-east-2.amazonaws.com/cloudformation.yaml"
|
|
22
|
+
horizontal
|
|
23
|
+
arrow
|
|
24
|
+
>
|
|
25
|
+
Deploy TestDriver infrastructure with one click
|
|
26
|
+
</Card>
|
|
27
|
+
|
|
16
28
|
## Overview
|
|
17
29
|
|
|
18
30
|
The setup process involves three main steps:
|
|
@@ -21,6 +33,7 @@ The setup process involves three main steps:
|
|
|
21
33
|
2. **On-Demand Instance Spawning** — Use `spawn-runner.sh` to launch TestDriver instances when you need to run tests
|
|
22
34
|
3. **CI/CD Integration** — Automate the lifecycle in GitHub Actions: spawn instance → run tests → terminate instance
|
|
23
35
|
|
|
36
|
+
|
|
24
37
|
## Prerequisites
|
|
25
38
|
|
|
26
39
|
Before you begin, ensure you have:
|
|
@@ -31,7 +44,7 @@ Before you begin, ensure you have:
|
|
|
31
44
|
- A GitHub repository for your tests
|
|
32
45
|
|
|
33
46
|
<Tip>
|
|
34
|
-
The TestDriver Golden Image AMI ID is `ami-
|
|
47
|
+
The TestDriver Golden Image AMI ID is `ami-0504bf50fad62f312`. Contact us to get access in your preferred AWS region.
|
|
35
48
|
</Tip>
|
|
36
49
|
|
|
37
50
|
## Step 1: Deploy CloudFormation Stack
|
|
@@ -43,57 +56,88 @@ Our CloudFormation template creates all the AWS infrastructure you need:
|
|
|
43
56
|
- IAM roles and instance profiles
|
|
44
57
|
- EC2 launch template for instance creation
|
|
45
58
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
<Tabs>
|
|
60
|
+
<Tab title="GUI">
|
|
61
|
+
Click the button below to launch the CloudFormation stack in your AWS Console:
|
|
62
|
+
|
|
63
|
+
<Card
|
|
64
|
+
title="Launch Stack"
|
|
65
|
+
icon="aws"
|
|
66
|
+
href="https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?templateURL=https://v7-cloudformation-template.s3.us-east-2.amazonaws.com/cloudformation.yaml"
|
|
67
|
+
horizontal
|
|
68
|
+
arrow
|
|
69
|
+
>
|
|
70
|
+
Deploy TestDriver infrastructure with one click
|
|
71
|
+
</Card>
|
|
72
|
+
|
|
73
|
+
Configure the stack parameters:
|
|
74
|
+
- **Stack name**: `testdriver-infrastructure` (or your preferred name)
|
|
75
|
+
- **ProjectTag**: `testdriver`
|
|
76
|
+
- **AllowedIngressCidr**: Your IP range (e.g., `203.0.113.0/24`)
|
|
77
|
+
- **InstanceType**: `c5.xlarge` (recommended)
|
|
78
|
+
- **CreateKeyPair**: `true`
|
|
79
|
+
|
|
80
|
+
<Warning>
|
|
81
|
+
**Security**: Replace `AllowedIngressCidr` with your specific IP ranges to restrict VPC access. Avoid using `0.0.0.0/0` in production.
|
|
82
|
+
</Warning>
|
|
83
|
+
|
|
84
|
+
### Get Your Launch Template ID
|
|
85
|
+
|
|
86
|
+
After the stack creation completes, navigate to the **Outputs** tab to find your `LaunchTemplateId`:
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
<Tip>
|
|
91
|
+
**Save this ID** — you'll need it for spawning instances and CI configuration.
|
|
92
|
+
</Tip>
|
|
93
|
+
</Tab>
|
|
94
|
+
<Tab title="CLI">
|
|
95
|
+
Download the template from the [TestDriver CLI repository](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/cloudformation.yaml), then deploy:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
aws cloudformation deploy \
|
|
99
|
+
--template-file setup/aws/cloudformation.yaml \
|
|
100
|
+
--stack-name testdriver-infrastructure \
|
|
101
|
+
--parameter-overrides \
|
|
102
|
+
ProjectTag=testdriver \
|
|
103
|
+
AllowedIngressCidr=0.0.0.0/0 \
|
|
104
|
+
InstanceType=c5.xlarge \
|
|
105
|
+
CreateKeyPair=true \
|
|
106
|
+
--capabilities CAPABILITY_IAM
|
|
107
|
+
```
|
|
59
108
|
|
|
60
|
-
<Warning>
|
|
61
|
-
|
|
62
|
-
</Warning>
|
|
109
|
+
<Warning>
|
|
110
|
+
**Security**: Replace `AllowedIngressCidr=0.0.0.0/0` with your specific IP ranges to restrict VPC access.
|
|
111
|
+
</Warning>
|
|
63
112
|
|
|
64
|
-
### Get Your Launch Template ID
|
|
113
|
+
### Get Your Launch Template ID
|
|
65
114
|
|
|
66
|
-
After deployment completes, retrieve the launch template ID:
|
|
115
|
+
After deployment completes, retrieve the launch template ID:
|
|
67
116
|
|
|
68
|
-
```bash
|
|
69
|
-
aws cloudformation describe-stacks \
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```
|
|
117
|
+
```bash
|
|
118
|
+
aws cloudformation describe-stacks \
|
|
119
|
+
--stack-name testdriver-infrastructure \
|
|
120
|
+
--query 'Stacks[0].Outputs[?OutputKey==`LaunchTemplateId`].OutputValue' \
|
|
121
|
+
--output text
|
|
122
|
+
```
|
|
74
123
|
|
|
75
|
-
<Tip>
|
|
76
|
-
|
|
77
|
-
</Tip>
|
|
124
|
+
<Tip>
|
|
125
|
+
**Save this ID** — you'll need it for spawning instances and CI configuration.
|
|
126
|
+
</Tip>
|
|
127
|
+
</Tab>
|
|
128
|
+
</Tabs>
|
|
78
129
|
|
|
79
130
|
## Step 2: Spawn Test Instances
|
|
80
131
|
|
|
81
|
-
Use the `spawn-runner.sh` script to launch instances on-demand. This script:
|
|
132
|
+
Use the [`spawn-runner.sh`](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/spawn-runner.sh) script to launch instances on-demand. This script:
|
|
82
133
|
|
|
83
134
|
- Launches a new EC2 instance using your launch template
|
|
84
135
|
- Waits for the instance to be ready
|
|
85
|
-
-
|
|
136
|
+
- Validates SSM connectivity
|
|
86
137
|
- Returns instance details for test execution
|
|
87
138
|
|
|
88
139
|
```bash
|
|
89
|
-
|
|
90
|
-
export AWS_REGION=us-east-2
|
|
91
|
-
export AMI_ID=ami-086b5b4b86d78987c
|
|
92
|
-
export AWS_LAUNCH_TEMPLATE_ID=lt-your-template-id
|
|
93
|
-
export RESOLUTION=1440x900 # Optional, default is 1440x900
|
|
94
|
-
|
|
95
|
-
# Spawn an instance
|
|
96
|
-
./setup/aws/spawn-runner.sh
|
|
140
|
+
AWS_REGION=us-east-2 AMI_ID=ami-0504bf50fad62f312 AWS_LAUNCH_TEMPLATE_ID=lt-your-template-id sh setup/aws/spawn-runner.sh
|
|
97
141
|
```
|
|
98
142
|
|
|
99
143
|
Output:
|
|
@@ -105,10 +149,28 @@ AWS_REGION=us-east-2
|
|
|
105
149
|
|
|
106
150
|
### Run Tests Against Your Instance
|
|
107
151
|
|
|
108
|
-
|
|
152
|
+
Specify the instance IP using the `TD_IP` environment variable:
|
|
109
153
|
|
|
110
154
|
```bash
|
|
111
|
-
TD_API_KEY=your-api-key
|
|
155
|
+
TD_API_KEY=your-api-key TD_IP=1.2.3.4 npx vitest run
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
In your test file, pass the IP to TestDriver:
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
import { describe, it } from "vitest";
|
|
162
|
+
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";
|
|
163
|
+
|
|
164
|
+
describe("My Test", () => {
|
|
165
|
+
it("should run on self-hosted instance", async (context) => {
|
|
166
|
+
const testdriver = TestDriver(context, {
|
|
167
|
+
ip: process.env.TD_IP,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
await testdriver.provision.chrome({ url: "https://example.com" });
|
|
171
|
+
// ... your test steps
|
|
172
|
+
});
|
|
173
|
+
});
|
|
112
174
|
```
|
|
113
175
|
|
|
114
176
|
### Terminate Instances
|
|
@@ -176,7 +238,7 @@ jobs:
|
|
|
176
238
|
run: npx vitest run
|
|
177
239
|
env:
|
|
178
240
|
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
179
|
-
|
|
241
|
+
TD_IP: ${{ steps.aws-setup.outputs.public-ip }}
|
|
180
242
|
|
|
181
243
|
- name: Shutdown AWS Instance
|
|
182
244
|
if: always()
|
|
@@ -198,9 +260,60 @@ jobs:
|
|
|
198
260
|
| `AWS_SECRET_ACCESS_KEY` | AWS secret key | `wJalrXUtnFEMI/K7MDENG...` |
|
|
199
261
|
| `AWS_REGION` | AWS region | `us-east-2` |
|
|
200
262
|
| `AWS_LAUNCH_TEMPLATE_ID` | From CloudFormation output | `lt-07c53ce8349b958d1` |
|
|
201
|
-
| `AMI_ID` | TestDriver AMI ID | `ami-
|
|
263
|
+
| `AMI_ID` | TestDriver AMI ID | `ami-0504bf50fad62f312` |
|
|
202
264
|
| `TD_API_KEY` | Your TestDriver API key | From [console.testdriver.ai](https://console.testdriver.ai) |
|
|
203
265
|
|
|
266
|
+
### Example Workflow
|
|
267
|
+
|
|
268
|
+
For a complete real-world example with matrix-based test execution and dynamic test file discovery, see the [`self-hosted.yml`](https://github.com/testdriverai/testdriverai/blob/main/setup/aws/self-hosted.yml) workflow in the TestDriver repository.
|
|
269
|
+
|
|
270
|
+
<Tip>
|
|
271
|
+
**Local Testing**: You can test your GitHub Actions workflow locally using [nektos/act](https://github.com/nektos/act). The `self-hosted.yml` workflow includes commented lines for installing the AWS CLI when running with `act`.
|
|
272
|
+
</Tip>
|
|
273
|
+
|
|
274
|
+
## Manual Instance Management
|
|
275
|
+
|
|
276
|
+
You can manage TestDriver instances manually through the AWS Console or CLI. This is useful for debugging, development, or running tests outside of CI/CD.
|
|
277
|
+
|
|
278
|
+
### Starting an Instance
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
aws ec2 run-instances \
|
|
282
|
+
--region us-east-2 \
|
|
283
|
+
--image-id ami-0504bf50fad62f312 \
|
|
284
|
+
--launch-template LaunchTemplateId=lt-your-template-id \
|
|
285
|
+
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=testdriver-manual}]'
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Stopping an Instance
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
aws ec2 stop-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Starting a Stopped Instance
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
aws ec2 start-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Terminating Instances
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
aws ec2 terminate-instances --region us-east-2 --instance-ids i-1234567890abcdef0
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Connecting to an Instance
|
|
307
|
+
|
|
308
|
+
You can connect to running instances via:
|
|
309
|
+
- **RDP** — Use the public IP on port 3389
|
|
310
|
+
- **VNC** — Access via web browser at `http://<public-ip>:5900`
|
|
311
|
+
- **AWS Console** — Use EC2 Instance Connect or Session Manager
|
|
312
|
+
|
|
313
|
+
<Note>
|
|
314
|
+
Stopped instances retain their EBS volumes and can be restarted later. Terminated instances are permanently deleted. Always terminate instances when done to avoid storage costs.
|
|
315
|
+
</Note>
|
|
316
|
+
|
|
204
317
|
## AMI Customization
|
|
205
318
|
|
|
206
319
|
The TestDriver Golden Image comes pre-configured with:
|
package/package.json
CHANGED
|
@@ -81,8 +81,8 @@ Parameters:
|
|
|
81
81
|
|
|
82
82
|
CreateKeyPair:
|
|
83
83
|
Type: String
|
|
84
|
-
AllowedValues: [yes, no]
|
|
85
|
-
Default: yes
|
|
84
|
+
AllowedValues: ["yes", "no"]
|
|
85
|
+
Default: "yes"
|
|
86
86
|
Description: Create a new key pair for instance access? (If 'no', you must provide an existing key name)
|
|
87
87
|
ExistingKeyName:
|
|
88
88
|
Type: String
|
|
@@ -168,15 +168,15 @@ Resources:
|
|
|
168
168
|
IpProtocol: tcp,
|
|
169
169
|
FromPort: 8765,
|
|
170
170
|
ToPort: 8765,
|
|
171
|
-
CidrIp:
|
|
172
|
-
Description: "pyautogui-cli WebSockets -
|
|
171
|
+
CidrIp: 0.0.0.0/0,
|
|
172
|
+
Description: "pyautogui-cli WebSockets - Open for testing",
|
|
173
173
|
}
|
|
174
174
|
- {
|
|
175
175
|
IpProtocol: tcp,
|
|
176
|
-
FromPort:
|
|
177
|
-
ToPort:
|
|
178
|
-
CidrIp:
|
|
179
|
-
Description: "
|
|
176
|
+
FromPort: 5800,
|
|
177
|
+
ToPort: 5800,
|
|
178
|
+
CidrIp: !Ref AllowedIngressCidr,
|
|
179
|
+
Description: "WebVNC 5800",
|
|
180
180
|
}
|
|
181
181
|
- {
|
|
182
182
|
IpProtocol: tcp,
|