fix(e2e): use dedicated port 9750 for tauri-driver (avoid conflicts)
- tauri-driver spawned with --port 9750 (was default 4444) - Pre-check: fail fast if port already in use (clear error message) - TCP readiness probe uses the dedicated port - Follows project port convention (9000-9999 range)
This commit is contained in:
parent
91a3b56dba
commit
ae321ad108
2 changed files with 47 additions and 33 deletions
|
|
@ -22,7 +22,7 @@ xvfb-run --auto-servernum npm run test:e2e
|
||||||
|
|
||||||
| Tool | Required | Install |
|
| Tool | Required | Install |
|
||||||
|------|----------|---------|
|
|------|----------|---------|
|
||||||
| tauri-driver | Yes | `cargo install tauri-driver` |
|
| tauri-driver | Yes | `cargo install tauri-driver` (runs on port 9750) |
|
||||||
| Debug binary | Yes | `cargo tauri build --debug --no-bundle` |
|
| Debug binary | Yes | `cargo tauri build --debug --no-bundle` |
|
||||||
| X11/Wayland | Yes (Linux) | Use `xvfb-run` in CI |
|
| X11/Wayland | Yes (Linux) | Use `xvfb-run` in CI |
|
||||||
| Claude CLI | Optional | LLM-judged tests skip if absent |
|
| Claude CLI | Optional | LLM-judged tests skip if absent |
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ process.env.AGOR_TEST = '1';
|
||||||
process.env.AGOR_TEST_DATA_DIR = fixture.dataDir;
|
process.env.AGOR_TEST_DATA_DIR = fixture.dataDir;
|
||||||
process.env.AGOR_TEST_CONFIG_DIR = fixture.configDir;
|
process.env.AGOR_TEST_CONFIG_DIR = fixture.configDir;
|
||||||
|
|
||||||
|
// ── Port ──
|
||||||
|
// Unique port for this project's tauri-driver (avoids conflict with other
|
||||||
|
// Tauri apps or WebDriver instances on the same machine).
|
||||||
|
// Range 9000-9999 per project convention. See CLAUDE.md port table.
|
||||||
|
const TAURI_DRIVER_PORT = 9750;
|
||||||
|
|
||||||
console.log(`Test fixture created at ${fixture.rootDir}`);
|
console.log(`Test fixture created at ${fixture.rootDir}`);
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
|
@ -31,9 +37,9 @@ export const config = {
|
||||||
runner: 'local',
|
runner: 'local',
|
||||||
maxInstances: 1, // Tauri doesn't support parallel sessions
|
maxInstances: 1, // Tauri doesn't support parallel sessions
|
||||||
|
|
||||||
// ── Connection (external tauri-driver on port 4444) ──
|
// ── Connection (tauri-driver on dedicated port) ──
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
port: 4444,
|
port: TAURI_DRIVER_PORT,
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|
||||||
// ── Specs ──
|
// ── Specs ──
|
||||||
|
|
@ -120,13 +126,24 @@ export const config = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn tauri-driver before the session.
|
* Spawn tauri-driver on a dedicated port before the session.
|
||||||
* tauri-driver bridges WebDriver protocol to WebKit2GTK's inspector.
|
* First checks that the port is free (fails fast if another instance is running).
|
||||||
* Uses TCP probe to confirm port 4444 is accepting connections.
|
* Uses TCP probe to confirm readiness after spawn.
|
||||||
*/
|
*/
|
||||||
beforeSession() {
|
beforeSession() {
|
||||||
return new Promise((res, reject) => {
|
return new Promise((res, reject) => {
|
||||||
tauriDriver = spawn('tauri-driver', [], {
|
// Fail fast if port is already in use (another tauri-driver or stale process)
|
||||||
|
const preCheck = createConnection({ port: TAURI_DRIVER_PORT, host: 'localhost' }, () => {
|
||||||
|
preCheck.destroy();
|
||||||
|
reject(new Error(
|
||||||
|
`Port ${TAURI_DRIVER_PORT} already in use. Kill the existing process: ` +
|
||||||
|
`lsof -ti:${TAURI_DRIVER_PORT} | xargs kill`
|
||||||
|
));
|
||||||
|
});
|
||||||
|
preCheck.on('error', () => {
|
||||||
|
preCheck.destroy();
|
||||||
|
// Port is free — spawn tauri-driver
|
||||||
|
tauriDriver = spawn('tauri-driver', ['--port', String(TAURI_DRIVER_PORT)], {
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -137,29 +154,26 @@ export const config = {
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
// TCP readiness probe — poll port 4444 until it accepts a connection
|
// TCP readiness probe — poll until port accepts connections
|
||||||
const maxWaitMs = 10_000;
|
const deadline = Date.now() + 10_000;
|
||||||
const intervalMs = 200;
|
|
||||||
const deadline = Date.now() + maxWaitMs;
|
|
||||||
|
|
||||||
function probe() {
|
function probe() {
|
||||||
if (Date.now() > deadline) {
|
if (Date.now() > deadline) {
|
||||||
reject(new Error('tauri-driver did not become ready within 10s'));
|
reject(new Error(`tauri-driver did not become ready on port ${TAURI_DRIVER_PORT} within 10s`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sock = createConnection({ port: 4444, host: 'localhost' }, () => {
|
const sock = createConnection({ port: TAURI_DRIVER_PORT, host: 'localhost' }, () => {
|
||||||
sock.destroy();
|
sock.destroy();
|
||||||
|
console.log(`tauri-driver ready on port ${TAURI_DRIVER_PORT}`);
|
||||||
res();
|
res();
|
||||||
});
|
});
|
||||||
sock.on('error', () => {
|
sock.on('error', () => {
|
||||||
sock.destroy();
|
sock.destroy();
|
||||||
setTimeout(probe, intervalMs);
|
setTimeout(probe, 200);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give it a moment before first probe
|
|
||||||
setTimeout(probe, 300);
|
setTimeout(probe, 300);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue