Skip to content

Commit ff2849d

Browse files
unify
1 parent 5a197c1 commit ff2849d

File tree

6 files changed

+48
-107
lines changed

6 files changed

+48
-107
lines changed

.github/workflows/pullrequest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
153153
# Run E2E tests against deployed worker
154154
- name: Run E2E tests
155-
run: npx vitest run --config vitest.e2e.shared.config.ts && npx vitest run --config vitest.e2e.isolated.config.ts
155+
run: npx vitest run --config vitest.e2e.config.ts
156156
env:
157157
TEST_WORKER_URL: ${{ steps.get-url.outputs.worker_url }}
158158
CI: true

packages/sandbox/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
"typecheck": "tsc --noEmit",
3737
"docker:local": "cd ../.. && docker build -f packages/sandbox/Dockerfile --target default --platform linux/amd64 --build-arg SANDBOX_VERSION=$npm_package_version -t cloudflare/sandbox-test:$npm_package_version . && docker build -f packages/sandbox/Dockerfile --target python --platform linux/amd64 --build-arg SANDBOX_VERSION=$npm_package_version -t cloudflare/sandbox-test:$npm_package_version-python .",
3838
"test": "vitest run --config vitest.config.ts \"$@\"",
39-
"test:e2e": "cd ../.. && vitest run --config vitest.e2e.shared.config.ts && vitest run --config vitest.e2e.isolated.config.ts",
40-
"test:e2e:shared": "cd ../.. && vitest run --config vitest.e2e.shared.config.ts \"$@\"",
41-
"test:e2e:isolated": "cd ../.. && vitest run --config vitest.e2e.isolated.config.ts \"$@\""
39+
"test:e2e": "cd ../.. && vitest run --config vitest.e2e.config.ts \"$@\""
4240
},
4341
"exports": {
4442
".": {

tests/e2e/bucket-mounting.test.ts

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
1+
import { beforeAll, describe, expect, test } from 'vitest';
22
import {
3-
cleanupSandbox,
4-
createSandboxId,
5-
createTestHeaders
6-
} from './helpers/test-fixtures';
7-
import {
8-
getTestWorkerUrl,
9-
type WranglerDevRunner
10-
} from './helpers/wrangler-runner';
3+
getSharedSandbox,
4+
createUniqueSession
5+
} from './helpers/global-sandbox';
116
import type { ExecResult } from '@repo/shared';
127
import type { SuccessResponse, BucketGetResponse } from './test-worker/types';
138

@@ -33,33 +28,19 @@ describe('Bucket Mounting E2E', () => {
3328
}
3429

3530
describe('local', () => {
36-
let runner: WranglerDevRunner | null;
3731
let workerUrl: string;
38-
let currentSandboxId: string | null = null;
32+
let headers: Record<string, string>;
3933

4034
const TEST_BUCKET = 'sandbox-e2e-test';
4135
const MOUNT_PATH = '/mnt/test-data';
4236
const TEST_FILE = `e2e-test-${Date.now()}.txt`;
4337
const TEST_CONTENT = `Bucket mounting E2E test - ${new Date().toISOString()}`;
4438

4539
beforeAll(async () => {
46-
const result = await getTestWorkerUrl();
47-
workerUrl = result.url;
48-
runner = result.runner;
49-
}, 30000);
50-
51-
afterEach(async () => {
52-
if (currentSandboxId) {
53-
await cleanupSandbox(workerUrl, currentSandboxId);
54-
currentSandboxId = null;
55-
}
56-
});
57-
58-
afterAll(async () => {
59-
if (runner) {
60-
await runner.stop();
61-
}
62-
});
40+
const sandbox = await getSharedSandbox();
41+
workerUrl = sandbox.workerUrl;
42+
headers = sandbox.createHeaders(createUniqueSession());
43+
}, 120000);
6344

6445
test('should mount bucket and perform bidirectional file operations', async () => {
6546
// Verify required credentials are present
@@ -76,9 +57,6 @@ describe('Bucket Mounting E2E', () => {
7657
);
7758
}
7859

79-
currentSandboxId = createSandboxId();
80-
const headers = createTestHeaders(currentSandboxId);
81-
8260
const PRE_EXISTING_FILE = `pre-existing-${Date.now()}.txt`;
8361
const PRE_EXISTING_CONTENT =
8462
'This file was created in R2 before mounting';

vitest.e2e.config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { config } from 'dotenv';
2+
import { defineConfig } from 'vitest/config';
3+
4+
config();
5+
6+
/**
7+
* E2E tests using shared sandbox - runs in parallel
8+
* Tests use unique sessions for isolation within one container.
9+
* Bucket-mounting tests self-skip locally (require FUSE/CI).
10+
*/
11+
export default defineConfig({
12+
test: {
13+
name: 'e2e',
14+
globals: true,
15+
environment: 'node',
16+
include: ['tests/e2e/**/*.test.ts'],
17+
18+
testTimeout: 120000,
19+
hookTimeout: 60000,
20+
teardownTimeout: 30000,
21+
22+
// Global setup creates sandbox BEFORE threads spawn, passes info through a tmp file
23+
globalSetup: ['tests/e2e/global-setup.ts'],
24+
25+
// Threads run in parallel - they all use the same sandbox through a tmp file
26+
pool: 'threads',
27+
poolOptions: {
28+
threads: {
29+
singleThread: false,
30+
isolate: false
31+
}
32+
},
33+
fileParallelism: true,
34+
35+
retry: 1
36+
}
37+
});

vitest.e2e.isolated.config.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

vitest.e2e.shared.config.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)