@playwright-orchestrator/mongo 1.1.0 → 1.1.2
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 +7 -0
- package/dist/create-args.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -16
- package/dist/mongo-db-adapter.d.ts +1 -1
- package/dist/mongo-db-adapter.js +35 -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
|
@@ -3,5 +3,12 @@ export interface CreateArgs {
|
|
|
3
3
|
db: string;
|
|
4
4
|
collectionNamePrefix: string;
|
|
5
5
|
tls?: boolean;
|
|
6
|
+
tlsCA?: string;
|
|
7
|
+
tlsKey?: string;
|
|
8
|
+
tlsKeyPassword?: string;
|
|
9
|
+
tlsPassphrase?: string;
|
|
10
|
+
tlsAllowInvalidCertificates?: boolean;
|
|
11
|
+
tlsAllowInvalidHostnames?: boolean;
|
|
12
|
+
tlsInsecure?: boolean;
|
|
6
13
|
debug?: boolean;
|
|
7
14
|
}
|
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,25 @@
|
|
|
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'))
|
|
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-key-password <string>', 'TLS key password').env('TLS_KEY_PASSWORD'))
|
|
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('--tls-allow-invalid-certificates', 'Allow invalid certificates').env('TLS_ALLOW_INVALID_CERTIFICATES'))
|
|
21
|
+
.addOption(new Option('--tls-allow-invalid-hostnames', 'Allow invalid hostnames').env('TLS_ALLOW_INVALID_HOSTNAMES'))
|
|
22
|
+
.addOption(new Option('--tls-insecure', 'Insecure').env('TLS_INSECURE'))
|
|
23
|
+
.addOption(new Option('--debug', 'Add extra fields for some collections').env('DEBUG'));
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
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,26 @@
|
|
|
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, tlsKey, tlsPassphrase, tlsAllowInvalidCertificates, tlsAllowInvalidHostnames, tlsInsecure, tlsKeyPassword, debug, } = args;
|
|
44
13
|
super();
|
|
45
|
-
this.client = new
|
|
14
|
+
this.client = new MongoClient(connectionString, {
|
|
15
|
+
tls,
|
|
16
|
+
tlsCAFile: tlsCA,
|
|
17
|
+
tlsCertificateKeyFile: tlsKey,
|
|
18
|
+
tlsCertificateKeyFilePassword: tlsKeyPassword,
|
|
19
|
+
passphrase: tlsPassphrase,
|
|
20
|
+
tlsAllowInvalidCertificates,
|
|
21
|
+
tlsAllowInvalidHostnames,
|
|
22
|
+
tlsInsecure,
|
|
23
|
+
});
|
|
46
24
|
this.db = this.client.db(db);
|
|
47
25
|
this.runsCollection = `${collectionNamePrefix}_test_runs`;
|
|
48
26
|
this.testsCollection = `${collectionNamePrefix}_tests`;
|
|
@@ -54,11 +32,11 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
54
32
|
$gte: this.generateTestId(runId, 0),
|
|
55
33
|
$lt: this.generateTestId(runId, MAX_ORDER),
|
|
56
34
|
},
|
|
57
|
-
status: { $in: [
|
|
35
|
+
status: { $in: [TestStatus.Ready] },
|
|
58
36
|
}, {
|
|
59
37
|
$set: {
|
|
60
38
|
updated: new Date(),
|
|
61
|
-
status:
|
|
39
|
+
status: TestStatus.Ongoing,
|
|
62
40
|
},
|
|
63
41
|
});
|
|
64
42
|
if (!result)
|
|
@@ -74,10 +52,10 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
74
52
|
};
|
|
75
53
|
}
|
|
76
54
|
async finishTest(runId, test) {
|
|
77
|
-
await this.updateTestStatus(runId, test,
|
|
55
|
+
await this.updateTestStatus(runId, test, TestStatus.Passed);
|
|
78
56
|
}
|
|
79
57
|
async failTest(runId, test) {
|
|
80
|
-
await this.updateTestStatus(runId, test,
|
|
58
|
+
await this.updateTestStatus(runId, test, TestStatus.Failed);
|
|
81
59
|
}
|
|
82
60
|
async updateTestStatus(runId, test, status) {
|
|
83
61
|
const { order } = test;
|
|
@@ -93,7 +71,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
93
71
|
const tests = this.flattenTestRun(testRun.testRun);
|
|
94
72
|
const run = {
|
|
95
73
|
_id: this.generateRunId(runId),
|
|
96
|
-
status:
|
|
74
|
+
status: RunStatus.Created,
|
|
97
75
|
config: testRun.config,
|
|
98
76
|
args,
|
|
99
77
|
updated: new Date(),
|
|
@@ -108,7 +86,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
108
86
|
timeout,
|
|
109
87
|
line,
|
|
110
88
|
column,
|
|
111
|
-
status:
|
|
89
|
+
status: TestStatus.Ready,
|
|
112
90
|
updated: new Date(),
|
|
113
91
|
...(this.debug ? { runId, order } : {}),
|
|
114
92
|
};
|
|
@@ -131,9 +109,9 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
131
109
|
$set: {
|
|
132
110
|
status: {
|
|
133
111
|
$cond: {
|
|
134
|
-
if: { $in: ['$status', [
|
|
135
|
-
then:
|
|
136
|
-
else:
|
|
112
|
+
if: { $in: ['$status', [RunStatus.Created]] },
|
|
113
|
+
then: RunStatus.Run,
|
|
114
|
+
else: RunStatus.RepeatRun,
|
|
137
115
|
},
|
|
138
116
|
},
|
|
139
117
|
updated: now,
|
|
@@ -144,16 +122,16 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
144
122
|
throw new Error(`Run ${runId} not found`);
|
|
145
123
|
}
|
|
146
124
|
const { status: statusBefore } = run;
|
|
147
|
-
if (statusBefore ===
|
|
125
|
+
if (statusBefore === RunStatus.Created || statusBefore === RunStatus.Finished) {
|
|
148
126
|
await this.tests.updateMany({
|
|
149
127
|
_id: {
|
|
150
128
|
$gte: this.generateTestId(runId, 0),
|
|
151
129
|
$lt: this.generateTestId(runId, MAX_ORDER),
|
|
152
130
|
},
|
|
153
|
-
status:
|
|
131
|
+
status: TestStatus.Failed,
|
|
154
132
|
}, {
|
|
155
133
|
$set: {
|
|
156
|
-
status:
|
|
134
|
+
status: TestStatus.Ready,
|
|
157
135
|
updated: now,
|
|
158
136
|
},
|
|
159
137
|
});
|
|
@@ -164,7 +142,7 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
164
142
|
async finishShard(runId) {
|
|
165
143
|
await this.runs.updateOne({ _id: uuid.parse(runId) }, {
|
|
166
144
|
$set: {
|
|
167
|
-
status:
|
|
145
|
+
status: RunStatus.Finished,
|
|
168
146
|
updated: new Date(),
|
|
169
147
|
},
|
|
170
148
|
});
|
|
@@ -184,10 +162,10 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
184
162
|
orderBytes[0] = (order >> 8) & 0xff;
|
|
185
163
|
orderBytes[1] = order & 0xff;
|
|
186
164
|
const combined = new Uint8Array([...binaryRunId, ...orderBytes]);
|
|
187
|
-
return new
|
|
165
|
+
return new Binary(combined, Binary.SUBTYPE_USER_DEFINED);
|
|
188
166
|
}
|
|
189
167
|
generateRunId(runId) {
|
|
190
|
-
return new
|
|
168
|
+
return new Binary(uuid.parse(runId));
|
|
191
169
|
}
|
|
192
170
|
parseTestId(testId) {
|
|
193
171
|
const runId = uuid.stringify(testId.buffer.slice(0, 16));
|
|
@@ -195,4 +173,3 @@ class MongoDbAdapter extends core_1.Adapter {
|
|
|
195
173
|
return { runId, order };
|
|
196
174
|
}
|
|
197
175
|
}
|
|
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.2",
|
|
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"}
|