@playwright-orchestrator/mongo 1.3.4 → 1.4.1
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/mongo-db-adapter.js
CHANGED
|
@@ -33,13 +33,14 @@ let MongoDbAdapter = class MongoDbAdapter extends BaseAdapter {
|
|
|
33
33
|
if (!run) {
|
|
34
34
|
throw new Error(`Run ${runId} not found`);
|
|
35
35
|
}
|
|
36
|
-
const config = run
|
|
36
|
+
const { config, shards } = run;
|
|
37
37
|
const tests = await this.tests
|
|
38
38
|
.find(this.generateTestIdQuery(runId, TestStatus.Failed, TestStatus.Passed))
|
|
39
39
|
.toArray();
|
|
40
40
|
return {
|
|
41
41
|
runId,
|
|
42
42
|
config,
|
|
43
|
+
shards,
|
|
43
44
|
tests: tests.map(({ file, line, column, status, report, projects }) => {
|
|
44
45
|
const position = `${line}:${column}`;
|
|
45
46
|
const { duration, fails, title, lastSuccessfulRun, ema } = report;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type { ShardHandler } from '@playwright-orchestrator/core';
|
|
1
|
+
import type { ShardHandler, TestRunContext } from '@playwright-orchestrator/core';
|
|
2
2
|
import type { TestItem, TestRunConfig } from '@playwright-orchestrator/core';
|
|
3
3
|
import type { CreateArgs } from './create-args.js';
|
|
4
4
|
import { MongoConnection } from './mongo-connection.js';
|
|
5
5
|
export declare class MongoShardHandler implements ShardHandler {
|
|
6
|
+
private readonly runContext;
|
|
6
7
|
private readonly runsCollection;
|
|
7
8
|
private readonly testsCollection;
|
|
8
9
|
private readonly connection;
|
|
9
|
-
constructor({ collectionNamePrefix }: CreateArgs, connection: MongoConnection);
|
|
10
|
-
getNextTest(
|
|
11
|
-
getNextTestByProject(
|
|
10
|
+
constructor({ collectionNamePrefix }: CreateArgs, connection: MongoConnection, runContext: TestRunContext);
|
|
11
|
+
getNextTest(_config: TestRunConfig): Promise<TestItem | undefined>;
|
|
12
|
+
getNextTestByProject(project: string): Promise<TestItem | undefined>;
|
|
12
13
|
private claimNextTest;
|
|
13
|
-
startShard(
|
|
14
|
-
finishShard(
|
|
14
|
+
startShard(): Promise<TestRunConfig>;
|
|
15
|
+
finishShard(): Promise<void>;
|
|
15
16
|
private get runs();
|
|
16
17
|
private get tests();
|
|
17
18
|
private generateTestIdQuery;
|
|
@@ -11,25 +11,27 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
import { injectable, inject } from 'inversify';
|
|
14
|
-
import { RunStatus, TestStatus } from '@playwright-orchestrator/core';
|
|
14
|
+
import { RunStatus, SYMBOLS, TestStatus } from '@playwright-orchestrator/core';
|
|
15
15
|
import { MongoConnection } from './mongo-connection.js';
|
|
16
16
|
import { MONGO_CONFIG, MONGO_CONNECTION } from './symbols.js';
|
|
17
17
|
import { generateTestId, generateRunId, parseTestId } from './helpers.js';
|
|
18
18
|
const MAX_ORDER = 0b1111111111111111;
|
|
19
19
|
let MongoShardHandler = class MongoShardHandler {
|
|
20
|
+
runContext;
|
|
20
21
|
runsCollection;
|
|
21
22
|
testsCollection;
|
|
22
23
|
connection;
|
|
23
|
-
constructor({ collectionNamePrefix }, connection) {
|
|
24
|
+
constructor({ collectionNamePrefix }, connection, runContext) {
|
|
25
|
+
this.runContext = runContext;
|
|
24
26
|
this.connection = connection;
|
|
25
27
|
this.runsCollection = `${collectionNamePrefix}_test_runs`;
|
|
26
28
|
this.testsCollection = `${collectionNamePrefix}_tests`;
|
|
27
29
|
}
|
|
28
|
-
async getNextTest(
|
|
29
|
-
return this.claimNextTest(runId);
|
|
30
|
+
async getNextTest(_config) {
|
|
31
|
+
return this.claimNextTest(this.runContext.runId);
|
|
30
32
|
}
|
|
31
|
-
async getNextTestByProject(
|
|
32
|
-
return this.claimNextTest(runId, project);
|
|
33
|
+
async getNextTestByProject(project) {
|
|
34
|
+
return this.claimNextTest(this.runContext.runId, project);
|
|
33
35
|
}
|
|
34
36
|
async claimNextTest(runId, project) {
|
|
35
37
|
const query = project
|
|
@@ -44,8 +46,10 @@ let MongoShardHandler = class MongoShardHandler {
|
|
|
44
46
|
const { order } = parseTestId(result._id);
|
|
45
47
|
return { file, position: `${line}:${column}`, projects, timeout, ema, order, children, testId };
|
|
46
48
|
}
|
|
47
|
-
async startShard(
|
|
49
|
+
async startShard() {
|
|
50
|
+
const { runId, shardId } = this.runContext;
|
|
48
51
|
const now = new Date();
|
|
52
|
+
const nowMs = now.getTime();
|
|
49
53
|
const run = await this.runs.findOneAndUpdate({ _id: generateRunId(runId) }, [
|
|
50
54
|
{
|
|
51
55
|
$set: {
|
|
@@ -56,6 +60,9 @@ let MongoShardHandler = class MongoShardHandler {
|
|
|
56
60
|
else: RunStatus.RepeatRun,
|
|
57
61
|
},
|
|
58
62
|
},
|
|
63
|
+
[`shards.${shardId}`]: {
|
|
64
|
+
$ifNull: [`$shards.${shardId}`, { shardId, started: nowMs }],
|
|
65
|
+
},
|
|
59
66
|
updated: now,
|
|
60
67
|
},
|
|
61
68
|
},
|
|
@@ -70,8 +77,21 @@ let MongoShardHandler = class MongoShardHandler {
|
|
|
70
77
|
}
|
|
71
78
|
return run.config;
|
|
72
79
|
}
|
|
73
|
-
async finishShard(
|
|
74
|
-
|
|
80
|
+
async finishShard() {
|
|
81
|
+
const { runId, shardId } = this.runContext;
|
|
82
|
+
const now = new Date();
|
|
83
|
+
const nowMs = now.getTime();
|
|
84
|
+
await this.runs.updateOne({ _id: generateRunId(runId) }, [
|
|
85
|
+
{
|
|
86
|
+
$set: {
|
|
87
|
+
status: RunStatus.Finished,
|
|
88
|
+
updated: now,
|
|
89
|
+
[`shards.${shardId}.finished`]: {
|
|
90
|
+
$ifNull: [`$shards.${shardId}.finished`, nowMs],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
]);
|
|
75
95
|
}
|
|
76
96
|
get runs() {
|
|
77
97
|
return this.connection.db.collection(this.runsCollection);
|
|
@@ -93,6 +113,7 @@ MongoShardHandler = __decorate([
|
|
|
93
113
|
injectable(),
|
|
94
114
|
__param(0, inject(MONGO_CONFIG)),
|
|
95
115
|
__param(1, inject(MONGO_CONNECTION)),
|
|
96
|
-
|
|
116
|
+
__param(2, inject(SYMBOLS.RunContext)),
|
|
117
|
+
__metadata("design:paramtypes", [Object, MongoConnection, Object])
|
|
97
118
|
], MongoShardHandler);
|
|
98
119
|
export { MongoShardHandler };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { RunStatus, TestItem, TestRunConfig, TestStatus } from '@playwright-orchestrator/core';
|
|
1
|
+
import { RunStatus, TestItem, TestRunConfig, TestShard, TestStatus } from '@playwright-orchestrator/core';
|
|
2
2
|
import { Binary, Document } from 'mongodb';
|
|
3
3
|
export interface TestRunDocument extends Document {
|
|
4
4
|
_id: Binary;
|
|
5
5
|
status: RunStatus;
|
|
6
|
+
shards: Record<string, TestShard>;
|
|
6
7
|
config: TestRunConfig;
|
|
7
8
|
updated: Date;
|
|
8
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright-orchestrator/mongo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "Rostyslav Kudrevatykh",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"inversify": "^8.0.0-beta.0",
|
|
19
19
|
"mongodb": "^6.12.0",
|
|
20
20
|
"uuid": "^11.0.0",
|
|
21
|
-
"@playwright-orchestrator/core": "1.
|
|
21
|
+
"@playwright-orchestrator/core": "1.4.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {},
|
|
24
24
|
"main": "dist/index.js",
|