testdriverai 7.2.35 → 7.2.37
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/interfaces/cli/lib/base.js +23 -7
- package/interfaces/vitest-plugin.mjs +138 -40
- 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:
|
|
@@ -144,19 +144,35 @@ class BaseCommand extends Command {
|
|
|
144
144
|
});
|
|
145
145
|
|
|
146
146
|
// Handle process signals to ensure clean disconnection
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
let isExiting = false;
|
|
148
|
+
const cleanupAndExit = async (signal) => {
|
|
149
|
+
if (isExiting) return;
|
|
150
|
+
isExiting = true;
|
|
151
|
+
|
|
152
|
+
console.log(`\nReceived ${signal}, cleaning up...`);
|
|
153
|
+
|
|
154
|
+
// Use the agent's exit method for proper cleanup
|
|
155
|
+
if (this.agent) {
|
|
149
156
|
try {
|
|
150
|
-
this.agent.
|
|
157
|
+
await this.agent.exit(true, false, false);
|
|
151
158
|
} catch (err) {
|
|
152
|
-
|
|
159
|
+
console.error("Error during cleanup:", err.message);
|
|
153
160
|
}
|
|
161
|
+
} else {
|
|
162
|
+
// Fallback if no agent
|
|
163
|
+
if (this.agent?.sandbox) {
|
|
164
|
+
try {
|
|
165
|
+
this.agent.sandbox.close();
|
|
166
|
+
} catch (err) {
|
|
167
|
+
// Ignore close errors
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
process.exit(1);
|
|
154
171
|
}
|
|
155
|
-
process.exit(1);
|
|
156
172
|
};
|
|
157
173
|
|
|
158
|
-
process.on('SIGINT', cleanupAndExit);
|
|
159
|
-
process.on('SIGTERM', cleanupAndExit);
|
|
174
|
+
process.on('SIGINT', () => cleanupAndExit('SIGINT'));
|
|
175
|
+
process.on('SIGTERM', () => cleanupAndExit('SIGTERM'));
|
|
160
176
|
|
|
161
177
|
// Handle unhandled promise rejections to prevent them from interfering with the exit flow
|
|
162
178
|
// This is particularly important when JavaScript execution in VM contexts leaves dangling promises
|
|
@@ -383,11 +383,23 @@ export async function cleanupTestDriver(testdriver) {
|
|
|
383
383
|
* Handle process termination and mark test run as cancelled
|
|
384
384
|
*/
|
|
385
385
|
async function handleProcessExit() {
|
|
386
|
+
logger.debug("handleProcessExit called");
|
|
387
|
+
logger.debug("testRun:", !!pluginState.testRun);
|
|
388
|
+
logger.debug("testRunId:", pluginState.testRunId);
|
|
389
|
+
logger.debug("testRunCompleted:", pluginState.testRunCompleted);
|
|
390
|
+
|
|
386
391
|
if (!pluginState.testRun || !pluginState.testRunId) {
|
|
392
|
+
logger.debug("No test run to cancel - skipping cleanup");
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Prevent duplicate completion
|
|
397
|
+
if (pluginState.testRunCompleted) {
|
|
398
|
+
logger.debug("Test run already completed - skipping cancellation");
|
|
387
399
|
return;
|
|
388
400
|
}
|
|
389
401
|
|
|
390
|
-
logger.debug("
|
|
402
|
+
logger.debug("Marking test run as cancelled...");
|
|
391
403
|
|
|
392
404
|
try {
|
|
393
405
|
const stats = {
|
|
@@ -413,8 +425,10 @@ async function handleProcessExit() {
|
|
|
413
425
|
completeData.platform = platform;
|
|
414
426
|
}
|
|
415
427
|
|
|
428
|
+
logger.debug("Calling completeTestRun with:", JSON.stringify(completeData));
|
|
416
429
|
await completeTestRun(completeData);
|
|
417
|
-
|
|
430
|
+
pluginState.testRunCompleted = true;
|
|
431
|
+
logger.info("Test run marked as cancelled");
|
|
418
432
|
} catch (error) {
|
|
419
433
|
logger.error("Failed to mark test run as cancelled:", error.message);
|
|
420
434
|
}
|
|
@@ -422,21 +436,77 @@ async function handleProcessExit() {
|
|
|
422
436
|
|
|
423
437
|
// Set up process exit handlers
|
|
424
438
|
let exitHandlersRegistered = false;
|
|
439
|
+
let isExiting = false;
|
|
440
|
+
let isCancelling = false; // Track if we're in the process of cancelling due to SIGINT/SIGTERM
|
|
425
441
|
|
|
426
442
|
function registerExitHandlers() {
|
|
427
443
|
if (exitHandlersRegistered) return;
|
|
428
444
|
exitHandlersRegistered = true;
|
|
429
445
|
|
|
430
|
-
// Handle Ctrl+C
|
|
431
|
-
process.
|
|
432
|
-
|
|
433
|
-
|
|
446
|
+
// Handle Ctrl+C - use 'once' and prepend to run before Vitest's handler
|
|
447
|
+
process.prependOnceListener("SIGINT", () => {
|
|
448
|
+
logger.debug("SIGINT received, cleaning up...");
|
|
449
|
+
if (isExiting) {
|
|
450
|
+
logger.debug("Already exiting, skipping duplicate handler");
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
isExiting = true;
|
|
454
|
+
isCancelling = true; // Mark that we're cancelling
|
|
455
|
+
|
|
456
|
+
// Temporarily override process.exit to prevent Vitest from exiting before we're done
|
|
457
|
+
const originalExit = process.exit;
|
|
458
|
+
let exitCalled = false;
|
|
459
|
+
let exitCode = 130;
|
|
460
|
+
|
|
461
|
+
process.exit = (code) => {
|
|
462
|
+
if (!exitCalled) {
|
|
463
|
+
exitCalled = true;
|
|
464
|
+
exitCode = code ?? 130;
|
|
465
|
+
logger.debug(`process.exit(${exitCode}) called, waiting for cleanup...`);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
handleProcessExit()
|
|
470
|
+
.then(() => {
|
|
471
|
+
logger.debug("Cleanup completed successfully");
|
|
472
|
+
})
|
|
473
|
+
.catch((err) => {
|
|
474
|
+
logger.error("Error during SIGINT cleanup:", err.message);
|
|
475
|
+
})
|
|
476
|
+
.finally(() => {
|
|
477
|
+
logger.debug(`Exiting with code ${exitCode}`);
|
|
478
|
+
// Restore and call original exit
|
|
479
|
+
process.exit = originalExit;
|
|
480
|
+
process.exit(exitCode);
|
|
481
|
+
});
|
|
434
482
|
});
|
|
435
483
|
|
|
436
484
|
// Handle kill command
|
|
437
|
-
process.
|
|
438
|
-
|
|
439
|
-
|
|
485
|
+
process.prependOnceListener("SIGTERM", () => {
|
|
486
|
+
logger.debug("SIGTERM received, cleaning up...");
|
|
487
|
+
if (isExiting) return;
|
|
488
|
+
isExiting = true;
|
|
489
|
+
isCancelling = true;
|
|
490
|
+
|
|
491
|
+
const originalExit = process.exit;
|
|
492
|
+
let exitCode = 143;
|
|
493
|
+
|
|
494
|
+
process.exit = (code) => {
|
|
495
|
+
exitCode = code ?? 143;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
handleProcessExit()
|
|
499
|
+
.then(() => {
|
|
500
|
+
logger.debug("Cleanup completed successfully");
|
|
501
|
+
})
|
|
502
|
+
.catch((err) => {
|
|
503
|
+
logger.error("Error during SIGTERM cleanup:", err.message);
|
|
504
|
+
})
|
|
505
|
+
.finally(() => {
|
|
506
|
+
logger.debug(`Exiting with code ${exitCode}`);
|
|
507
|
+
process.exit = originalExit;
|
|
508
|
+
process.exit(exitCode);
|
|
509
|
+
});
|
|
440
510
|
});
|
|
441
511
|
|
|
442
512
|
}
|
|
@@ -512,9 +582,9 @@ class TestDriverReporter {
|
|
|
512
582
|
}
|
|
513
583
|
|
|
514
584
|
async initializeTestRun() {
|
|
515
|
-
logger.debug("
|
|
516
|
-
logger.debug("
|
|
517
|
-
logger.debug("
|
|
585
|
+
logger.debug("initializeTestRun called");
|
|
586
|
+
logger.debug("API key present:", !!pluginState.apiKey);
|
|
587
|
+
logger.debug("API root:", pluginState.apiRoot);
|
|
518
588
|
|
|
519
589
|
// Check if we should enable the reporter
|
|
520
590
|
if (!pluginState.apiKey) {
|
|
@@ -552,9 +622,9 @@ class TestDriverReporter {
|
|
|
552
622
|
// Default to linux if no tests write platform info
|
|
553
623
|
testRunData.platform = "linux";
|
|
554
624
|
|
|
555
|
-
logger.debug("Creating test run with data:", testRunData);
|
|
625
|
+
logger.debug("Creating test run with data:", JSON.stringify(testRunData));
|
|
556
626
|
pluginState.testRun = await createTestRun(testRunData);
|
|
557
|
-
logger.debug("Test run created
|
|
627
|
+
logger.debug("Test run created:", JSON.stringify(pluginState.testRun));
|
|
558
628
|
|
|
559
629
|
// Store in environment variables for worker processes to access
|
|
560
630
|
process.env.TD_TEST_RUN_ID = pluginState.testRunId;
|
|
@@ -571,7 +641,7 @@ class TestDriverReporter {
|
|
|
571
641
|
startTime: pluginState.startTime,
|
|
572
642
|
});
|
|
573
643
|
|
|
574
|
-
logger.
|
|
644
|
+
logger.info(`Test run created: ${pluginState.testRunId}`);
|
|
575
645
|
} catch (error) {
|
|
576
646
|
logger.error("Failed to initialize:", error.message);
|
|
577
647
|
pluginState.apiKey = null;
|
|
@@ -580,8 +650,24 @@ class TestDriverReporter {
|
|
|
580
650
|
}
|
|
581
651
|
|
|
582
652
|
async onTestRunEnd(testModules, unhandledErrors, reason) {
|
|
583
|
-
logger.debug("
|
|
584
|
-
logger.debug("
|
|
653
|
+
logger.debug("onTestRunEnd called with reason:", reason);
|
|
654
|
+
logger.debug("API key present:", !!pluginState.apiKey);
|
|
655
|
+
logger.debug("Test run present:", !!pluginState.testRun);
|
|
656
|
+
logger.debug("Test run ID:", pluginState.testRunId);
|
|
657
|
+
logger.debug("isCancelling:", isCancelling);
|
|
658
|
+
logger.debug("testRunCompleted:", pluginState.testRunCompleted);
|
|
659
|
+
|
|
660
|
+
// If we're cancelling due to SIGINT/SIGTERM, skip - handleProcessExit will handle it
|
|
661
|
+
if (isCancelling) {
|
|
662
|
+
logger.debug("Cancellation in progress via signal handler, skipping onTestRunEnd");
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// If already completed (by handleProcessExit), skip
|
|
667
|
+
if (pluginState.testRunCompleted) {
|
|
668
|
+
logger.debug("Test run already completed, skipping");
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
585
671
|
|
|
586
672
|
if (!pluginState.apiKey) {
|
|
587
673
|
logger.warn("Skipping completion - no API key (was it cleared after init failure?)");
|
|
@@ -644,10 +730,11 @@ class TestDriverReporter {
|
|
|
644
730
|
}
|
|
645
731
|
|
|
646
732
|
// Test cases are reported directly from teardownTest
|
|
647
|
-
logger.debug("
|
|
733
|
+
logger.debug("Calling completeTestRun API...");
|
|
734
|
+
logger.debug("Complete data:", JSON.stringify(completeData));
|
|
648
735
|
|
|
649
736
|
const completeResponse = await completeTestRun(completeData);
|
|
650
|
-
logger.debug("
|
|
737
|
+
logger.debug("API response:", JSON.stringify(completeResponse));
|
|
651
738
|
|
|
652
739
|
// Mark test run as completed to prevent duplicate completion
|
|
653
740
|
pluginState.testRunCompleted = true;
|
|
@@ -657,7 +744,7 @@ class TestDriverReporter {
|
|
|
657
744
|
const consoleUrl = getConsoleUrl(pluginState.apiRoot);
|
|
658
745
|
if (testRunDbId) {
|
|
659
746
|
const testRunUrl = `${consoleUrl}/runs/${testRunDbId}`;
|
|
660
|
-
logger.
|
|
747
|
+
logger.info(`View test run: ${testRunUrl}`);
|
|
661
748
|
// Output in a parseable format for CI
|
|
662
749
|
console.log(`TESTDRIVER_RUN_URL=${testRunUrl}`);
|
|
663
750
|
|
|
@@ -665,7 +752,7 @@ class TestDriverReporter {
|
|
|
665
752
|
await postGitHubCommentIfEnabled(testRunUrl, stats, completeData);
|
|
666
753
|
}
|
|
667
754
|
|
|
668
|
-
logger.
|
|
755
|
+
logger.info(`Test run completed: ${stats.passedTests}/${stats.totalTests} passed`);
|
|
669
756
|
} catch (error) {
|
|
670
757
|
logger.error("Failed to complete test run:", error.message);
|
|
671
758
|
logger.debug("Error stack:", error.stack);
|
|
@@ -1134,27 +1221,38 @@ async function createTestRun(data) {
|
|
|
1134
1221
|
|
|
1135
1222
|
async function completeTestRun(data) {
|
|
1136
1223
|
const url = `${pluginState.apiRoot}/api/v1/testdriver/test-run-complete`;
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
const errorText = await response.text();
|
|
1152
|
-
throw new Error(
|
|
1153
|
-
`API error: ${response.status} ${response.statusText} - ${errorText}`,
|
|
1224
|
+
logger.debug(`completeTestRun: POSTing to ${url}`);
|
|
1225
|
+
|
|
1226
|
+
try {
|
|
1227
|
+
const response = await withTimeout(
|
|
1228
|
+
fetch(url, {
|
|
1229
|
+
method: "POST",
|
|
1230
|
+
headers: {
|
|
1231
|
+
"Content-Type": "application/json",
|
|
1232
|
+
Authorization: `Bearer ${pluginState.token}`,
|
|
1233
|
+
},
|
|
1234
|
+
body: JSON.stringify(data),
|
|
1235
|
+
}),
|
|
1236
|
+
10000,
|
|
1237
|
+
"Internal Complete Test Run",
|
|
1154
1238
|
);
|
|
1155
|
-
}
|
|
1156
1239
|
|
|
1157
|
-
|
|
1240
|
+
logger.debug(`completeTestRun: Response status ${response.status}`);
|
|
1241
|
+
|
|
1242
|
+
if (!response.ok) {
|
|
1243
|
+
const errorText = await response.text();
|
|
1244
|
+
throw new Error(
|
|
1245
|
+
`API error: ${response.status} ${response.statusText} - ${errorText}`,
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const result = await response.json();
|
|
1250
|
+
logger.debug(`completeTestRun: Success`);
|
|
1251
|
+
return result;
|
|
1252
|
+
} catch (error) {
|
|
1253
|
+
logger.error(`completeTestRun: Error - ${error.message}`);
|
|
1254
|
+
throw error;
|
|
1255
|
+
}
|
|
1158
1256
|
}
|
|
1159
1257
|
|
|
1160
1258
|
// Global state setup moved to setup file (vitestSetup.mjs)
|
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,
|