@playwright-orchestrator/pg 1.4.3 → 1.5.0
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.
|
@@ -13,4 +13,8 @@ export declare class PgShardHandler implements ShardHandler {
|
|
|
13
13
|
private claimNextTest;
|
|
14
14
|
startShard(): Promise<TestRunConfig>;
|
|
15
15
|
finishShard(): Promise<void>;
|
|
16
|
+
getRemainingCounters(_config: TestRunConfig): Promise<{
|
|
17
|
+
remainingCount: number;
|
|
18
|
+
remainingTime: number;
|
|
19
|
+
}>;
|
|
16
20
|
}
|
package/dist/pg-shard-handler.js
CHANGED
|
@@ -57,10 +57,20 @@ let PgShardHandler = class PgShardHandler {
|
|
|
57
57
|
RETURNING *`,
|
|
58
58
|
values,
|
|
59
59
|
});
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (result.rowCount === 0) {
|
|
61
|
+
await client.query('COMMIT');
|
|
62
62
|
return undefined;
|
|
63
|
+
}
|
|
63
64
|
const { file, line, character, projects, timeout, ema, order_num, children, test_id } = result.rows[0];
|
|
65
|
+
await client.query({
|
|
66
|
+
text: `UPDATE ${this.configTable}
|
|
67
|
+
SET config = jsonb_set(jsonb_set(config,
|
|
68
|
+
'{remainingCount}', ((config->>'remainingCount')::bigint - 1)::text::jsonb),
|
|
69
|
+
'{remainingTime}', ((config->>'remainingTime')::float - $2)::text::jsonb)
|
|
70
|
+
WHERE id = $1`,
|
|
71
|
+
values: [runId, ema],
|
|
72
|
+
});
|
|
73
|
+
await client.query('COMMIT');
|
|
64
74
|
return {
|
|
65
75
|
file,
|
|
66
76
|
position: `${line}:${character}`,
|
|
@@ -110,6 +120,16 @@ let PgShardHandler = class PgShardHandler {
|
|
|
110
120
|
WHERE id = $1;`,
|
|
111
121
|
values: [runId, RunStatus.Created],
|
|
112
122
|
});
|
|
123
|
+
if (statusBefore === RunStatus.Finished) {
|
|
124
|
+
await client.query({
|
|
125
|
+
text: `UPDATE ${this.configTable}
|
|
126
|
+
SET config = jsonb_set(jsonb_set(config,
|
|
127
|
+
'{remainingCount}', (SELECT COUNT(*) FROM ${this.testsTable} WHERE run_id = $1 AND status = ${TestStatus.Ready})::text::jsonb),
|
|
128
|
+
'{remainingTime}', (SELECT COALESCE(SUM(ema), 0) FROM ${this.testsTable} WHERE run_id = $1 AND status = ${TestStatus.Ready})::text::jsonb)
|
|
129
|
+
WHERE id = $1`,
|
|
130
|
+
values: [runId],
|
|
131
|
+
});
|
|
132
|
+
}
|
|
113
133
|
}
|
|
114
134
|
await client.query({
|
|
115
135
|
text: `UPDATE ${this.configTable}
|
|
@@ -140,6 +160,20 @@ let PgShardHandler = class PgShardHandler {
|
|
|
140
160
|
shards = jsonb_set(shards, $3, to_jsonb((EXTRACT(EPOCH FROM NOW()) * 1000)::bigint))
|
|
141
161
|
WHERE id = $1 AND shards #>> $3::text[] IS NULL;`, [runId, RunStatus.Finished, `{${shardId},finished}`]);
|
|
142
162
|
}
|
|
163
|
+
async getRemainingCounters(_config) {
|
|
164
|
+
const { runId } = this.runContext;
|
|
165
|
+
const result = await this.pool.query({
|
|
166
|
+
text: `SELECT config->>'remainingCount' AS remaining_count, config->>'remainingTime' AS remaining_time FROM ${this.configTable} WHERE id = $1`,
|
|
167
|
+
values: [runId],
|
|
168
|
+
});
|
|
169
|
+
if (result.rowCount === 0)
|
|
170
|
+
return { remainingCount: 0, remainingTime: 0 };
|
|
171
|
+
const { remaining_count, remaining_time } = result.rows[0];
|
|
172
|
+
return {
|
|
173
|
+
remainingCount: Math.max(0, Number(remaining_count ?? 0)),
|
|
174
|
+
remainingTime: Math.max(0, Number(remaining_time ?? 0)),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
143
177
|
};
|
|
144
178
|
PgShardHandler = __decorate([
|
|
145
179
|
injectable(),
|
|
@@ -73,6 +73,8 @@ let PgTestRunCreator = class PgTestRunCreator extends BaseTestRunCreator {
|
|
|
73
73
|
const client = await this.pool.connect();
|
|
74
74
|
try {
|
|
75
75
|
await client.query('BEGIN');
|
|
76
|
+
run.config.remainingCount = tests.length;
|
|
77
|
+
run.config.remainingTime = tests.reduce((sum, t) => sum + t.ema, 0);
|
|
76
78
|
await client.query({
|
|
77
79
|
text: `INSERT INTO ${this.configTable} (id, status, config, shards) VALUES ($1, $2, $3, '{}')`,
|
|
78
80
|
values: [runId, RunStatus.Created, JSON.stringify(run.config)],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright-orchestrator/pg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "Rostyslav Kudrevatykh",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"commander": "^13.0.0",
|
|
18
18
|
"inversify": "^8.0.0-beta.0",
|
|
19
19
|
"pg": "^8.13.1",
|
|
20
|
-
"@playwright-orchestrator/core": "1.
|
|
20
|
+
"@playwright-orchestrator/core": "1.5.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/pg": "^8.11.0"
|