@playwright-orchestrator/mongo 1.1.0 → 1.1.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/create-args.d.ts +4 -0
- package/dist/create-args.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -16
- package/dist/mongo-db-adapter.d.ts +1 -1
- package/dist/mongo-db-adapter.js +32 -58
- package/package.json +6 -6
- package/dist/package.json +0 -32
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/create-args.d.ts
CHANGED
package/dist/create-args.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from '@commander-js/extra-typings';
|
|
2
|
-
import { CreateArgs } from './create-args';
|
|
3
|
-
import { MongoDbAdapter } from './mongo-db-adapter';
|
|
2
|
+
import { CreateArgs } from './create-args.js';
|
|
3
|
+
import { MongoDbAdapter } from './mongo-db-adapter.js';
|
|
4
4
|
export declare function factory(args: CreateArgs): Promise<MongoDbAdapter>;
|
|
5
5
|
export declare function createOptions(command: Command): void;
|
|
6
6
|
export declare const description = "MongoDB storage adapter";
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.createOptions = createOptions;
|
|
6
|
-
const extra_typings_1 = require("@commander-js/extra-typings");
|
|
7
|
-
const mongo_db_adapter_1 = require("./mongo-db-adapter");
|
|
8
|
-
async function factory(args) {
|
|
9
|
-
return new mongo_db_adapter_1.MongoDbAdapter(args);
|
|
1
|
+
import { Option } from '@commander-js/extra-typings';
|
|
2
|
+
import { MongoDbAdapter } from './mongo-db-adapter.js';
|
|
3
|
+
export async function factory(args) {
|
|
4
|
+
return new MongoDbAdapter(args);
|
|
10
5
|
}
|
|
11
|
-
function createOptions(command) {
|
|
6
|
+
export function createOptions(command) {
|
|
12
7
|
command
|
|
13
|
-
.addOption(new
|
|
8
|
+
.addOption(new Option('--collection-name-prefix <string>', 'Collections name prefix')
|
|
14
9
|
.default('playwright_orchestrator')
|
|
15
10
|
.env('TABLE_NAME_PREFIX'))
|
|
16
|
-
.addOption(new
|
|
11
|
+
.addOption(new Option('--connection-string <string>', 'Connection string')
|
|
17
12
|
.makeOptionMandatory()
|
|
18
13
|
.env('CONNECTION_STRING'))
|
|
19
|
-
.addOption(new
|
|
20
|
-
.addOption(new
|
|
21
|
-
.addOption(new
|
|
14
|
+
.addOption(new Option('--db <string>', 'Database name').env('DB').makeOptionMandatory())
|
|
15
|
+
.addOption(new Option('--tls', 'Enable TLS').env('TLS'))
|
|
16
|
+
.addOption(new Option('--tls-ca <string>', 'TLS CA').env('TLS_CA'))
|
|
17
|
+
.addOption(new Option('--tls-cert <string>', 'TLS certificate').env('TLS_CERT'))
|
|
18
|
+
.addOption(new Option('--tls-key <string>', 'TLS key').env('TLS_KEY'))
|
|
19
|
+
.addOption(new Option('--tls-passphrase <string>', 'TLS passphrase').env('TLS_PASSPHRASE'))
|
|
20
|
+
.addOption(new Option('--debug', 'Add extra fields for some collections').env('DEBUG'));
|
|
22
21
|
}
|
|
23
|
-
|
|
22
|
+
export const description = 'MongoDB storage adapter';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestItem, TestRunInfo, Adapter, TestRunConfig } from '@playwright-orchestrator/core';
|
|
2
|
-
import { CreateArgs } from './create-args';
|
|
2
|
+
import { CreateArgs } from './create-args.js';
|
|
3
3
|
export declare class MongoDbAdapter extends Adapter {
|
|
4
4
|
private readonly runsCollection;
|
|
5
5
|
private readonly testsCollection;
|
package/dist/mongo-db-adapter.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.MongoDbAdapter = void 0;
|
|
37
|
-
const core_1 = require("@playwright-orchestrator/core");
|
|
38
|
-
const mongodb_1 = require("mongodb");
|
|
39
|
-
const uuid = __importStar(require("uuid"));
|
|
1
|
+
import { Adapter, RunStatus, TestStatus, } from '@playwright-orchestrator/core';
|
|
2
|
+
import { MongoClient, Binary } from 'mongodb';
|
|
3
|
+
import * as uuid from 'uuid';
|
|
40
4
|
const MAX_ORDER = 0b1111111111111111;
|
|
41
|
-
class MongoDbAdapter extends
|
|
5
|
+
export class MongoDbAdapter extends Adapter {
|
|
6
|
+
runsCollection;
|
|
7
|
+
testsCollection;
|
|
8
|
+
debug;
|
|
9
|
+
db;
|
|
10
|
+
client;
|
|
42
11
|
constructor(args) {
|
|
43
|
-
const { connectionString, collectionNamePrefix, db, tls, debug } = args;
|
|
12
|
+
const { connectionString, collectionNamePrefix, db, tls, tlsCA, tlsCert, tlsKey, tlsPassphrase, debug } = args;
|
|
44
13
|
super();
|
|
45
|
-
this.client = new
|
|
14
|
+
this.client = new MongoClient(connectionString, {
|
|
15
|
+
tls,
|
|
16
|
+
ca: tlsCA,
|
|
17
|
+
cert: tlsCert,
|
|
18
|
+
key: tlsKey,
|
|
19
|
+
passphrase: tlsPassphrase,
|
|
20
|
+
});
|
|
46
21
|
this.db = this.client.db(db);
|
|
47
22
|
this.runsCollection = `${collectionNamePrefix}_test_runs`;
|
|
48
23
|
this.testsCollection = `${collectionNamePrefix}_tests`;
|
|
@@ -54,11 +29,11 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
54
29
|
$gte: this.generateTestId(runId, 0),
|
|
55
30
|
$lt: this.generateTestId(runId, MAX_ORDER),
|
|
56
31
|
},
|
|
57
|
-
status: { $in: [
|
|
32
|
+
status: { $in: [TestStatus.Ready] },
|
|
58
33
|
}, {
|
|
59
34
|
$set: {
|
|
60
35
|
updated: new Date(),
|
|
61
|
-
status:
|
|
36
|
+
status: TestStatus.Ongoing,
|
|
62
37
|
},
|
|
63
38
|
});
|
|
64
39
|
if (!result)
|
|
@@ -74,10 +49,10 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
74
49
|
};
|
|
75
50
|
}
|
|
76
51
|
async finishTest(runId, test) {
|
|
77
|
-
await this.updateTestStatus(runId, test,
|
|
52
|
+
await this.updateTestStatus(runId, test, TestStatus.Passed);
|
|
78
53
|
}
|
|
79
54
|
async failTest(runId, test) {
|
|
80
|
-
await this.updateTestStatus(runId, test,
|
|
55
|
+
await this.updateTestStatus(runId, test, TestStatus.Failed);
|
|
81
56
|
}
|
|
82
57
|
async updateTestStatus(runId, test, status) {
|
|
83
58
|
const { order } = test;
|
|
@@ -93,7 +68,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
93
68
|
const tests = this.flattenTestRun(testRun.testRun);
|
|
94
69
|
const run = {
|
|
95
70
|
_id: this.generateRunId(runId),
|
|
96
|
-
status:
|
|
71
|
+
status: RunStatus.Created,
|
|
97
72
|
config: testRun.config,
|
|
98
73
|
args,
|
|
99
74
|
updated: new Date(),
|
|
@@ -108,7 +83,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
108
83
|
timeout,
|
|
109
84
|
line,
|
|
110
85
|
column,
|
|
111
|
-
status:
|
|
86
|
+
status: TestStatus.Ready,
|
|
112
87
|
updated: new Date(),
|
|
113
88
|
...(this.debug ? { runId, order } : {}),
|
|
114
89
|
};
|
|
@@ -131,9 +106,9 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
131
106
|
$set: {
|
|
132
107
|
status: {
|
|
133
108
|
$cond: {
|
|
134
|
-
if: { $in: ['$status', [
|
|
135
|
-
then:
|
|
136
|
-
else:
|
|
109
|
+
if: { $in: ['$status', [RunStatus.Created]] },
|
|
110
|
+
then: RunStatus.Run,
|
|
111
|
+
else: RunStatus.RepeatRun,
|
|
137
112
|
},
|
|
138
113
|
},
|
|
139
114
|
updated: now,
|
|
@@ -144,16 +119,16 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
144
119
|
throw new Error(`Run ${runId} not found`);
|
|
145
120
|
}
|
|
146
121
|
const { status: statusBefore } = run;
|
|
147
|
-
if (statusBefore ===
|
|
122
|
+
if (statusBefore === RunStatus.Created || statusBefore === RunStatus.Finished) {
|
|
148
123
|
await this.tests.updateMany({
|
|
149
124
|
_id: {
|
|
150
125
|
$gte: this.generateTestId(runId, 0),
|
|
151
126
|
$lt: this.generateTestId(runId, MAX_ORDER),
|
|
152
127
|
},
|
|
153
|
-
status:
|
|
128
|
+
status: TestStatus.Failed,
|
|
154
129
|
}, {
|
|
155
130
|
$set: {
|
|
156
|
-
status:
|
|
131
|
+
status: TestStatus.Ready,
|
|
157
132
|
updated: now,
|
|
158
133
|
},
|
|
159
134
|
});
|
|
@@ -164,7 +139,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
164
139
|
async finishShard(runId) {
|
|
165
140
|
await this.runs.updateOne({ _id: uuid.parse(runId) }, {
|
|
166
141
|
$set: {
|
|
167
|
-
status:
|
|
142
|
+
status: RunStatus.Finished,
|
|
168
143
|
updated: new Date(),
|
|
169
144
|
},
|
|
170
145
|
});
|
|
@@ -184,10 +159,10 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
184
159
|
orderBytes[0] = (order >> 8) & 0xff;
|
|
185
160
|
orderBytes[1] = order & 0xff;
|
|
186
161
|
const combined = new Uint8Array([...binaryRunId, ...orderBytes]);
|
|
187
|
-
return new
|
|
162
|
+
return new Binary(combined, Binary.SUBTYPE_USER_DEFINED);
|
|
188
163
|
}
|
|
189
164
|
generateRunId(runId) {
|
|
190
|
-
return new
|
|
165
|
+
return new Binary(uuid.parse(runId));
|
|
191
166
|
}
|
|
192
167
|
parseTestId(testId) {
|
|
193
168
|
const runId = uuid.stringify(testId.buffer.slice(0, 16));
|
|
@@ -195,4 +170,3 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
195
170
|
return { runId, order };
|
|
196
171
|
}
|
|
197
172
|
}
|
|
198
|
-
exports.MongoDbAdapter = MongoDbAdapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright-orchestrator/mongo",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "Rostyslav Kudrevatykh",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@commander-js/extra-typings": "^13.0.0",
|
|
17
|
+
"@playwright-orchestrator/core": "^1.1.0",
|
|
18
|
+
"commander": "^13.0.0",
|
|
16
19
|
"mongodb": "^6.12.0"
|
|
17
20
|
},
|
|
18
21
|
"devDependencies": {},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"@playwright-orchestrator/core": "^1.0.0"
|
|
22
|
-
},
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"type": "module",
|
|
23
24
|
"exports": {
|
|
24
25
|
".": {
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
26
|
"default": "./dist/index.js"
|
|
27
27
|
}
|
|
28
28
|
},
|
package/dist/package.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@playwright-orchestrator/mongo",
|
|
3
|
-
"version": "1.1.0",
|
|
4
|
-
"keywords": [],
|
|
5
|
-
"author": "Rostyslav Kudrevatykh",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"description": "Playwright orchestrator MongoDB plugin",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/rostmanrk/playwright-orchestrator.git"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
],
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"mongodb": "^6.12.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {},
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"@commander-js/extra-typings": "^13.0.0",
|
|
21
|
-
"@playwright-orchestrator/core": "^1.0.0"
|
|
22
|
-
},
|
|
23
|
-
"exports": {
|
|
24
|
-
".": {
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
|
-
"default": "./dist/index.js"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"prepare": "cp ../../LICENSE.md ./"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../create-args.ts","../index.ts","../mongo-db-adapter.ts","../package.json"],"version":"5.7.2"}
|