@dionlarson/playwright-orchestrator-pg 1.3.7 → 1.3.9
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/dist/postgresql-adapter.js +16 -6
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ export class PostgreSQLAdapter extends Adapter {
|
|
|
26
26
|
async getNextTest(runId, config) {
|
|
27
27
|
const client = await this.pool.connect();
|
|
28
28
|
try {
|
|
29
|
+
console.log(`[pg-adapter] getNextTest: BEGIN transaction`);
|
|
29
30
|
await client.query('BEGIN');
|
|
30
31
|
const result = await client.query({
|
|
31
32
|
text: `WITH next_test AS (
|
|
@@ -42,14 +43,17 @@ export class PostgreSQLAdapter extends Adapter {
|
|
|
42
43
|
RETURNING *`,
|
|
43
44
|
values: [runId, TestStatus.Ready, TestStatus.Ongoing],
|
|
44
45
|
});
|
|
46
|
+
console.log(`[pg-adapter] getNextTest: got ${result.rowCount} rows, order_num=${result.rows[0]?.order_num}`);
|
|
45
47
|
await client.query('COMMIT');
|
|
48
|
+
console.log(`[pg-adapter] getNextTest: COMMIT`);
|
|
46
49
|
if (result.rowCount === 0)
|
|
47
50
|
return undefined;
|
|
48
51
|
const { file, line, character, project, timeout, order_num } = result.rows[0];
|
|
49
52
|
return { file, position: `${line}:${character}`, project, timeout, order: order_num };
|
|
50
53
|
}
|
|
51
54
|
catch (e) {
|
|
52
|
-
|
|
55
|
+
console.log(`[pg-adapter] getNextTest: ERROR ${e}, rolling back`);
|
|
56
|
+
await client.query('ROLLBACK');
|
|
53
57
|
}
|
|
54
58
|
finally {
|
|
55
59
|
client.release();
|
|
@@ -227,22 +231,28 @@ export class PostgreSQLAdapter extends Adapter {
|
|
|
227
231
|
async updateTestWithResults(status, { runId, test, config, testResult }) {
|
|
228
232
|
const testId = this.getTestId({ ...test, ...testResult });
|
|
229
233
|
const { rows: [testInfo], } = await this.pool.query({
|
|
230
|
-
text: `SELECT
|
|
231
|
-
id,
|
|
234
|
+
text: `SELECT
|
|
235
|
+
id,
|
|
232
236
|
ema,
|
|
233
237
|
(
|
|
234
|
-
SELECT COUNT(*) FROM ${this.testInfoHistoryTable}
|
|
238
|
+
SELECT COUNT(*) FROM ${this.testInfoHistoryTable}
|
|
235
239
|
WHERE status = ${TestStatus.Failed} AND test_info_id = info.id
|
|
236
240
|
) AS fails,
|
|
237
241
|
(
|
|
238
|
-
SELECT updated FROM ${this.testInfoHistoryTable}
|
|
239
|
-
WHERE status = ${TestStatus.Passed} AND test_info_id = info.id
|
|
242
|
+
SELECT updated FROM ${this.testInfoHistoryTable}
|
|
243
|
+
WHERE status = ${TestStatus.Passed} AND test_info_id = info.id
|
|
240
244
|
ORDER BY updated DESC LIMIT 1
|
|
241
245
|
) AS last_successful_run
|
|
242
246
|
FROM ${this.testInfoTable} info
|
|
243
247
|
WHERE name = $1`,
|
|
244
248
|
values: [testId],
|
|
245
249
|
});
|
|
250
|
+
// Test not found in database - this shouldn't happen as saveTestRun should create it
|
|
251
|
+
// But handle gracefully to avoid crashes
|
|
252
|
+
if (!testInfo) {
|
|
253
|
+
console.warn(`[pg-adapter] Test not found in database: ${testId}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
246
256
|
const report = {
|
|
247
257
|
title: testResult.title,
|
|
248
258
|
status,
|