@elench/testkit 0.1.38 → 0.1.39
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/README.md +12 -3
- package/lib/cli/args.mjs +6 -7
- package/lib/cli/args.test.mjs +9 -4
- package/lib/cli/index.mjs +15 -4
- package/lib/config/index.mjs +118 -0
- package/lib/runner/default-runtime-runner.mjs +4 -4
- package/lib/runner/execution-config.mjs +108 -0
- package/lib/runner/execution-config.test.mjs +101 -0
- package/lib/runner/lifecycle.mjs +7 -7
- package/lib/runner/orchestrator.mjs +51 -24
- package/lib/runner/planning.mjs +42 -2
- package/lib/runner/planning.test.mjs +175 -3
- package/lib/runner/playwright-config.test.mjs +1 -1
- package/lib/runner/playwright-runner.mjs +2 -2
- package/lib/runner/readiness.mjs +2 -2
- package/lib/runner/reporting.mjs +5 -2
- package/lib/runner/reporting.test.mjs +12 -1
- package/lib/runner/runtime-contexts.mjs +38 -47
- package/lib/runner/services.mjs +4 -4
- package/lib/runner/stack-manager.mjs +146 -0
- package/lib/runner/template.mjs +40 -32
- package/lib/runner/template.test.mjs +42 -35
- package/lib/runner/worker-loop.mjs +17 -14
- package/lib/setup/index.d.ts +23 -0
- package/package.json +1 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { formatError } from "./formatting.mjs";
|
|
2
2
|
import { runDalBatch, runHttpK6Batch } from "./default-runtime-runner.mjs";
|
|
3
3
|
import { runPlaywrightBatch } from "./playwright-runner.mjs";
|
|
4
|
-
import {
|
|
5
|
-
cleanupWorker,
|
|
6
|
-
ensureWorkerGraph,
|
|
7
|
-
resetCurrentGraph,
|
|
8
|
-
} from "./runtime-contexts.mjs";
|
|
9
4
|
|
|
10
5
|
const HTTP_K6_TYPES = new Set(["integration", "e2e", "load"]);
|
|
11
6
|
|
|
@@ -14,7 +9,6 @@ export function createWorker(workerId, productDir) {
|
|
|
14
9
|
workerId,
|
|
15
10
|
productDir,
|
|
16
11
|
currentGraphKey: null,
|
|
17
|
-
graphContexts: new Map(),
|
|
18
12
|
graphSwitches: 0,
|
|
19
13
|
taskCount: 0,
|
|
20
14
|
};
|
|
@@ -23,7 +17,7 @@ export function createWorker(workerId, productDir) {
|
|
|
23
17
|
export async function runWorker(
|
|
24
18
|
worker,
|
|
25
19
|
queue,
|
|
26
|
-
|
|
20
|
+
stackManager,
|
|
27
21
|
trackers,
|
|
28
22
|
timingUpdates,
|
|
29
23
|
lifecycle,
|
|
@@ -32,7 +26,7 @@ export async function runWorker(
|
|
|
32
26
|
recordGraphError
|
|
33
27
|
) {
|
|
34
28
|
const startedAt = Date.now();
|
|
35
|
-
console.log(`\n══
|
|
29
|
+
console.log(`\n══ worker ${worker.workerId} ══`);
|
|
36
30
|
const errors = [];
|
|
37
31
|
|
|
38
32
|
try {
|
|
@@ -41,9 +35,14 @@ export async function runWorker(
|
|
|
41
35
|
const batch = claimNextBatch(queue, worker.currentGraphKey);
|
|
42
36
|
if (!batch) break;
|
|
43
37
|
|
|
38
|
+
let lease = null;
|
|
44
39
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if (worker.currentGraphKey && worker.currentGraphKey !== batch.graphKey) {
|
|
41
|
+
worker.graphSwitches += 1;
|
|
42
|
+
}
|
|
43
|
+
worker.currentGraphKey = batch.graphKey;
|
|
44
|
+
lease = await stackManager.acquire(batch);
|
|
45
|
+
const outcomes = await runBatch(lease.context, batch, lifecycle);
|
|
47
46
|
for (const outcome of outcomes) {
|
|
48
47
|
recordTaskOutcome(trackers, outcome.task, outcome);
|
|
49
48
|
timingUpdates.push({
|
|
@@ -52,15 +51,19 @@ export async function runWorker(
|
|
|
52
51
|
});
|
|
53
52
|
worker.taskCount += 1;
|
|
54
53
|
}
|
|
54
|
+
await stackManager.release(lease, { accessMode: batch.accessMode });
|
|
55
55
|
} catch (error) {
|
|
56
56
|
const message = formatError(error);
|
|
57
57
|
errors.push(message);
|
|
58
|
-
recordGraphError(trackers,
|
|
59
|
-
await
|
|
58
|
+
recordGraphError(trackers, { assignedTargets: lease?.context?.assignedTargets || [batch.targetName] }, message);
|
|
59
|
+
await stackManager.release(lease, {
|
|
60
|
+
accessMode: batch.accessMode,
|
|
61
|
+
invalidate: lease !== null,
|
|
62
|
+
});
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
} finally {
|
|
63
|
-
|
|
66
|
+
worker.currentGraphKey = null;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
return {
|
|
@@ -76,7 +79,7 @@ export async function runWorker(
|
|
|
76
79
|
async function runBatch(context, batch, lifecycle) {
|
|
77
80
|
const targetConfig = context.configByName.get(batch.targetName);
|
|
78
81
|
if (!targetConfig) {
|
|
79
|
-
throw new Error(`
|
|
82
|
+
throw new Error(`Stack is missing target config "${batch.targetName}"`);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
if (batch.framework === "playwright") {
|
package/lib/setup/index.d.ts
CHANGED
|
@@ -33,6 +33,27 @@ export interface SkipConfig {
|
|
|
33
33
|
suites?: SkipSuiteRule[];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export interface SuiteExecutionRule {
|
|
37
|
+
selector: string;
|
|
38
|
+
stackMode: "shared" | "pooled" | "isolated";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface FileExecutionRule {
|
|
42
|
+
path: string;
|
|
43
|
+
stackMode: "shared" | "pooled" | "isolated";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ServiceExecutionConfig {
|
|
47
|
+
suites?: SuiteExecutionRule[];
|
|
48
|
+
files?: FileExecutionRule[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TestkitExecutionConfig {
|
|
52
|
+
workers?: number;
|
|
53
|
+
stackMode?: "shared" | "pooled" | "isolated";
|
|
54
|
+
stackCount?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
36
57
|
export interface ServiceConfig {
|
|
37
58
|
database?: LocalDatabaseConfig;
|
|
38
59
|
databaseFrom?: string;
|
|
@@ -55,9 +76,11 @@ export interface ServiceConfig {
|
|
|
55
76
|
migrate?: LifecycleConfig;
|
|
56
77
|
seed?: LifecycleConfig;
|
|
57
78
|
skip?: SkipConfig;
|
|
79
|
+
execution?: ServiceExecutionConfig;
|
|
58
80
|
}
|
|
59
81
|
|
|
60
82
|
export interface TestkitSetup {
|
|
83
|
+
execution?: TestkitExecutionConfig;
|
|
61
84
|
profiles?: {
|
|
62
85
|
http?: Record<string, HttpSuiteConfig>;
|
|
63
86
|
};
|