testit-js-commons 3.7.9 → 4.0.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.
- package/lib/common/types/config.type.d.ts +8 -0
- package/lib/common/utils/index.d.ts +1 -0
- package/lib/common/utils/index.js +1 -0
- package/lib/common/utils/tms-load-test-run-debug.d.ts +3 -0
- package/lib/common/utils/tms-load-test-run-debug.js +20 -0
- package/lib/helpers/config/config.helper.js +14 -6
- package/lib/helpers/config/config.helper.test.d.ts +1 -0
- package/lib/helpers/config/config.helper.test.js +40 -0
- package/lib/services/attachments/attachments.service.js +89 -22
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +1 -0
- package/lib/services/syncstorage/index.d.ts +2 -0
- package/lib/services/syncstorage/index.js +18 -0
- package/lib/services/syncstorage/syncstorage.runner.d.ts +49 -0
- package/lib/services/syncstorage/syncstorage.runner.js +350 -0
- package/lib/services/syncstorage/syncstorage.runner.test.d.ts +1 -0
- package/lib/services/syncstorage/syncstorage.runner.test.js +78 -0
- package/lib/services/syncstorage/syncstorage.type.d.ts +21 -0
- package/lib/services/syncstorage/syncstorage.type.js +19 -0
- package/lib/services/testruns/testruns.converter.d.ts +2 -0
- package/lib/services/testruns/testruns.converter.js +3 -0
- package/lib/services/testruns/testruns.service.d.ts +2 -0
- package/lib/services/testruns/testruns.service.js +62 -1
- package/lib/services/testruns/testruns.type.d.ts +2 -0
- package/lib/strategy/base.strategy.d.ts +4 -0
- package/lib/strategy/base.strategy.js +97 -2
- package/lib/sync-storage/dist/ApiClient.js +655 -0
- package/lib/sync-storage/dist/api/CompletionApi.js +114 -0
- package/lib/sync-storage/dist/api/HealthApi.js +69 -0
- package/lib/sync-storage/dist/api/SystemApi.js +69 -0
- package/lib/sync-storage/dist/api/TestResultsApi.js +122 -0
- package/lib/sync-storage/dist/api/WorkersApi.js +113 -0
- package/lib/sync-storage/dist/index.js +118 -0
- package/lib/sync-storage/dist/model/CompletionResponse.js +86 -0
- package/lib/sync-storage/dist/model/HealthStatusResponse.js +86 -0
- package/lib/sync-storage/dist/model/InProgressPublishedResponse.js +74 -0
- package/lib/sync-storage/dist/model/RegisterRequest.js +114 -0
- package/lib/sync-storage/dist/model/RegisterResponse.js +122 -0
- package/lib/sync-storage/dist/model/SetWorkerStatusRequest.js +102 -0
- package/lib/sync-storage/dist/model/SetWorkerStatusResponse.js +90 -0
- package/lib/sync-storage/dist/model/ShutdownResponse.js +90 -0
- package/lib/sync-storage/dist/model/TestResultCutApiModel.js +122 -0
- package/lib/sync-storage/dist/model/TestResultSaveResponse.js +90 -0
- package/lib/sync-storage/index.d.ts +772 -0
- package/package.json +7 -4
|
@@ -11,6 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseStrategy = void 0;
|
|
13
13
|
const client_1 = require("../client");
|
|
14
|
+
const utils_1 = require("../common/utils");
|
|
15
|
+
const syncstorage_1 = require("../services/syncstorage");
|
|
14
16
|
class BaseStrategy {
|
|
15
17
|
constructor(config) {
|
|
16
18
|
this.config = config;
|
|
@@ -19,14 +21,26 @@ class BaseStrategy {
|
|
|
19
21
|
}
|
|
20
22
|
setup() {
|
|
21
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a;
|
|
22
25
|
const testRunId = yield this.testRunId;
|
|
26
|
+
yield this.tryStartSyncStorage(testRunId);
|
|
27
|
+
yield ((_a = this.syncStorageRunner) === null || _a === void 0 ? void 0 : _a.setWorkerStatus("in_progress"));
|
|
23
28
|
yield this.client.testRuns.startTestRun(testRunId);
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
31
|
teardown() {
|
|
27
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
28
34
|
const testRunId = yield this.testRunId;
|
|
29
|
-
yield this.
|
|
35
|
+
yield ((_a = this.syncStorageRunner) === null || _a === void 0 ? void 0 : _a.setWorkerStatus("completed"));
|
|
36
|
+
yield ((_b = this.syncStorageRunner) === null || _b === void 0 ? void 0 : _b.completeProcessing());
|
|
37
|
+
// With active sync-storage, run completion is finalized by sync-storage itself.
|
|
38
|
+
// Calling completeTestRun from adapters can finish the run too early and skip late results.
|
|
39
|
+
// if (this.syncStorageRunner?.isActive()) {
|
|
40
|
+
// logTmsLoadTestRun("skip completeTestRun in adapter teardown: sync-storage is active");
|
|
41
|
+
// return;
|
|
42
|
+
// }
|
|
43
|
+
//await this.client.testRuns.completeTestRun(testRunId);
|
|
30
44
|
});
|
|
31
45
|
}
|
|
32
46
|
loadAutotest(autotest, status) {
|
|
@@ -67,8 +81,78 @@ class BaseStrategy {
|
|
|
67
81
|
}
|
|
68
82
|
loadTestRun(autotests) {
|
|
69
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
70
85
|
const testRunId = yield this.testRunId;
|
|
71
|
-
|
|
86
|
+
const firstResult = autotests[0];
|
|
87
|
+
(0, utils_1.logTmsLoadTestRun)("loadTestRun enter", {
|
|
88
|
+
testRunId,
|
|
89
|
+
batchSize: autotests.length,
|
|
90
|
+
firstExternalId: firstResult === null || firstResult === void 0 ? void 0 : firstResult.autoTestExternalId,
|
|
91
|
+
syncRunnerActive: Boolean((_b = (_a = this.syncStorageRunner) === null || _a === void 0 ? void 0 : _a.isActive) === null || _b === void 0 ? void 0 : _b.call(_a)),
|
|
92
|
+
isMaster: Boolean((_d = (_c = this.syncStorageRunner) === null || _c === void 0 ? void 0 : _c.isMasterWorker) === null || _d === void 0 ? void 0 : _d.call(_c)),
|
|
93
|
+
});
|
|
94
|
+
// InProgress is only for the first result (the one used for sync storage cut).
|
|
95
|
+
// Its final payload is deferred until teardown, so TMS does not immediately flip to final status.
|
|
96
|
+
if (firstResult) {
|
|
97
|
+
const isMasterWorker = Boolean((_f = (_e = this.syncStorageRunner) === null || _e === void 0 ? void 0 : _e.isMasterWorker) === null || _f === void 0 ? void 0 : _f.call(_e));
|
|
98
|
+
const published = yield ((_g = this.syncStorageRunner) === null || _g === void 0 ? void 0 : _g.sendInProgressTestResult((0, syncstorage_1.toTestResultCutModel)(firstResult, this.config.projectId)));
|
|
99
|
+
(0, utils_1.logTmsLoadTestRun)("syncStorage sendInProgressTestResult", {
|
|
100
|
+
isMasterWorker,
|
|
101
|
+
published: Boolean(published),
|
|
102
|
+
});
|
|
103
|
+
if (!isMasterWorker) {
|
|
104
|
+
// Global ordering: non-master waits for sync-storage published flag from master.
|
|
105
|
+
const timeoutMs = this.getInProgressFirstGraceMs();
|
|
106
|
+
if (timeoutMs > 0 && this.syncStorageRunner) {
|
|
107
|
+
(0, utils_1.logTmsLoadTestRun)("non-master wait for in-progress published", { timeoutMs });
|
|
108
|
+
const publishedByMaster = yield this.syncStorageRunner.waitForInProgressPublished(timeoutMs);
|
|
109
|
+
(0, utils_1.logTmsLoadTestRun)("non-master wait result", { publishedByMaster });
|
|
110
|
+
}
|
|
111
|
+
(0, utils_1.logTmsLoadTestRun)("skip InProgress stub: current worker is not sync master");
|
|
112
|
+
yield this.client.testRuns.loadAutotests(testRunId, autotests);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (!published) {
|
|
116
|
+
(0, utils_1.logTmsLoadTestRun)("skip InProgress stub: sync cut was not published");
|
|
117
|
+
yield this.client.testRuns.loadAutotests(testRunId, autotests);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
(0, utils_1.logTmsLoadTestRun)("InProgress slot acquired", {
|
|
121
|
+
autoTestExternalId: firstResult.autoTestExternalId,
|
|
122
|
+
testRunId,
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
yield this.client.testRuns.postInProgressAutotestResult(testRunId, firstResult);
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
(0, utils_1.logTmsLoadTestRun)("postInProgressAutotestResult FAILED", {
|
|
129
|
+
autoTestExternalId: firstResult.autoTestExternalId,
|
|
130
|
+
message: err instanceof Error ? err.message : String(err),
|
|
131
|
+
});
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
134
|
+
// For published sync-storage InProgress, finalization of the first result is handled by sync-storage.
|
|
135
|
+
const rest = autotests.slice(1);
|
|
136
|
+
if (rest.length > 0) {
|
|
137
|
+
yield this.client.testRuns.loadAutotests(testRunId, rest);
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Normal path: no placeholder created here — upload finals as-is.
|
|
142
|
+
yield this.client.testRuns.loadAutotests(testRunId, autotests);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
tryStartSyncStorage(testRunId) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
if (!this.config.syncStorageEnabled) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const runner = new syncstorage_1.SyncStorageRunner(testRunId, this.config);
|
|
151
|
+
const started = yield runner.start();
|
|
152
|
+
if (!started) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.syncStorageRunner = runner;
|
|
72
156
|
});
|
|
73
157
|
}
|
|
74
158
|
updateTestRun(config) {
|
|
@@ -85,5 +169,16 @@ class BaseStrategy {
|
|
|
85
169
|
this.client.testRuns.updateTestRun(testRun);
|
|
86
170
|
});
|
|
87
171
|
}
|
|
172
|
+
getInProgressFirstGraceMs() {
|
|
173
|
+
const raw = process.env.TMS_SYNC_INPROGRESS_FIRST_GRACE_MS;
|
|
174
|
+
if (!raw) {
|
|
175
|
+
return BaseStrategy.INPROGRESS_FIRST_GRACE_MS;
|
|
176
|
+
}
|
|
177
|
+
const parsed = Number(raw);
|
|
178
|
+
return Number.isFinite(parsed) && parsed >= 0
|
|
179
|
+
? parsed
|
|
180
|
+
: BaseStrategy.INPROGRESS_FIRST_GRACE_MS;
|
|
181
|
+
}
|
|
88
182
|
}
|
|
89
183
|
exports.BaseStrategy = BaseStrategy;
|
|
184
|
+
BaseStrategy.INPROGRESS_FIRST_GRACE_MS = 3000;
|